- building required runtime images as part of the build, instead of
depending on the images from the personal dockerhub account
- use helper methods from utils instead of self-written alternatives
- convert test data file to yaml
- extract and use WaitForAnImageStreamTag() method
... | ... |
@@ -1,14 +1,11 @@ |
1 | 1 |
package builds |
2 | 2 |
|
3 | 3 |
import ( |
4 |
- "fmt" |
|
5 | 4 |
"path/filepath" |
6 |
- "time" |
|
7 | 5 |
|
8 | 6 |
g "github.com/onsi/ginkgo" |
9 | 7 |
o "github.com/onsi/gomega" |
10 | 8 |
exutil "github.com/openshift/origin/test/extended/util" |
11 |
- "k8s.io/kubernetes/pkg/util/wait" |
|
12 | 9 |
e2e "k8s.io/kubernetes/test/e2e/framework" |
13 | 10 |
) |
14 | 11 |
|
... | ... |
@@ -16,43 +13,46 @@ var _ = g.Describe("[builds][Slow] s2i extended build", func() { |
16 | 16 |
defer g.GinkgoRecover() |
17 | 17 |
|
18 | 18 |
var ( |
19 |
- oc = exutil.NewCLI("extended-build", exutil.KubeConfigPath()) |
|
20 |
- testDataDir = exutil.FixturePath("testdata", "build-extended") |
|
21 |
- scriptsFromRepoBc = filepath.Join(testDataDir, "bc-scripts-in-repo.json") |
|
22 |
- scriptsFromUrlBc = filepath.Join(testDataDir, "bc-scripts-by-url.json") |
|
23 |
- scriptsFromImageBc = filepath.Join(testDataDir, "bc-scripts-in-the-image.json") |
|
19 |
+ oc = exutil.NewCLI("extended-build", exutil.KubeConfigPath()) |
|
20 |
+ testDataDir = exutil.FixturePath("testdata", "build-extended") |
|
21 |
+ runnerConf = filepath.Join(testDataDir, "jvm-runner.yaml") |
|
22 |
+ runnerWithScriptsConf = filepath.Join(testDataDir, "jvm-runner-with-scripts.yaml") |
|
23 |
+ scriptsFromRepoBc = filepath.Join(testDataDir, "bc-scripts-in-repo.yaml") |
|
24 |
+ scriptsFromUrlBc = filepath.Join(testDataDir, "bc-scripts-by-url.yaml") |
|
25 |
+ scriptsFromImageBc = filepath.Join(testDataDir, "bc-scripts-in-the-image.yaml") |
|
24 | 26 |
) |
25 | 27 |
|
28 |
+ g.JustBeforeEach(func() { |
|
29 |
+ g.By("waiting for builder service account") |
|
30 |
+ err := exutil.WaitForBuilderAccount(oc.KubeREST().ServiceAccounts(oc.Namespace())) |
|
31 |
+ o.Expect(err).NotTo(o.HaveOccurred()) |
|
32 |
+ |
|
33 |
+ // we have to wait until image stream tag will be available, otherwise |
|
34 |
+ // `oc start-build` will fail with 'imagestreamtags "wildfly:10.0" not found' error. |
|
35 |
+ // See this issue for details: https://github.com/openshift/origin/issues/10103 |
|
36 |
+ err = exutil.WaitForAnImageStreamTag(oc, "openshift", "wildfly", "10.0") |
|
37 |
+ o.Expect(err).NotTo(o.HaveOccurred()) |
|
38 |
+ }) |
|
39 |
+ |
|
26 | 40 |
g.Describe("with scripts from the source repository", func() { |
27 | 41 |
oc.SetOutputDir(exutil.TestContext.OutputDir) |
28 | 42 |
|
29 | 43 |
g.It("should use assemble-runtime script from the source repository", func() { |
30 |
- const buildConfigName = "java-extended-build-from-repo" |
|
31 | 44 |
|
32 |
- g.By("creating build config") |
|
33 |
- err := oc.Run("create").Args("-f", scriptsFromRepoBc).Execute() |
|
45 |
+ g.By("creating jvm-runner configuration") |
|
46 |
+ err := exutil.CreateResource(runnerConf, oc) |
|
34 | 47 |
o.Expect(err).NotTo(o.HaveOccurred()) |
35 | 48 |
|
36 |
- // we have to wait until image stream tag will be available, otherwise |
|
37 |
- // `oc start-build` will fail with 'imagestreamtags "wildfly:10.0" not found' error. |
|
38 |
- // See this issue for details: https://github.com/openshift/origin/issues/10103 |
|
39 |
- g.By("waiting when image stream tag for wildfly will be available") |
|
40 |
- wait.Poll(1*time.Second, 1*time.Minute, func() (bool, error) { |
|
41 |
- out, err := oc.Run("get").Args("imagestreamtags", "--namespace", "openshift", "--output", `jsonpath='{.items[?(@.metadata.name=="wildfly:10.0")].image.dockerImageReference}'`).Output() |
|
42 |
- if err != nil { |
|
43 |
- fmt.Fprintf(g.GinkgoWriter, "Could not get image stream tag for wildfly: %v\n", err) |
|
44 |
- return false, err |
|
45 |
- } |
|
46 |
- if len(out) > 0 && out != "''" { |
|
47 |
- fmt.Fprintf(g.GinkgoWriter, "Using image stream tag for wildfly: %s\n", out) |
|
48 |
- return true, nil |
|
49 |
- } |
|
50 |
- |
|
51 |
- return false, nil |
|
52 |
- }) |
|
49 |
+ g.By("building jvm-runner image") |
|
50 |
+ br, _ := exutil.StartBuildAndWait(oc, "jvm-runner") |
|
51 |
+ br.AssertSuccess() |
|
52 |
+ |
|
53 |
+ g.By("creating build config") |
|
54 |
+ err = exutil.CreateResource(scriptsFromRepoBc, oc) |
|
55 |
+ o.Expect(err).NotTo(o.HaveOccurred()) |
|
53 | 56 |
|
54 | 57 |
g.By("running the build") |
55 |
- br, _ := exutil.StartBuildAndWait(oc, buildConfigName, "--build-loglevel=5") |
|
58 |
+ br, _ = exutil.StartBuildAndWait(oc, "java-extended-build-from-repo", "--build-loglevel=5") |
|
56 | 59 |
br.AssertSuccess() |
57 | 60 |
buildLog, err := br.Logs() |
58 | 61 |
if err != nil { |
... | ... |
@@ -75,14 +75,21 @@ var _ = g.Describe("[builds][Slow] s2i extended build", func() { |
75 | 75 |
oc.SetOutputDir(exutil.TestContext.OutputDir) |
76 | 76 |
|
77 | 77 |
g.It("should use assemble-runtime script from URL", func() { |
78 |
- const buildConfigName = "java-extended-build-from-url" |
|
78 |
+ |
|
79 |
+ g.By("creating jvm-runner configuration") |
|
80 |
+ err := exutil.CreateResource(runnerConf, oc) |
|
81 |
+ o.Expect(err).NotTo(o.HaveOccurred()) |
|
82 |
+ |
|
83 |
+ g.By("building jvm-runner image") |
|
84 |
+ br, _ := exutil.StartBuildAndWait(oc, "jvm-runner") |
|
85 |
+ br.AssertSuccess() |
|
79 | 86 |
|
80 | 87 |
g.By("creating build config") |
81 |
- err := oc.Run("create").Args("-f", scriptsFromUrlBc).Execute() |
|
88 |
+ err = exutil.CreateResource(scriptsFromUrlBc, oc) |
|
82 | 89 |
o.Expect(err).NotTo(o.HaveOccurred()) |
83 | 90 |
|
84 | 91 |
g.By("running the build") |
85 |
- br, _ := exutil.StartBuildAndWait(oc, buildConfigName, "--build-loglevel=5") |
|
92 |
+ br, _ = exutil.StartBuildAndWait(oc, "java-extended-build-from-url", "--build-loglevel=5") |
|
86 | 93 |
br.AssertSuccess() |
87 | 94 |
buildLog, err := br.Logs() |
88 | 95 |
if err != nil { |
... | ... |
@@ -105,15 +112,21 @@ var _ = g.Describe("[builds][Slow] s2i extended build", func() { |
105 | 105 |
oc.SetOutputDir(exutil.TestContext.OutputDir) |
106 | 106 |
|
107 | 107 |
g.It("should use assemble-runtime script from that image", func() { |
108 |
- const buildConfigName = "java-extended-build-from-image" |
|
109 |
- const buildName = buildConfigName + "-1" |
|
108 |
+ |
|
109 |
+ g.By("creating jvm-runner-with-scripts configuration") |
|
110 |
+ err := exutil.CreateResource(runnerWithScriptsConf, oc) |
|
111 |
+ o.Expect(err).NotTo(o.HaveOccurred()) |
|
112 |
+ |
|
113 |
+ g.By("building jvm-runner-with-scripts image") |
|
114 |
+ br, _ := exutil.StartBuildAndWait(oc, "jvm-runner-with-scripts") |
|
115 |
+ br.AssertSuccess() |
|
110 | 116 |
|
111 | 117 |
g.By("creating build config") |
112 |
- err := oc.Run("create").Args("-f", scriptsFromImageBc).Execute() |
|
118 |
+ err = exutil.CreateResource(scriptsFromImageBc, oc) |
|
113 | 119 |
o.Expect(err).NotTo(o.HaveOccurred()) |
114 | 120 |
|
115 | 121 |
g.By("running the build") |
116 |
- br, _ := exutil.StartBuildAndWait(oc, buildConfigName, "--build-loglevel=5") |
|
122 |
+ br, _ = exutil.StartBuildAndWait(oc, "java-extended-build-from-image", "--build-loglevel=5") |
|
117 | 123 |
br.AssertSuccess() |
118 | 124 |
buildLog, err := br.Logs() |
119 | 125 |
if err != nil { |
... | ... |
@@ -4,7 +4,6 @@ import ( |
4 | 4 |
"fmt" |
5 | 5 |
"os" |
6 | 6 |
"strconv" |
7 |
- "time" |
|
8 | 7 |
|
9 | 8 |
kapi "k8s.io/kubernetes/pkg/api" |
10 | 9 |
"k8s.io/kubernetes/pkg/api/resource" |
... | ... |
@@ -144,7 +143,7 @@ var _ = g.Describe("[images] openshift limit range admission", func() { |
144 | 144 |
g.By(fmt.Sprintf("trying to tag a docker image below limit %v", limit)) |
145 | 145 |
err = oc.Run("import-image").Args("stream:dockerimage", "--confirm", "--insecure", "--from", tag2Image["tag1"].DockerImageReference).Execute() |
146 | 146 |
o.Expect(err).NotTo(o.HaveOccurred()) |
147 |
- err = waitForAnImageStreamTag(oc, "stream", "dockerimage") |
|
147 |
+ err = exutil.WaitForAnImageStreamTag(oc, oc.Namespace(), "stream", "dockerimage") |
|
148 | 148 |
o.Expect(err).NotTo(o.HaveOccurred()) |
149 | 149 |
|
150 | 150 |
g.By(fmt.Sprintf("trying to tag a docker image exceeding limit %v", limit)) |
... | ... |
@@ -211,7 +210,7 @@ var _ = g.Describe("[images] openshift limit range admission", func() { |
211 | 211 |
g.By(fmt.Sprintf("trying to import from repository %q below quota %v", s1ref.Exact(), limit)) |
212 | 212 |
err = oc.Run("import-image").Args("bulkimport", "--confirm", "--insecure", "--all", "--from", s1ref.Exact()).Execute() |
213 | 213 |
o.Expect(err).NotTo(o.HaveOccurred()) |
214 |
- err = waitForAnImageStreamTag(oc, "bulkimport", "tag1") |
|
214 |
+ err = exutil.WaitForAnImageStreamTag(oc, oc.Namespace(), "bulkimport", "tag1") |
|
215 | 215 |
o.Expect(err).NotTo(o.HaveOccurred()) |
216 | 216 |
|
217 | 217 |
g.By(fmt.Sprintf("trying to import tags from repository %q exceeding quota %v", s2ref.Exact(), limit)) |
... | ... |
@@ -303,35 +302,6 @@ func bumpLimit(oc *exutil.CLI, resourceName kapi.ResourceName, limit string) (ka |
303 | 303 |
return res, err |
304 | 304 |
} |
305 | 305 |
|
306 |
-// waitForAnImageStreamTag waits until an image stream with given name has non-empty history for given tag |
|
307 |
-func waitForAnImageStreamTag(oc *exutil.CLI, name, tag string) error { |
|
308 |
- g.By(fmt.Sprintf("waiting for an is importer to import a tag %s into a stream %s", tag, name)) |
|
309 |
- start := time.Now() |
|
310 |
- c := make(chan error) |
|
311 |
- go func() { |
|
312 |
- err := exutil.WaitForAnImageStream( |
|
313 |
- oc.REST().ImageStreams(oc.Namespace()), |
|
314 |
- name, |
|
315 |
- func(is *imageapi.ImageStream) bool { |
|
316 |
- if history, exists := is.Status.Tags[tag]; !exists || len(history.Items) == 0 { |
|
317 |
- return false |
|
318 |
- } |
|
319 |
- return true |
|
320 |
- }, |
|
321 |
- func(is *imageapi.ImageStream) bool { |
|
322 |
- return time.Now().After(start.Add(waitTimeout)) |
|
323 |
- }) |
|
324 |
- c <- err |
|
325 |
- }() |
|
326 |
- |
|
327 |
- select { |
|
328 |
- case e := <-c: |
|
329 |
- return e |
|
330 |
- case <-time.After(waitTimeout): |
|
331 |
- return fmt.Errorf("timed out while waiting of an image stream tag %s/%s:%s", oc.Namespace(), name, tag) |
|
332 |
- } |
|
333 |
-} |
|
334 |
- |
|
335 | 306 |
// getMaxImagesBulkImportedPerRepository returns a maximum numbers of images that can be imported from |
336 | 307 |
// repository at once. The value is obtained from environment variable which must be set. |
337 | 308 |
func getMaxImagesBulkImportedPerRepository() (int, error) { |
338 | 309 |
deleted file mode 100644 |
... | ... |
@@ -1,39 +0,0 @@ |
1 |
-{ |
|
2 |
- "kind": "BuildConfig", |
|
3 |
- "apiVersion": "v1", |
|
4 |
- "metadata": { |
|
5 |
- "name": "java-extended-build-from-url" |
|
6 |
- }, |
|
7 |
- "spec": { |
|
8 |
- "source": { |
|
9 |
- "git": { |
|
10 |
- "uri": "https://github.com/php-coder/java-maven-hello-world.git" |
|
11 |
- } |
|
12 |
- }, |
|
13 |
- "strategy": { |
|
14 |
- "sourceStrategy": { |
|
15 |
- "from": { |
|
16 |
- "kind": "ImageStreamTag", |
|
17 |
- "name": "wildfly:10.0", |
|
18 |
- "namespace": "openshift" |
|
19 |
- }, |
|
20 |
- "runtimeImage": { |
|
21 |
- "kind": "DockerImage", |
|
22 |
- "name": "phpcoder/base-jdk:8" |
|
23 |
- }, |
|
24 |
- "runtimeArtifacts": [ |
|
25 |
- { |
|
26 |
- "sourcePath": "/opt/s2i/destination/src/target/hello.jar" |
|
27 |
- } |
|
28 |
- ], |
|
29 |
- "env": [ |
|
30 |
- { |
|
31 |
- "name": "USING_ENV_FROM_BUILD_CONFIG", |
|
32 |
- "value": "yes" |
|
33 |
- } |
|
34 |
- ], |
|
35 |
- "scripts": "https://raw.githubusercontent.com/php-coder/java-maven-hello-world/s2i-assemble-and-assemble-runtime/.s2i/bin" |
|
36 |
- } |
|
37 |
- } |
|
38 |
- } |
|
39 |
-} |
40 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,23 @@ |
0 |
+kind: BuildConfig |
|
1 |
+apiVersion: v1 |
|
2 |
+metadata: |
|
3 |
+ name: java-extended-build-from-url |
|
4 |
+spec: |
|
5 |
+ source: |
|
6 |
+ git: |
|
7 |
+ uri: "https://github.com/php-coder/java-maven-hello-world.git" |
|
8 |
+ strategy: |
|
9 |
+ sourceStrategy: |
|
10 |
+ from: |
|
11 |
+ kind: ImageStreamTag |
|
12 |
+ name: "wildfly:10.0" |
|
13 |
+ namespace: openshift |
|
14 |
+ runtimeImage: |
|
15 |
+ kind: ImageStreamTag |
|
16 |
+ name: "jvm-runner:0.1" |
|
17 |
+ runtimeArtifacts: |
|
18 |
+ - sourcePath: /opt/s2i/destination/src/target/hello.jar |
|
19 |
+ env: |
|
20 |
+ - name: USING_ENV_FROM_BUILD_CONFIG |
|
21 |
+ value: "yes" |
|
22 |
+ scripts: "https://raw.githubusercontent.com/php-coder/java-maven-hello-world/s2i-assemble-and-assemble-runtime/.s2i/bin" |
0 | 23 |
deleted file mode 100644 |
... | ... |
@@ -1,39 +0,0 @@ |
1 |
-{ |
|
2 |
- "kind": "BuildConfig", |
|
3 |
- "apiVersion": "v1", |
|
4 |
- "metadata": { |
|
5 |
- "name": "java-extended-build-from-repo" |
|
6 |
- }, |
|
7 |
- "spec": { |
|
8 |
- "source": { |
|
9 |
- "git": { |
|
10 |
- "uri": "https://github.com/php-coder/java-maven-hello-world.git", |
|
11 |
- "ref": "s2i-assemble-and-assemble-runtime" |
|
12 |
- } |
|
13 |
- }, |
|
14 |
- "strategy": { |
|
15 |
- "sourceStrategy": { |
|
16 |
- "from": { |
|
17 |
- "kind": "ImageStreamTag", |
|
18 |
- "name": "wildfly:10.0", |
|
19 |
- "namespace": "openshift" |
|
20 |
- }, |
|
21 |
- "runtimeImage": { |
|
22 |
- "kind": "DockerImage", |
|
23 |
- "name": "phpcoder/base-jdk:8" |
|
24 |
- }, |
|
25 |
- "runtimeArtifacts": [ |
|
26 |
- { |
|
27 |
- "sourcePath": "/opt/s2i/destination/src/target/hello.jar" |
|
28 |
- } |
|
29 |
- ], |
|
30 |
- "env": [ |
|
31 |
- { |
|
32 |
- "name": "USING_ENV_FROM_BUILD_CONFIG", |
|
33 |
- "value": "yes" |
|
34 |
- } |
|
35 |
- ] |
|
36 |
- } |
|
37 |
- } |
|
38 |
- } |
|
39 |
-} |
40 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,23 @@ |
0 |
+kind: BuildConfig |
|
1 |
+apiVersion: v1 |
|
2 |
+metadata: |
|
3 |
+ name: java-extended-build-from-repo |
|
4 |
+spec: |
|
5 |
+ source: |
|
6 |
+ git: |
|
7 |
+ uri: "https://github.com/php-coder/java-maven-hello-world.git" |
|
8 |
+ ref: s2i-assemble-and-assemble-runtime |
|
9 |
+ strategy: |
|
10 |
+ sourceStrategy: |
|
11 |
+ from: |
|
12 |
+ kind: ImageStreamTag |
|
13 |
+ name: "wildfly:10.0" |
|
14 |
+ namespace: openshift |
|
15 |
+ runtimeImage: |
|
16 |
+ kind: ImageStreamTag |
|
17 |
+ name: "jvm-runner:0.1" |
|
18 |
+ runtimeArtifacts: |
|
19 |
+ - sourcePath: /opt/s2i/destination/src/target/hello.jar |
|
20 |
+ env: |
|
21 |
+ - name: USING_ENV_FROM_BUILD_CONFIG |
|
22 |
+ value: "yes" |
0 | 23 |
deleted file mode 100644 |
... | ... |
@@ -1,34 +0,0 @@ |
1 |
-{ |
|
2 |
- "kind": "BuildConfig", |
|
3 |
- "apiVersion": "v1", |
|
4 |
- "metadata": { |
|
5 |
- "name": "java-extended-build-from-image" |
|
6 |
- }, |
|
7 |
- "spec": { |
|
8 |
- "source": { |
|
9 |
- "git": { |
|
10 |
- "uri": "https://github.com/php-coder/java-maven-hello-world.git", |
|
11 |
- "ref": "s2i-assemble-only" |
|
12 |
- } |
|
13 |
- }, |
|
14 |
- "strategy": { |
|
15 |
- "sourceStrategy": { |
|
16 |
- "from": { |
|
17 |
- "kind": "ImageStreamTag", |
|
18 |
- "name": "wildfly:10.0", |
|
19 |
- "namespace": "openshift" |
|
20 |
- }, |
|
21 |
- "runtimeImage": { |
|
22 |
- "kind": "DockerImage", |
|
23 |
- "name": "phpcoder/hello-world-runtime:0.2" |
|
24 |
- }, |
|
25 |
- "env": [ |
|
26 |
- { |
|
27 |
- "name": "USING_ENV_FROM_BUILD_CONFIG", |
|
28 |
- "value": "yes" |
|
29 |
- } |
|
30 |
- ] |
|
31 |
- } |
|
32 |
- } |
|
33 |
- } |
|
34 |
-} |
35 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,21 @@ |
0 |
+kind: BuildConfig |
|
1 |
+apiVersion: v1 |
|
2 |
+metadata: |
|
3 |
+ name: java-extended-build-from-image |
|
4 |
+spec: |
|
5 |
+ source: |
|
6 |
+ git: |
|
7 |
+ uri: "https://github.com/php-coder/java-maven-hello-world.git" |
|
8 |
+ ref: s2i-assemble-only |
|
9 |
+ strategy: |
|
10 |
+ sourceStrategy: |
|
11 |
+ from: |
|
12 |
+ kind: ImageStreamTag |
|
13 |
+ name: "wildfly:10.0" |
|
14 |
+ namespace: openshift |
|
15 |
+ runtimeImage: |
|
16 |
+ kind: ImageStreamTag |
|
17 |
+ name: "jvm-runner-with-scripts:0.1" |
|
18 |
+ env: |
|
19 |
+ - name: USING_ENV_FROM_BUILD_CONFIG |
|
20 |
+ value: "yes" |
0 | 21 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,32 @@ |
0 |
+kind: List |
|
1 |
+apiVersion: v1 |
|
2 |
+items: |
|
3 |
+ |
|
4 |
+- kind: ImageStream |
|
5 |
+ apiVersion: v1 |
|
6 |
+ metadata: |
|
7 |
+ name: jvm-runner-with-scripts |
|
8 |
+ |
|
9 |
+- kind: BuildConfig |
|
10 |
+ apiVersion: v1 |
|
11 |
+ metadata: |
|
12 |
+ name: jvm-runner-with-scripts |
|
13 |
+ spec: |
|
14 |
+ source: |
|
15 |
+ dockerfile: | |
|
16 |
+ FROM jboss/base-jdk:8 |
|
17 |
+ LABEL io.openshift.s2i.scripts-url "image:///usr/libexec/s2i" |
|
18 |
+ LABEL io.openshift.s2i.assemble-input-files "/opt/s2i/destination/src/target/hello.jar" |
|
19 |
+ USER root |
|
20 |
+ RUN mkdir -p /usr/libexec/s2i && \ |
|
21 |
+ curl -s https://raw.githubusercontent.com/php-coder/java-maven-hello-world/s2i-assemble-and-assemble-runtime/.s2i/bin/assemble-runtime | tee /usr/libexec/s2i/assemble-runtime && \ |
|
22 |
+ chmod +x /usr/libexec/s2i/assemble-runtime && \ |
|
23 |
+ curl -s https://raw.githubusercontent.com/php-coder/java-maven-hello-world/s2i-assemble-and-assemble-runtime/.s2i/bin/run | tee /usr/libexec/s2i/run && \ |
|
24 |
+ chmod +x /usr/libexec/s2i/run |
|
25 |
+ USER 1000 |
|
26 |
+ strategy: |
|
27 |
+ type: Docker |
|
28 |
+ output: |
|
29 |
+ to: |
|
30 |
+ kind: ImageStreamTag |
|
31 |
+ name: jvm-runner-with-scripts:0.1 |
0 | 32 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,24 @@ |
0 |
+kind: List |
|
1 |
+apiVersion: v1 |
|
2 |
+items: |
|
3 |
+ |
|
4 |
+- kind: ImageStream |
|
5 |
+ apiVersion: v1 |
|
6 |
+ metadata: |
|
7 |
+ name: jvm-runner |
|
8 |
+ |
|
9 |
+- kind: BuildConfig |
|
10 |
+ apiVersion: v1 |
|
11 |
+ metadata: |
|
12 |
+ name: jvm-runner |
|
13 |
+ spec: |
|
14 |
+ source: |
|
15 |
+ dockerfile: | |
|
16 |
+ FROM jboss/base-jdk:8 |
|
17 |
+ USER 1000 |
|
18 |
+ strategy: |
|
19 |
+ type: Docker |
|
20 |
+ output: |
|
21 |
+ to: |
|
22 |
+ kind: ImageStreamTag |
|
23 |
+ name: jvm-runner:0.1 |
... | ... |
@@ -379,7 +379,7 @@ func (c *CLI) OutputToFile(filename string) (string, error) { |
379 | 379 |
func (c *CLI) Execute() error { |
380 | 380 |
out, err := c.Output() |
381 | 381 |
if _, err := io.Copy(g.GinkgoWriter, strings.NewReader(out+"\n")); err != nil { |
382 |
- fmt.Printf("ERROR: Unable to copy the output to ginkgo writer") |
|
382 |
+ fmt.Fprintln(os.Stderr, "ERROR: Unable to copy the output to ginkgo writer") |
|
383 | 383 |
} |
384 | 384 |
os.Stdout.Sync() |
385 | 385 |
return err |
... | ... |
@@ -565,6 +565,36 @@ func WaitForAnImageStream(client client.ImageStreamInterface, |
565 | 565 |
} |
566 | 566 |
} |
567 | 567 |
|
568 |
+// WaitForAnImageStreamTag waits until an image stream with given name has non-empty history for given tag. |
|
569 |
+func WaitForAnImageStreamTag(oc *CLI, namespace, name, tag string) error { |
|
570 |
+ waitTimeout := time.Second * 60 |
|
571 |
+ g.By(fmt.Sprintf("waiting for an is importer to import a tag %s into a stream %s", tag, name)) |
|
572 |
+ start := time.Now() |
|
573 |
+ c := make(chan error) |
|
574 |
+ go func() { |
|
575 |
+ err := WaitForAnImageStream( |
|
576 |
+ oc.REST().ImageStreams(namespace), |
|
577 |
+ name, |
|
578 |
+ func(is *imageapi.ImageStream) bool { |
|
579 |
+ if history, exists := is.Status.Tags[tag]; !exists || len(history.Items) == 0 { |
|
580 |
+ return false |
|
581 |
+ } |
|
582 |
+ return true |
|
583 |
+ }, |
|
584 |
+ func(is *imageapi.ImageStream) bool { |
|
585 |
+ return time.Now().After(start.Add(waitTimeout)) |
|
586 |
+ }) |
|
587 |
+ c <- err |
|
588 |
+ }() |
|
589 |
+ |
|
590 |
+ select { |
|
591 |
+ case e := <-c: |
|
592 |
+ return e |
|
593 |
+ case <-time.After(waitTimeout): |
|
594 |
+ return fmt.Errorf("timed out while waiting of an image stream tag %s/%s:%s", namespace, name, tag) |
|
595 |
+ } |
|
596 |
+} |
|
597 |
+ |
|
568 | 598 |
// CheckImageStreamLatestTagPopulatedFn returns true if the imagestream has a ':latest' tag filed |
569 | 599 |
var CheckImageStreamLatestTagPopulatedFn = func(i *imageapi.ImageStream) bool { |
570 | 600 |
_, ok := i.Status.Tags["latest"] |