Skip to content

Commit

Permalink
Merge pull request #13285 from gabemontero/sync-plugin-pr-tester
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot authored Mar 8, 2017
2 parents aff7b5b + c8b84ee commit a4efef0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
25 changes: 21 additions & 4 deletions test/extended/builds/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ import (
)

const (
localPluginSnapshotImage = "openshift/jenkins-client-plugin-snapshot-test:latest"
localClientPluginSnapshotImageStream = "jenkins-client-plugin-snapshot-test"
localClientPluginSnapshotImage = "openshift/" + localClientPluginSnapshotImageStream + ":latest"
localSyncPluginSnapshotImageStream = "jenkins-sync-plugin-snapshot-test"
localSyncPluginSnapshotImage = "openshift/" + localSyncPluginSnapshotImageStream + ":latest"
clientLicenseText = "About OpenShift Client Jenkins Plugin"
syncLicenseText = "About OpenShift Sync"
clientPluginName = "openshift-client"
syncPluginName = "openshift-sync"
)

func debugAnyJenkinsFailure(br *exutil.BuildResult, name string, oc *exutil.CLI, dumpMaster bool) {
Expand Down Expand Up @@ -56,9 +63,19 @@ var _ = g.Describe("[builds][Slow] openshift pipeline build", func() {
dcLogStdOut, dcLogStdErr *bytes.Buffer
setupJenkins = func() {
// Deploy Jenkins
g.By(fmt.Sprintf("calling oc new-app -f %q", jenkinsTemplatePath))
var licensePrefix, pluginName string
newAppArgs := []string{"-f", jenkinsTemplatePath}
newAppArgs, useSnapshotImage := jenkins.SetupSnapshotImage(localPluginSnapshotImage, "jenkins-client-plugin-snapshot-test", newAppArgs, oc)
newAppArgs, useSnapshotImage := jenkins.SetupSnapshotImage(jenkins.UseLocalClientPluginSnapshotEnvVarName, localClientPluginSnapshotImage, localClientPluginSnapshotImageStream, newAppArgs, oc)
if !useSnapshotImage {
newAppArgs, useSnapshotImage = jenkins.SetupSnapshotImage(jenkins.UseLocalSyncPluginSnapshotEnvVarName, localSyncPluginSnapshotImage, localSyncPluginSnapshotImageStream, newAppArgs, oc)
licensePrefix = syncLicenseText
pluginName = syncPluginName
} else {
licensePrefix = clientLicenseText
pluginName = clientPluginName
}

g.By(fmt.Sprintf("calling oc new-app useSnapshotImage %v with license text %s and newAppArgs %#v", useSnapshotImage, licensePrefix, newAppArgs))
err := oc.Run("new-app").Args(newAppArgs...).Execute()
o.Expect(err).NotTo(o.HaveOccurred())

Expand All @@ -80,7 +97,7 @@ var _ = g.Describe("[builds][Slow] openshift pipeline build", func() {
if useSnapshotImage {
g.By("verifying the test image is being used")
// for the test image, confirm that a snapshot version of the plugin is running in the jenkins image we'll test against
_, err = j.WaitForContent(`About OpenShift Client Jenkins Plugin ([0-9\.]+)-SNAPSHOT`, 200, 10*time.Minute, "/pluginManager/plugin/openshift-client/thirdPartyLicenses")
_, err = j.WaitForContent(licensePrefix+` ([0-9\.]+)-SNAPSHOT`, 200, 10*time.Minute, "/pluginManager/plugin/"+pluginName+"/thirdPartyLicenses")
o.Expect(err).NotTo(o.HaveOccurred())
}

Expand Down
5 changes: 3 additions & 2 deletions test/extended/image_ecosystem/jenkins_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (
)

const (
localPluginSnapshotImage = "openshift/jenkins-plugin-snapshot-test:latest"
localPluginSnapshotImageStream = "jenkins-plugin-snapshot-test"
localPluginSnapshotImage = "openshift/" + localPluginSnapshotImageStream + ":latest"
)

// ginkgolog creates simple entry in the GinkgoWriter.
Expand Down Expand Up @@ -151,7 +152,7 @@ var _ = g.Describe("[image_ecosystem][jenkins][Slow] openshift pipeline plugin",
g.By("kick off the build for the jenkins ephermeral and application templates")

newAppArgs := []string{exutil.FixturePath("..", "..", "examples", "jenkins", "jenkins-ephemeral-template.json")}
newAppArgs, useSnapshotImage := jenkins.SetupSnapshotImage(localPluginSnapshotImage, "jenkins-plugin-snapshot-test", newAppArgs, oc)
newAppArgs, useSnapshotImage := jenkins.SetupSnapshotImage(jenkins.UseLocalPluginSnapshotEnvVarName, localPluginSnapshotImage, localPluginSnapshotImageStream, newAppArgs, oc)

err := oc.Run("new-app").Args(newAppArgs...).Execute()
o.Expect(err).NotTo(o.HaveOccurred())
Expand Down
13 changes: 7 additions & 6 deletions test/extended/util/jenkins/ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import (
)

const (
useLocalPluginSnapshotEnvVarName = "USE_SNAPSHOT_JENKINS_IMAGE"
UseLocalPluginSnapshotEnvVarName = "USE_SNAPSHOT_JENKINS_IMAGE"
UseLocalClientPluginSnapshotEnvVarName = "USE_SNAPSHOT_JENKINS_CLIENT_IMAGE"
UseLocalSyncPluginSnapshotEnvVarName = "USE_SNAPSHOT_JENKINS_SYNC_IMAGE"
)

// JenkinsRef represents a Jenkins instance running on an OpenShift server
Expand Down Expand Up @@ -340,15 +342,15 @@ func FindJenkinsPod(oc *exutil.CLI) *kapi.Pod {
}

// pulls in a jenkins image built from a PR change for one of our plugins
func SetupSnapshotImage(localImageName, snapshotImageStream string, newAppArgs []string, oc *exutil.CLI) ([]string, bool) {
func SetupSnapshotImage(envVarName, localImageName, snapshotImageStream string, newAppArgs []string, oc *exutil.CLI) ([]string, bool) {
tag := []string{localImageName}
hexIDs, err := exutil.DumpAndReturnTagging(tag)

// If the user has expressed an interest in local plugin testing by setting the
// SNAPSHOT_JENKINS_IMAGE environment variable, try to use the local image. Inform them
// either about which image is being used in case their test fails.
snapshotImagePresent := len(hexIDs) > 0 && err == nil
useSnapshotImage := os.Getenv(useLocalPluginSnapshotEnvVarName) != ""
useSnapshotImage := os.Getenv(envVarName) != ""

if useSnapshotImage {
g.By("Creating a snapshot Jenkins imagestream and overridding the default Jenkins imagestream")
Expand All @@ -357,12 +359,11 @@ func SetupSnapshotImage(localImageName, snapshotImageStream string, newAppArgs [
ginkgolog("")
ginkgolog("")
ginkgolog("IMPORTANT: You are testing a local jenkins snapshot image.")
ginkgolog("In order to target the official image stream, you must unset %s before running extended tests.", useLocalPluginSnapshotEnvVarName)
ginkgolog("In order to target the official image stream, you must unset %s before running extended tests.", envVarName)
ginkgolog("")
ginkgolog("")

// Create an imagestream based on the Jenkins' plugin PR-Testing image (https://github.com/openshift/jenkins-plugin/blob/master/PR-Testing/README).
snapshotImageStream := "jenkins-plugin-snapshot-test"
err = oc.Run("new-build").Args("-D", fmt.Sprintf("FROM %s", localImageName), "--to", snapshotImageStream).Execute()
o.Expect(err).NotTo(o.HaveOccurred())

Expand All @@ -382,7 +383,7 @@ func SetupSnapshotImage(localImageName, snapshotImageStream string, newAppArgs [
ginkgolog("")
ginkgolog("")
ginkgolog("IMPORTANT: You have a local OpenShift jenkins snapshot image, but it is not being used for testing.")
ginkgolog("In order to target your local image, you must set %s to some value before running extended tests.", useLocalPluginSnapshotEnvVarName)
ginkgolog("In order to target your local image, you must set %s to some value before running extended tests.", envVarName)
ginkgolog("")
ginkgolog("")
}
Expand Down

0 comments on commit a4efef0

Please sign in to comment.