Skip to content
Open
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
38 changes: 19 additions & 19 deletions tests/e2e/backup_restore_cli_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func runApplicationBackupAndRestoreViaCLI(brCase ApplicationBackupRestoreCase, u

// CLI teardown function
func tearDownBackupAndRestoreViaCLI(brCase BackupRestoreCase, installTime time.Time, report ginkgo.SpecReport) {
log.Println("Post backup and restore state (CLI): ", report.State.String())
log.Println("Post backup and restore state (CLI): ", strings.ToUpper(report.State.String()))

if report.Failed() {
knownFlake = lib.CheckIfFlakeOccurred(accumulatedTestLogs)
Expand Down Expand Up @@ -265,8 +265,8 @@ var _ = ginkgo.Describe("Backup and restore tests via OADP CLI", ginkgo.Label("c
Namespace: "mysql-persistent",
Name: "mysql-csi-cli-e2e",
BackupRestoreType: lib.CSI,
PreBackupVerify: todoListReady(true, false, "mysql"),
PostRestoreVerify: todoListReady(false, false, "mysql"),
PreBackupVerify: verifyApplicationReady(true, false, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, false, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand All @@ -276,8 +276,8 @@ var _ = ginkgo.Describe("Backup and restore tests via OADP CLI", ginkgo.Label("c
Namespace: "mongo-persistent",
Name: "mongo-csi-cli-e2e",
BackupRestoreType: lib.CSI,
PreBackupVerify: todoListReady(true, false, "mongo"),
PostRestoreVerify: todoListReady(false, false, "mongo"),
PreBackupVerify: verifyApplicationReady(true, false, "todolist", "todolist-route", "mongo", false, "mongo-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, false, "todolist", "todolist-route", "mongo", false, "mongo-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand All @@ -287,8 +287,8 @@ var _ = ginkgo.Describe("Backup and restore tests via OADP CLI", ginkgo.Label("c
Namespace: "mysql-persistent",
Name: "mysql-twovol-csi-cli-e2e",
BackupRestoreType: lib.CSI,
PreBackupVerify: todoListReady(true, true, "mysql"),
PostRestoreVerify: todoListReady(false, true, "mysql"),
PreBackupVerify: verifyApplicationReady(true, true, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, true, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand All @@ -298,8 +298,8 @@ var _ = ginkgo.Describe("Backup and restore tests via OADP CLI", ginkgo.Label("c
Namespace: "mysql-persistent",
Name: "mysql-kopia-cli-e2e",
BackupRestoreType: lib.KOPIA,
PreBackupVerify: todoListReady(true, false, "mysql"),
PostRestoreVerify: todoListReady(false, false, "mysql"),
PreBackupVerify: verifyApplicationReady(true, false, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, false, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand All @@ -309,8 +309,8 @@ var _ = ginkgo.Describe("Backup and restore tests via OADP CLI", ginkgo.Label("c
Namespace: "mongo-persistent",
Name: "mongo-datamover-cli-e2e",
BackupRestoreType: lib.CSIDataMover,
PreBackupVerify: todoListReady(true, false, "mongo"),
PostRestoreVerify: todoListReady(false, false, "mongo"),
PreBackupVerify: verifyApplicationReady(true, false, "todolist", "todolist-route", "mongo", false, "mongo-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, false, "todolist", "todolist-route", "mongo", false, "mongo-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand All @@ -320,8 +320,8 @@ var _ = ginkgo.Describe("Backup and restore tests via OADP CLI", ginkgo.Label("c
Namespace: "mysql-persistent",
Name: "mysql-datamover-cli-e2e",
BackupRestoreType: lib.CSIDataMover,
PreBackupVerify: todoListReady(true, false, "mysql"),
PostRestoreVerify: todoListReady(false, false, "mysql"),
PreBackupVerify: verifyApplicationReady(true, false, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, false, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand All @@ -332,8 +332,8 @@ var _ = ginkgo.Describe("Backup and restore tests via OADP CLI", ginkgo.Label("c
Namespace: "mongo-persistent",
Name: "mongo-blockdevice-cli-e2e",
BackupRestoreType: lib.CSIDataMover,
PreBackupVerify: todoListReady(true, false, "mongo"),
PostRestoreVerify: todoListReady(false, false, "mongo"),
PreBackupVerify: verifyApplicationReady(true, false, "todolist", "todolist-route", "mongo", false, "mongo-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, false, "todolist", "todolist-route", "mongo", false, "mongo-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand All @@ -343,8 +343,8 @@ var _ = ginkgo.Describe("Backup and restore tests via OADP CLI", ginkgo.Label("c
Namespace: "mysql-persistent",
Name: "mysql-native-snapshots-cli-e2e",
BackupRestoreType: lib.NativeSnapshots,
PreBackupVerify: todoListReady(true, false, "mysql"),
PostRestoreVerify: todoListReady(false, false, "mysql"),
PreBackupVerify: verifyApplicationReady(true, false, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, false, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand All @@ -354,8 +354,8 @@ var _ = ginkgo.Describe("Backup and restore tests via OADP CLI", ginkgo.Label("c
Namespace: "mongo-persistent",
Name: "mongo-native-snapshots-cli-e2e",
BackupRestoreType: lib.NativeSnapshots,
PreBackupVerify: todoListReady(true, false, "mongo"),
PostRestoreVerify: todoListReady(false, false, "mongo"),
PreBackupVerify: verifyApplicationReady(true, false, "todolist", "todolist-route", "mongo", false, "mongo-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, false, "todolist", "todolist-route", "mongo", false, "mongo-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand Down
76 changes: 36 additions & 40 deletions tests/e2e/backup_restore_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,27 @@ type ApplicationBackupRestoreCase struct {
PvcSuffixName string
}

func todoListReady(preBackupState bool, twoVol bool, database string) VerificationFunction {
func verifyApplicationReady(preBackupState bool, twoVol bool, appName, routeName, workloadName string, isDC bool, sccName string) VerificationFunction {
return VerificationFunction(func(ocClient client.Client, namespace string) error {
log.Printf("checking for the NAMESPACE: %s", namespace)
gomega.Eventually(lib.IsDeploymentReady(ocClient, namespace, database), time.Minute*10, time.Second*10).Should(gomega.BeTrue())
// perhaps we phase out deploymentConfigs?
//gomega.Eventually(lib.IsDCReady(ocClient, namespace, "todolist"), time.Minute*10, time.Second*10).Should(gomega.BeTrue())
gomega.Eventually(lib.AreApplicationPodsRunning(kubernetesClientForSuiteRun, namespace), time.Minute*9, time.Second*5).Should(gomega.BeTrue())
// This test confirms that SCC restore logic in our plugin is working
err := lib.DoesSCCExist(ocClient, database+"-persistent-scc")
if err != nil {
return err
log.Printf("checking %s for the NAMESPACE: %s", appName, namespace)
if workloadName != "" {
if isDC {
gomega.Eventually(lib.IsDCReady(ocClient, namespace, workloadName), time.Minute*10, time.Second*10).Should(gomega.BeTrue())
} else {
gomega.Eventually(lib.IsDeploymentReady(ocClient, namespace, workloadName), time.Minute*10, time.Second*10).Should(gomega.BeTrue())
}
}
err = lib.VerifyBackupRestoreData(runTimeClientForSuiteRun, kubernetesClientForSuiteRun, kubeConfig, artifact_dir, namespace, "todolist-route", "todolist", "todolist", preBackupState, twoVol)
return err
})
}
gomega.Eventually(lib.AreApplicationPodsRunning(kubernetesClientForSuiteRun, namespace), time.Minute*9, time.Second*5).Should(gomega.BeTrue())

func parksAppReady(preBackupState bool, twoVol bool, DCReadyCheck bool) VerificationFunction {
return VerificationFunction(func(ocClient client.Client, namespace string) error {
log.Printf("checking parksapp for the NAMESPACE: %s", namespace)
if DCReadyCheck {
gomega.Eventually(lib.IsDCReady(ocClient, namespace, "restify"), time.Minute*10, time.Second*10).Should(gomega.BeTrue())
if sccName != "" {
// This test confirms that SCC restore logic in our plugin is working
err := lib.DoesSCCExist(ocClient, sccName)
if err != nil {
return err
}
}
gomega.Eventually(lib.AreApplicationPodsRunning(kubernetesClientForSuiteRun, namespace), time.Minute*9, time.Second*5).Should(gomega.BeTrue())
err := lib.VerifyBackupRestoreData(runTimeClientForSuiteRun, kubernetesClientForSuiteRun, kubeConfig, artifact_dir, namespace, "restify", "restify", "restify", preBackupState, twoVol)

err := lib.VerifyBackupRestoreData(runTimeClientForSuiteRun, kubernetesClientForSuiteRun, kubeConfig, artifact_dir, namespace, routeName, appName, appName, preBackupState, twoVol)
return err
})
}
Expand Down Expand Up @@ -317,7 +313,7 @@ func getFailedTestLogs(oadpNamespace string, appNamespace string, installTime ti
}

func tearDownBackupAndRestore(brCase BackupRestoreCase, installTime time.Time, report ginkgo.SpecReport) {
log.Println("Post backup and restore state: ", report.State.String())
log.Println("Post backup and restore state: ", strings.ToUpper(report.State.String()))
gatherLogs(brCase, installTime, report)
tearDownDPAResources(brCase)
deleteNamespace(brCase.Namespace)
Expand Down Expand Up @@ -403,8 +399,8 @@ var _ = ginkgo.Describe("Backup and restore tests", ginkgo.Ordered, func() {
Namespace: "mysql-persistent",
Name: "mysql-csi-e2e",
BackupRestoreType: lib.CSI,
PreBackupVerify: todoListReady(true, false, "mysql"),
PostRestoreVerify: todoListReady(false, false, "mysql"),
PreBackupVerify: verifyApplicationReady(true, false, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, false, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand All @@ -414,8 +410,8 @@ var _ = ginkgo.Describe("Backup and restore tests", ginkgo.Ordered, func() {
Namespace: "mongo-persistent",
Name: "mongo-csi-e2e",
BackupRestoreType: lib.CSI,
PreBackupVerify: todoListReady(true, false, "mongo"),
PostRestoreVerify: todoListReady(false, false, "mongo"),
PreBackupVerify: verifyApplicationReady(true, false, "todolist", "todolist-route", "mongo", false, "mongo-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, false, "todolist", "todolist-route", "mongo", false, "mongo-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand All @@ -425,8 +421,8 @@ var _ = ginkgo.Describe("Backup and restore tests", ginkgo.Ordered, func() {
Namespace: "mysql-persistent",
Name: "mysql-twovol-csi-e2e",
BackupRestoreType: lib.CSI,
PreBackupVerify: todoListReady(true, true, "mysql"),
PostRestoreVerify: todoListReady(false, true, "mysql"),
PreBackupVerify: verifyApplicationReady(true, true, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, true, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand All @@ -436,8 +432,8 @@ var _ = ginkgo.Describe("Backup and restore tests", ginkgo.Ordered, func() {
Namespace: "mysql-persistent",
Name: "mysql-kopia-e2e",
BackupRestoreType: lib.KOPIA,
PreBackupVerify: todoListReady(true, false, "mysql"),
PostRestoreVerify: todoListReady(false, false, "mysql"),
PreBackupVerify: verifyApplicationReady(true, false, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, false, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand All @@ -447,8 +443,8 @@ var _ = ginkgo.Describe("Backup and restore tests", ginkgo.Ordered, func() {
Namespace: "mongo-persistent",
Name: "mongo-datamover-e2e",
BackupRestoreType: lib.CSIDataMover,
PreBackupVerify: todoListReady(true, false, "mongo"),
PostRestoreVerify: todoListReady(false, false, "mongo"),
PreBackupVerify: verifyApplicationReady(true, false, "todolist", "todolist-route", "mongo", false, "mongo-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, false, "todolist", "todolist-route", "mongo", false, "mongo-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand All @@ -458,8 +454,8 @@ var _ = ginkgo.Describe("Backup and restore tests", ginkgo.Ordered, func() {
Namespace: "mysql-persistent",
Name: "mysql-datamover-e2e",
BackupRestoreType: lib.CSIDataMover,
PreBackupVerify: todoListReady(true, false, "mysql"),
PostRestoreVerify: todoListReady(false, false, "mysql"),
PreBackupVerify: verifyApplicationReady(true, false, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, false, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand All @@ -470,8 +466,8 @@ var _ = ginkgo.Describe("Backup and restore tests", ginkgo.Ordered, func() {
Namespace: "mongo-persistent",
Name: "mongo-blockdevice-e2e",
BackupRestoreType: lib.CSIDataMover,
PreBackupVerify: todoListReady(true, false, "mongo"),
PostRestoreVerify: todoListReady(false, false, "mongo"),
PreBackupVerify: verifyApplicationReady(true, false, "todolist", "todolist-route", "mongo", false, "mongo-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, false, "todolist", "todolist-route", "mongo", false, "mongo-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand All @@ -481,8 +477,8 @@ var _ = ginkgo.Describe("Backup and restore tests", ginkgo.Ordered, func() {
Namespace: "mysql-persistent",
Name: "mysql-native-snapshots-e2e",
BackupRestoreType: lib.NativeSnapshots,
PreBackupVerify: todoListReady(true, false, "mysql"),
PostRestoreVerify: todoListReady(false, false, "mysql"),
PreBackupVerify: verifyApplicationReady(true, false, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, false, "todolist", "todolist-route", "mysql", false, "mysql-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand All @@ -492,8 +488,8 @@ var _ = ginkgo.Describe("Backup and restore tests", ginkgo.Ordered, func() {
Namespace: "mongo-persistent",
Name: "mongo-native-snapshots-e2e",
BackupRestoreType: lib.NativeSnapshots,
PreBackupVerify: todoListReady(true, false, "mongo"),
PostRestoreVerify: todoListReady(false, false, "mongo"),
PreBackupVerify: verifyApplicationReady(true, false, "todolist", "todolist-route", "mongo", false, "mongo-persistent-scc"),
PostRestoreVerify: verifyApplicationReady(false, false, "todolist", "todolist-route", "mongo", false, "mongo-persistent-scc"),
BackupTimeout: 20 * time.Minute,
},
}, nil),
Expand Down
10 changes: 9 additions & 1 deletion tests/e2e/lib/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,16 @@ func AreVolumeSnapshotsReady(ocClient client.Client, backupName string) wait.Con

func IsDCReady(ocClient client.Client, namespace, dcName string) wait.ConditionFunc {
return func() (bool, error) {
// Only execute checks if a DeploymentConfig object is detected in the namespace
hasDC, err := HasDCsInNamespace(ocClient, namespace)
if err != nil {
return false, err
}
if !hasDC {
return true, nil
}
dc := ocpappsv1.DeploymentConfig{}
err := ocClient.Get(context.Background(), client.ObjectKey{
err = ocClient.Get(context.Background(), client.ObjectKey{
Namespace: namespace,
Name: dcName,
}, &dc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ items:
startupProbe:
exec:
command:
- bash
- -c
- |
mongosh admin --authenticationDatabase admin -u "$MONGO_INITDB_ROOT_USERNAME" -p "$MONGO_INITDB_ROOT_PASSWORD" --eval 'db.adminCommand("ping")'
- mongosh
- admin
- -u $(MONGO_INITDB_ROOT_USERNAME)
- -p $(MONGO_INITDB_ROOT_PASSWORD)
- --eval 'printjson(db.getCollectionNames())'
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
Expand Down Expand Up @@ -189,8 +190,8 @@ items:
port: 27017
selector:
app: mongo
- apiVersion: apps/v1
kind: Deployment
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
name: todolist
namespace: mongo-persistent
Expand All @@ -201,9 +202,8 @@ items:
spec:
replicas: 1
selector:
matchLabels:
app: todolist
service: todolist
app: todolist
service: todolist
strategy:
type: Recreate
template:
Expand All @@ -215,25 +215,13 @@ items:
spec:
containers:
- name: todolist
image: quay.io/migtools/oadp-ci-todolist-mongo-go-4
image: quay.io/migtools/oadp-ci-todolist-mongo-go-1
env:
- name: foo
value: bar
ports:
- containerPort: 8000
protocol: TCP
livenessProbe:
httpGet:
path: /
port: 8000
initialDelaySeconds: 10
periodSeconds: 10
readinessProbe:
httpGet:
path: /
port: 8000
initialDelaySeconds: 5
periodSeconds: 5
initContainers:
- name: init-myservice
image: docker.io/curlimages/curl:8.5.0
Expand Down
Loading