From 7b28745fdb30fc58c45b6dfa33d397f0ecda600c Mon Sep 17 00:00:00 2001 From: Lukas Piwowarski Date: Fri, 13 Oct 2023 17:47:13 +0300 Subject: [PATCH] Add python-tempestconf options --- api/bases/test.openstack.org_tempests.yaml | 110 ++++++++++++++- api/v1beta1/tempest_types.go | 133 +++++++++++++++++- api/v1beta1/zz_generated.deepcopy.go | 26 +++- .../bases/test.openstack.org_tempests.yaml | 110 ++++++++++++++- config/samples/test_v1beta1_tempest.yaml | 56 +++++++- controllers/tempest_controller.go | 16 +++ docs/source/samples/tempest-config.yaml | 2 + docs/source/samples/tempest-deployment.yaml | 3 + docs/source/samples/tempestconf-config.yaml | 38 +++++ docs/source/tempest_pod.rst | 8 ++ pkg/tempest/job.go | 82 +++++++++-- 11 files changed, 563 insertions(+), 21 deletions(-) create mode 100644 docs/source/samples/tempestconf-config.yaml diff --git a/api/bases/test.openstack.org_tempests.yaml b/api/bases/test.openstack.org_tempests.yaml index 516f5582..9627a208 100644 --- a/api/bases/test.openstack.org_tempests.yaml +++ b/api/bases/test.openstack.org_tempests.yaml @@ -109,6 +109,113 @@ spec: description: OpenStackConfigSecret is the name of the Secret containing the secure.yaml type: string + pythonTempestconfRun: + description: TempestSpec PythonTempestconf parts + properties: + append: + default: "" + description: Append values to tempest.conf + type: string + collectTiming: + default: false + description: Collect per-API call timing information. + type: boolean + convertToRaw: + default: false + description: Convert images to raw format before uploading. + type: boolean + create: + default: true + description: Create Tempest resources + type: boolean + createAccountsFile: + default: "" + description: Generate Tempest accounts file. + type: string + debug: + default: false + description: Print debugging information. + type: boolean + deployerInput: + default: "" + description: Path to deployer file + type: string + flavorMinDisk: + default: -1 + description: Specify minimum disk size for new flavors + format: int64 + type: integer + flavorMinMem: + default: -1 + description: Specify minimum memory for new flavors + format: int64 + type: integer + generateProfile: + default: "" + description: Generate a sample profile.yaml file. + type: string + image: + default: "" + description: An image name/path/url to be uploaded to glance if + it’s not already there. + type: string + imageDiskFormat: + default: "" + description: A format of an image to be uploaded to glance. + type: string + insecure: + default: false + description: Explicitly allow client to perform “insecure” TLS + (https) requests. + type: boolean + networkID: + default: "" + description: Specify which network with external connectivity + should be used by the test. + type: string + noDefaultDeployer: + default: false + description: Do not check for the default deployer input in + type: boolean + nonAdmin: + default: false + description: Simulate non-admin credentials. + type: boolean + out: + default: "" + description: Output file + type: string + overrides: + default: "" + description: Override options + type: string + profile: + default: "" + description: python-tempestconf’s profile.yaml file + type: string + remove: + default: "" + description: Append values to tempest.conf + type: string + retryImage: + default: false + description: Allow tempestconf to retry download an image, in + case of failure. + type: boolean + testAccounts: + default: "" + description: Tempest accounts.yaml file + type: string + timeout: + default: -1 + description: Set request timeout (in seconds). + format: int64 + type: integer + verbose: + default: false + description: Print more information about the execution. + type: boolean + type: object tempestRun: description: TempestSpec TempestRun parts properties: @@ -120,7 +227,7 @@ spec: type: string type: array concurrency: - default: 0 + default: -1 description: Concurrency is the Default concurrency format: int64 type: integer @@ -202,3 +309,4 @@ spec: storage: true subresources: status: {} + diff --git a/api/v1beta1/tempest_types.go b/api/v1beta1/tempest_types.go index 86f5213c..e290230c 100644 --- a/api/v1beta1/tempest_types.go +++ b/api/v1beta1/tempest_types.go @@ -47,15 +47,139 @@ type TempestRunSpec struct { SkippedTests []string `json:"skippedTests,omitempty"` // +kubebuilder:validation:Optional - // +kubebuilder:default:=0 + // +kubebuilder:default:=-1 // Concurrency is the Default concurrency - Concurrency *int64 `json:"concurrency,omitempty"` + Concurrency int64 `json:"concurrency,omitempty"` // +kubebuilder:validation:Optional // WorkerFile is the detailed concurry spec file WorkerFile string `json:"workerFile,omitempty"` } +// TempestSpec PythonTempestconf parts +type PythonTempestconfRunSpec struct { + // +kubebuilder:validation:Optional + // +kubebuilder:default=true + // Create Tempest resources + Create bool `json:"create"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + // Collect per-API call timing information. + CollectTiming bool `json:"collectTiming"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + // Explicitly allow client to perform “insecure” TLS (https) requests. + Insecure bool `json:"insecure"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + // Do not check for the default deployer input in + NoDefaultDeployer bool `json:"noDefaultDeployer"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + // Print debugging information. + Debug bool `json:"debug"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + // Print more information about the execution. + Verbose bool `json:"verbose"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + // Simulate non-admin credentials. + NonAdmin bool `json:"nonAdmin"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + // Allow tempestconf to retry download an image, in case of failure. + RetryImage bool `json:"retryImage"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + // Convert images to raw format before uploading. + ConvertToRaw bool `json:"convertToRaw"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default="" + // Output file + Out string `json:"out"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default="" + // Path to deployer file + DeployerInput string `json:"deployerInput"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default="" + // Tempest accounts.yaml file + TestAccounts string `json:"testAccounts"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default="" + // Generate Tempest accounts file. + CreateAccountsFile string `json:"createAccountsFile"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default="" + // python-tempestconf’s profile.yaml file + Profile string `json:"profile"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default="" + // Generate a sample profile.yaml file. + GenerateProfile string `json:"generateProfile"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default="" + // A format of an image to be uploaded to glance. + ImageDiskFormat string `json:"imageDiskFormat"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default="" + // An image name/path/url to be uploaded to glance if it’s not already there. + Image string `json:"image"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=-1 + // Specify minimum memory for new flavors + FlavorMinMem int64 `json:"flavorMinMem"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=-1 + // Specify minimum disk size for new flavors + FlavorMinDisk int64 `json:"flavorMinDisk"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default="" + // Specify which network with external connectivity should be used by the test. + NetworkID string `json:"networkID"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default="" + // Append values to tempest.conf + Append string `json:"append"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default="" + // Append values to tempest.conf + Remove string `json:"remove"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default="" + // Override options + Overrides string `json:"overrides"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=-1 + // Set request timeout (in seconds). + Timeout int64 `json:"timeout"` +} + + // TempestSpec defines the desired state of Tempest type TempestSpec struct { // +kubebuilder:validation:Required @@ -92,10 +216,12 @@ type TempestSpec struct { // +kubebuilder:validation:Optional TempestRun *TempestRunSpec `json:"tempestRun,omitempty"` + // +kubebuilder:validation:Optional + PythonTempestconfRun *PythonTempestconfRunSpec `json:"pythonTempestconfRun,omitempty"` + // TODO(slaweq): add more tempest run parameters here } - // MetalLBConfig to configure the MetalLB loadbalancer service type MetalLBConfig struct { // +kubebuilder:validation:Required @@ -177,3 +303,4 @@ func (instance Tempest) RbacNamespace() string { func (instance Tempest) RbacResourceName() string { return "neutron-" + instance.Name } + diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 3f631537..eb25c1f1 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -61,6 +61,21 @@ func (in *MetalLBConfig) DeepCopy() *MetalLBConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PythonTempestconfRunSpec) DeepCopyInto(out *PythonTempestconfRunSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PythonTempestconfRunSpec. +func (in *PythonTempestconfRunSpec) DeepCopy() *PythonTempestconfRunSpec { + if in == nil { + return nil + } + out := new(PythonTempestconfRunSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Tempest) DeepCopyInto(out *Tempest) { *out = *in @@ -133,11 +148,6 @@ func (in *TempestRunSpec) DeepCopyInto(out *TempestRunSpec) { *out = make([]string, len(*in)) copy(*out, *in) } - if in.Concurrency != nil { - in, out := &in.Concurrency, &out.Concurrency - *out = new(int64) - **out = **in - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TempestRunSpec. @@ -182,6 +192,11 @@ func (in *TempestSpec) DeepCopyInto(out *TempestSpec) { *out = new(TempestRunSpec) (*in).DeepCopyInto(*out) } + if in.PythonTempestconfRun != nil { + in, out := &in.PythonTempestconfRun, &out.PythonTempestconfRun + *out = new(PythonTempestconfRunSpec) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TempestSpec. @@ -237,3 +252,4 @@ func (in *TempestStatus) DeepCopy() *TempestStatus { in.DeepCopyInto(out) return out } + diff --git a/config/crd/bases/test.openstack.org_tempests.yaml b/config/crd/bases/test.openstack.org_tempests.yaml index 516f5582..9627a208 100644 --- a/config/crd/bases/test.openstack.org_tempests.yaml +++ b/config/crd/bases/test.openstack.org_tempests.yaml @@ -109,6 +109,113 @@ spec: description: OpenStackConfigSecret is the name of the Secret containing the secure.yaml type: string + pythonTempestconfRun: + description: TempestSpec PythonTempestconf parts + properties: + append: + default: "" + description: Append values to tempest.conf + type: string + collectTiming: + default: false + description: Collect per-API call timing information. + type: boolean + convertToRaw: + default: false + description: Convert images to raw format before uploading. + type: boolean + create: + default: true + description: Create Tempest resources + type: boolean + createAccountsFile: + default: "" + description: Generate Tempest accounts file. + type: string + debug: + default: false + description: Print debugging information. + type: boolean + deployerInput: + default: "" + description: Path to deployer file + type: string + flavorMinDisk: + default: -1 + description: Specify minimum disk size for new flavors + format: int64 + type: integer + flavorMinMem: + default: -1 + description: Specify minimum memory for new flavors + format: int64 + type: integer + generateProfile: + default: "" + description: Generate a sample profile.yaml file. + type: string + image: + default: "" + description: An image name/path/url to be uploaded to glance if + it’s not already there. + type: string + imageDiskFormat: + default: "" + description: A format of an image to be uploaded to glance. + type: string + insecure: + default: false + description: Explicitly allow client to perform “insecure” TLS + (https) requests. + type: boolean + networkID: + default: "" + description: Specify which network with external connectivity + should be used by the test. + type: string + noDefaultDeployer: + default: false + description: Do not check for the default deployer input in + type: boolean + nonAdmin: + default: false + description: Simulate non-admin credentials. + type: boolean + out: + default: "" + description: Output file + type: string + overrides: + default: "" + description: Override options + type: string + profile: + default: "" + description: python-tempestconf’s profile.yaml file + type: string + remove: + default: "" + description: Append values to tempest.conf + type: string + retryImage: + default: false + description: Allow tempestconf to retry download an image, in + case of failure. + type: boolean + testAccounts: + default: "" + description: Tempest accounts.yaml file + type: string + timeout: + default: -1 + description: Set request timeout (in seconds). + format: int64 + type: integer + verbose: + default: false + description: Print more information about the execution. + type: boolean + type: object tempestRun: description: TempestSpec TempestRun parts properties: @@ -120,7 +227,7 @@ spec: type: string type: array concurrency: - default: 0 + default: -1 description: Concurrency is the Default concurrency format: int64 type: integer @@ -202,3 +309,4 @@ spec: storage: true subresources: status: {} + diff --git a/config/samples/test_v1beta1_tempest.yaml b/config/samples/test_v1beta1_tempest.yaml index d2ee6e52..65344aa7 100644 --- a/config/samples/test_v1beta1_tempest.yaml +++ b/config/samples/test_v1beta1_tempest.yaml @@ -4,8 +4,62 @@ metadata: name: tempest-tests namespace: openstack spec: - containerImage: quay.io/podified-antelope-centos9/openstack-tempest:current-podified + containerImage: docker.io/lpiwowar/openstack-tempest:experiment5 tempestRun: allowedTests: - tempest.api.identity.v3.* concurrency: 8 + pythonTempestconfRun: + # NOTE: All parameters have default values (use only when you want to override + # the default behaviour) + create: true + collectTiming: false + insecure: false + noDefaultDeployer: false + debug: false + verbose: false + nonAdmin: false + retryImage: false + convertToRaw: false + out: ./etc/tempest.conf + flavorMinMem: 128 + flavorMinDisk: 1 + timeout: 600 + imageDiskFormat: qcow2 + image: https://download.cirros-cloud.net/0.5.2/cirros-0.5.2-x86_64-disk.img + + # The following text will be mounted to the tempest pod + # as deployer_input.yaml + # deployerInput: | + # value1: exmaple_value2 + # value2: example_value2 + + # The following text will be mounted to the tempest pod + # as /etc/test_operator/deployer_input.yaml + # testAccounts: | + # - username: 'multi_role_user' + # tenant_name: 'test_tenant_42' + # password: 'test_password' + # roles: + # - 'fun_role' + # - 'not_an_admin' + # - 'an_admin' + + # The following text will be mounted to the tempest pod + # as /etc/test_operator/profile.yaml + # testAccounts: | + + + # createAccountsFile: /path/to/accounts.yaml + # generateProfile: /path/to/profile.yaml + # networkID: + # append: | # <-- Use | to preserve \n + # section1.name1 value1 + # section1.name1 value2 + # remove: | # <-- Use | to preserve \n + # section1.name1 value1 + # section1.name1 value2 + # overrides: | # <-- Use | to preserve \n + # overrides_section1.name1 value1 + # overrides_section1.name1 value2 + diff --git a/controllers/tempest_controller.go b/controllers/tempest_controller.go index e1b47367..bb01d64d 100644 --- a/controllers/tempest_controller.go +++ b/controllers/tempest_controller.go @@ -87,6 +87,8 @@ func (r *TempestReconciler) GetScheme() *runtime.Scheme { // Reconcile - Tempest func (r *TempestReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, _err error) { + // logging := log.FromContext(ctx) + _ = r.Log.WithValues("tempest", req.NamespacedName) // Fetch the Tempest instance @@ -394,6 +396,18 @@ func (r *TempestReconciler) generateServiceConfigMaps( templateParameters["AllowedTests"] = instance.Spec.TempestRun.AllowedTests templateParameters["SkippedTests"] = instance.Spec.TempestRun.SkippedTests + if len(instance.Spec.PythonTempestconfRun.DeployerInput) != 0 { + customData["deployer_input.yaml"] = instance.Spec.PythonTempestconfRun.DeployerInput + } + + if len(instance.Spec.PythonTempestconfRun.TestAccounts) != 0 { + customData["accounts.yaml"] = instance.Spec.PythonTempestconfRun.TestAccounts + } + + if len(instance.Spec.PythonTempestconfRun.Profile) != 0 { + customData["profile.yaml"] = instance.Spec.PythonTempestconfRun.Profile + } + cms := []util.Template{ // ScriptsConfigMap { @@ -414,5 +428,7 @@ func (r *TempestReconciler) generateServiceConfigMaps( CustomData: customData, }, } + return configmap.EnsureConfigMaps(ctx, h, instance, cms, nil) } + diff --git a/docs/source/samples/tempest-config.yaml b/docs/source/samples/tempest-config.yaml index 027c3e04..7d14d73e 100644 --- a/docs/source/samples/tempest-config.yaml +++ b/docs/source/samples/tempest-config.yaml @@ -5,3 +5,5 @@ metadata: data: include.txt: | tempest.api.identity.v3 + profile.yaml: | + create: true diff --git a/docs/source/samples/tempest-deployment.yaml b/docs/source/samples/tempest-deployment.yaml index ac12f530..d4b0d63e 100644 --- a/docs/source/samples/tempest-deployment.yaml +++ b/docs/source/samples/tempest-deployment.yaml @@ -41,6 +41,9 @@ spec: # configuration and run tempest yourself. # command: ["/usr/bin/dumb-init", "sleep", "infinity"] restartPolicy: Never + envFrom: + - configMapRef: + name: tempestconf-data volumeMounts: - mountPath: "/var/lib/tempest/external_files/" name: tempest-workdir diff --git a/docs/source/samples/tempestconf-config.yaml b/docs/source/samples/tempestconf-config.yaml new file mode 100644 index 00000000..daef32f6 --- /dev/null +++ b/docs/source/samples/tempestconf-config.yaml @@ -0,0 +1,38 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: tempestconf-data +data: + TEMPESTCONF_CREATE: "true" + TEMPESTCONF_INSECURE: "false" + TEMPESTCONF_COLLECT_TIMING: "false" + TEMPESTCONF_NO_DEFAULT_DEPLOYER: "false" + TEMPESTCONF_DEBUG: "false" + TEMPESTCONF_VERBOSE: "false" + TEMPESTCONF_NO_RNG: "false" + TEMPESTCONF_NON_ADMIN: "false" + TEMPESTCONF_RETRY_IMAGE: "false" + TEMPESTCONF_CONVERT_TO_RAW: "false" + + TEMPESTCONF_TIMEOUT: "600" + TEMPESTCONF_OUT: "./etc/tempest.conf" + # TEMPESTCONF_DEPLOYER_INPUT: "/etc/test_operator/deployer_input.yaml" + # TEMPESTCONF_TEST_ACCOUNTS: "/etc/test_operator/accounts.yaml" + # TEMPESTCONF_CREATE_ACCOUNTS_FILE: "/etc/test_operator/accounts.yaml" + TEMPESTCONF_PROFILE: "/etc/test_operator/profile.yaml" + # TEMPESTCONF_GENERATE_PROFILE: "/etc/test_operator/profile.yaml" + TEMPESTCONF_IMAGE_DISK_FORMAT: "qcow2" + TEMPESTCONF_IMAGE: "https://download.cirros-cloud.net/0.5.2/cirros-0.5.2-x86_64-disk.img" + TEMPESTCONF_FLAVOR_MIN_MEM: "128" + TEMPESTCONF_FLAVOR_MIN_DISK: "1" + # TEMPESTCONF_NETWORK_ID: "" + # TEMPESTCONF_APPEND: | + # section.value1 value1 + # section.value1 value2 + # TEMPESTCONF_REMOVE: | + # section.value1 value1 + # section.value1 value2 + TEMPESTCONF_OVERRIDES: | + section.value1 value1 + section.value1 value2 + diff --git a/docs/source/tempest_pod.rst b/docs/source/tempest_pod.rst index cfe96cdd..101b2236 100644 --- a/docs/source/tempest_pod.rst +++ b/docs/source/tempest_pod.rst @@ -15,6 +15,14 @@ Create a file named ``tempest-config.yaml`` with the following content: The file contains tempest configuration and will be used to pass any tempest options to the container running Tempest. +Create a file named ``tempestconf-config.yaml`` with the following content: + +.. literalinclude:: samples/tempestconf-config.yaml + :language: yaml + +The file contains tempest configuration and will be used to pass any tempestconf +options to the container running Tempest. + Then create a file named ``tempest-deployment.yaml`` with the following content: .. literalinclude:: samples/tempest-deployment.yaml diff --git a/pkg/tempest/job.go b/pkg/tempest/job.go index a5ecf5de..c2f2ad24 100644 --- a/pkg/tempest/job.go +++ b/pkg/tempest/job.go @@ -10,6 +10,22 @@ import ( "strconv" ) +func getDefaultBool(variable bool) env.Setter { + if variable { + return env.SetValue("true") + } else { + return env.SetValue("false") + } +} + +func getDefaultInt(variable int64) env.Setter { + if variable != -1 { + return env.SetValue(strconv.FormatInt(variable, 10)) + } else { + return env.SetValue("") + } +} + // Job - prepare job to run Tempest tests func Job( instance *testv1beta1.Tempest, @@ -19,11 +35,50 @@ func Job( envVars := map[string]env.Setter{} runAsUser := int64(42480) runAsGroup := int64(42480) - if instance.Spec.TempestRun.Concurrency != nil { - envVars["TEMPEST_CONCURRENCY"] = env.SetValue(strconv.FormatInt(*instance.Spec.TempestRun.Concurrency, 10)) - } else { - envVars["TEMPEST_CONCURRENCY"] = env.SetValue("0") - } + + /* Tempest */ + // Int + envVars["TEMPEST_CONCURRENCY"] = getDefaultInt(instance.Spec.TempestRun.Concurrency) + + /* Tempestconf */ + // Bool + envVars["TEMPESTCONF_CREATE"] = getDefaultBool(instance.Spec.PythonTempestconfRun.Create) + envVars["TEMPESTCONF_COLLECT_TIMING"] = getDefaultBool(instance.Spec.PythonTempestconfRun.CollectTiming) + envVars["TEMPESTCONF_INSECURE"] = getDefaultBool(instance.Spec.PythonTempestconfRun.Insecure) + envVars["TEMPESTCONF_NO_DEFAULT_DEPLOYER"] = getDefaultBool(instance.Spec.PythonTempestconfRun.NoDefaultDeployer) + envVars["TEMPESTCONF_DEBUG"] = getDefaultBool(instance.Spec.PythonTempestconfRun.Debug) + envVars["TEMPESTCONF_VERBOSE"] = getDefaultBool(instance.Spec.PythonTempestconfRun.Verbose) + envVars["TEMPESTCONF_NON_ADMIN"] = getDefaultBool(instance.Spec.PythonTempestconfRun.NonAdmin) + envVars["TEMPESTCONF_RETRY_IMAGE"] = getDefaultBool(instance.Spec.PythonTempestconfRun.RetryImage) + envVars["TEMPESTCONF_CONVERT_TO_RAW"] = getDefaultBool(instance.Spec.PythonTempestconfRun.ConvertToRaw) + + // Int + envVars["TEMPESTCONF_TIMEOUT"] = getDefaultInt(instance.Spec.PythonTempestconfRun.Timeout) + envVars["TEMPESTCONF_FLAVOR_MIN_MEM"] = getDefaultInt(instance.Spec.PythonTempestconfRun.FlavorMinMem) + envVars["TEMPESTCONF_FLAVOR_MIN_DISK"] = getDefaultInt(instance.Spec.PythonTempestconfRun.FlavorMinDisk) + + // String + envVars["TEMPESTCONF_OUT"] = env.SetValue(instance.Spec.PythonTempestconfRun.Out) + envVars["TEMPESTCONF_CREATE_ACCOUNTS_FILE"] = env.SetValue(instance.Spec.PythonTempestconfRun.CreateAccountsFile) + envVars["TEMPESTCONF_GENERATE_PROFILE"] = env.SetValue(instance.Spec.PythonTempestconfRun.GenerateProfile) + envVars["TEMPESTCONF_IMAGE_DISK_FORMAT"] = env.SetValue(instance.Spec.PythonTempestconfRun.ImageDiskFormat) + envVars["TEMPESTCONF_IMAGE"] = env.SetValue(instance.Spec.PythonTempestconfRun.Image) + envVars["TEMPESTCONF_NETWORK_ID"] = env.SetValue(instance.Spec.PythonTempestconfRun.NetworkID) + envVars["TEMPESTCONF_APPEND"] = env.SetValue(instance.Spec.PythonTempestconfRun.Append) + envVars["TEMPESTCONF_REMOVE"] = env.SetValue(instance.Spec.PythonTempestconfRun.Remove) + envVars["TEMPESTCONF_OVERRIDES"] = env.SetValue(instance.Spec.PythonTempestconfRun.Overrides) + + if len(instance.Spec.PythonTempestconfRun.DeployerInput) > 0 { + envVars["TEMPESTCONF_DEPLOYER_INPUT"] = env.SetValue("/etc/test_operator/deployer_input.yaml") + } + + if len(instance.Spec.PythonTempestconfRun.DeployerInput) > 0 { + envVars["TEMPESTCONF_TEST_ACCOUNTS"] = env.SetValue("/etc/test_operator/accounts.yaml") + } + + if len(instance.Spec.PythonTempestconfRun.Profile) > 0 { + envVars["PROFILE"] = env.SetValue("/etc/test_operator/profile.yaml") + } job := &batchv1.Job{ ObjectMeta: metav1.ObjectMeta{ @@ -44,14 +99,20 @@ func Job( }, Containers: []corev1.Container{ { - Name: instance.Name + "-tests-runner", - Image: instance.Spec.ContainerImage, - Command: []string{ - "/usr/local/bin/container-scripts/invoke_tempest", - }, + Name: instance.Name + "-tests-runner", + Image: instance.Spec.ContainerImage, Args: []string{}, Env: env.MergeEnvs([]corev1.EnvVar{}, envVars), VolumeMounts: GetVolumeMounts(), + EnvFrom: []corev1.EnvFromSource{ + { + ConfigMapRef: &corev1.ConfigMapEnvSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: instance.Name + "-config-data", + }, + }, + }, + }, }, }, Volumes: GetVolumes(instance), @@ -62,3 +123,4 @@ func Job( return job } +