From 07dbeed6a45703917321fd886a71ac4021097c84 Mon Sep 17 00:00:00 2001 From: Wen Zhou Date: Fri, 30 Aug 2024 16:15:48 +0200 Subject: [PATCH] test: update e2e testcases (#1208) * test: update e2e testcases - rename files - add check on FTer CRD - use label from labels.ODHAppPrefix - update misleading log message - re-order test cases - rename DSC CR from e2e-test to e2e-test-dsc Signed-off-by: Wen Zhou * fix: missing "/" Signed-off-by: Wen Zhou --------- Signed-off-by: Wen Zhou (cherry picked from commit a611427b6dfba2a2652de18af7b2a8a74db78173) --- tests/e2e/creation_test.go | 27 +++++++++++++-------------- tests/e2e/deletion_test.go | 5 +++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/e2e/creation_test.go b/tests/e2e/creation_test.go index 05bb3651737..711f5cde8c3 100644 --- a/tests/e2e/creation_test.go +++ b/tests/e2e/creation_test.go @@ -47,12 +47,16 @@ func creationTestSuite(t *testing.T) { t.Run("Creation of more than one of DSCInitialization instance", func(t *testing.T) { testCtx.testDSCIDuplication(t) }) - t.Run("Validate DSCInitialization instance", func(t *testing.T) { err = testCtx.validateDSCI() require.NoError(t, err, "error validating DSCInitialization instance") - }) + t.Run("Check owned namespaces exist", func(t *testing.T) { + err = testCtx.testOwnedNamespacesAllExist() + require.NoError(t, err, "error owned namespace is missing") + }) + + // DSC t.Run("Creation of DataScienceCluster instance", func(t *testing.T) { err = testCtx.testDSCCreation() require.NoError(t, err, "error creating DataScienceCluster instance") @@ -61,11 +65,6 @@ func creationTestSuite(t *testing.T) { testCtx.testDSCDuplication(t) }) - t.Run("Validate DSCInitialization instance", func(t *testing.T) { - err = testCtx.validateDSCI() - require.NoError(t, err, "error validating DSCInitialization instance") - }) - t.Run("Validate Ownerrefrences exist", func(t *testing.T) { err = testCtx.testOwnerrefrences() require.NoError(t, err, "error getting all DataScienceCluster's Ownerrefrences") @@ -75,10 +74,6 @@ func creationTestSuite(t *testing.T) { err = testCtx.testAllComponentCreation(t) require.NoError(t, err, "error testing deployments for DataScienceCluster: "+testCtx.testDsc.Name) }) - t.Run("Validate DSC Ready", func(t *testing.T) { - err = testCtx.validateDSCReady() - require.NoError(t, err, "DataScienceCluster instance is not Ready") - }) // Kserve t.Run("Validate Knative resoruce", func(t *testing.T) { @@ -191,6 +186,7 @@ func (tc *testContext) validateDSCReady() error { return waitDSCReady(tc) } +// Verify DSC instance is in Ready phase when all components are up and running func waitDSCReady(tc *testContext) error { // wait for 2 mins which is on the safe side, normally it should get ready once all components are ready err := tc.wait(func(ctx context.Context) (bool, error) { @@ -303,6 +299,7 @@ func (tc *testContext) testComponentCreation(component components.ComponentInter } appList, err := tc.kubeClient.AppsV1().Deployments(tc.applicationsNamespace).List(ctx, metav1.ListOptions{ + LabelSelector: labels.ODH.Component(componentName), }) if err != nil { @@ -388,7 +385,7 @@ func (tc *testContext) testOwnerrefrences() error { // Test Dashboard component if tc.testDsc.Spec.Components.Dashboard.ManagementState == operatorv1.Managed { appDeployments, err := tc.kubeClient.AppsV1().Deployments(tc.applicationsNamespace).List(tc.ctx, metav1.ListOptions{ - LabelSelector: labels.ODH.Component("rhods-dashboard"), + LabelSelector: labels.ODH.Component(tc.testDsc.Spec.Components.Dashboard.GetComponentName()), }) if err != nil { return fmt.Errorf("error listing component deployments %w", err) @@ -444,7 +441,8 @@ func (tc *testContext) testDefaultCertsAvailable() error { func (tc *testContext) testUpdateComponentReconcile() error { // Test Updating Dashboard Replicas appDeployments, err := tc.kubeClient.AppsV1().Deployments(tc.applicationsNamespace).List(tc.ctx, metav1.ListOptions{ - LabelSelector: labels.ODH.Component("rhods-dashboard"), + + LabelSelector: labels.ODH.Component(tc.testDsc.Spec.Components.Dashboard.GetComponentName()), }) if err != nil { return err @@ -495,7 +493,8 @@ func (tc *testContext) testUpdateDSCComponentEnabled() error { if tc.testDsc.Spec.Components.Dashboard.ManagementState == operatorv1.Managed { appDeployments, err := tc.kubeClient.AppsV1().Deployments(tc.applicationsNamespace).List(tc.ctx, metav1.ListOptions{ - LabelSelector: labels.ODH.Component("rhods-dashboard"), + + LabelSelector: labels.ODH.Component(tc.testDsc.Spec.Components.Dashboard.GetComponentName()), }) if err != nil { return fmt.Errorf("error getting enabled component %v", "rhods-dashboard") diff --git a/tests/e2e/deletion_test.go b/tests/e2e/deletion_test.go index 69b2163ca87..9d1c4fc4078 100644 --- a/tests/e2e/deletion_test.go +++ b/tests/e2e/deletion_test.go @@ -30,11 +30,11 @@ func deletionTestSuite(t *testing.T) { }) t.Run(testCtx.testDsc.Name, func(t *testing.T) { - t.Run("Deletion DSC instance", func(t *testing.T) { + t.Run("Deletion: DSC instance", func(t *testing.T) { err = testCtx.testDeletionExistDSC() require.NoError(t, err, "Error to delete DSC instance") }) - t.Run("Check all component resource are deleted", func(t *testing.T) { + t.Run("Check: all component resource are deleted", func(t *testing.T) { err = testCtx.testAllApplicationDeletion(t) require.NoError(t, err, "Should not found component exist") }) @@ -78,6 +78,7 @@ func (tc *testContext) testComponentDeletion(component components.ComponentInter }) if err != nil { log.Printf("error getting component deployments :%v. Trying again...", err) + return false, err }