diff --git a/tests/e2e/creation_test.go b/tests/e2e/creation_test.go index 3fbfe5f10d6..84e79ff2d57 100644 --- a/tests/e2e/creation_test.go +++ b/tests/e2e/creation_test.go @@ -3,24 +3,19 @@ package e2e_test import ( "context" - "errors" "fmt" "log" "reflect" - "strings" "testing" - "time" operatorv1 "github.com/openshift/api/operator/v1" "github.com/stretchr/testify/require" - corev1 "k8s.io/api/core/v1" k8serr "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/client-go/util/retry" "sigs.k8s.io/controller-runtime/pkg/client" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" @@ -29,8 +24,6 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/controllers/components/modelregistry" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/feature/serverless" - - . "github.com/onsi/gomega" ) func creationTestSuite(t *testing.T) { @@ -86,15 +79,6 @@ func creationTestSuite(t *testing.T) { require.NoError(t, err, "error validating ModelRegistry config") }) } - // Trusted CA Bundle - t.Run("Validate trusted CA bundle when Managed", func(t *testing.T) { - err = testCtx.testTrustedCABundleWhenManaged(t) - require.NoError(t, err, "error validating trusted CA bundle") - }) - t.Run("Validate trusted CA bundle when Removed", func(t *testing.T) { - err = testCtx.testTrustedCABundleWhenRemoved(t) - require.NoError(t, err, "error validating trusted CA bundle") - }) }) } @@ -135,16 +119,6 @@ func (tc *testContext) testDSCICreation() error { return nil } -func (tc *testContext) WithT(t *testing.T) *WithT { - t.Helper() - - g := NewWithT(t) - g.SetDefaultEventuallyTimeout(generalWaitTimeout) - g.SetDefaultEventuallyPollingInterval(1 * time.Second) - - return g -} - func (tc *testContext) testDSCCreation(t *testing.T) error { t.Helper() // Create DataScienceCluster resource if not already created @@ -379,65 +353,6 @@ func (tc *testContext) validateDSC() error { return nil } -func (tc *testContext) testTrustedCABundleWhenManaged(t *testing.T) error { - t.Helper() - CAConfigMapName := "odh-trusted-ca-bundle" - CADataFieldName := "odh-ca-bundle.crt" - - foundConfigMap := &corev1.ConfigMap{} - err := tc.customClient.Get(tc.ctx, client.ObjectKey{ - Name: CAConfigMapName, - Namespace: tc.testDSCI.Spec.ApplicationsNamespace, - }, foundConfigMap) - - if err != nil { - return fmt.Errorf("Config map not found, %w", err) - } - - checkNewline := strings.HasSuffix(foundConfigMap.Data[CADataFieldName], "\n") - - // When ManagementState is Managed the newline will be present at the end of configmap. - if checkNewline == false { - return errors.New("Newline not found at the end of configmap") - } - - if strings.TrimSpace(foundConfigMap.Data[CADataFieldName]) != tc.testDSCI.Spec.TrustedCABundle.CustomCABundle { - return fmt.Errorf("odh-trusted-ca-bundle in config map does not match with DSCI's TrustedCABundle.CustomCABundle, needs update: %w", err) - } - - return nil -} - -func (tc *testContext) testTrustedCABundleWhenRemoved(t *testing.T) error { - t.Helper() - g := tc.WithT(t) - CAConfigMapName := "odh-trusted-ca-bundle" - err := retry.RetryOnConflict(retry.DefaultRetry, func() error { - // refresh the instance in case it was updated during the reconcile - err := tc.customClient.Get(tc.ctx, types.NamespacedName{Name: tc.testDSCI.Name}, tc.testDSCI) - if err != nil { - return fmt.Errorf("error getting resource %w", err) - } - - // Disable the TrustedCABundle - tc.testDSCI.Spec.TrustedCABundle.ManagementState = operatorv1.Removed - - return tc.customClient.Update(tc.ctx, tc.testDSCI) - }) - - if err != nil { - return fmt.Errorf("error after retry %w", err) - } - - foundConfigMap := &corev1.ConfigMap{} - g.Eventually(tc.customClient.Get).WithArguments(tc.ctx, client.ObjectKey{ - Name: CAConfigMapName, - Namespace: tc.testDSCI.Spec.ApplicationsNamespace, - }, foundConfigMap).Should(Succeed()) - - return nil -} - func (tc *testContext) testDefaultCertsAvailable() error { // Get expected cert secrets defaultIngressCtrl, err := cluster.FindAvailableIngressController(tc.ctx, tc.customClient) diff --git a/tests/e2e/helper_test.go b/tests/e2e/helper_test.go index 2fb523d0b47..358d737dd08 100644 --- a/tests/e2e/helper_test.go +++ b/tests/e2e/helper_test.go @@ -113,11 +113,7 @@ func setupDSCICR(name string) *dsciv1.DSCInitialization { }, TrustedCABundle: &dsciv1.TrustedCABundleSpec{ ManagementState: operatorv1.Managed, - CustomCABundle: `-----BEGIN CERTIFICATE----- - MIIFVjCCAz6gAwIBAgIUQ+NxE9izWRRdt86M/TX9b7wFjUUwDQYJKoZIhvcNAQEL - ... - IrrVQJLuM7IjWcmOvFjai57QGfIvWcaMY1q6n6MLsLOaXLoRuBLpDLvPbmyAhykU - ------END ------`, + CustomCABundle: "", }, ServiceMesh: &infrav1.ServiceMeshSpec{ ControlPlane: infrav1.ControlPlaneSpec{