Skip to content

Commit

Permalink
add e2e test case (#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleyvjoy authored Jun 18, 2024
1 parent 3c8a342 commit a46968c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/e2e/steps/steps_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package steps

import (
"bytes"
"context"
"fmt"
"os"
Expand Down Expand Up @@ -1407,3 +1408,24 @@ func (step *Step) validateApplicationMobilityNotInstalled(cr csmv1.ContainerStor
fmt.Println("All AM pods removed ")
return nil
}

func (step *Step) validateRbacCreated(_ Resource, namespace string) error {
fmt.Println("=== validating Rbac created ===")

cmd := exec.Command("kubectl", "get", "rolebindings", "-n", "namespacename")
var out bytes.Buffer
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
return fmt.Errorf("failed to run command")
}

roles := strings.Split(out.String(), "\n")
for _, role := range roles {
if strings.Contains(role, "Role/connectivity-client-docker-k8s") {
return nil
}
}

return nil
}
1 change: 1 addition & 0 deletions tests/e2e/steps/steps_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func StepRunnerInit(runner *Runner, ctrlClient client.Client, clientSet *kuberne
runner.addStep(`^Validate connectivity client from CR \[(\d+)\] is installed$`, step.validateConnectivityClientInstalled)
runner.addStep(`^Validate connectivity client from CR \[(\d+)\] is not installed$`, step.validateConnectivityClientNotInstalled)
runner.addStep(`^Uninstall connectivity client from CR \[(\d+)\]`, step.uninstallConnectivityClient)
runner.addStep(`^Validate rbac created in namespace \[([^"]*)\]$`, step.validateRbacCreated)
}

func (runner *Runner) addStep(expr string, stepFunc interface{}) {
Expand Down
20 changes: 20 additions & 0 deletions tests/e2e/testfiles/connectivity-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,23 @@
- "Validate connectivity client from CR [1] is installed"
- "Uninstall connectivity client from CR [1]"
- "Validate connectivity client from CR [1] is not installed"

- scenario: "Validate role/rolebindings created for brownfield-onboard scenario"
paths:
- "testfiles/connectivity_client.yaml"
- "testfiles/storage_csm_powerflex.yaml"
steps:
- "Given an environment with k8s or openshift, and CSM operator installed"
- "Set up secret with template [testfiles/powerflex-templates/powerflex-secret-template.yaml] name [test-vxflexos-config] in namespace [test-vxflexos] for [pflex]"
- "Apply custom resource [2]"
- "Validate custom resource [2]"
- "Validate [powerflex] driver from CR [2] is installed"
- "Install connectivity client from CR [1]"
- "Validate connectivity client from CR [1] is installed"
- "Validate rbac created in namespace [test-vxflexos]"
- "Uninstall connectivity client from CR [1]"
- "Validate connectivity client from CR [1] is not installed"
- "Enable forceRemoveDriver on CR [2]"
- "Delete custom resource [2]"
- "Restore template [testfiles/powerflex-templates/powerflex-secret-template.yaml] for [pflex]"
- "Restore template [testfiles/powerflex-templates/powerflex-storageclass-template.yaml] for [pflex]"

0 comments on commit a46968c

Please sign in to comment.