Skip to content

Commit

Permalink
Fix e2e with new yamls and support restic again (#328)
Browse files Browse the repository at this point in the history
* Deploy velero-crds and velero secret

* resolve conflicts

* formatting and linting

* resolve main-branch conflicts

* code cleanup and working secret automation with real data

* Update application_mobility.go

Resolve merge conflict errors

* changed fmt error to log error

* use fmt print instead error

* Restic changes and update e2e yamls

* minor correction in test yaml

* working e2e and support restic again

* Update alt-velero-secret.yaml

* Update application_mobility.go

* Removing duplicate test scenario

* resolve merge conflict

---------

Co-authored-by: Jooseppi Luna <[email protected]>
  • Loading branch information
kumarkgosa and jooseppi-luna authored Aug 24, 2023
1 parent ae989a8 commit 27d6c29
Show file tree
Hide file tree
Showing 13 changed files with 228 additions and 268 deletions.
36 changes: 11 additions & 25 deletions pkg/modules/application_mobility.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ const (
InitContainerImage = "<INIT_CONTAINER_IMAGE>"
//AccessContents - contents of the object store secret
AccessContents = "<CRED_CONTENTS>"
//AccessKeyID - contains the aws access key id
AccessKeyID = "<KEY_ID>"
//AccessKey - contains the aws access key
AccessKey = "<KEY>"
//AKeyID - contains the aws access key id
AKeyID = "<KEY_ID>"
//AKey - contains the aws access key
AKey = "<KEY>"

// AppMobCtrlMgrComponent - component name in cr for app-mobility controller-manager
AppMobCtrlMgrComponent = "application-mobility-controller-manager"
Expand Down Expand Up @@ -142,11 +142,10 @@ func VeleroCrdDeploy(ctx context.Context, isDeleting bool, op utils.OperatorConf
if err != nil {
return err
}
err = applyDeleteObjects(ctx, ctrlClient, yamlString, isDeleting)
if err != nil {
return err
er := applyDeleteObjects(ctx, ctrlClient, yamlString, isDeleting)
if er != nil {
return er
}

return nil
}

Expand Down Expand Up @@ -437,8 +436,8 @@ func getCreateVeleroAccess(op utils.OperatorConfig, cr csmv1.ContainerStorageMod

yamlString = strings.ReplaceAll(yamlString, VeleroNamespace, veleroNS)
yamlString = strings.ReplaceAll(yamlString, VeleroAccess, credName)
yamlString = strings.ReplaceAll(yamlString, AccessKeyID, accessID)
yamlString = strings.ReplaceAll(yamlString, AccessKey, access)
yamlString = strings.ReplaceAll(yamlString, AKeyID, accessID)
yamlString = strings.ReplaceAll(yamlString, AKey, access)

return yamlString, nil
}
Expand Down Expand Up @@ -746,19 +745,8 @@ func getRestic(op utils.OperatorConfig, cr csmv1.ContainerStorageModule) (string
veleroNS := ""
veleroImgPullPolicy := ""
veleroImg := ""
credName := ""
objectSecretName := ""

for _, component := range appMob.Components {
if component.Name == AppMobCtrlMgrComponent {
for _, env := range component.Envs {
if strings.Contains(AppMobObjStoreSecretName, env.Name) {
objectSecretName = env.Value
}
}
}
}

for _, component := range appMob.Components {
if component.Name == AppMobVeleroComponent {
if component.Image != "" {
Expand All @@ -771,8 +759,8 @@ func getRestic(op utils.OperatorConfig, cr csmv1.ContainerStorageModule) (string
if strings.Contains(VeleroNamespace, env.Name) {
veleroNS = env.Value
}
if strings.Contains(VeleroAccess, env.Name) {
credName = env.Value
if strings.Contains(AppMobObjStoreSecretName, env.Name) {
objectSecretName = env.Value
}

}
Expand All @@ -788,9 +776,7 @@ func getRestic(op utils.OperatorConfig, cr csmv1.ContainerStorageModule) (string

yamlString = strings.ReplaceAll(yamlString, VeleroImage, veleroImg)
yamlString = strings.ReplaceAll(yamlString, VeleroNamespace, veleroNS)
yamlString = strings.ReplaceAll(yamlString, VeleroAccess, credName)
yamlString = strings.ReplaceAll(yamlString, VeleroImagePullPolicy, veleroImgPullPolicy)
yamlString = strings.ReplaceAll(yamlString, AppMobObjStoreSecretName, objectSecretName)
return yamlString, nil
}

Expand Down
2 changes: 0 additions & 2 deletions tests/e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,6 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU=
github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM=
github.com/onsi/ginkgo/v2 v2.12.0 h1:UIVDowFPwpg6yMUpPjGkYvf06K3RAiJXUhCxEwQVHRI=
github.com/onsi/ginkgo/v2 v2.12.0/go.mod h1:ZNEzXISYlqpb8S36iN71ifqLi3vVD1rVJGvWRCJOUpQ=
github.com/onsi/gomega v1.27.8 h1:gegWiwZjBsf2DgiSbf5hpokZ98JVDMcWkUiigk6/KXc=
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/steps/step_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func checkApplicationMobilityPods(namespace string, k8sClient kubernetes.Interfa

for _, pod := range allPods {
podMsg, podRunning := arePodsRunning(pod)
if podRunning == false {
if podRunning == false && pod.Status.Phase != "Succeeded" {
return fmt.Errorf("pod %s not running: %+v", pod.Name, podMsg)
}
}
Expand Down
8 changes: 3 additions & 5 deletions tests/e2e/steps/steps_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,6 @@ func (step *Step) validateModuleNotInstalled(res Resource, module string, crNumS

case csmv1.Resiliency:
return step.validateResiliencyNotInstalled(cr)

//case csmv1.ApplicationMobility:
// return step.validateAppMobNotInstalled(cr)
}
}
}
Expand Down Expand Up @@ -863,7 +860,8 @@ func (step *Step) validateAuthorizationProxyServerNotInstalled(cr csmv1.Containe
}

func (step *Step) validateAppMobInstalled(cr csmv1.ContainerStorageModule) error {
time.Sleep(5 * time.Second)
//providing additional time to get appmob pods up to running
time.Sleep(10 * time.Second)
instance := new(csmv1.ContainerStorageModule)
if err := step.ctrlClient.Get(context.TODO(), client.ObjectKey{
Namespace: cr.Namespace,
Expand All @@ -890,7 +888,7 @@ func (step *Step) validateAppMobInstalled(cr csmv1.ContainerStorageModule) error
}

// provide few seconds for cluster to settle down
time.Sleep(20 * time.Second)
time.Sleep(10 * time.Second)
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ stringData:
cloud: |
[default]
aws_access_key_id=access_key
aws_secret_access_key=secret_access_key
aws_secret_access_key=access_key123
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: cloud-creds
name: existing-cred
namespace: application-mobility
labels:
app.kubernetes.io/name: application-mobility-velero
Expand All @@ -11,4 +11,4 @@ stringData:
cloud: |
[default]
aws_access_key_id=access_key
aws_secret_access_key=secret_access_key
aws_secret_access_key=secret_access_key123
63 changes: 10 additions & 53 deletions tests/e2e/testfiles/appmob-values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- scenario: "Install App Mobility with Velero and Cert-Manager already installed"
- scenario: "Install App Mobility with all features enabled while Velero and Cert-Manager already installed"
paths:
- "testfiles/csm_application_mobility_vanilla.yaml"
modules:
Expand All @@ -20,19 +20,17 @@
run:
- sh verify-app-mobility.sh

- scenario: "Install App Mobility Controller with different env variables than default"
- scenario: "Install App Mobility Controller manager with different env variables along with velero"
paths:
- "testfiles/csm_application_mobility_controller_diff_env.yaml"
modules:
steps:
- "Given an environment with k8s or openshift, and CSM operator installed"
- "Install [velero]"
- "Install [cert-manager]"
- "Apply custom resource [1]"
- "Validate [application-mobility] module from CR [1] is installed"
#- "Run custom test"
# Last two steps perform Clean Up
- "Uninstall [velero]"
- "Uninstall [cert-manager]"
- "Enable forceRemoveModule on CR [1]"
- "Delete custom resource [1]"
Expand All @@ -44,63 +42,29 @@

- scenario: "Install App Mobility Velero with different env variables than default"
paths:
- "testfiles/application-mobility-templates/alt-velero-secret.yaml"
- "testfiles/csm_application_mobility_velero_diff_env.yaml"
modules:
steps:
- "Given an environment with k8s or openshift, and CSM operator installed"

- "Install [cert-manager]"
- "Apply custom resource [1]"
- "Validate [application-mobility] module from CR [1] is installed"
- "Apply custom resource [2]"
- "Validate [application-mobility] module from CR [2] is installed"
#- "Run custom test"
# Last two steps perform Clean Up
- "Uninstall [cert-manager]"
- "Enable forceRemoveModule on CR [1]"
- "Delete custom resource [1]"
customTest:
# name of custom test to run
name: verify app-mobility
run:
- sh verify-app-mobility.sh

- scenario: "Install App Mobility with Cert-Manager"
paths:
- "testfiles/csm_application_mobility_cert_manager.yaml"
modules:
steps:
- "Given an environment with k8s or openshift, and CSM operator installed"
- "Install [velero]"
- "Apply custom resource [1]"
- "Validate [application-mobility] module from CR [1] is installed"
#- "Run custom test"
# Last two steps perform Clean Up
- "Uninstall [velero]"
- "Enable forceRemoveModule on CR [1]"
- "Delete custom resource [1]"
customTest:
# name of custom test to run
name: verify app-mobility
run:
- sh verify-app-mobility.sh

- scenario: "Install App Mobility with Cert-Manager and Velero"
paths:
- "testfiles/csm_application_mobility_velero_with_cert.yaml"
modules:
steps:
- "Given an environment with k8s or openshift, and CSM operator installed"
- "Apply custom resource [1]"
- "Validate [application-mobility] module from CR [1] is installed"
#- "Run custom test"
# Last two steps perform Clean Up
- "Enable forceRemoveModule on CR [1]"
- "Enable forceRemoveModule on CR [2]"
- "Delete custom resource [1]"
- "Delete custom resource [2]"
customTest:
# name of custom test to run
name: verify app-mobility
run:
- sh verify-app-mobility.sh

- scenario: "Install App Mobility with velero when cert-manager is already installed"
- scenario: "Install App Mobility with velero not installed and cert-manager already installed on machine"
paths:
- "testfiles/csm_application_mobility_test_velero.yaml"
modules:
Expand All @@ -117,16 +81,13 @@
customTest:
# name of custom test to run
name: verify app-mobility
# Provide command-line argument to run. Ginkgo will run the command and return output
# The command should be accessible from e2e_test repo. The cert-csi path is supplied in the values file.
# Example:
# ./hello_world.sh
run:
- sh verify-app-mobility.sh

- scenario: "Install App Mobility with powerflex driver"
paths:
- "testfiles/csm_application_mobility_velero_with_cert.yaml"
- "testfiles/csm_application_mobility_vanilla.yaml"
- "testfiles/storage_csm_powerflex.yaml"
modules:
steps:
Expand All @@ -146,10 +107,6 @@
customTest:
# name of the custom test to run
name: verify app-mobility
# Provide command-line argument to run. Ginkgo will run the command and return output
# The command should be accessible from e2e_test repo. The cert-csi path is supplied in the values file.
# Example:
# ./hello_world.sh
run:
- sh verify-app-mobility.sh

93 changes: 57 additions & 36 deletions tests/e2e/testfiles/csm_application_mobility_cert_manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ spec:
# License for application mobility
# Default value: license
- name: "APPLICATION_MOBILITY_LICENSE_NAME"
value: "license"

# Storage-service ingress configuration
# Default value: velero-restic-credentials
- name: "APPLICATION_MOBILITY_OBJECT_STORE_SECRET_NAME"
value: "velero-restic-credentials"
value: "license"

# enabled: Enable/Disable cert-manager
# Allowed values:
Expand All @@ -41,49 +36,75 @@ spec:
# Default value: false
- name: cert-manager
enabled: true
# enabled: Enable/Disable Velero and Restic Services
# Allowed values:
# true: enable deployment of cert-manager
# false: disable deployment of cert-manager only if it's already deployed
# Default value: false
# enabled: Enable/Disable Velero
- name: velero
#existingSecret: existing_secret_name
image: velero/velero:v1.8.1
image: velero/velero:v1.10.0
imagePullPolicy: IfNotPresent
enabled: false
#use-volume-snapshots: false
#cleanUpCRDs: false
#deployRestic: false
#initContainers:
# - name: dell-custom-velero-plugin
# image: dellemc/csm-application-mobility-velero-plugin:v0.1.0
# volumeMounts:
# - mountPath: /target
# name: plugins
# - name: velero-plugin-for-aws
# image: velero/velero-plugin-for-aws:v1.5.0
# volumeMounts:
# - mountPath: /target
# name: plugins
enabled: true
useVolumeSnapshot: false
cleanUpCRDs: false
# enabled: Enable/Disable Restic Services
deployRestic: true
envs:
# Backup storage location name
# Allowed values: string
# Default value: default
- name: "BACKUPSTORAGELOCATION_NAME"
value: "default"

# Velero bucket name
# Allowed values: string
# Default value: my-bucket
- name: "BUCKET_NAME"
value: "my-bucket"

# Namespace for Velero installation
# Default value: application-mobility
- name: "VELERO_NAMESPACE"
value: "application-mobility"

# Based on the objectstore being used , the velero plugin and its configuration may need to change!
# GCP and Azure plugins configuration are different. See more details at: https://github.com/vmware-tanzu/helm-charts/blob/main/charts/velero/README.md
# Sample value: aws
- name: "CONFIG_PROVIDER"
# Based on the objectstore being used, the velero plugin and its configuration may need to change!
# default value: aws
- name: "PROVIDER"
value: "aws"

# name to be used for secret that will be created to hold object store credentials. Used in conjunction with secretContents
# Default value: cloud-creds
- name: "VELERO_SECRET"
value: "cloud-creds"
# Name of the volume snapshot location where snapshots are being taken. Required.
# Volume-snapshot-Location Provider will be same as CONFIG_PROVIDER
# Default value : default
- name: "VOL_SNAPSHOT_LOCATION_NAME"
value: "default"

# Name of the backup storage url
# This field has to be changed to a functional backup storage url
# Default value: existing-cred
- name: "BACKUP_STORAGE_URL"
value: "localhost:8000"

# Name of the secret in velero namespace that has credentials to access object store
# We can leave the field empty if there no existing secret in velero installed namespace
# Default value: existing-cred
- name: "APPLICATION_MOBILITY_OBJECT_STORE_SECRET_NAME"
value: "existing-cred"

#If velero is not already present in cluster, set enabled to true to create a secret.
#Either this or APPLICATION_MOBILITY_OBJECT_STORE_SECRET_NAME above must be provided.
credentials:
- enabled: false
#Specify the name to be used for secret that will be created to hold object store credentials.
name: cloud-creds
#Specify the object store access credentials to be stored in a secret with key "cloud".
secretContents:
aws_access_key_id: #Provide the access key id here
aws_secret_access_key: #provide the access key here


# Init containers to add to the Velero deployment's pod spec. At least one plugin provider image is required.
# If the value is a string then it is evaluated as a template.
- initContainer:
#initContainer image for the configuration-provider - csi
- name: dell-custom-velero-plugin
image: dellemc/csm-application-mobility-velero-plugin:v0.1.0

#initContainer image for the configuration-provider - aws
- name: velero-plugin-for-aws
image: velero/velero-plugin-for-aws:v1.5.0
Loading

0 comments on commit 27d6c29

Please sign in to comment.