Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove TempestRegexp argument #7

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions api/bases/test.openstack.org_tempests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ spec:
spec:
description: TempestSpec defines the desired state of Tempest
properties:
allowedTests:
description: AllowedTests
items:
type: string
type: array
backoffLimit:
default: 0
description: BackoffLimimt allows to define the maximum number of
Expand Down Expand Up @@ -114,14 +109,30 @@ spec:
description: OpenStackConfigSecret is the name of the Secret containing
the secure.yaml
type: string
skippedTests:
description: SkippedTests
items:
type: string
type: array
tempestRegex:
description: TempestRegex
type: string
tempestRun:
description: TempestSpec TempestRun parts
properties:
allowedTests:
default:
- tempest.api.identity.v3
description: AllowedTests
items:
type: string
type: array
concurrency:
default: 0
description: Concurrency is the Default concurrency
format: int64
type: integer
skippedTests:
description: SkippedTests
items:
type: string
type: array
workerFile:
description: WorkerFile is the detailed concurry spec file
type: string
type: object
required:
- containerImage
- openStackConfigMap
Expand Down
37 changes: 25 additions & 12 deletions api/v1beta1/tempest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,27 @@ type Hash struct {
Hash string `json:"hash,omitempty"`
}

// TempestSpec TempestRun parts
type TempestRunSpec struct {
// +kubebuilder:validation:Optional
// +kubebuilder:default={"tempest.api.identity.v3"}
// AllowedTests
AllowedTests []string `json:"allowedTests,omitempty"`

// +kubebuilder:validation:Optional
// SkippedTests
SkippedTests []string `json:"skippedTests,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default:=0
// Concurrency is the Default concurrency
Concurrency *int64 `json:"concurrency,omitempty"`

// +kubebuilder:validation:Optional
// WorkerFile is the detailed concurry spec file
WorkerFile string `json:"workerFile,omitempty"`
}

// TempestSpec defines the desired state of Tempest
type TempestSpec struct {
// +kubebuilder:validation:Required
Expand Down Expand Up @@ -63,26 +84,18 @@ type TempestSpec struct {
// ExternalEndpoints, expose a VIP using a pre-created IPAddressPool
ExternalEndpoints []MetalLBConfig `json:"externalEndpoints,omitempty"`

// +kubebuilder:validation:Optional
// TempestRegex
TempestRegex string `json:"tempestRegex,omitempty"`

// +kubebuilder:validation:Optional
// AllowedTests
AllowedTests []string `json:"allowedTests,omitempty"`

// +kubebuilder:validation:Optional
// SkippedTests
SkippedTests []string `json:"skippedTests,omitempty"`

// BackoffLimimt allows to define the maximum number of retried executions (defaults to 6).
// +kubebuilder:default:=0
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:number"}
BackoffLimit *int32 `json:"backoffLimit,omitempty"`

// +kubebuilder:validation:Optional
TempestRun *TempestRunSpec `json:"tempestRun,omitempty"`

// TODO(slaweq): add more tempest run parameters here
}


// MetalLBConfig to configure the MetalLB loadbalancer service
type MetalLBConfig struct {
// +kubebuilder:validation:Required
Expand Down
45 changes: 35 additions & 10 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 24 additions & 13 deletions config/crd/bases/test.openstack.org_tempests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ spec:
spec:
description: TempestSpec defines the desired state of Tempest
properties:
allowedTests:
description: AllowedTests
items:
type: string
type: array
backoffLimit:
default: 0
description: BackoffLimimt allows to define the maximum number of
Expand Down Expand Up @@ -114,14 +109,30 @@ spec:
description: OpenStackConfigSecret is the name of the Secret containing
the secure.yaml
type: string
skippedTests:
description: SkippedTests
items:
type: string
type: array
tempestRegex:
description: TempestRegex
type: string
tempestRun:
description: TempestSpec TempestRun parts
properties:
allowedTests:
default:
- tempest.api.identity.v3
description: AllowedTests
items:
type: string
type: array
concurrency:
default: 0
description: Concurrency is the Default concurrency
format: int64
type: integer
skippedTests:
description: SkippedTests
items:
type: string
type: array
workerFile:
description: WorkerFile is the detailed concurry spec file
type: string
type: object
required:
- containerImage
- openStackConfigMap
Expand Down
5 changes: 4 additions & 1 deletion config/samples/test_v1beta1_tempest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ metadata:
namespace: openstack
spec:
containerImage: quay.io/podified-antelope-centos9/openstack-tempest:current-podified
secret: tempest-secret
tempestRun:
allowedTests:
- tempest.api.identity.v3.*
concurrency: 8
10 changes: 8 additions & 2 deletions controllers/tempest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,14 @@ func (r *TempestReconciler) generateServiceConfigMaps(
cmLabels := labels.GetLabels(instance, labels.GetGroupLabel(tempest.ServiceName), map[string]string{})

templateParameters := make(map[string]interface{})
customData := make(map[string]string)

templateParameters["AllowedTests"] = instance.Spec.AllowedTests
templateParameters["SkippedTests"] = instance.Spec.SkippedTests
if len(instance.Spec.TempestRun.WorkerFile) != 0 {
customData["worker_file.yaml"] = instance.Spec.TempestRun.WorkerFile
}

templateParameters["AllowedTests"] = instance.Spec.TempestRun.AllowedTests
templateParameters["SkippedTests"] = instance.Spec.TempestRun.SkippedTests

cms := []util.Template{
// ScriptsConfigMap
Expand All @@ -406,6 +411,7 @@ func (r *TempestReconciler) generateServiceConfigMaps(
InstanceType: instance.Kind,
Labels: cmLabels,
ConfigOptions: templateParameters,
CustomData: customData,
},
}
return configmap.EnsureConfigMaps(ctx, h, instance, cms, nil)
Expand Down
18 changes: 8 additions & 10 deletions pkg/tempest/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"strconv"
)

// Job - prepare job to run Tempest tests
Expand All @@ -18,13 +19,10 @@ func Job(
envVars := map[string]env.Setter{}
runAsUser := int64(42480)
runAsGroup := int64(42480)

args := []string{
"/var/lib/tempest/run_tempest.sh",
}
if instance.Spec.TempestRegex != "" {
args = append(args, "--regex")
args = append(args, instance.Spec.TempestRegex)
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")
}

job := &batchv1.Job{
Expand All @@ -40,9 +38,9 @@ func Job(
RestartPolicy: corev1.RestartPolicyNever,
ServiceAccountName: instance.RbacResourceName(),
SecurityContext: &corev1.PodSecurityContext{
RunAsUser: &runAsUser,
RunAsUser: &runAsUser,
RunAsGroup: &runAsGroup,
FSGroup: &runAsGroup,
FSGroup: &runAsGroup,
},
Containers: []corev1.Container{
{
Expand All @@ -51,7 +49,7 @@ func Job(
Command: []string{
"/usr/local/bin/container-scripts/invoke_tempest",
},
Args: []string{},
Args: []string{},
Env: env.MergeEnvs([]corev1.EnvVar{}, envVars),
VolumeMounts: GetVolumeMounts(),
},
Expand Down
9 changes: 7 additions & 2 deletions templates/tempest/bin/invoke_tempest
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ cd "$TEMPEST_DIR"
# TODO: consider profile support, deployer-input and other args passing
discover-tempest-config --os-cloud "$OS_CLOUD" --debug --create identity.v3_endpoint_type public

if [ -e $OPERATOR_ETC/worker_file.yaml ]; then
WORKER_FILE="--worker-file $OPERATOR_ETC/worker_file.yaml"
fi

tempest run \
--include-list ${OPERATOR_ETC}/include.txt \
--exclude-list ${OPERATOR_ETC}/exclude.txt
--concurrency "${TEMPEST_CONCURRENCY}" $WORKER_FILE \
--include-list "${OPERATOR_ETC}/include.txt" \
--exclude-list "${OPERATOR_ETC}/exclude.txt"

# NOTE: We might not want to fail when tests are executed
RETURN_VALUE=$?
Expand Down
2 changes: 0 additions & 2 deletions templates/tempest/config/include.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{{range $val := .AllowedTests }}
{{$val}}
{{ else }}
tempest.api.identity.v3
{{end}}
Loading