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

test: Workload e2e #235

Merged
merged 21 commits into from
Aug 19, 2022
Merged

test: Workload e2e #235

merged 21 commits into from
Aug 19, 2022

Conversation

Arvindthiru
Copy link
Contributor

Description of your changes

Fixes #

I have:

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

Special notes for your reviewer

@Arvindthiru Arvindthiru changed the title Workload e2e test: Workload e2e Aug 16, 2022
test/e2e/work_load_test.go Outdated Show resolved Hide resolved
test/e2e/work_load_test.go Outdated Show resolved Hide resolved
@Arvindthiru Arvindthiru marked this pull request as ready for review August 16, 2022 20:43
test/e2e/work_load_test.go Outdated Show resolved Hide resolved
test/e2e/work_load_test.go Outdated Show resolved Hide resolved
var crp *v1alpha1.ClusterResourcePlacement

BeforeEach(func() {
memberNS = NewNamespace(fmt.Sprintf(utils.NamespaceNameFormat, MemberCluster.ClusterName))
Copy link
Contributor Author

@Arvindthiru Arvindthiru Aug 18, 2022

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.

Comment on lines 91 to 115
// 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())
})
}

Copy link
Contributor

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?

Copy link
Contributor Author

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

"fmt"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"golang.org/x/net/context"
"go.goms.io/fleet/pkg/utils"
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

return apierrors.IsNotFound(err)
}, framework.PollTimeout, framework.PollInterval).Should(Equal(true))
})
AfterEach(func() {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it below BeforeEach

Comment on lines 34 to 35
framework.CreateNamespace(*MemberCluster, memberNS)
framework.WaitNamespace(*MemberCluster, memberNS)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider group them together?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 41 to 42
framework.CreateMemberCluster(*HubCluster, mc)
framework.WaitMemberCluster(*HubCluster, mc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 44 to 49
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)
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIxed

Comment on lines 53 to 57
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)
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

cr = &rbacv1.ClusterRole{
ObjectMeta: v1.ObjectMeta{
Name: "test-cluster-role",
Labels: map[string]string{"fleet.azure.com/name": "test"},
Copy link
Contributor

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

Copy link
Contributor Author

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

Comment on lines 69 to 79
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))
Copy link
Contributor

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?

Copy link
Contributor Author

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


By("check if internal member cluster created in the hub cluster")
imc = NewInternalMemberCluster(MemberCluster.ClusterName, memberNS.Name)
imc = &v1alpha1.InternalMemberCluster{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why make this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted back

@ryanzhang-oss ryanzhang-oss merged commit 2933825 into Azure:main Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants