Skip to content

Commit

Permalink
Split tempest run args
Browse files Browse the repository at this point in the history
!backward incomatible!

Moving the tempest run related args to their own
section. Adding concurrency related args.
  • Loading branch information
afazekas committed Sep 20, 2023
1 parent 34deecb commit eb5dd46
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 48 deletions.
36 changes: 24 additions & 12 deletions api/bases/test.openstack.org_tempests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ spec:
spec:
description: TempestSpec defines the desired state of Tempest
properties:
allowedTests:
default:
- tempest.api.identity.v3
description: AllowedTests
items:
type: string
type: array
backoffLimit:
default: 0
description: BackoffLimimt allows to define the maximum number of
Expand Down Expand Up @@ -116,11 +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
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
34 changes: 25 additions & 9 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,23 +84,18 @@ type TempestSpec struct {
// ExternalEndpoints, expose a VIP using a pre-created IPAddressPool
ExternalEndpoints []MetalLBConfig `json:"externalEndpoints,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default={"tempest.api.identity.v3"}
// 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.

36 changes: 24 additions & 12 deletions config/crd/bases/test.openstack.org_tempests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ spec:
spec:
description: TempestSpec defines the desired state of Tempest
properties:
allowedTests:
default:
- tempest.api.identity.v3
description: AllowedTests
items:
type: string
type: array
backoffLimit:
default: 0
description: BackoffLimimt allows to define the maximum number of
Expand Down Expand Up @@ -116,11 +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
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
6 changes: 6 additions & 0 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,6 +19,11 @@ 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")
}

job := &batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
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

0 comments on commit eb5dd46

Please sign in to comment.