Skip to content

Commit

Permalink
Add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RemindD committed Jun 12, 2024
1 parent 6e5318d commit 3bdaa8c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion k8s/apis/workflow/v1/activation_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (r *Activation) ValidateUpdate(old runtime.Object) (admission.Warnings, err
return nil, fmt.Errorf("expected an Activation object")
}
// Compare the Spec of the current and old Activation objects
validationError := oldActivation.validateSpecOnUpdate(oldActivation)
validationError := r.validateSpecOnUpdate(oldActivation)
if validationError != nil {
activationWebhookValidationMetrics.ControllerValidationLatency(
validateUpdateTime,
Expand Down
27 changes: 27 additions & 0 deletions test/integration/scenarios/04.workflow/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ var (
testVerify = []string{
"./verify/...",
}

CampaignNotExistActivation = "test/integration/scenarios/04.workflow/manifest/activation-campaignnotexist.yaml"

WithStageActivation = "test/integration/scenarios/04.workflow/manifest/activation-stage.yaml"
)

// Entry point for running the tests
Expand All @@ -80,6 +84,10 @@ func Test() error {
if err != nil {
return err
}
err = FaultTest(namespace)
if err != nil {
return err
}
}

return nil
Expand Down Expand Up @@ -181,6 +189,25 @@ func Verify() error {
return nil
}

func FaultTest(namespace string) error {
repoPath := os.Getenv("REPO_PATH")
if repoPath == "" {
repoPath = "../../../../"
}
var err error
CampaignNotExistActivationAbs := filepath.Join(repoPath, CampaignNotExistActivation)
err = shellcmd.Command(fmt.Sprintf("kubectl apply -f %s -n %s", CampaignNotExistActivationAbs, namespace)).Run()
if err == nil {
return fmt.Errorf("fault test failed for non-existing campaign")
}
WithStageActivationAbs := filepath.Join(repoPath, WithStageActivation)
err = shellcmd.Command(fmt.Sprintf("kubectl apply -f %s -n %s", WithStageActivationAbs, namespace)).Run()
if err == nil {
return fmt.Errorf("fault test failed for non-existing campaign")
}
return nil
}

// Clean up
func Cleanup() {
localenvCmd(fmt.Sprintf("dumpSymphonyLogsForTest '%s'", TEST_NAME), "")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: workflow.symphony/v1
kind: Activation
metadata:
name: 04workflow2
spec:
campaign: "04campaign:v2"

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: workflow.symphony/v1
kind: Activation
metadata:
name: 04workflow
spec:
campaign: "04campaign:v1"
stage: "deploy"

0 comments on commit 3bdaa8c

Please sign in to comment.