-
Notifications
You must be signed in to change notification settings - Fork 25
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
test: Workload e2e #235
test: Workload e2e #235
Conversation
60daed6
to
54cad6e
Compare
test/e2e/work_load_test.go
Outdated
var crp *v1alpha1.ClusterResourcePlacement | ||
|
||
BeforeEach(func() { | ||
memberNS = NewNamespace(fmt.Sprintf(utils.NamespaceNameFormat, MemberCluster.ClusterName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be setup here because once we create namespace resource version gets added, this resets it once we delete between tests.
// CreateClusterRole create cluster role in the hub cluster. | ||
func CreateClusterRole(cluster Cluster, cr *rbacv1.ClusterRole) { | ||
ginkgo.By(fmt.Sprintf("Creating ClusterRole (%s)", cr.Name), func() { | ||
err := cluster.KubeClient.Create(context.TODO(), cr) | ||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) | ||
}) | ||
} | ||
|
||
// WaitClusterRole waits for cluster roles to be created. | ||
func WaitClusterRole(cluster Cluster, cr *rbacv1.ClusterRole) { | ||
klog.Infof("Waiting for ClusterRole(%s) to be synced", cr.Name) | ||
gomega.Eventually(func() error { | ||
err := cluster.KubeClient.Get(context.TODO(), types.NamespacedName{Name: cr.Name, Namespace: ""}, cr) | ||
return err | ||
}, PollTimeout, PollInterval).ShouldNot(gomega.HaveOccurred()) | ||
} | ||
|
||
// DeleteClusterRole deletes cluster role on cluster. | ||
func DeleteClusterRole(cluster Cluster, cr *rbacv1.ClusterRole) { | ||
ginkgo.By(fmt.Sprintf("Deleting ClusterRole(%s)", cr.Name), func() { | ||
err := cluster.KubeClient.Delete(context.TODO(), cr) | ||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) | ||
}) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is clusterRole part of the common file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to test/e2e/utils/helper.go
test/e2e/join_leave_member_test.go
Outdated
"fmt" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"golang.org/x/net/context" | ||
"go.goms.io/fleet/pkg/utils" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be with the local group
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
test/e2e/join_leave_member_test.go
Outdated
return apierrors.IsNotFound(err) | ||
}, framework.PollTimeout, framework.PollInterval).Should(Equal(true)) | ||
}) | ||
AfterEach(func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normally, by convention, the AfterEach is put in the front. It's like defer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved it below BeforeEach
test/e2e/join_leave_member_test.go
Outdated
framework.CreateNamespace(*MemberCluster, memberNS) | ||
framework.WaitNamespace(*MemberCluster, memberNS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider group them together?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
test/e2e/join_leave_member_test.go
Outdated
framework.CreateMemberCluster(*HubCluster, mc) | ||
framework.WaitMemberCluster(*HubCluster, mc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
test/e2e/join_leave_member_test.go
Outdated
By("check if member cluster is marked as readyToJoin") | ||
framework.WaitConditionMemberCluster(*HubCluster, mc, v1alpha1.ConditionTypeMemberClusterReadyToJoin, v1.ConditionTrue, 3*framework.PollTimeout) | ||
|
||
By("check if internal member cluster created in the hub cluster") | ||
imc = NewInternalMemberCluster(MemberCluster.ClusterName, memberNS.Name) | ||
framework.WaitInternalMemberCluster(*HubCluster, imc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't the order be reversed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIxed
test/e2e/join_leave_member_test.go
Outdated
By("check if internal member cluster condition is updated to Joined") | ||
framework.WaitConditionInternalMemberCluster(*HubCluster, imc, v1alpha1.AgentJoined, v1.ConditionTrue, 3*framework.PollTimeout) | ||
|
||
By("check if member cluster condition is updated to Joined") | ||
framework.WaitConditionMemberCluster(*HubCluster, mc, v1alpha1.ConditionTypeMemberClusterJoin, v1.ConditionTrue, 3*framework.PollTimeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at this point, this IT has only 2 things, why not either fold it into beforeEach or merge with the leave test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
test/e2e/work_load_test.go
Outdated
cr = &rbacv1.ClusterRole{ | ||
ObjectMeta: v1.ObjectMeta{ | ||
Name: "test-cluster-role", | ||
Labels: map[string]string{"fleet.azure.com/name": "test"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this label should be extract as a var as it's used by the CRP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added labelKey and labelValue vars
test/e2e/join_leave_member_test.go
Outdated
AfterEach(func() { | ||
framework.DeleteNamespace(*MemberCluster, memberNS) | ||
Eventually(func() bool { | ||
err := MemberCluster.KubeClient.Get(context.TODO(), types.NamespacedName{Name: memberNS.Name, Namespace: ""}, memberNS) | ||
return apierrors.IsNotFound(err) | ||
}, framework.PollTimeout, framework.PollInterval).Should(Equal(true)) | ||
framework.DeleteMemberCluster(*HubCluster, mc) | ||
Eventually(func() bool { | ||
err := HubCluster.KubeClient.Get(context.TODO(), types.NamespacedName{Name: memberNS.Name, Namespace: ""}, memberNS) | ||
return apierrors.IsNotFound(err) | ||
}, framework.PollTimeout, framework.PollInterval).Should(Equal(true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you move afterEach block to the top?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved it to the top
test/e2e/work_load_test.go
Outdated
|
||
By("check if internal member cluster created in the hub cluster") | ||
imc = NewInternalMemberCluster(MemberCluster.ClusterName, memberNS.Name) | ||
imc = &v1alpha1.InternalMemberCluster{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why make this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted back
Description of your changes
Fixes #
I have:
make reviewable
to ensure this PR is ready for review.How has this code been tested
Special notes for your reviewer