From 7eef6ce097956aa996ee9190c7ad6725a4a6c5bc Mon Sep 17 00:00:00 2001 From: Brandon Squizzato <35474886+bsquizz@users.noreply.github.com> Date: Tue, 12 Sep 2023 14:16:29 -0400 Subject: [PATCH] [RFR] Add 'env' field to IQE CJI spec (#855) * Add 'env' field to IQE CJI spec * Add logic for updating env vars and kuttl tests * Update IQEJobSpec CRD documentation * Fix implicit memory aliasing in for loop --- .../v1alpha1/clowdjobinvocation_types.go | 44 +++-- .../v1alpha1/zz_generated.deepcopy.go | 11 ++ .../cloud.redhat.com_clowdjobinvocations.yaml | 179 ++++++++++++++--- .../cloud.redhat.com/providers/iqe/impl.go | 22 +++ deploy-mutate.yml | 181 +++++++++++++++--- deploy.yml | 181 +++++++++++++++--- .../modules/ROOT/pages/api_reference.adoc | 31 +-- tests/kuttl/test-iqe-jobs/01-assert.yaml | 4 +- tests/kuttl/test-iqe-jobs/01-pods.yaml | 8 +- 9 files changed, 534 insertions(+), 127 deletions(-) diff --git a/apis/cloud.redhat.com/v1alpha1/clowdjobinvocation_types.go b/apis/cloud.redhat.com/v1alpha1/clowdjobinvocation_types.go index dc04ef21a..c4072c5c3 100644 --- a/apis/cloud.redhat.com/v1alpha1/clowdjobinvocation_types.go +++ b/apis/cloud.redhat.com/v1alpha1/clowdjobinvocation_types.go @@ -23,6 +23,7 @@ import ( batchv1 "k8s.io/api/batch/v1" + core "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -46,54 +47,55 @@ type JobTestingSpec struct { } type IqeJobSpec struct { - // By default, Clowder will set the image on the ClowdJob to be the - // baseImage:name-of-iqe-plugin, but only the tag can be overridden here + // Image tag to use for IQE container. By default, Clowder will set the image tag to be + // baseImage:name-of-iqe-plugin, where baseImage is defined in the ClowdEnvironment. Only the tag can be overridden here. ImageTag string `json:"imageTag,omitempty"` - // By default, Clowder will use the plugin name indicated in the ClowdApp's - // spec.testing.iqePlugin field. A comma,separated,list of plugins can be supplied - // here if you wish you override the plugins. + // A comma,separated,list indicating IQE plugin(s) to run tests for. By default, Clowder will use the plugin name given on the ClowdApp's + // spec.testing.iqePlugin field. Use this field if you wish you override the plugin list. IqePlugins string `json:"plugins,omitempty"` - // Indiciates the presence of a selenium container - // Note: currently not implemented + // Defines configuration for a selenium container (optional) UI IqeUISpec `json:"ui,omitempty"` - // sets the pytest -m args + // Specifies environment variables to set on the IQE container + Env *[]core.EnvVar `json:"env,omitempty"` + + // Changes entrypoint to invoke 'iqe container-debug' so that container starts but does not run tests, allowing 'rsh' to be invoked + Debug bool `json:"debug,omitempty"` + + // (DEPRECATED, using 'env' now preferred) sets IQE_MARKER_EXPRESSION env var on the IQE container Marker string `json:"marker,omitempty"` - // sets value for ENV_FOR_DYNACONF + // (DEPRECATED, using 'env' now preferred) sets ENV_FOR_DYNACONF env var on the IQE container DynaconfEnvName string `json:"dynaconfEnvName"` - // sets pytest -k args + // (DEPRECATED, using 'env' now preferred) sets IQE_FILTER_EXPRESSION env var on the IQE container Filter string `json:"filter,omitempty"` - // Use to start the IQE pod without running tests and leave it up so that 'rsh' can be invoked - Debug bool `json:"debug,omitempty"` - - // sets values passed to IQE '--requirements' arg + // (DEPRECATED, using 'env' now preferred) sets IQE_REQUIREMENTS env var on the IQE container Requirements *[]string `json:"requirements,omitempty"` - // sets values passed to IQE '--requirements-priority' arg + // (DEPRECATED, using 'env' now preferred) sets IQE_REQUIREMENTS_PRIORITY env var on the IQE container RequirementsPriority *[]string `json:"requirementsPriority,omitempty"` - // sets values passed to IQE '--test-importance' arg + // (DEPRECATED, using 'env' now preferred) sets IQE_TEST_IMPORTANCE env var on the IQE container TestImportance *[]string `json:"testImportance,omitempty"` - // sets value for IQE_LOG_LEVEL (default if empty: "info") + // (DEPRECATED, using 'env' now preferred) sets IQE_LOG_LEVEL env var on the IQE container //+kubebuilder:validation:Enum={"", "critical", "error", "warning", "info", "debug", "notset"} LogLevel string `json:"logLevel,omitempty"` - // sets value passed to IQE 'IQE_PARALLEL_ENABLED' arg + // (DEPRECATED, using 'env' now preferred) sets IQE_PARALLEL_ENABLED env var on the IQE container ParallelEnabled string `json:"parallelEnabled,omitempty"` - // sets value passed to IQE 'IQE_PARALLEL_WORKER_COUNT' arg + // (DEPRECATED, using 'env' now preferred) sets IQE_PARALLEL_WORKER_COUNT env var on the IQE container ParallelWorkerCount string `json:"parallelWorkerCount,omitempty"` - // sets value passed to IQE 'IQE_RP_ARGS' report portal args + // (DEPRECATED, using 'env' now preferred) sets IQE_RP_ARGS env var on the IQE container RpArgs string `json:"rpArgs,omitempty"` - // sets value passed to IQE 'IQE_IBUTSU_SOURCE' args + // (DEPRECATED, using 'env' now preferred) sets IQE_IBUTSU_SOURCE env var on the IQE container IbutsuSource string `json:"ibutsuSource,omitempty"` } diff --git a/apis/cloud.redhat.com/v1alpha1/zz_generated.deepcopy.go b/apis/cloud.redhat.com/v1alpha1/zz_generated.deepcopy.go index a0e275c63..49ded6f5f 100644 --- a/apis/cloud.redhat.com/v1alpha1/zz_generated.deepcopy.go +++ b/apis/cloud.redhat.com/v1alpha1/zz_generated.deepcopy.go @@ -766,6 +766,17 @@ func (in *IqeConfig) DeepCopy() *IqeConfig { func (in *IqeJobSpec) DeepCopyInto(out *IqeJobSpec) { *out = *in out.UI = in.UI + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = new([]v1.EnvVar) + if **in != nil { + in, out := *in, *out + *out = make([]v1.EnvVar, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + } if in.Requirements != nil { in, out := &in.Requirements, &out.Requirements *out = new([]string) diff --git a/config/crd/bases/cloud.redhat.com_clowdjobinvocations.yaml b/config/crd/bases/cloud.redhat.com_clowdjobinvocations.yaml index 916fe6ecf..0c23b5a31 100644 --- a/config/crd/bases/cloud.redhat.com_clowdjobinvocations.yaml +++ b/config/crd/bases/cloud.redhat.com_clowdjobinvocations.yaml @@ -62,27 +62,146 @@ spec: ClowdApp's definition of the job properties: debug: - description: Use to start the IQE pod without running tests - and leave it up so that 'rsh' can be invoked + description: Changes entrypoint to invoke 'iqe container-debug' + so that container starts but does not run tests, allowing + 'rsh' to be invoked type: boolean dynaconfEnvName: - description: sets value for ENV_FOR_DYNACONF + description: (DEPRECATED, using 'env' now preferred) sets + ENV_FOR_DYNACONF env var on the IQE container type: string + env: + description: Specifies environment variables to set on the + IQE container + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must + be a C_IDENTIFIER. + type: string + value: + description: 'Variable references $(VAR_NAME) are expanded + using the previously defined environment variables + in the container and any service environment variables. + If a variable cannot be resolved, the reference in + the input string will be unchanged. Double $$ are + reduced to a single $, which allows for escaping the + $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce + the string literal "$(VAR_NAME)". Escaped references + will never be expanded, regardless of whether the + variable exists or not. Defaults to "".' + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, + kind, uid?' + type: string + optional: + description: Specify whether the ConfigMap or + its key must be defined + type: boolean + required: + - key + type: object + fieldRef: + description: 'Selects a field of the pod: supports + metadata.name, metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.podIP, + status.podIPs.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in + the specified API version. + type: string + required: + - fieldPath + type: object + resourceFieldRef: + description: 'Selects a resource of the container: + only resources limits and requests (limits.cpu, + limits.memory, limits.ephemeral-storage, requests.cpu, + requests.memory and requests.ephemeral-storage) + are currently supported.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of + the exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select + from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, + kind, uid?' + type: string + optional: + description: Specify whether the Secret or its + key must be defined + type: boolean + required: + - key + type: object + type: object + required: + - name + type: object + type: array filter: - description: sets pytest -k args + description: (DEPRECATED, using 'env' now preferred) sets + IQE_FILTER_EXPRESSION env var on the IQE container type: string ibutsuSource: - description: sets value passed to IQE 'IQE_IBUTSU_SOURCE' - args + description: (DEPRECATED, using 'env' now preferred) sets + IQE_IBUTSU_SOURCE env var on the IQE container type: string imageTag: - description: By default, Clowder will set the image on the - ClowdJob to be the baseImage:name-of-iqe-plugin, but only - the tag can be overridden here + description: Image tag to use for IQE container. By default, + Clowder will set the image tag to be baseImage:name-of-iqe-plugin, + where baseImage is defined in the ClowdEnvironment. Only + the tag can be overridden here. type: string logLevel: - description: 'sets value for IQE_LOG_LEVEL (default if empty: - "info")' + description: (DEPRECATED, using 'env' now preferred) sets + IQE_LOG_LEVEL env var on the IQE container enum: - "" - critical @@ -93,46 +212,48 @@ spec: - notset type: string marker: - description: sets the pytest -m args + description: (DEPRECATED, using 'env' now preferred) sets + IQE_MARKER_EXPRESSION env var on the IQE container type: string parallelEnabled: - description: sets value passed to IQE 'IQE_PARALLEL_ENABLED' - arg + description: (DEPRECATED, using 'env' now preferred) sets + IQE_PARALLEL_ENABLED env var on the IQE container type: string parallelWorkerCount: - description: sets value passed to IQE 'IQE_PARALLEL_WORKER_COUNT' - arg + description: (DEPRECATED, using 'env' now preferred) sets + IQE_PARALLEL_WORKER_COUNT env var on the IQE container type: string plugins: - description: By default, Clowder will use the plugin name - indicated in the ClowdApp's spec.testing.iqePlugin field. - A comma,separated,list of plugins can be supplied here if - you wish you override the plugins. + description: A comma,separated,list indicating IQE plugin(s) + to run tests for. By default, Clowder will use the plugin + name given on the ClowdApp's spec.testing.iqePlugin field. + Use this field if you wish you override the plugin list. type: string requirements: - description: sets values passed to IQE '--requirements' arg + description: (DEPRECATED, using 'env' now preferred) sets + IQE_REQUIREMENTS env var on the IQE container items: type: string type: array requirementsPriority: - description: sets values passed to IQE '--requirements-priority' - arg + description: (DEPRECATED, using 'env' now preferred) sets + IQE_REQUIREMENTS_PRIORITY env var on the IQE container items: type: string type: array rpArgs: - description: sets value passed to IQE 'IQE_RP_ARGS' report - portal args + description: (DEPRECATED, using 'env' now preferred) sets + IQE_RP_ARGS env var on the IQE container type: string testImportance: - description: sets values passed to IQE '--test-importance' - arg + description: (DEPRECATED, using 'env' now preferred) sets + IQE_TEST_IMPORTANCE env var on the IQE container items: type: string type: array ui: - description: 'Indiciates the presence of a selenium container - Note: currently not implemented' + description: Defines configuration for a selenium container + (optional) properties: enabled: description: No longer used diff --git a/controllers/cloud.redhat.com/providers/iqe/impl.go b/controllers/cloud.redhat.com/providers/iqe/impl.go index 7c542da76..88f951da0 100644 --- a/controllers/cloud.redhat.com/providers/iqe/impl.go +++ b/controllers/cloud.redhat.com/providers/iqe/impl.go @@ -37,6 +37,24 @@ func joinNullableSlice(s *[]string) string { return "" } +func updateEnvVars(existingEnvVars []core.EnvVar, newEnvVars []core.EnvVar) []core.EnvVar { + for _, newEnvVar := range newEnvVars { + replaced := false + for idx, existingEnvVar := range existingEnvVars { + if existingEnvVar.Name == newEnvVar.Name { + p := &existingEnvVars[idx] + p.Value = newEnvVar.Value + replaced = true + } + } + if !replaced { + existingEnvVars = append(existingEnvVars, newEnvVar) + } + } + + return existingEnvVars +} + func createIqeContainer(j *batchv1.Job, nn types.NamespacedName, cji *crd.ClowdJobInvocation, env *crd.ClowdEnvironment, app *crd.ClowdApp) *core.Container { // create env vars iqePlugins := app.Spec.Testing.IqePlugin @@ -67,6 +85,10 @@ func createIqeContainer(j *batchv1.Job, nn types.NamespacedName, cji *crd.ClowdJ {Name: "IQE_IBUTSU_SOURCE", Value: cji.Spec.Testing.Iqe.IbutsuSource}, } + if cji.Spec.Testing.Iqe.Env != nil { + envVars = updateEnvVars(envVars, *cji.Spec.Testing.Iqe.Env) + } + // set image tag iqeImage := env.Spec.Providers.Testing.Iqe.ImageBase diff --git a/deploy-mutate.yml b/deploy-mutate.yml index 4dd4602eb..8bcf3fbf6 100644 --- a/deploy-mutate.yml +++ b/deploy-mutate.yml @@ -6787,27 +6787,147 @@ objects: ClowdApp's definition of the job properties: debug: - description: Use to start the IQE pod without running tests - and leave it up so that 'rsh' can be invoked + description: Changes entrypoint to invoke 'iqe container-debug' + so that container starts but does not run tests, allowing + 'rsh' to be invoked type: boolean dynaconfEnvName: - description: sets value for ENV_FOR_DYNACONF + description: (DEPRECATED, using 'env' now preferred) sets + ENV_FOR_DYNACONF env var on the IQE container type: string + env: + description: Specifies environment variables to set on the + IQE container + items: + description: EnvVar represents an environment variable + present in a Container. + properties: + name: + description: Name of the environment variable. Must + be a C_IDENTIFIER. + type: string + value: + description: 'Variable references $(VAR_NAME) are + expanded using the previously defined environment + variables in the container and any service environment + variables. If a variable cannot be resolved, the + reference in the input string will be unchanged. + Double $$ are reduced to a single $, which allows + for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" + will produce the string literal "$(VAR_NAME)". Escaped + references will never be expanded, regardless of + whether the variable exists or not. Defaults to + "".' + type: string + valueFrom: + description: Source for the environment variable's + value. Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, + kind, uid?' + type: string + optional: + description: Specify whether the ConfigMap + or its key must be defined + type: boolean + required: + - key + type: object + fieldRef: + description: 'Selects a field of the pod: supports + metadata.name, metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.podIP, + status.podIPs.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in + the specified API version. + type: string + required: + - fieldPath + type: object + resourceFieldRef: + description: 'Selects a resource of the container: + only resources limits and requests (limits.cpu, + limits.memory, limits.ephemeral-storage, requests.cpu, + requests.memory and requests.ephemeral-storage) + are currently supported.' + properties: + containerName: + description: 'Container name: required for + volumes, optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of + the exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + secretKeyRef: + description: Selects a key of a secret in the + pod's namespace + properties: + key: + description: The key of the secret to select + from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, + kind, uid?' + type: string + optional: + description: Specify whether the Secret or + its key must be defined + type: boolean + required: + - key + type: object + type: object + required: + - name + type: object + type: array filter: - description: sets pytest -k args + description: (DEPRECATED, using 'env' now preferred) sets + IQE_FILTER_EXPRESSION env var on the IQE container type: string ibutsuSource: - description: sets value passed to IQE 'IQE_IBUTSU_SOURCE' - args + description: (DEPRECATED, using 'env' now preferred) sets + IQE_IBUTSU_SOURCE env var on the IQE container type: string imageTag: - description: By default, Clowder will set the image on the - ClowdJob to be the baseImage:name-of-iqe-plugin, but only - the tag can be overridden here + description: Image tag to use for IQE container. By default, + Clowder will set the image tag to be baseImage:name-of-iqe-plugin, + where baseImage is defined in the ClowdEnvironment. Only + the tag can be overridden here. type: string logLevel: - description: 'sets value for IQE_LOG_LEVEL (default if empty: - "info")' + description: (DEPRECATED, using 'env' now preferred) sets + IQE_LOG_LEVEL env var on the IQE container enum: - '' - critical @@ -6818,47 +6938,48 @@ objects: - notset type: string marker: - description: sets the pytest -m args + description: (DEPRECATED, using 'env' now preferred) sets + IQE_MARKER_EXPRESSION env var on the IQE container type: string parallelEnabled: - description: sets value passed to IQE 'IQE_PARALLEL_ENABLED' - arg + description: (DEPRECATED, using 'env' now preferred) sets + IQE_PARALLEL_ENABLED env var on the IQE container type: string parallelWorkerCount: - description: sets value passed to IQE 'IQE_PARALLEL_WORKER_COUNT' - arg + description: (DEPRECATED, using 'env' now preferred) sets + IQE_PARALLEL_WORKER_COUNT env var on the IQE container type: string plugins: - description: By default, Clowder will use the plugin name - indicated in the ClowdApp's spec.testing.iqePlugin field. - A comma,separated,list of plugins can be supplied here - if you wish you override the plugins. + description: A comma,separated,list indicating IQE plugin(s) + to run tests for. By default, Clowder will use the plugin + name given on the ClowdApp's spec.testing.iqePlugin field. + Use this field if you wish you override the plugin list. type: string requirements: - description: sets values passed to IQE '--requirements' - arg + description: (DEPRECATED, using 'env' now preferred) sets + IQE_REQUIREMENTS env var on the IQE container items: type: string type: array requirementsPriority: - description: sets values passed to IQE '--requirements-priority' - arg + description: (DEPRECATED, using 'env' now preferred) sets + IQE_REQUIREMENTS_PRIORITY env var on the IQE container items: type: string type: array rpArgs: - description: sets value passed to IQE 'IQE_RP_ARGS' report - portal args + description: (DEPRECATED, using 'env' now preferred) sets + IQE_RP_ARGS env var on the IQE container type: string testImportance: - description: sets values passed to IQE '--test-importance' - arg + description: (DEPRECATED, using 'env' now preferred) sets + IQE_TEST_IMPORTANCE env var on the IQE container items: type: string type: array ui: - description: 'Indiciates the presence of a selenium container - Note: currently not implemented' + description: Defines configuration for a selenium container + (optional) properties: enabled: description: No longer used diff --git a/deploy.yml b/deploy.yml index 1cd803776..e0d48e3d4 100644 --- a/deploy.yml +++ b/deploy.yml @@ -6787,27 +6787,147 @@ objects: ClowdApp's definition of the job properties: debug: - description: Use to start the IQE pod without running tests - and leave it up so that 'rsh' can be invoked + description: Changes entrypoint to invoke 'iqe container-debug' + so that container starts but does not run tests, allowing + 'rsh' to be invoked type: boolean dynaconfEnvName: - description: sets value for ENV_FOR_DYNACONF + description: (DEPRECATED, using 'env' now preferred) sets + ENV_FOR_DYNACONF env var on the IQE container type: string + env: + description: Specifies environment variables to set on the + IQE container + items: + description: EnvVar represents an environment variable + present in a Container. + properties: + name: + description: Name of the environment variable. Must + be a C_IDENTIFIER. + type: string + value: + description: 'Variable references $(VAR_NAME) are + expanded using the previously defined environment + variables in the container and any service environment + variables. If a variable cannot be resolved, the + reference in the input string will be unchanged. + Double $$ are reduced to a single $, which allows + for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" + will produce the string literal "$(VAR_NAME)". Escaped + references will never be expanded, regardless of + whether the variable exists or not. Defaults to + "".' + type: string + valueFrom: + description: Source for the environment variable's + value. Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, + kind, uid?' + type: string + optional: + description: Specify whether the ConfigMap + or its key must be defined + type: boolean + required: + - key + type: object + fieldRef: + description: 'Selects a field of the pod: supports + metadata.name, metadata.namespace, `metadata.labels['''']`, + `metadata.annotations['''']`, spec.nodeName, + spec.serviceAccountName, status.hostIP, status.podIP, + status.podIPs.' + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in + the specified API version. + type: string + required: + - fieldPath + type: object + resourceFieldRef: + description: 'Selects a resource of the container: + only resources limits and requests (limits.cpu, + limits.memory, limits.ephemeral-storage, requests.cpu, + requests.memory and requests.ephemeral-storage) + are currently supported.' + properties: + containerName: + description: 'Container name: required for + volumes, optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of + the exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + secretKeyRef: + description: Selects a key of a secret in the + pod's namespace + properties: + key: + description: The key of the secret to select + from. Must be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, + kind, uid?' + type: string + optional: + description: Specify whether the Secret or + its key must be defined + type: boolean + required: + - key + type: object + type: object + required: + - name + type: object + type: array filter: - description: sets pytest -k args + description: (DEPRECATED, using 'env' now preferred) sets + IQE_FILTER_EXPRESSION env var on the IQE container type: string ibutsuSource: - description: sets value passed to IQE 'IQE_IBUTSU_SOURCE' - args + description: (DEPRECATED, using 'env' now preferred) sets + IQE_IBUTSU_SOURCE env var on the IQE container type: string imageTag: - description: By default, Clowder will set the image on the - ClowdJob to be the baseImage:name-of-iqe-plugin, but only - the tag can be overridden here + description: Image tag to use for IQE container. By default, + Clowder will set the image tag to be baseImage:name-of-iqe-plugin, + where baseImage is defined in the ClowdEnvironment. Only + the tag can be overridden here. type: string logLevel: - description: 'sets value for IQE_LOG_LEVEL (default if empty: - "info")' + description: (DEPRECATED, using 'env' now preferred) sets + IQE_LOG_LEVEL env var on the IQE container enum: - '' - critical @@ -6818,47 +6938,48 @@ objects: - notset type: string marker: - description: sets the pytest -m args + description: (DEPRECATED, using 'env' now preferred) sets + IQE_MARKER_EXPRESSION env var on the IQE container type: string parallelEnabled: - description: sets value passed to IQE 'IQE_PARALLEL_ENABLED' - arg + description: (DEPRECATED, using 'env' now preferred) sets + IQE_PARALLEL_ENABLED env var on the IQE container type: string parallelWorkerCount: - description: sets value passed to IQE 'IQE_PARALLEL_WORKER_COUNT' - arg + description: (DEPRECATED, using 'env' now preferred) sets + IQE_PARALLEL_WORKER_COUNT env var on the IQE container type: string plugins: - description: By default, Clowder will use the plugin name - indicated in the ClowdApp's spec.testing.iqePlugin field. - A comma,separated,list of plugins can be supplied here - if you wish you override the plugins. + description: A comma,separated,list indicating IQE plugin(s) + to run tests for. By default, Clowder will use the plugin + name given on the ClowdApp's spec.testing.iqePlugin field. + Use this field if you wish you override the plugin list. type: string requirements: - description: sets values passed to IQE '--requirements' - arg + description: (DEPRECATED, using 'env' now preferred) sets + IQE_REQUIREMENTS env var on the IQE container items: type: string type: array requirementsPriority: - description: sets values passed to IQE '--requirements-priority' - arg + description: (DEPRECATED, using 'env' now preferred) sets + IQE_REQUIREMENTS_PRIORITY env var on the IQE container items: type: string type: array rpArgs: - description: sets value passed to IQE 'IQE_RP_ARGS' report - portal args + description: (DEPRECATED, using 'env' now preferred) sets + IQE_RP_ARGS env var on the IQE container type: string testImportance: - description: sets values passed to IQE '--test-importance' - arg + description: (DEPRECATED, using 'env' now preferred) sets + IQE_TEST_IMPORTANCE env var on the IQE container items: type: string type: array ui: - description: 'Indiciates the presence of a selenium container - Note: currently not implemented' + description: Defines configuration for a selenium container + (optional) properties: enabled: description: No longer used diff --git a/docs/antora/modules/ROOT/pages/api_reference.adoc b/docs/antora/modules/ROOT/pages/api_reference.adoc index 2358c42a8..be52317dd 100644 --- a/docs/antora/modules/ROOT/pages/api_reference.adoc +++ b/docs/antora/modules/ROOT/pages/api_reference.adoc @@ -583,21 +583,22 @@ InitContainer is a struct defining a k8s init container. This will be deployed a [cols="25a,75a", options="header"] |=== | Field | Description -| *`imageTag`* __string__ | By default, Clowder will set the image on the ClowdJob to be the baseImage:name-of-iqe-plugin, but only the tag can be overridden here -| *`plugins`* __string__ | By default, Clowder will use the plugin name indicated in the ClowdApp's spec.testing.iqePlugin field. A comma,separated,list of plugins can be supplied here if you wish you override the plugins. -| *`ui`* __xref:{anchor_prefix}-github-com-redhatinsights-clowder-apis-cloud-redhat-com-v1alpha1-iqeuispec[$$IqeUISpec$$]__ | Indiciates the presence of a selenium container Note: currently not implemented -| *`marker`* __string__ | sets the pytest -m args -| *`dynaconfEnvName`* __string__ | sets value for ENV_FOR_DYNACONF -| *`filter`* __string__ | sets pytest -k args -| *`debug`* __boolean__ | Use to start the IQE pod without running tests and leave it up so that 'rsh' can be invoked -| *`requirements`* __string__ | sets values passed to IQE '--requirements' arg -| *`requirementsPriority`* __string__ | sets values passed to IQE '--requirements-priority' arg -| *`testImportance`* __string__ | sets values passed to IQE '--test-importance' arg -| *`logLevel`* __string__ | sets value for IQE_LOG_LEVEL (default if empty: "info") -| *`parallelEnabled`* __string__ | sets value passed to IQE 'IQE_PARALLEL_ENABLED' arg -| *`parallelWorkerCount`* __string__ | sets value passed to IQE 'IQE_PARALLEL_WORKER_COUNT' arg -| *`rpArgs`* __string__ | sets value passed to IQE 'IQE_RP_ARGS' report portal args -| *`ibutsuSource`* __string__ | sets value passed to IQE 'IQE_IBUTSU_SOURCE' args +| *`imageTag`* __string__ | Image tag to use for IQE container. By default, Clowder will set the image tag to be baseImage:name-of-iqe-plugin, where baseImage is defined in the ClowdEnvironment. Only the tag can be overridden here. +| *`plugins`* __string__ | A comma,separated,list indicating IQE plugin(s) to run tests for. By default, Clowder will use the plugin name given on the ClowdApp's spec.testing.iqePlugin field. Use this field if you wish you override the plugin list. +| *`ui`* __xref:{anchor_prefix}-github-com-redhatinsights-clowder-apis-cloud-redhat-com-v1alpha1-iqeuispec[$$IqeUISpec$$]__ | Defines configuration for a selenium container (optional) +| *`env`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#envvar-v1-core[$$EnvVar$$]__ | Specifies environment variables to set on the IQE container +| *`debug`* __boolean__ | Changes entrypoint to invoke 'iqe container-debug' so that container starts but does not run tests, allowing 'rsh' to be invoked +| *`marker`* __string__ | (DEPRECATED, using 'env' now preferred) sets IQE_MARKER_EXPRESSION env var on the IQE container +| *`dynaconfEnvName`* __string__ | (DEPRECATED, using 'env' now preferred) sets ENV_FOR_DYNACONF env var on the IQE container +| *`filter`* __string__ | (DEPRECATED, using 'env' now preferred) sets IQE_FILTER_EXPRESSION env var on the IQE container +| *`requirements`* __string__ | (DEPRECATED, using 'env' now preferred) sets IQE_REQUIREMENTS env var on the IQE container +| *`requirementsPriority`* __string__ | (DEPRECATED, using 'env' now preferred) sets IQE_REQUIREMENTS_PRIORITY env var on the IQE container +| *`testImportance`* __string__ | (DEPRECATED, using 'env' now preferred) sets IQE_TEST_IMPORTANCE env var on the IQE container +| *`logLevel`* __string__ | (DEPRECATED, using 'env' now preferred) sets IQE_LOG_LEVEL env var on the IQE container +| *`parallelEnabled`* __string__ | (DEPRECATED, using 'env' now preferred) sets IQE_PARALLEL_ENABLED env var on the IQE container +| *`parallelWorkerCount`* __string__ | (DEPRECATED, using 'env' now preferred) sets IQE_PARALLEL_WORKER_COUNT env var on the IQE container +| *`rpArgs`* __string__ | (DEPRECATED, using 'env' now preferred) sets IQE_RP_ARGS env var on the IQE container +| *`ibutsuSource`* __string__ | (DEPRECATED, using 'env' now preferred) sets IQE_IBUTSU_SOURCE env var on the IQE container |=== diff --git a/tests/kuttl/test-iqe-jobs/01-assert.yaml b/tests/kuttl/test-iqe-jobs/01-assert.yaml index e8fd4921b..b1d54da17 100644 --- a/tests/kuttl/test-iqe-jobs/01-assert.yaml +++ b/tests/kuttl/test-iqe-jobs/01-assert.yaml @@ -51,7 +51,7 @@ spec: - name: IQE_FILTER_EXPRESSION value: "test_plugin_accessible" - name: IQE_LOG_LEVEL - value: "debug" + value: "warning" - name: IQE_REQUIREMENTS value: "some,requirements" - name: IQE_REQUIREMENTS_PRIORITY @@ -66,6 +66,8 @@ spec: value: "true" - name: IQE_IBUTSU_SOURCE value: "post_stage_deploy" + - name: SOME_ENV_VAR + value: "some_value" resources: limits: cpu: "2" diff --git a/tests/kuttl/test-iqe-jobs/01-pods.yaml b/tests/kuttl/test-iqe-jobs/01-pods.yaml index 9c8310e0f..7442153ca 100644 --- a/tests/kuttl/test-iqe-jobs/01-pods.yaml +++ b/tests/kuttl/test-iqe-jobs/01-pods.yaml @@ -73,12 +73,18 @@ spec: iqe: imageTag: latest plugins: "some,different,plugins" + env: + - name: SOME_ENV_VAR + value: some_value + # test env var override behavior using IQE_LOG_LEVEL + - name: IQE_LOG_LEVEL + value: warning ui: enabled: false marker: "smoke" dynaconfEnvName: "clowder_smoke" filter: "test_plugin_accessible" - logLevel: "debug" + logLevel: "debug" # we expect this to be overridden requirements: - "some" - "requirements"