Skip to content

Commit 5b03834

Browse files
committed
add PR testing hook for openshift-login plugin
1 parent de7602b commit 5b03834

File tree

3 files changed

+67
-10
lines changed

3 files changed

+67
-10
lines changed

test/extended/builds/pipeline.go

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,37 @@ var _ = g.Describe("[builds][Slow] openshift pipeline build", func() {
7171
dcLogStdOut, dcLogStdErr *bytes.Buffer
7272
setupJenkins = func() {
7373
// Deploy Jenkins
74+
// NOTE, we use these tests for both a) nightly regression runs against the latest openshift jenkins image on docker hub, and
75+
// b) PR testing for changes to the various openshift jenkins plugins we support. With scenario b), a docker image that extends
76+
// our jenkins image is built, where the proposed plugin change is injected, overwritting the current released version of the plugin.
77+
// Our test/PR jobs on ci.openshift create those images, as well as set env vars this test suite looks for. When both the env var
78+
// and test image is present, a new image stream is created using the test image, and our jenkins template is instantiated with
79+
// an override to use that images stream and test image
7480
var licensePrefix, pluginName string
81+
useSnapshotImage := false
7582
// our pipeline jobs, between jenkins and oc invocations, need more mem than the default
7683
newAppArgs := []string{"-f", jenkinsTemplatePath, "-p", "MEMORY_LIMIT=2Gi"}
77-
newAppArgs, useSnapshotImage := jenkins.SetupSnapshotImage(jenkins.UseLocalClientPluginSnapshotEnvVarName, localClientPluginSnapshotImage, localClientPluginSnapshotImageStream, newAppArgs, oc)
78-
if !useSnapshotImage {
79-
newAppArgs, useSnapshotImage = jenkins.SetupSnapshotImage(jenkins.UseLocalSyncPluginSnapshotEnvVarName, localSyncPluginSnapshotImage, localSyncPluginSnapshotImageStream, newAppArgs, oc)
80-
licensePrefix = syncLicenseText
81-
pluginName = syncPluginName
82-
} else {
84+
clientPluginNewAppArgs, useClientPluginSnapshotImage := jenkins.SetupSnapshotImage(jenkins.UseLocalClientPluginSnapshotEnvVarName, localClientPluginSnapshotImage, localClientPluginSnapshotImageStream, newAppArgs, oc)
85+
syncPluginNewAppArgs, useSyncPluginSnapshotImage := jenkins.SetupSnapshotImage(jenkins.UseLocalSyncPluginSnapshotEnvVarName, localSyncPluginSnapshotImage, localSyncPluginSnapshotImageStream, newAppArgs, oc)
86+
switch {
87+
case useClientPluginSnapshotImage && useSyncPluginSnapshotImage:
88+
fmt.Fprintf(g.GinkgoWriter,
89+
"\nBOTH %s and %s for PR TESTING ARE SET. WILL NOT CHOOSE BETWEEN THE TWO SO TESTING CURRENT PLUGIN VERSIONS IN LATEST OPENSHIFT JENKINS IMAGE ON DOCKER HUB.\n",
90+
jenkins.UseLocalClientPluginSnapshotEnvVarName, jenkins.UseLocalSyncPluginSnapshotEnvVarName)
91+
case useClientPluginSnapshotImage:
92+
fmt.Fprintf(g.GinkgoWriter, "\nTHE UPCOMING TESTS WILL LEVERAGE AN IMAGE THAT EXTENDS THE LATEST OPENSHIFT JENKINS IMAGE AND OVERRIDES THE OPENSHIFT CLIENT PLUGIN WITH A NEW VERSION BUILT FROM PROPOSED CHANGES TO THAT PLUGIN.\n")
8393
licensePrefix = clientLicenseText
8494
pluginName = clientPluginName
95+
useSnapshotImage = true
96+
newAppArgs = clientPluginNewAppArgs
97+
case useSyncPluginSnapshotImage:
98+
fmt.Fprintf(g.GinkgoWriter, "\nTHE UPCOMING TESTS WILL LEVERAGE AN IMAGE THAT EXTENDS THE LATEST OPENSHIFT JENKINS IMAGE AND OVERRIDES THE OPENSHIFT SYNC PLUGIN WITH A NEW VERSION BUILT FROM PROPOSED CHANGES TO THAT PLUGIN.\n")
99+
licensePrefix = syncLicenseText
100+
pluginName = syncPluginName
101+
useSnapshotImage = true
102+
newAppArgs = syncPluginNewAppArgs
103+
default:
104+
fmt.Fprintf(g.GinkgoWriter, "\nNO PR TEST ENV VARS SET SO TESTING CURRENT PLUGIN VERSIONS IN LATEST OPENSHIFT JENKINS IMAGE ON DOCKER HUB.\n")
85105
}
86106

87107
g.By(fmt.Sprintf("calling oc new-app useSnapshotImage %v with license text %s and newAppArgs %#v", useSnapshotImage, licensePrefix, newAppArgs))

test/extended/image_ecosystem/jenkins_plugin.go

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ import (
2323
)
2424

2525
const (
26-
localPluginSnapshotImageStream = "jenkins-plugin-snapshot-test"
27-
localPluginSnapshotImage = "openshift/" + localPluginSnapshotImageStream + ":latest"
26+
localPluginSnapshotImageStream = "jenkins-plugin-snapshot-test"
27+
localPluginSnapshotImage = "openshift/" + localPluginSnapshotImageStream + ":latest"
28+
localLoginPluginSnapshotImageStream = "jenkins-login-plugin-snapshot-test"
29+
localLoginPluginSnapshotImage = "openshift/" + localLoginPluginSnapshotImageStream + ":latest"
30+
originalLicenseText = "About OpenShift Pipeline Jenkins Plugin"
31+
originalPluginName = "openshift-pipeline"
32+
loginLicenseText = "About OpenShift Login Plugin"
33+
loginPluginName = "openshift-login"
2834
)
2935

3036
// ginkgolog creates simple entry in the GinkgoWriter.
@@ -153,8 +159,38 @@ var _ = g.Describe("[image_ecosystem][jenkins][Slow] openshift pipeline plugin",
153159

154160
g.By("kick off the build for the jenkins ephemeral and application templates")
155161

162+
// Deploy Jenkins
163+
// NOTE, we use these tests for both a) nightly regression runs against the latest openshift jenkins image on docker hub, and
164+
// b) PR testing for changes to the various openshift jenkins plugins we support. With scenario b), a docker image that extends
165+
// our jenkins image is built, where the proposed plugin change is injected, overwritting the current released version of the plugin.
166+
// Our test/PR jobs on ci.openshift create those images, as well as set env vars this test suite looks for. When both the env var
167+
// and test image is present, a new image stream is created using the test image, and our jenkins template is instantiated with
168+
// an override to use that images stream and test image
169+
var licensePrefix, pluginName string
156170
newAppArgs := []string{exutil.FixturePath("..", "..", "examples", "jenkins", "jenkins-ephemeral-template.json")}
157-
newAppArgs, useSnapshotImage := jenkins.SetupSnapshotImage(jenkins.UseLocalPluginSnapshotEnvVarName, localPluginSnapshotImage, localPluginSnapshotImageStream, newAppArgs, oc)
171+
useSnapshotImage := false
172+
origPluginNewAppArgs, useOrigPluginSnapshotImage := jenkins.SetupSnapshotImage(jenkins.UseLocalPluginSnapshotEnvVarName, localPluginSnapshotImage, localPluginSnapshotImageStream, newAppArgs, oc)
173+
loginPluginNewAppArgs, useLoginPluginSnapshotImage := jenkins.SetupSnapshotImage(jenkins.UseLocalLoginPluginSnapshotEnvVarName, localLoginPluginSnapshotImage, localLoginPluginSnapshotImageStream, newAppArgs, oc)
174+
switch {
175+
case useOrigPluginSnapshotImage && useLoginPluginSnapshotImage:
176+
fmt.Fprintf(g.GinkgoWriter,
177+
"\nBOTH %s and %s for PR TESTING ARE SET. WILL NOT CHOOSE BETWEEN THE TWO SO TESTING CURRENT PLUGIN VERSIONS IN LATEST OPENSHIFT JENKINS IMAGE ON DOCKER HUB.\n",
178+
jenkins.UseLocalPluginSnapshotEnvVarName, jenkins.UseLocalLoginPluginSnapshotEnvVarName)
179+
case useOrigPluginSnapshotImage:
180+
fmt.Fprintf(g.GinkgoWriter, "\nTHE UPCOMING TESTS WILL LEVERAGE AN IMAGE THAT EXTENDS THE LATEST OPENSHIFT JENKINS IMAGE AND OVERRIDES THE OPENSHIFT PIPELINE PLUGIN WITH A NEW VERSION BUILT FROM PROPOSED CHANGES TO THAT PLUGIN.\n")
181+
licensePrefix = originalLicenseText
182+
pluginName = originalPluginName
183+
useSnapshotImage = true
184+
newAppArgs = origPluginNewAppArgs
185+
case useLoginPluginSnapshotImage:
186+
fmt.Fprintf(g.GinkgoWriter, "\nTHE UPCOMING TESTS WILL LEVERAGE AN IMAGE THAT EXTENDS THE LATEST OPENSHIFT JENKINS IMAGE AND OVERRIDES THE OPENSHIFT LOGIN PLUGIN WITH A NEW VERSION BUILT FROM PROPOSED CHANGES TO THAT PLUGIN.\n")
187+
licensePrefix = loginLicenseText
188+
pluginName = loginPluginName
189+
useSnapshotImage = true
190+
newAppArgs = loginPluginNewAppArgs
191+
default:
192+
fmt.Fprintf(g.GinkgoWriter, "\nNO PR TEST ENV VARS SET SO TESTING CURRENT PLUGIN VERSIONS IN LATEST OPENSHIFT JENKINS IMAGE ON DOCKER HUB.\n")
193+
}
158194

159195
err := oc.Run("new-app").Args(newAppArgs...).Execute()
160196
o.Expect(err).NotTo(o.HaveOccurred())
@@ -177,7 +213,7 @@ var _ = g.Describe("[image_ecosystem][jenkins][Slow] openshift pipeline plugin",
177213
if useSnapshotImage {
178214
g.By("verifying the test image is being used")
179215
// for the test image, confirm that a snapshot version of the plugin is running in the jenkins image we'll test against
180-
_, err = j.WaitForContent(`About OpenShift Pipeline Jenkins Plugin ([0-9\.]+)-SNAPSHOT`, 200, 10*time.Minute, "/pluginManager/plugin/openshift-pipeline/thirdPartyLicenses")
216+
_, err = j.WaitForContent(licensePrefix+` ([0-9\.]+)-SNAPSHOT`, 200, 10*time.Minute, "/pluginManager/plugin/"+pluginName+"/thirdPartyLicenses")
181217
o.Expect(err).NotTo(o.HaveOccurred())
182218
}
183219

test/extended/util/jenkins/ref.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const (
2828
UseLocalPluginSnapshotEnvVarName = "USE_SNAPSHOT_JENKINS_IMAGE"
2929
UseLocalClientPluginSnapshotEnvVarName = "USE_SNAPSHOT_JENKINS_CLIENT_IMAGE"
3030
UseLocalSyncPluginSnapshotEnvVarName = "USE_SNAPSHOT_JENKINS_SYNC_IMAGE"
31+
UseLocalLoginPluginSnapshotEnvVarName = "USE_SNAPSHOT_JENKINS_LOGIN_IMAGE"
3132
)
3233

3334
// JenkinsRef represents a Jenkins instance running on an OpenShift server

0 commit comments

Comments
 (0)