Skip to content

Commit

Permalink
make reviewable
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvindthiru committed Nov 1, 2023
1 parent 1ec7881 commit 9301204
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 4 additions & 6 deletions test/e2e/v1alpha1/utils/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
rbacv1 "k8s.io/api/rbac/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/api/errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -51,7 +49,7 @@ var (
func DeleteMemberCluster(ctx context.Context, cluster framework.Cluster, mc *fleetv1alpha1.MemberCluster) {
gomega.Expect(cluster.KubeClient.Delete(ctx, mc)).Should(gomega.Succeed(), "Failed to delete member cluster %s in %s cluster", mc.Name, cluster.ClusterName)
gomega.Eventually(func() bool {
return apierrors.IsNotFound(cluster.KubeClient.Get(ctx, types.NamespacedName{Name: mc.Name}, mc))
return errors.IsNotFound(cluster.KubeClient.Get(ctx, types.NamespacedName{Name: mc.Name}, mc))
}, PollTimeout, PollInterval).Should(gomega.BeTrue(), "Failed to wait for member cluster %s to be deleted in %s cluster", mc.Name, cluster.ClusterName)
}

Expand Down Expand Up @@ -99,7 +97,7 @@ func WaitWork(ctx context.Context, cluster framework.Cluster, workName, workName
func DeleteNamespace(ctx context.Context, cluster framework.Cluster, ns *corev1.Namespace) {
gomega.Expect(cluster.KubeClient.Delete(context.TODO(), ns)).Should(gomega.Succeed(), "Failed to delete namespace %s in %s cluster", ns.Name, cluster.ClusterName)
gomega.Eventually(func() bool {
return apierrors.IsNotFound(cluster.KubeClient.Get(ctx, types.NamespacedName{Name: ns.Name}, ns))
return errors.IsNotFound(cluster.KubeClient.Get(ctx, types.NamespacedName{Name: ns.Name}, ns))
}, PollTimeout, PollInterval).Should(gomega.BeTrue(), "Failed to wait for namespace %s to be deleted in %s cluster", ns.Name, cluster.ClusterName)
}

Expand Down Expand Up @@ -242,7 +240,7 @@ func CreateResourcesForWebHookE2E(ctx context.Context, hubCluster *framework.Clu
func DeleteResourcesForWebHookE2E(ctx context.Context, hubCluster *framework.Cluster) {
gomega.Eventually(func() bool {
var imc fleetv1alpha1.InternalMemberCluster
return apierrors.IsNotFound(hubCluster.KubeClient.Get(ctx, types.NamespacedName{Name: "test-mc", Namespace: "fleet-member-test-mc"}, &imc))
return errors.IsNotFound(hubCluster.KubeClient.Get(ctx, types.NamespacedName{Name: "test-mc", Namespace: "fleet-member-test-mc"}, &imc))
}, PollTimeout, PollInterval).Should(gomega.BeTrue(), "Failed to wait for internal member cluster %s to be deleted in %s cluster", "test-mc", hubCluster.ClusterName)

crb := rbacv1.ClusterRoleBinding{
Expand Down Expand Up @@ -314,7 +312,7 @@ func CleanUpMemberClusterResources(ctx context.Context, hubCluster *framework.Cl
},
}
gomega.Eventually(func() bool {
return k8sErrors.IsNotFound(hubCluster.KubeClient.Get(ctx, types.NamespacedName{Name: imc.Name, Namespace: imc.Namespace}, imc))
return errors.IsNotFound(hubCluster.KubeClient.Get(ctx, types.NamespacedName{Name: imc.Name, Namespace: imc.Namespace}, imc))
}, PollTimeout, PollInterval).Should(gomega.BeTrue())
}

Expand Down
8 changes: 4 additions & 4 deletions test/e2e/v1alpha1/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var (
workGVK = metav1.GroupVersionKind{Group: workv1alpha1.GroupVersion.Group, Version: workv1alpha1.GroupVersion.Version, Kind: "Work"}
iseGVK = metav1.GroupVersionKind{Group: fleetnetworkingv1alpha1.GroupVersion.Group, Version: fleetnetworkingv1alpha1.GroupVersion.Version, Kind: "InternalServiceExport"}

testDeployment = appsv1.Deployment{
deployment = appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
Kind: "Deployment",
APIVersion: "apps/v1",
Expand Down Expand Up @@ -908,7 +908,7 @@ var _ = Describe("Fleet's Work Resource Handler webhook tests", func() {
testMemberClusterNamespace = fmt.Sprintf(utils.NamespaceNameFormat, mcName)
testutils.CreateMemberClusterResource(ctx, HubCluster, mcName, "random-user")
testutils.CheckInternalMemberClusterExists(ctx, HubCluster, mcName, testMemberClusterNamespace)
deploymentBytes, err := json.Marshal(testDeployment)
deploymentBytes, err := json.Marshal(deployment)
Expect(err).Should(Succeed())
w := workv1alpha1.Work{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -946,7 +946,7 @@ var _ = Describe("Fleet's Work Resource Handler webhook tests", func() {
})

It("should deny CREATE operation on work CR for user not in MC identity", func() {
deploymentBytes, err := json.Marshal(testDeployment)
deploymentBytes, err := json.Marshal(deployment)
Expect(err).Should(Succeed())
w := workv1alpha1.Work{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -1019,7 +1019,7 @@ var _ = Describe("Fleet's Work Resource Handler webhook tests", func() {
testutils.CreateMemberClusterResource(ctx, HubCluster, mcName, "test-user")
testutils.CheckInternalMemberClusterExists(ctx, HubCluster, mcName, testMemberClusterNamespace)

deploymentBytes, err := json.Marshal(testDeployment)
deploymentBytes, err := json.Marshal(deployment)
Expect(err).Should(Succeed())
w := workv1alpha1.Work{
ObjectMeta: metav1.ObjectMeta{
Expand Down

0 comments on commit 9301204

Please sign in to comment.