Skip to content

Commit

Permalink
Add e2e test and add component name into message
Browse files Browse the repository at this point in the history
- revert to use old DW manifests till it is ready
- update e2e test log

Signed-off-by: Wen Zhou <[email protected]>
  • Loading branch information
zdtsw committed Oct 8, 2023
1 parent 5354240 commit d61a87e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (r *DataScienceClusterReconciler) reconcileSubComponent(ctx context.Context
if managed {
message = "Component is enabled"
} else if unmanaged {
message = "Component is unmanaged"
message = "Component " + componentName + " is unmanaged"
}
status.SetComponentCondition(&saved.Status.Conditions, componentName, status.ReconcileInit, message, corev1.ConditionUnknown)
})
Expand Down
6 changes: 4 additions & 2 deletions get_all_manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ MANIFESTS_TARBALL_URL="${GITHUB_URL}/${MANIFEST_ORG}/odh-manifests/tarball/${MAN
# component: dsp, kserve, dashbaord, cf/ray. in the format of "repo-org:repo-name:branch-name:source-folder:target-folder"
# TODO: workbench, modelmesh, monitoring, etc
declare -A COMPONENT_MANIFESTS=(
["codeflare"]="opendatahub-io:codeflare-operator:main:config:codeflare"
["ray"]="opendatahub-io:kuberay:master:ray-operator/config:ray"
# ["codeflare"]="opendatahub-io:codeflare-operator:main:config:codeflare"
["codeflare"]="opendatahub-io:distributed-workloads:main:codeflare-stack:codeflare"
#["ray"]="opendatahub-io:kuberay:master:ray-operator/config:ray"
["ray"]="opendatahub-io:distributed-workloads:main:ray:ray"
["data-science-pipelines-operator"]="opendatahub-io:data-science-pipelines-operator:main:config:data-science-pipelines-operator"
["odh-dashboard"]="opendatahub-io:odh-dashboard:incubation:manifests:odh-dashboard"
["kf-notebook-controller"]="opendatahub-io:kubeflow:v1.7-branch:components/notebook-controller/config:odh-notebook-controller/kf-notebook-controller"
Expand Down
54 changes: 32 additions & 22 deletions tests/e2e/dsc_creation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func creationTestSuite(t *testing.T) {
err = testCtx.testUpdateComponentReconcile()
require.NoError(t, err, "error testing updates for DSC managed resource")
})
t.Run("Validate Component Enabled field", func(t *testing.T) {
t.Run("Validate Component managementState field", func(t *testing.T) {
err = testCtx.testUpdateDSCComponentEnabled()
require.NoError(t, err, "error testing component enabled field")
require.NoError(t, err, "error testing component managementState field")
})
})
}
Expand Down Expand Up @@ -113,11 +113,11 @@ func (tc *testContext) testAllApplicationCreation(t *testing.T) error {
err = tc.testApplicationCreation(&(tc.testDsc.Spec.Components.Dashboard))
if tc.testDsc.Spec.Components.Dashboard.ManagementState == operatorv1.Managed {
if err != nil {
require.NoError(t, err, "error validating application %v when enabled", tc.testDsc.Spec.Components.Dashboard.GetComponentName())
require.NoError(t, err, "error validating application %v when Managed", tc.testDsc.Spec.Components.Dashboard.GetComponentName())
}
} else {
if err == nil {
require.NoError(t, err, "error validating application %v when disabled", tc.testDsc.Spec.Components.Dashboard.GetComponentName())
require.NoError(t, err, "error validating application %v when Removed", tc.testDsc.Spec.Components.Dashboard.GetComponentName())
}
}
})
Expand All @@ -128,11 +128,11 @@ func (tc *testContext) testAllApplicationCreation(t *testing.T) error {
err = tc.testApplicationCreation(&(tc.testDsc.Spec.Components.ModelMeshServing))
if tc.testDsc.Spec.Components.ModelMeshServing.ManagementState == operatorv1.Managed {
if err != nil {
require.NoError(t, err, "error validating application %v when enabled", tc.testDsc.Spec.Components.ModelMeshServing.GetComponentName())
require.NoError(t, err, "error validating application %v when Managed", tc.testDsc.Spec.Components.ModelMeshServing.GetComponentName())
}
} else {
if err == nil {
require.NoError(t, err, "error validating application %v when disabled", tc.testDsc.Spec.Components.ModelMeshServing.GetComponentName())
require.NoError(t, err, "error validating application %v when Removed", tc.testDsc.Spec.Components.ModelMeshServing.GetComponentName())
}
}
})
Expand All @@ -147,12 +147,12 @@ func (tc *testContext) testAllApplicationCreation(t *testing.T) error {
if strings.Contains(err.Error(), "Please install the operator before enabling component") {
t.Logf("expected error: %v", err.Error())
} else {
require.NoError(t, err, "error validating application %v when enabled", tc.testDsc.Spec.Components.Kserve.GetComponentName())
require.NoError(t, err, "error validating application %v when Managed", tc.testDsc.Spec.Components.Kserve.GetComponentName())
}
}
} else {
if err == nil {
require.NoError(t, err, "error validating application %v when disabled", tc.testDsc.Spec.Components.Kserve.GetComponentName())
require.NoError(t, err, "error validating application %v when Removed", tc.testDsc.Spec.Components.Kserve.GetComponentName())
}
}
})
Expand All @@ -163,11 +163,11 @@ func (tc *testContext) testAllApplicationCreation(t *testing.T) error {
err = tc.testApplicationCreation(&(tc.testDsc.Spec.Components.Workbenches))
if tc.testDsc.Spec.Components.Workbenches.ManagementState == operatorv1.Managed {
if err != nil {
require.NoError(t, err, "error validating application %v when enabled", tc.testDsc.Spec.Components.Workbenches.GetComponentName())
require.NoError(t, err, "error validating application %v when Managed", tc.testDsc.Spec.Components.Workbenches.GetComponentName())
}
} else {
if err == nil {
require.NoError(t, err, "error validating application %v when disabled", tc.testDsc.Spec.Components.Workbenches.GetComponentName())
require.NoError(t, err, "error validating application %v when Removed", tc.testDsc.Spec.Components.Workbenches.GetComponentName())
}
}
})
Expand All @@ -178,11 +178,11 @@ func (tc *testContext) testAllApplicationCreation(t *testing.T) error {
err = tc.testApplicationCreation(&(tc.testDsc.Spec.Components.DataSciencePipelines))
if tc.testDsc.Spec.Components.DataSciencePipelines.ManagementState == operatorv1.Managed {
if err != nil {
require.NoError(t, err, "error validating application %v when enabled", tc.testDsc.Spec.Components.DataSciencePipelines.GetComponentName())
require.NoError(t, err, "error validating application %v when Managed", tc.testDsc.Spec.Components.DataSciencePipelines.GetComponentName())
}
} else {
if err == nil {
require.NoError(t, err, "error validating application %v when disabled", tc.testDsc.Spec.Components.DataSciencePipelines.GetComponentName())
require.NoError(t, err, "error validating application %v when Removed", tc.testDsc.Spec.Components.DataSciencePipelines.GetComponentName())
}
}
})
Expand All @@ -197,12 +197,16 @@ func (tc *testContext) testAllApplicationCreation(t *testing.T) error {
if strings.Contains(err.Error(), "Please install the operator before enabling component") {
t.Logf("expected error: %v", err.Error())
} else {
require.NoError(t, err, "error validating application %v when enabled", tc.testDsc.Spec.Components.CodeFlare.GetComponentName())
require.NoError(t, err, "error validating application %v when Managed", tc.testDsc.Spec.Components.CodeFlare.GetComponentName())
}
}
} else if tc.testDsc.Spec.Components.CodeFlare.ManagementState == operatorv1.Unmanaged {
if err != nil {
require.NoError(t, err, "error validating application %v when Unmanaged", tc.testDsc.Spec.Components.CodeFlare.GetComponentName())
}
} else {
if err == nil {
require.NoError(t, err, "error validating application %v when disabled", tc.testDsc.Spec.Components.CodeFlare.GetComponentName())
require.NoError(t, err, "error validating application %v when Removed", tc.testDsc.Spec.Components.CodeFlare.GetComponentName())
}
}
})
Expand All @@ -213,11 +217,11 @@ func (tc *testContext) testAllApplicationCreation(t *testing.T) error {
err = tc.testApplicationCreation(&(tc.testDsc.Spec.Components.Ray))
if tc.testDsc.Spec.Components.Ray.ManagementState == operatorv1.Managed {
if err != nil {
require.NoError(t, err, "error validating application %v when enabled", tc.testDsc.Spec.Components.Ray.GetComponentName())
require.NoError(t, err, "error validating application %v when Managed", tc.testDsc.Spec.Components.Ray.GetComponentName())
}
} else {
if err == nil {
require.NoError(t, err, "error validating application %v when disabled", tc.testDsc.Spec.Components.Ray.GetComponentName())
require.NoError(t, err, "error validating application %v when Removed", tc.testDsc.Spec.Components.Ray.GetComponentName())
}
}
})
Expand All @@ -228,11 +232,11 @@ func (tc *testContext) testAllApplicationCreation(t *testing.T) error {
err = tc.testApplicationCreation(&(tc.testDsc.Spec.Components.TrustyAI))
if tc.testDsc.Spec.Components.TrustyAI.ManagementState == operatorv1.Managed {
if err != nil {
require.NoError(t, err, "error validating application %v when enabled", tc.testDsc.Spec.Components.TrustyAI.GetComponentName())
require.NoError(t, err, "error validating application %v when Managed", tc.testDsc.Spec.Components.TrustyAI.GetComponentName())
}
} else {
if err == nil {
require.NoError(t, err, "error validating application %v when disabled", tc.testDsc.Spec.Components.TrustyAI.GetComponentName())
require.NoError(t, err, "error validating application %v when Removed", tc.testDsc.Spec.Components.TrustyAI.GetComponentName())
}
}
})
Expand Down Expand Up @@ -270,6 +274,12 @@ func (tc *testContext) testApplicationCreation(component components.ComponentInt
return true, err
}
}
// check component does not create deployment e.g CF
for _, Condition := range tc.testDsc.Status.Conditions {
if strings.Contains(Condition.Message, "Component "+component.GetComponentName()+" is unmanaged") {
return true, err
}
}
return false, nil
}
})
Expand Down Expand Up @@ -350,16 +360,16 @@ func (tc *testContext) testUpdateDSCComponentEnabled() error {
LabelSelector: "app.kubernetes.io/part-of=" + tc.testDsc.Spec.Components.Dashboard.GetComponentName(),
})
if err != nil {
return fmt.Errorf("error getting enabled component %v", tc.testDsc.Spec.Components.Dashboard.GetComponentName())
return fmt.Errorf("error getting Managed component %v", tc.testDsc.Spec.Components.Dashboard.GetComponentName())
}
if len(appDeployments.Items) > 0 {
dashboardDeploymentName = appDeployments.Items[0].Name
if appDeployments.Items[0].Status.ReadyReplicas == 0 {
return fmt.Errorf("error getting enabled component: %s its deployment 'ReadyReplicas'", dashboardDeploymentName)
return fmt.Errorf("error getting Managed component: %s its deployment 'ReadyReplicas'", dashboardDeploymentName)
}
}
} else {
return fmt.Errorf("dashboard spec should be in 'enabled: true' state in order to perform test")
return fmt.Errorf("dashboard spec should be in 'Managed' state in order to perform test")
}

// Disable component Dashboard
Expand All @@ -377,7 +387,7 @@ func (tc *testContext) testUpdateDSCComponentEnabled() error {
// Return err itself here (not wrapped inside another error)
// so that RetryOnConflict can identify it correctly.
if err != nil {
return fmt.Errorf("error updating component from 'enabled: true' to 'enabled: false': %w", err)
return fmt.Errorf("error updating component from 'Managed' to 'Removed: false': %w", err)
}
return nil
})
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ func setupDSCInstance() *dsc.DataScienceCluster {
ManagementState: operatorv1.Managed,
},
},
// this should not return error from operator but it wont have anythng running
// because we do not pre-install CFO and we set it to be unmanaged
CodeFlare: codeflare.CodeFlare{
Component: components.Component{
ManagementState: operatorv1.Removed,
ManagementState: operatorv1.Unmanaged,
},
},
Ray: ray.Ray{
Expand Down

0 comments on commit d61a87e

Please sign in to comment.