Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "tests: e2e test for trusted-ca-bundle" #1495

Merged
merged 1 commit into from
Jan 13, 2025
Merged
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
85 changes: 0 additions & 85 deletions tests/e2e/creation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand Down Expand Up @@ -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")
})
})
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions tests/e2e/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Loading