| ... | ... |
@@ -2,43 +2,46 @@ package builds |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 |
+ "strings" |
|
| 5 | 6 |
|
| 6 | 7 |
g "github.com/onsi/ginkgo" |
| 7 | 8 |
o "github.com/onsi/gomega" |
| 8 | 9 |
|
| 9 |
- dockerClient "github.com/fsouza/go-dockerclient" |
|
| 10 | 10 |
exutil "github.com/openshift/origin/test/extended/util" |
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
const ( |
| 14 |
- buildPrefixFS = "ruby-sample-build-fs" |
|
| 15 | 14 |
buildPrefixTS = "ruby-sample-build-ts" |
| 16 |
- buildPrefixFD = "ruby-sample-build-fd" |
|
| 17 | 15 |
buildPrefixTD = "ruby-sample-build-td" |
| 18 |
- buildPrefixFC = "ruby-sample-build-fc" |
|
| 19 | 16 |
buildPrefixTC = "ruby-sample-build-tc" |
| 17 |
+) |
|
| 20 | 18 |
|
| 21 |
- corruptor = "docker.io/openshift/origin-deployer" |
|
| 22 |
- |
|
| 23 |
- varSubSrc = "SERVICE_REGISTRY_IP" |
|
| 19 |
+func scrapeLogs(bldPrefix string, oc *exutil.CLI) {
|
|
| 20 |
+ // kick off the app/lang build and verify the builder image accordingly |
|
| 21 |
+ br, err := exutil.StartBuildAndWait(oc, bldPrefix) |
|
| 22 |
+ o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred()) |
|
| 24 | 23 |
|
| 25 |
- bldr = "forcepull-extended-test-builder" |
|
| 26 |
- bldrPrefix = "forcepull-bldr" |
|
| 27 |
-) |
|
| 24 |
+ out, err := br.Logs() |
|
| 25 |
+ o.Expect(err).NotTo(o.HaveOccurred()) |
|
| 26 |
+ lines := strings.Split(out, "\n") |
|
| 27 |
+ found := false |
|
| 28 |
+ for _, line := range lines {
|
|
| 29 |
+ if strings.Contains(line, "Pulling image") && strings.Contains(line, "centos/ruby") {
|
|
| 30 |
+ fmt.Fprintf(g.GinkgoWriter, "\n\nfound pull image line %s\n\n", line) |
|
| 31 |
+ found = true |
|
| 32 |
+ break |
|
| 33 |
+ } |
|
| 34 |
+ } |
|
| 28 | 35 |
|
| 29 |
-var ( |
|
| 30 |
- resetData map[string]string |
|
| 31 |
- authCfg *dockerClient.AuthConfiguration |
|
| 32 |
- fullImageName string |
|
| 33 |
- tags []string |
|
| 34 |
- varSubDest string |
|
| 35 |
-) |
|
| 36 |
+ if !found {
|
|
| 37 |
+ fmt.Fprintf(g.GinkgoWriter, "\n\n build log dump on failed test: %s\n\n", out) |
|
| 38 |
+ o.Expect(found).To(o.BeTrue()) |
|
| 39 |
+ } |
|
| 36 | 40 |
|
| 37 |
-func doTest(bldPrefix, debugStr string, same bool, oc *exutil.CLI) {
|
|
| 38 |
- // corrupt the builder image |
|
| 39 |
- exutil.CorruptImage(fullImageName, corruptor) |
|
| 41 |
+} |
|
| 40 | 42 |
|
| 41 |
- if bldPrefix == buildPrefixFC || bldPrefix == buildPrefixTC {
|
|
| 43 |
+func checkPodFlag(bldPrefix string, oc *exutil.CLI) {
|
|
| 44 |
+ if bldPrefix == buildPrefixTC {
|
|
| 42 | 45 |
// grant access to the custom build strategy |
| 43 | 46 |
err := oc.AsAdmin().Run("adm").Args("policy", "add-cluster-role-to-user", "system:build-strategy-custom", oc.Username()).Execute()
|
| 44 | 47 |
o.Expect(err).NotTo(o.HaveOccurred()) |
| ... | ... |
@@ -52,78 +55,29 @@ func doTest(bldPrefix, debugStr string, same bool, oc *exutil.CLI) {
|
| 52 | 52 |
_, err := exutil.StartBuildAndWait(oc, bldPrefix) |
| 53 | 53 |
o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred()) |
| 54 | 54 |
|
| 55 |
- if same {
|
|
| 56 |
- exutil.VerifyImagesSame(fullImageName, corruptor, debugStr) |
|
| 57 |
- } else {
|
|
| 58 |
- exutil.VerifyImagesDifferent(fullImageName, corruptor, debugStr) |
|
| 59 |
- } |
|
| 55 |
+ out, err := oc.Run("get").Args("pods", bldPrefix+"-1-build", "-o", "jsonpath='{.spec.containers[0].imagePullPolicy}'").Output()
|
|
| 56 |
+ o.Expect(err).NotTo(o.HaveOccurred()) |
|
| 57 |
+ o.Expect(out).To(o.Equal("'Always'"))
|
|
| 60 | 58 |
|
| 61 |
- // reset corrupted tagging for next test |
|
| 62 |
- exutil.ResetImage(resetData) |
|
| 63 |
- // dump tags/hexids for debug |
|
| 64 |
- _, err = exutil.DumpAndReturnTagging(tags) |
|
| 65 |
- o.ExpectWithOffset(1, err).NotTo(o.HaveOccurred()) |
|
| 66 | 59 |
} |
| 67 | 60 |
|
| 68 | 61 |
/* |
| 69 | 62 |
If docker.io is not responding to requests in a timely manner, this test suite will be adversely affected. |
| 70 | 63 |
|
| 71 |
-If you suspect such a situation, attempt pulling some openshift images other than ruby-22-centos7 or origin-custom-docker-builder |
|
| 64 |
+If you suspect such a situation, attempt pulling some openshift images other than ruby-22-centos7 |
|
| 72 | 65 |
while this test is running and compare results. Restarting your docker daemon, assuming you can ping docker.io quickly, could |
| 73 | 66 |
be a quick fix. |
| 74 |
- |
|
| 75 |
-Also, in order to build the test case specific builder images only once, we currently have to do all the testing within a single g.It block. |
|
| 76 |
-The project/namespace were being destroyed between tests, and that includes removal of the specific builder images |
|
| 77 |
-we built. The credentials also are recycled between those points. |
|
| 78 |
- |
|
| 79 |
-Dumping of the ImageStreams and Secrets JSON output at the various points proved this out. |
|
| 80 | 67 |
*/ |
| 81 | 68 |
|
| 82 |
-var _ = g.Describe("[LocalNode][builds] forcePull should affect pulling builder images", func() {
|
|
| 69 |
+var _ = g.Describe("[builds] forcePull should affect pulling builder images", func() {
|
|
| 83 | 70 |
defer g.GinkgoRecover() |
| 84 | 71 |
var oc = exutil.NewCLI("forcepull", exutil.KubeConfigPath())
|
| 85 | 72 |
|
| 86 | 73 |
g.BeforeEach(func() {
|
| 87 | 74 |
|
| 88 |
- g.By("refresh corruptor, prep forcepull builder")
|
|
| 89 |
- exutil.PullImage(corruptor, dockerClient.AuthConfiguration{})
|
|
| 90 |
- |
|
| 91 |
- exutil.DumpImage(corruptor) |
|
| 92 |
- |
|
| 93 |
- // create the image streams and build configs for a test case specific builders |
|
| 94 |
- setupPath := exutil.FixturePath("testdata", "forcepull-setup.json")
|
|
| 95 |
- err := exutil.CreateResource(setupPath, oc) |
|
| 96 |
- |
|
| 97 |
- // kick off the build for the new builder image just for force pull so we can corrupt them without conflicting with |
|
| 98 |
- // any other tests potentially running in parallel |
|
| 99 |
- br, _ := exutil.StartBuildAndWait(oc, bldrPrefix) |
|
| 100 |
- br.AssertSuccess() |
|
| 101 |
- |
|
| 102 |
- serviceIP, err := oc.Run("get").Args("svc", "docker-registry", "-n", "default", "--config", exutil.KubeConfigPath()).Template("{{.spec.clusterIP}}").Output()
|
|
| 103 |
- o.Expect(err).NotTo(o.HaveOccurred()) |
|
| 104 |
- port, err := oc.Run("get").Args("svc", "docker-registry", "-n", "default", "--config", exutil.KubeConfigPath()).Template("{{ $x := index .spec.ports 0}}{{$x.port}}").Output()
|
|
| 105 |
- o.Expect(err).NotTo(o.HaveOccurred()) |
|
| 106 |
- g.By(fmt.Sprintf("docker-registry service IP is %s and port %s ", serviceIP, port))
|
|
| 107 |
- |
|
| 108 |
- // get the auth so we can pull the build image from the internal docker registry since the builder controller will remove it |
|
| 109 |
- // from the docker daemon cache when the docker build completes; |
|
| 110 |
- authCfg, err = exutil.BuildAuthConfiguration(serviceIP+":"+port, oc) |
|
| 111 |
- |
|
| 112 |
- // now actually pull the image back in from the openshift internal docker registry |
|
| 113 |
- fullImageName = authCfg.ServerAddress + "/" + oc.Namespace() + "/" + bldr |
|
| 114 |
- err = exutil.PullImage(fullImageName, *authCfg) |
|
| 115 |
- o.Expect(err).NotTo(o.HaveOccurred()) |
|
| 116 |
- exutil.DumpImage(fullImageName) |
|
| 117 |
- |
|
| 118 |
- //update the build configs in the json for the app/lang builds to point to the builder images in the internal docker registry |
|
| 119 |
- // and then create the build config resources |
|
| 120 |
- pre := exutil.FixturePath("testdata", "forcepull-test.json")
|
|
| 121 |
- post := exutil.ArtifactPath("forcepull-test.json")
|
|
| 122 |
- varSubDest = authCfg.ServerAddress + "/" + oc.Namespace() |
|
| 123 |
- |
|
| 124 | 75 |
// grant access to the custom build strategy |
| 125 | 76 |
g.By("granting system:build-strategy-custom")
|
| 126 |
- err = oc.AsAdmin().Run("adm").Args("policy", "add-cluster-role-to-user", "system:build-strategy-custom", oc.Username()).Execute()
|
|
| 77 |
+ err := oc.AsAdmin().Run("adm").Args("policy", "add-cluster-role-to-user", "system:build-strategy-custom", oc.Username()).Execute()
|
|
| 127 | 78 |
o.Expect(err).NotTo(o.HaveOccurred()) |
| 128 | 79 |
|
| 129 | 80 |
defer func() {
|
| ... | ... |
@@ -131,17 +85,11 @@ var _ = g.Describe("[LocalNode][builds] forcePull should affect pulling builder
|
| 131 | 131 |
o.Expect(err).NotTo(o.HaveOccurred()) |
| 132 | 132 |
}() |
| 133 | 133 |
|
| 134 |
- err = exutil.VarSubOnFile(pre, post, map[string]string{varSubSrc: varSubDest})
|
|
| 135 |
- o.Expect(err).NotTo(o.HaveOccurred()) |
|
| 136 |
- err = exutil.CreateResource(post, oc) |
|
| 134 |
+ g.By("create application build configs for 3 strategies")
|
|
| 135 |
+ apps := exutil.FixturePath("testdata", "forcepull-test.json")
|
|
| 136 |
+ err = exutil.CreateResource(apps, oc) |
|
| 137 | 137 |
o.Expect(err).NotTo(o.HaveOccurred()) |
| 138 | 138 |
|
| 139 |
- // dump the image textual tags and hex ids out for debug |
|
| 140 |
- tags = []string{fullImageName + ":latest", corruptor + ":latest"}
|
|
| 141 |
- hexIDs, err := exutil.DumpAndReturnTagging(tags) |
|
| 142 |
- o.Expect(err).NotTo(o.HaveOccurred()) |
|
| 143 |
- resetData = map[string]string{fullImageName: hexIDs[0], corruptor: hexIDs[1]}
|
|
| 144 |
- |
|
| 145 | 139 |
}) |
| 146 | 140 |
|
| 147 | 141 |
g.Context("ForcePull test context ", func() {
|
| ... | ... |
@@ -152,31 +100,29 @@ var _ = g.Describe("[LocalNode][builds] forcePull should affect pulling builder
|
| 152 | 152 |
o.Expect(err).NotTo(o.HaveOccurred()) |
| 153 | 153 |
}) |
| 154 | 154 |
|
| 155 |
- g.It("ForcePull test case execution", func() {
|
|
| 156 |
- |
|
| 157 |
- g.By("when s2i force pull is false")
|
|
| 158 |
- |
|
| 159 |
- doTest(buildPrefixFS, "s2i false app/lang build", true, oc) |
|
| 155 |
+ g.It("ForcePull test case execution s2i", func() {
|
|
| 160 | 156 |
|
| 161 | 157 |
g.By("when s2i force pull is true")
|
| 158 |
+ // run twice to ensure the builder image gets pulled even if it already exists on the node |
|
| 159 |
+ scrapeLogs(buildPrefixTS, oc) |
|
| 160 |
+ scrapeLogs(buildPrefixTS, oc) |
|
| 162 | 161 |
|
| 163 |
- doTest(buildPrefixTS, "s2i true app/lang build", false, oc) |
|
| 164 |
- |
|
| 165 |
- g.By("when docker force pull is false")
|
|
| 162 |
+ }) |
|
| 166 | 163 |
|
| 167 |
- doTest(buildPrefixFD, "dock false app/lang build", true, oc) |
|
| 164 |
+ g.It("ForcePull test case execution docker", func() {
|
|
| 168 | 165 |
|
| 169 | 166 |
g.By("docker when force pull is true")
|
| 167 |
+ // run twice to ensure the builder image gets pulled even if it already exists on the node |
|
| 168 |
+ scrapeLogs(buildPrefixTD, oc) |
|
| 169 |
+ scrapeLogs(buildPrefixTD, oc) |
|
| 170 | 170 |
|
| 171 |
- doTest(buildPrefixTD, "dock true app/lang build", false, oc) |
|
| 172 |
- |
|
| 173 |
- g.By("when custom force pull is false")
|
|
| 171 |
+ }) |
|
| 174 | 172 |
|
| 175 |
- doTest(buildPrefixFC, "cust false app/lang build", true, oc) |
|
| 173 |
+ g.It("ForcePull test case execution custom", func() {
|
|
| 176 | 174 |
|
| 177 | 175 |
g.By("when custom force pull is true")
|
| 178 | 176 |
|
| 179 |
- doTest(buildPrefixTC, "cust true app/lang build", false, oc) |
|
| 177 |
+ checkPodFlag(buildPrefixTC, oc) |
|
| 180 | 178 |
|
| 181 | 179 |
}) |
| 182 | 180 |
|
| 183 | 181 |
deleted file mode 100644 |
| ... | ... |
@@ -1,56 +0,0 @@ |
| 1 |
-{
|
|
| 2 |
- "kind": "List", |
|
| 3 |
- "apiVersion": "v1", |
|
| 4 |
- "metadata": {},
|
|
| 5 |
- "items": [ |
|
| 6 |
- {
|
|
| 7 |
- "kind": "ImageStream", |
|
| 8 |
- "apiVersion": "v1", |
|
| 9 |
- "metadata": {
|
|
| 10 |
- "name": "forcepull-extended-test-builder", |
|
| 11 |
- "creationTimestamp": null |
|
| 12 |
- }, |
|
| 13 |
- "spec": {},
|
|
| 14 |
- "status": {
|
|
| 15 |
- "dockerImageRepository": "" |
|
| 16 |
- } |
|
| 17 |
- }, |
|
| 18 |
- {
|
|
| 19 |
- "kind": "BuildConfig", |
|
| 20 |
- "apiVersion": "v1", |
|
| 21 |
- "metadata": {
|
|
| 22 |
- "name": "forcepull-bldr", |
|
| 23 |
- "creationTimestamp": null, |
|
| 24 |
- "labels": {
|
|
| 25 |
- "name": "forcepull-bldr" |
|
| 26 |
- } |
|
| 27 |
- }, |
|
| 28 |
- "spec": {
|
|
| 29 |
- "triggers": [], |
|
| 30 |
- "source": {
|
|
| 31 |
- "type": "Git", |
|
| 32 |
- "git": {
|
|
| 33 |
- "uri": "https://github.com/gabemontero/forcepull-extended-test-builder.git" |
|
| 34 |
- } |
|
| 35 |
- }, |
|
| 36 |
- "strategy": {
|
|
| 37 |
- "type": "Docker", |
|
| 38 |
- "dockerStrategy": {
|
|
| 39 |
- "env": [ |
|
| 40 |
- {
|
|
| 41 |
- "name": "BUILD_LOGLEVEL", |
|
| 42 |
- "value": "5" |
|
| 43 |
- } |
|
| 44 |
- ] |
|
| 45 |
- } |
|
| 46 |
- }, |
|
| 47 |
- "output": {
|
|
| 48 |
- "to": {
|
|
| 49 |
- "kind": "ImageStreamTag", |
|
| 50 |
- "name": "forcepull-extended-test-builder:latest" |
|
| 51 |
- } |
|
| 52 |
- } |
|
| 53 |
- } |
|
| 54 |
- } |
|
| 55 |
- ] |
|
| 56 |
-} |
|
| 57 | 1 |
\ No newline at end of file |
| ... | ... |
@@ -7,119 +7,6 @@ |
| 7 | 7 |
"kind": "BuildConfig", |
| 8 | 8 |
"apiVersion": "v1", |
| 9 | 9 |
"metadata": {
|
| 10 |
- "name": "ruby-sample-build-fc", |
|
| 11 |
- "creationTimestamp": null, |
|
| 12 |
- "labels": {
|
|
| 13 |
- "name": "ruby-sample-build-fc" |
|
| 14 |
- } |
|
| 15 |
- }, |
|
| 16 |
- "spec": {
|
|
| 17 |
- "triggers": [], |
|
| 18 |
- "source": {
|
|
| 19 |
- "type": "Git", |
|
| 20 |
- "git": {
|
|
| 21 |
- "uri": "https://github.com/openshift/ruby-hello-world.git" |
|
| 22 |
- } |
|
| 23 |
- }, |
|
| 24 |
- "strategy": {
|
|
| 25 |
- "type": "Custom", |
|
| 26 |
- "customStrategy": {
|
|
| 27 |
- "from": {
|
|
| 28 |
- "kind": "DockerImage", |
|
| 29 |
- "name": "${SERVICE_REGISTRY_IP}/forcepull-extended-test-builder"
|
|
| 30 |
- }, |
|
| 31 |
- "env": [ |
|
| 32 |
- {
|
|
| 33 |
- "name": "OPENSHIFT_CUSTOM_BUILD_BASE_IMAGE", |
|
| 34 |
- "value": "${SERVICE_REGISTRY_IP}/forcepull-extended-test-builder"
|
|
| 35 |
- }, |
|
| 36 |
- {
|
|
| 37 |
- "name": "BUILD_LOGLEVEL", |
|
| 38 |
- "value": "5" |
|
| 39 |
- } |
|
| 40 |
- ], |
|
| 41 |
- "exposeDockerSocket": true, |
|
| 42 |
- "forcePull": false |
|
| 43 |
- } |
|
| 44 |
- } |
|
| 45 |
- } |
|
| 46 |
- }, |
|
| 47 |
- {
|
|
| 48 |
- "kind": "BuildConfig", |
|
| 49 |
- "apiVersion": "v1", |
|
| 50 |
- "metadata": {
|
|
| 51 |
- "name": "ruby-sample-build-fd", |
|
| 52 |
- "creationTimestamp": null, |
|
| 53 |
- "labels": {
|
|
| 54 |
- "name": "ruby-sample-build-fd" |
|
| 55 |
- } |
|
| 56 |
- }, |
|
| 57 |
- "spec": {
|
|
| 58 |
- "triggers": [], |
|
| 59 |
- "source": {
|
|
| 60 |
- "type": "Git", |
|
| 61 |
- "git": {
|
|
| 62 |
- "uri": "https://github.com/openshift/ruby-hello-world.git" |
|
| 63 |
- } |
|
| 64 |
- }, |
|
| 65 |
- "strategy": {
|
|
| 66 |
- "type": "Docker", |
|
| 67 |
- "dockerStrategy": {
|
|
| 68 |
- "from": {
|
|
| 69 |
- "kind": "DockerImage", |
|
| 70 |
- "name": "${SERVICE_REGISTRY_IP}/forcepull-extended-test-builder"
|
|
| 71 |
- }, |
|
| 72 |
- "env": [ |
|
| 73 |
- {
|
|
| 74 |
- "name": "BUILD_LOGLEVEL", |
|
| 75 |
- "value": "5" |
|
| 76 |
- } |
|
| 77 |
- ], |
|
| 78 |
- "forcePull": false |
|
| 79 |
- } |
|
| 80 |
- } |
|
| 81 |
- } |
|
| 82 |
- }, |
|
| 83 |
- {
|
|
| 84 |
- "kind": "BuildConfig", |
|
| 85 |
- "apiVersion": "v1", |
|
| 86 |
- "metadata": {
|
|
| 87 |
- "name": "ruby-sample-build-fs", |
|
| 88 |
- "creationTimestamp": null, |
|
| 89 |
- "labels": {
|
|
| 90 |
- "name": "ruby-sample-build-fs" |
|
| 91 |
- } |
|
| 92 |
- }, |
|
| 93 |
- "spec": {
|
|
| 94 |
- "triggers": [], |
|
| 95 |
- "source": {
|
|
| 96 |
- "type": "Git", |
|
| 97 |
- "git": {
|
|
| 98 |
- "uri": "https://github.com/openshift/ruby-hello-world.git" |
|
| 99 |
- } |
|
| 100 |
- }, |
|
| 101 |
- "strategy": {
|
|
| 102 |
- "type": "Source", |
|
| 103 |
- "sourceStrategy": {
|
|
| 104 |
- "from": {
|
|
| 105 |
- "kind": "DockerImage", |
|
| 106 |
- "name": "${SERVICE_REGISTRY_IP}/forcepull-extended-test-builder"
|
|
| 107 |
- }, |
|
| 108 |
- "env": [ |
|
| 109 |
- {
|
|
| 110 |
- "name": "BUILD_LOGLEVEL", |
|
| 111 |
- "value": "5" |
|
| 112 |
- } |
|
| 113 |
- ], |
|
| 114 |
- "forcePull": false |
|
| 115 |
- } |
|
| 116 |
- } |
|
| 117 |
- } |
|
| 118 |
- }, |
|
| 119 |
- {
|
|
| 120 |
- "kind": "BuildConfig", |
|
| 121 |
- "apiVersion": "v1", |
|
| 122 |
- "metadata": {
|
|
| 123 | 10 |
"name": "ruby-sample-build-tc", |
| 124 | 11 |
"creationTimestamp": null, |
| 125 | 12 |
"labels": {
|
| ... | ... |
@@ -138,13 +25,14 @@ |
| 138 | 138 |
"type": "Custom", |
| 139 | 139 |
"customStrategy": {
|
| 140 | 140 |
"from": {
|
| 141 |
- "kind": "DockerImage", |
|
| 142 |
- "name": "${SERVICE_REGISTRY_IP}/forcepull-extended-test-builder"
|
|
| 141 |
+ "kind": "ImageStreamTag", |
|
| 142 |
+ "namespace": "openshift", |
|
| 143 |
+ "name": "ruby:latest" |
|
| 143 | 144 |
}, |
| 144 | 145 |
"env": [ |
| 145 | 146 |
{
|
| 146 | 147 |
"name": "OPENSHIFT_CUSTOM_BUILD_BASE_IMAGE", |
| 147 |
- "value": "${SERVICE_REGISTRY_IP}/forcepull-extended-test-builder"
|
|
| 148 |
+ "value": "ruby:latest" |
|
| 148 | 149 |
}, |
| 149 | 150 |
{
|
| 150 | 151 |
"name": "BUILD_LOGLEVEL", |
| ... | ... |
@@ -179,8 +67,9 @@ |
| 179 | 179 |
"type": "Docker", |
| 180 | 180 |
"dockerStrategy": {
|
| 181 | 181 |
"from": {
|
| 182 |
- "kind": "DockerImage", |
|
| 183 |
- "name": "${SERVICE_REGISTRY_IP}/forcepull-extended-test-builder"
|
|
| 182 |
+ "kind": "ImageStreamTag", |
|
| 183 |
+ "namespace": "openshift", |
|
| 184 |
+ "name": "ruby:latest" |
|
| 184 | 185 |
}, |
| 185 | 186 |
"env": [ |
| 186 | 187 |
{
|
| ... | ... |
@@ -215,8 +104,9 @@ |
| 215 | 215 |
"type": "Source", |
| 216 | 216 |
"sourceStrategy": {
|
| 217 | 217 |
"from": {
|
| 218 |
- "kind": "DockerImage", |
|
| 219 |
- "name": "${SERVICE_REGISTRY_IP}/forcepull-extended-test-builder"
|
|
| 218 |
+ "kind": "ImageStreamTag", |
|
| 219 |
+ "namespace": "openshift", |
|
| 220 |
+ "name": "ruby:latest" |
|
| 220 | 221 |
}, |
| 221 | 222 |
"env": [ |
| 222 | 223 |
{
|
| ... | ... |
@@ -230,4 +120,4 @@ |
| 230 | 230 |
} |
| 231 | 231 |
} |
| 232 | 232 |
] |
| 233 |
-} |
|
| 234 | 233 |
\ No newline at end of file |
| 234 |
+} |
| ... | ... |
@@ -14,55 +14,6 @@ import ( |
| 14 | 14 |
"k8s.io/kubernetes/pkg/credentialprovider" |
| 15 | 15 |
) |
| 16 | 16 |
|
| 17 |
-//TagImage will apply the "tagor" tag string to the image current tagged by "tagee" |
|
| 18 |
-func TagImage(tagee, tagor string) error {
|
|
| 19 |
- client, dcerr := tutil.NewDockerClient() |
|
| 20 |
- if dcerr != nil {
|
|
| 21 |
- return dcerr |
|
| 22 |
- } |
|
| 23 |
- opts := dockerClient.TagImageOptions{
|
|
| 24 |
- Repo: tagee, |
|
| 25 |
- Tag: "latest", |
|
| 26 |
- Force: true, |
|
| 27 |
- } |
|
| 28 |
- return client.TagImage(tagor, opts) |
|
| 29 |
-} |
|
| 30 |
- |
|
| 31 |
-//InspectImage initiates the equivalent of a `docker inspect` for the "name" parameter |
|
| 32 |
-func InspectImage(name string) (*dockerClient.Image, error) {
|
|
| 33 |
- client, err := tutil.NewDockerClient() |
|
| 34 |
- if err != nil {
|
|
| 35 |
- return nil, err |
|
| 36 |
- } |
|
| 37 |
- return client.InspectImage(name) |
|
| 38 |
-} |
|
| 39 |
- |
|
| 40 |
-//PullImage initiates the equivalent of a `docker pull` for the "name" parameter |
|
| 41 |
-func PullImage(name string, authCfg dockerClient.AuthConfiguration) error {
|
|
| 42 |
- client, err := tutil.NewDockerClient() |
|
| 43 |
- if err != nil {
|
|
| 44 |
- return err |
|
| 45 |
- } |
|
| 46 |
- opts := dockerClient.PullImageOptions{
|
|
| 47 |
- Repository: name, |
|
| 48 |
- Tag: "latest", |
|
| 49 |
- } |
|
| 50 |
- return client.PullImage(opts, authCfg) |
|
| 51 |
-} |
|
| 52 |
- |
|
| 53 |
-//PushImage initiates the equivalent of a `docker push` for the "name" parameter to the local registry |
|
| 54 |
-func PushImage(name string, authCfg dockerClient.AuthConfiguration) error {
|
|
| 55 |
- client, err := tutil.NewDockerClient() |
|
| 56 |
- if err != nil {
|
|
| 57 |
- return err |
|
| 58 |
- } |
|
| 59 |
- opts := dockerClient.PushImageOptions{
|
|
| 60 |
- Name: name, |
|
| 61 |
- Tag: "latest", |
|
| 62 |
- } |
|
| 63 |
- return client.PushImage(opts, authCfg) |
|
| 64 |
-} |
|
| 65 |
- |
|
| 66 | 17 |
//ListImages initiates the equivalent of a `docker images` |
| 67 | 18 |
func ListImages() ([]string, error) {
|
| 68 | 19 |
client, err := tutil.NewDockerClient() |
| ... | ... |
@@ -4,47 +4,8 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
|
| 6 | 6 |
g "github.com/onsi/ginkgo" |
| 7 |
- o "github.com/onsi/gomega" |
|
| 8 | 7 |
) |
| 9 | 8 |
|
| 10 |
-//CorruptImage is a helper that tags the image to be corrupted, the corruptee, as the corruptor string, resulting in the wrong image being used when corruptee is referenced later on; strategy is for ginkgo debug; ginkgo error checking leveraged |
|
| 11 |
-func CorruptImage(corruptee, corruptor string) {
|
|
| 12 |
- fmt.Fprintf(g.GinkgoWriter, "Calling docker tag to corrupt builder image %s by tagging %s", corruptee, corruptor) |
|
| 13 |
- |
|
| 14 |
- cerr := TagImage(corruptee, corruptor) |
|
| 15 |
- |
|
| 16 |
- fmt.Fprintf(g.GinkgoWriter, "Tagging %s to %s complete with err %v", corruptor, corruptee, cerr) |
|
| 17 |
- o.Expect(cerr).NotTo(o.HaveOccurred()) |
|
| 18 |
- VerifyImagesSame(corruptee, corruptor, "image corruption") |
|
| 19 |
-} |
|
| 20 |
- |
|
| 21 |
-//ResetImage is a helper the allows the programmer to undo any corruption performed by CorruptImage; ginkgo error checking leveraged |
|
| 22 |
-func ResetImage(tags map[string]string) {
|
|
| 23 |
- fmt.Fprintf(g.GinkgoWriter, "Calling docker tag to reset images") |
|
| 24 |
- |
|
| 25 |
- for corruptedTag, goodTag := range tags {
|
|
| 26 |
- err := TagImage(corruptedTag, goodTag) |
|
| 27 |
- fmt.Fprintf(g.GinkgoWriter, "Reset for %s to %s complete with err %v", corruptedTag, goodTag, err) |
|
| 28 |
- o.Expect(err).NotTo(o.HaveOccurred()) |
|
| 29 |
- } |
|
| 30 |
- |
|
| 31 |
-} |
|
| 32 |
- |
|
| 33 |
-//DumpImage is a helper that inspects the image along with some ginkgo debug |
|
| 34 |
-func DumpImage(name string) {
|
|
| 35 |
- fmt.Fprintf(g.GinkgoWriter, "Calling docker inspect for image %s", name) |
|
| 36 |
- |
|
| 37 |
- image, err := InspectImage(name) |
|
| 38 |
- o.Expect(err).NotTo(o.HaveOccurred()) |
|
| 39 |
- if image != nil {
|
|
| 40 |
- fmt.Fprintf(g.GinkgoWriter, "Returned docker image %+v", image) |
|
| 41 |
- fmt.Fprintf(g.GinkgoWriter, "Container config %+v and user %s", image.ContainerConfig, image.ContainerConfig.User) |
|
| 42 |
- if image.Config != nil {
|
|
| 43 |
- fmt.Fprintf(g.GinkgoWriter, "Image config %+v and user %s", image.Config, image.Config.User) |
|
| 44 |
- } |
|
| 45 |
- } |
|
| 46 |
-} |
|
| 47 |
- |
|
| 48 | 9 |
//DumpAndReturnTagging takes and array of tags and obtains the hex image IDs, dumps them to ginkgo for printing, and then returns them |
| 49 | 10 |
func DumpAndReturnTagging(tags []string) ([]string, error) {
|
| 50 | 11 |
hexIDs, err := GetImageIDForTags(tags) |
| ... | ... |
@@ -57,36 +18,6 @@ func DumpAndReturnTagging(tags []string) ([]string, error) {
|
| 57 | 57 |
return hexIDs, nil |
| 58 | 58 |
} |
| 59 | 59 |
|
| 60 |
-//VerifyImagesSame will take the two supplied image tags and see if they reference the same hexadecimal image ID; strategy is for debug |
|
| 61 |
-func VerifyImagesSame(comp1, comp2, strategy string) {
|
|
| 62 |
- tag1 := comp1 + ":latest" |
|
| 63 |
- tag2 := comp2 + ":latest" |
|
| 64 |
- |
|
| 65 |
- comps := []string{tag1, tag2}
|
|
| 66 |
- retIDs, gerr := GetImageIDForTags(comps) |
|
| 67 |
- |
|
| 68 |
- o.Expect(gerr).NotTo(o.HaveOccurred()) |
|
| 69 |
- fmt.Fprintf(g.GinkgoWriter, "%s compare image - %s, %s, %s, %s", strategy, tag1, tag2, retIDs[0], retIDs[1]) |
|
| 70 |
- o.Ω(len(retIDs[0])).Should(o.BeNumerically(">", 0))
|
|
| 71 |
- o.Ω(len(retIDs[1])).Should(o.BeNumerically(">", 0))
|
|
| 72 |
- o.Ω(retIDs[0]).Should(o.Equal(retIDs[1])) |
|
| 73 |
-} |
|
| 74 |
- |
|
| 75 |
-//VerifyImagesDifferent will that the two supplied image tags and see if they reference different hexadecimal image IDs; strategy is for ginkgo debug, also leverage ginkgo error checking |
|
| 76 |
-func VerifyImagesDifferent(comp1, comp2, strategy string) {
|
|
| 77 |
- tag1 := comp1 + ":latest" |
|
| 78 |
- tag2 := comp2 + ":latest" |
|
| 79 |
- |
|
| 80 |
- comps := []string{tag1, tag2}
|
|
| 81 |
- retIDs, gerr := GetImageIDForTags(comps) |
|
| 82 |
- |
|
| 83 |
- o.Expect(gerr).NotTo(o.HaveOccurred()) |
|
| 84 |
- fmt.Fprintf(g.GinkgoWriter, "%s compare image - %s, %s, %s, %s", strategy, tag1, tag2, retIDs[0], retIDs[1]) |
|
| 85 |
- o.Ω(len(retIDs[0])).Should(o.BeNumerically(">", 0))
|
|
| 86 |
- o.Ω(len(retIDs[1])).Should(o.BeNumerically(">", 0))
|
|
| 87 |
- o.Ω(retIDs[0] != retIDs[1]).Should(o.BeTrue()) |
|
| 88 |
-} |
|
| 89 |
- |
|
| 90 | 60 |
//CreateResource creates the resources from the supplied json file (not a template); ginkgo error checking included |
| 91 | 61 |
func CreateResource(jsonFilePath string, oc *CLI) error {
|
| 92 | 62 |
err := oc.Run("create").Args("-f", jsonFilePath).Execute()
|