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

[bp-2.3] Comment out tests that may cause ocp api server to degrade #689

Open
wants to merge 1 commit into
base: backplane-2.3
Choose a base branch
from
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
128 changes: 63 additions & 65 deletions test/e2e/managedcluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ package e2e
import (
"context"
"fmt"
"net/url"
"reflect"
"strconv"

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
configv1 "github.com/openshift/api/config/v1"
"github.com/stolostron/multicloud-operators-foundation/pkg/utils"
"github.com/stolostron/multicloud-operators-foundation/test/e2e/util"
e2eutil "github.com/stolostron/multicloud-operators-foundation/test/e2e/util"
Expand Down Expand Up @@ -55,69 +53,69 @@ var _ = ginkgo.Describe("Testing ManagedCluster", func() {
})

ginkgo.Context("Testing Clusterca sync", func() {
ginkgo.It("Get CA from apiserver", func() {
//Only need to test this case in ocp
if !isOcp {
return
}
//Create a fake secret for apiserver
fakesecretName := "fake-server-secret"
fakeSecret, err := e2eutil.CreateFakeTlsSecret(kubeClient, fakesecretName, utils.OpenshiftConfigNamespace)
gomega.Expect(err).ToNot(gomega.HaveOccurred())

//get apiserveraddress
apiserverAddress, err := utils.GetKubeAPIServerAddress(context.TODO(), ocpClient)
gomega.Expect(err).ToNot(gomega.HaveOccurred())

//add serving secret in apiserver
url, err := url.Parse(apiserverAddress)
gomega.Expect(err).ToNot(gomega.HaveOccurred())

apiserver, err := ocpClient.ConfigV1().APIServers().Get(context.TODO(), utils.ApiserverConfigName, metav1.GetOptions{})
gomega.Expect(err).ToNot(gomega.HaveOccurred())

newApiserver := apiserver.DeepCopy()
newApiserver.Spec.ServingCerts.NamedCertificates = []configv1.APIServerNamedServingCert{
{
Names: []string{
url.Hostname(),
},
ServingCertificate: configv1.SecretNameReference{
Name: fakesecretName,
},
},
}

newApiserver, err = ocpClient.ConfigV1().APIServers().Update(context.TODO(), newApiserver, metav1.UpdateOptions{})
gomega.Expect(err).ToNot(gomega.HaveOccurred())

gomega.Eventually(func() error {
cluster, err := clusterClient.ClusterV1().ManagedClusters().Get(context.Background(), defaultManagedCluster, metav1.GetOptions{})
if err != nil {
return err
}

if len(cluster.Spec.ManagedClusterClientConfigs) == 0 {
return fmt.Errorf("cluster.Spec.ManagedClusterClientConfigs should not be 0")
}
for _, config := range cluster.Spec.ManagedClusterClientConfigs {
if config.URL != apiserverAddress {
continue
}
if reflect.DeepEqual(config.CABundle, fakeSecret.Data["tls.crt"]) {
return nil
}
}
return fmt.Errorf("cannot found config")
}, eventuallyTimeout, eventuallyInterval).ShouldNot(gomega.HaveOccurred())

//rollback apiserver and delete secret
newApiserver.Spec.ServingCerts.NamedCertificates = []configv1.APIServerNamedServingCert{}
_, err = ocpClient.ConfigV1().APIServers().Update(context.TODO(), newApiserver, metav1.UpdateOptions{})
gomega.Expect(err).ToNot(gomega.HaveOccurred())
err = kubeClient.CoreV1().Secrets(utils.OpenshiftConfigNamespace).Delete(context.TODO(), fakesecretName, metav1.DeleteOptions{})
gomega.Expect(err).ToNot(gomega.HaveOccurred())
})
// ginkgo.It("Get CA from apiserver", func() {
// //Only need to test this case in ocp
// if !isOcp {
// return
// }
// //Create a fake secret for apiserver
// fakesecretName := "fake-server-secret"
// fakeSecret, err := e2eutil.CreateFakeTlsSecret(kubeClient, fakesecretName, utils.OpenshiftConfigNamespace)
// gomega.Expect(err).ToNot(gomega.HaveOccurred())

// //get apiserveraddress
// apiserverAddress, err := utils.GetKubeAPIServerAddress(context.TODO(), ocpClient)
// gomega.Expect(err).ToNot(gomega.HaveOccurred())

// //add serving secret in apiserver
// url, err := url.Parse(apiserverAddress)
// gomega.Expect(err).ToNot(gomega.HaveOccurred())

// apiserver, err := ocpClient.ConfigV1().APIServers().Get(context.TODO(), utils.ApiserverConfigName, metav1.GetOptions{})
// gomega.Expect(err).ToNot(gomega.HaveOccurred())

// newApiserver := apiserver.DeepCopy()
// newApiserver.Spec.ServingCerts.NamedCertificates = []configv1.APIServerNamedServingCert{
// {
// Names: []string{
// url.Hostname(),
// },
// ServingCertificate: configv1.SecretNameReference{
// Name: fakesecretName,
// },
// },
// }

// newApiserver, err = ocpClient.ConfigV1().APIServers().Update(context.TODO(), newApiserver, metav1.UpdateOptions{})
// gomega.Expect(err).ToNot(gomega.HaveOccurred())

// gomega.Eventually(func() error {
// cluster, err := clusterClient.ClusterV1().ManagedClusters().Get(context.Background(), defaultManagedCluster, metav1.GetOptions{})
// if err != nil {
// return err
// }

// if len(cluster.Spec.ManagedClusterClientConfigs) == 0 {
// return fmt.Errorf("cluster.Spec.ManagedClusterClientConfigs should not be 0")
// }
// for _, config := range cluster.Spec.ManagedClusterClientConfigs {
// if config.URL != apiserverAddress {
// continue
// }
// if reflect.DeepEqual(config.CABundle, fakeSecret.Data["tls.crt"]) {
// return nil
// }
// }
// return fmt.Errorf("cannot found config")
// }, eventuallyTimeout, eventuallyInterval).ShouldNot(gomega.HaveOccurred())

// //rollback apiserver and delete secret
// newApiserver.Spec.ServingCerts.NamedCertificates = []configv1.APIServerNamedServingCert{}
// _, err = ocpClient.ConfigV1().APIServers().Update(context.TODO(), newApiserver, metav1.UpdateOptions{})
// gomega.Expect(err).ToNot(gomega.HaveOccurred())
// err = kubeClient.CoreV1().Secrets(utils.OpenshiftConfigNamespace).Delete(context.TODO(), fakesecretName, metav1.DeleteOptions{})
// gomega.Expect(err).ToNot(gomega.HaveOccurred())
// })

ginkgo.It("Get CA from configmap", func() {
//Only need to test this case in ocp
Expand Down
118 changes: 59 additions & 59 deletions test/e2e/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,65 +427,65 @@ var _ = ginkgo.Describe("Cluster admin user should fail when updating clusterpoo
})
})

var _ = ginkgo.Describe("Testing webhook cert rotation", func() {
var userName = rand.String(6)
var clusterName = "e2e-" + userName
var rbacName = "e2e-" + userName
var userClusterClient clusterclient.Interface
ginkgo.BeforeEach(func() {
var err error
// create rbac with managedClusterSet/join <all> permission for user
rules := []rbacv1.PolicyRule{
helpers.NewRule("create").Groups(clusterv1beta2.GroupName).Resources("managedclustersets/join").RuleOrDie(),
helpers.NewRule("create", "update", "get").Groups(clusterv1.GroupName).Resources("managedclusters").RuleOrDie(),
}
err = util.CreateClusterRole(kubeClient, rbacName, rules)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())

err = util.CreateClusterRoleBindingForUser(kubeClient, rbacName, rbacName, userName)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())

// impersonate user to the cluster client
userClusterClient, err = util.NewClusterClientWithImpersonate(userName, nil)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())

})
ginkgo.AfterEach(func() {
var err error
err = util.CleanManagedCluster(clusterClient, clusterName)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())

err = util.DeleteClusterRoleBinding(kubeClient, rbacName)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())

err = util.DeleteClusterRole(kubeClient, rbacName)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
})

ginkgo.It("should create and update the managedCluster after cert rotation successfully", func() {
// delete secret/signing-key in openshift-service-ca ns to rotate the cert
err := kubeClient.CoreV1().Secrets("openshift-service-ca").Delete(context.TODO(), "signing-key", metav1.DeleteOptions{})
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())

gomega.Eventually(func() error {
_, err := kubeClient.CoreV1().Secrets("openshift-service-ca").Get(context.TODO(), "signing-key", metav1.GetOptions{})
return err
}, eventuallyTimeout, eventuallyInterval).ShouldNot(gomega.HaveOccurred())

err = kubeClient.CoreV1().Secrets(foundationNS).Delete(context.TODO(), "ocm-webhook", metav1.DeleteOptions{})
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())

gomega.Eventually(func() error {
_, err := kubeClient.CoreV1().Secrets(foundationNS).Get(context.TODO(), "ocm-webhook", metav1.GetOptions{})
return err
}, eventuallyTimeout, eventuallyInterval*5).ShouldNot(gomega.HaveOccurred())

cluster := util.NewManagedCluster(clusterName)
gomega.Eventually(func() error {
return util.CreateManagedCluster(userClusterClient, cluster)
}, eventuallyTimeout, eventuallyInterval*5).ShouldNot(gomega.HaveOccurred())
})
})
// var _ = ginkgo.Describe("Testing webhook cert rotation", func() {
// var userName = rand.String(6)
// var clusterName = "e2e-" + userName
// var rbacName = "e2e-" + userName
// var userClusterClient clusterclient.Interface
// ginkgo.BeforeEach(func() {
// var err error
// // create rbac with managedClusterSet/join <all> permission for user
// rules := []rbacv1.PolicyRule{
// helpers.NewRule("create").Groups(clusterv1beta2.GroupName).Resources("managedclustersets/join").RuleOrDie(),
// helpers.NewRule("create", "update", "get").Groups(clusterv1.GroupName).Resources("managedclusters").RuleOrDie(),
// }
// err = util.CreateClusterRole(kubeClient, rbacName, rules)
// gomega.Expect(err).ShouldNot(gomega.HaveOccurred())

// err = util.CreateClusterRoleBindingForUser(kubeClient, rbacName, rbacName, userName)
// gomega.Expect(err).ShouldNot(gomega.HaveOccurred())

// // impersonate user to the cluster client
// userClusterClient, err = util.NewClusterClientWithImpersonate(userName, nil)
// gomega.Expect(err).ShouldNot(gomega.HaveOccurred())

// })
// ginkgo.AfterEach(func() {
// var err error
// err = util.CleanManagedCluster(clusterClient, clusterName)
// gomega.Expect(err).ShouldNot(gomega.HaveOccurred())

// err = util.DeleteClusterRoleBinding(kubeClient, rbacName)
// gomega.Expect(err).ShouldNot(gomega.HaveOccurred())

// err = util.DeleteClusterRole(kubeClient, rbacName)
// gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
// })

// ginkgo.It("should create and update the managedCluster after cert rotation successfully", func() {
// // delete secret/signing-key in openshift-service-ca ns to rotate the cert
// err := kubeClient.CoreV1().Secrets("openshift-service-ca").Delete(context.TODO(), "signing-key", metav1.DeleteOptions{})
// gomega.Expect(err).ShouldNot(gomega.HaveOccurred())

// gomega.Eventually(func() error {
// _, err := kubeClient.CoreV1().Secrets("openshift-service-ca").Get(context.TODO(), "signing-key", metav1.GetOptions{})
// return err
// }, eventuallyTimeout, eventuallyInterval).ShouldNot(gomega.HaveOccurred())

// err = kubeClient.CoreV1().Secrets(foundationNS).Delete(context.TODO(), "ocm-webhook", metav1.DeleteOptions{})
// gomega.Expect(err).ShouldNot(gomega.HaveOccurred())

// gomega.Eventually(func() error {
// _, err := kubeClient.CoreV1().Secrets(foundationNS).Get(context.TODO(), "ocm-webhook", metav1.GetOptions{})
// return err
// }, eventuallyTimeout, eventuallyInterval*5).ShouldNot(gomega.HaveOccurred())

// cluster := util.NewManagedCluster(clusterName)
// gomega.Eventually(func() error {
// return util.CreateManagedCluster(userClusterClient, cluster)
// }, eventuallyTimeout, eventuallyInterval*5).ShouldNot(gomega.HaveOccurred())
// })
// })

var _ = ginkgo.Describe("Testing clusterset create and update", func() {
ginkgo.It("should get global Clusterset successfully", func() {
Expand Down