From 901964a24dad7365504b4bd3193126e5669f2186 Mon Sep 17 00:00:00 2001 From: Ben Parees Date: Thu, 18 Jul 2019 12:53:10 -0400 Subject: [PATCH] introduce generic test image test type --- cmd/ci-operator-prowgen/main.go | 10 +++++++++- pkg/api/config.go | 4 ++++ pkg/api/types.go | 33 ++++++++++++++++++++++----------- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/cmd/ci-operator-prowgen/main.go b/cmd/ci-operator-prowgen/main.go index 043d87ee433..e42cde790cc 100644 --- a/cmd/ci-operator-prowgen/main.go +++ b/cmd/ci-operator-prowgen/main.go @@ -171,7 +171,7 @@ func generateCiOperatorPodSpec(info *config.Info, target string, additionalArgs } func generatePodSpecTemplate(info *config.Info, release string, test *cioperatorapi.TestStepConfiguration) *kubeapi.PodSpec { - var template string + var testImageStreamTag, template string var clusterProfile cioperatorapi.ClusterProfile var needsReleaseRpms bool if conf := test.OpenshiftAnsibleClusterTestConfiguration; conf != nil { @@ -208,6 +208,10 @@ func generatePodSpecTemplate(info *config.Info, release string, test *cioperator } else if conf := test.OpenshiftInstallerConsoleClusterTestConfiguration; conf != nil { template = "cluster-launch-installer-console" clusterProfile = conf.ClusterProfile + } else if conf := test.OpenshiftInstallerCustomTestImageClusterTestConfiguration; conf != nil { + template = "cluster-launch-installer-custom-test-image" + clusterProfile = conf.ClusterProfile + testImageStreamTag = conf.From } var targetCloud string switch clusterProfile { @@ -256,6 +260,10 @@ func generatePodSpecTemplate(info *config.Info, release string, test *cioperator kubeapi.EnvVar{Name: "CLUSTER_TYPE", Value: targetCloud}, kubeapi.EnvVar{Name: "JOB_NAME_SAFE", Value: strings.Replace(test.As, "_", "-", -1)}, kubeapi.EnvVar{Name: "TEST_COMMAND", Value: test.Commands}) + if len(testImageStreamTag) > 0 { + container.Env = append(container.Env, + kubeapi.EnvVar{Name: "TEST_IMAGESTREAM_TAG", Value: testImageStreamTag}) + } } if needsReleaseRpms && (info.Org != "openshift" || info.Repo != "origin") { var repoPath = fmt.Sprintf("https://rpms.svc.ci.openshift.org/openshift-origin-v%s/", release) diff --git a/pkg/api/config.go b/pkg/api/config.go index 4e800439456..9576b4cb28a 100644 --- a/pkg/api/config.go +++ b/pkg/api/config.go @@ -260,6 +260,10 @@ func validateTestConfigurationType(fieldRoot string, test TestStepConfiguration, typeCount++ validationErrors = append(validationErrors, validateClusterProfile(fmt.Sprintf("%s", fieldRoot), testConfig.ClusterProfile)...) } + if testConfig := test.OpenshiftInstallerCustomTestImageClusterTestConfiguration; testConfig != nil { + typeCount++ + validationErrors = append(validationErrors, validateClusterProfile(fmt.Sprintf("%s", fieldRoot), testConfig.ClusterProfile)...) + } if test.OpenshiftInstallerRandomClusterTestConfiguration != nil { typeCount++ } diff --git a/pkg/api/types.go b/pkg/api/types.go index 63810bac60b..11729916e99 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -293,17 +293,18 @@ type TestStepConfiguration struct { Secret *Secret `json:"secret,omitempty"` // Only one of the following can be not-null. - ContainerTestConfiguration *ContainerTestConfiguration `json:"container,omitempty"` - OpenshiftAnsibleClusterTestConfiguration *OpenshiftAnsibleClusterTestConfiguration `json:"openshift_ansible,omitempty"` - OpenshiftAnsibleSrcClusterTestConfiguration *OpenshiftAnsibleSrcClusterTestConfiguration `json:"openshift_ansible_src,omitempty"` - OpenshiftAnsibleCustomClusterTestConfiguration *OpenshiftAnsibleCustomClusterTestConfiguration `json:"openshift_ansible_custom,omitempty"` - OpenshiftAnsible40ClusterTestConfiguration *OpenshiftAnsible40ClusterTestConfiguration `json:"openshift_ansible_40,omitempty"` - OpenshiftAnsibleUpgradeClusterTestConfiguration *OpenshiftAnsibleUpgradeClusterTestConfiguration `json:"openshift_ansible_upgrade,omitempty"` - OpenshiftInstallerClusterTestConfiguration *OpenshiftInstallerClusterTestConfiguration `json:"openshift_installer,omitempty"` - OpenshiftInstallerSrcClusterTestConfiguration *OpenshiftInstallerSrcClusterTestConfiguration `json:"openshift_installer_src,omitempty"` - OpenshiftInstallerUPIClusterTestConfiguration *OpenshiftInstallerUPIClusterTestConfiguration `json:"openshift_installer_upi,omitempty"` - OpenshiftInstallerConsoleClusterTestConfiguration *OpenshiftInstallerConsoleClusterTestConfiguration `json:"openshift_installer_console,omitempty"` - OpenshiftInstallerRandomClusterTestConfiguration *OpenshiftInstallerRandomClusterTestConfiguration `json:"openshift_installer_random,omitempty"` + ContainerTestConfiguration *ContainerTestConfiguration `json:"container,omitempty"` + OpenshiftAnsibleClusterTestConfiguration *OpenshiftAnsibleClusterTestConfiguration `json:"openshift_ansible,omitempty"` + OpenshiftAnsibleSrcClusterTestConfiguration *OpenshiftAnsibleSrcClusterTestConfiguration `json:"openshift_ansible_src,omitempty"` + OpenshiftAnsibleCustomClusterTestConfiguration *OpenshiftAnsibleCustomClusterTestConfiguration `json:"openshift_ansible_custom,omitempty"` + OpenshiftAnsible40ClusterTestConfiguration *OpenshiftAnsible40ClusterTestConfiguration `json:"openshift_ansible_40,omitempty"` + OpenshiftAnsibleUpgradeClusterTestConfiguration *OpenshiftAnsibleUpgradeClusterTestConfiguration `json:"openshift_ansible_upgrade,omitempty"` + OpenshiftInstallerClusterTestConfiguration *OpenshiftInstallerClusterTestConfiguration `json:"openshift_installer,omitempty"` + OpenshiftInstallerSrcClusterTestConfiguration *OpenshiftInstallerSrcClusterTestConfiguration `json:"openshift_installer_src,omitempty"` + OpenshiftInstallerUPIClusterTestConfiguration *OpenshiftInstallerUPIClusterTestConfiguration `json:"openshift_installer_upi,omitempty"` + OpenshiftInstallerConsoleClusterTestConfiguration *OpenshiftInstallerConsoleClusterTestConfiguration `json:"openshift_installer_console,omitempty"` + OpenshiftInstallerRandomClusterTestConfiguration *OpenshiftInstallerRandomClusterTestConfiguration `json:"openshift_installer_random,omitempty"` + OpenshiftInstallerCustomTestImageClusterTestConfiguration *OpenshiftInstallerCustomTestImageClusterTestConfiguration `json:"openshift_installer_custom_test_image,omitempty"` } // Secret describes a secret to be mounted inside a test @@ -440,6 +441,16 @@ type OpenshiftInstallerUPIClusterTestConfiguration struct { // chosen randomly and runs conformance tests. type OpenshiftInstallerRandomClusterTestConfiguration struct{} +// OpenshiftInstallerCustomTestImageClusterTestConfiguration describes a +// test that provisions a cluster using openshift-installer and +// executes a command in the image specified by the job configuration. +type OpenshiftInstallerCustomTestImageClusterTestConfiguration struct { + ClusterTestConfiguration `json:",inline"` + // From defines the imagestreamtag that will be used to run the + // provided test command. e.g. stable:console-test + From string `json:"from"` +} + // PipelineImageStreamTagReference is a tag on the // ImageStream corresponding to the code under test. // This tag will identify an image but not use any