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

feat: Ginkgo tests for Leave workflow Hub agent #108

Merged
merged 1 commit into from
Jul 5, 2022

Conversation

Arvindthiru
Copy link
Contributor

@Arvindthiru Arvindthiru commented Jun 17, 2022

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 Gingko tests for Leave workflow Hub agent feat: Gingko tests for Leave workflow Hub agent Jun 20, 2022
@codecov
Copy link

codecov bot commented Jun 22, 2022

Codecov upload limit reached ⚠️

This org is currently on the free Basic Plan; which includes 250 free private repo uploads each rolling month. This limit has been reached and additional reports cannot be generated. For unlimited uploads, upgrade to our pro plan.

Do you have questions or need help? Connect with our sales team today at [email protected]

@Arvindthiru Arvindthiru force-pushed the LeaveIT branch 2 times, most recently from 219b9d4 to def99ee Compare June 29, 2022 19:46
@Arvindthiru Arvindthiru marked this pull request as ready for review June 29, 2022 19:46
@Arvindthiru Arvindthiru changed the title feat: Gingko tests for Leave workflow Hub agent feat: Ginkgo tests for Leave workflow Hub agent Jun 29, 2022
Comment on lines 137 to 170
result, err := r.Reconcile(ctx, ctrl.Request{
NamespacedName: memberClusterNamespacedName,
})
Expect(result).Should(Equal(ctrl.Result{}))
Expect(err).Should(Not(HaveOccurred()))

By("simulate member agent updating internal member cluster status")
var imc fleetv1alpha1.InternalMemberCluster
Expect(k8sClient.Get(ctx, types.NamespacedName{Name: memberClusterName, Namespace: namespaceName}, &imc)).Should(Succeed())

imc.Status.Capacity = utils.NewResourceList()
imc.Status.Allocatable = utils.NewResourceList()
joinedCondition := metav1.Condition{
Type: fleetv1alpha1.ConditionTypeInternalMemberClusterJoin,
Status: metav1.ConditionTrue,
Reason: reasonMemberClusterJoined,
ObservedGeneration: imc.GetGeneration(),
}
heartBeatReceivedCondition := metav1.Condition{
Type: fleetv1alpha1.ConditionTypeInternalMemberClusterHeartbeat,
Status: metav1.ConditionTrue,
Reason: "InternalMemberClusterHeartbeatReceived",
ObservedGeneration: imc.GetGeneration(),
}
imc.SetConditions(joinedCondition, heartBeatReceivedCondition)
Expect(k8sClient.Status().Update(ctx, &imc)).Should(Succeed())

By("trigger reconcile again to update member cluster status")
result, err = r.Reconcile(ctx, ctrl.Request{
NamespacedName: memberClusterNamespacedName,
})
Expect(result).Should(Equal(ctrl.Result{}))
Expect(err).Should(Not(HaveOccurred()))

Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC, this is the join flow, right? Is there any way to move this to a beforeEach block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Move to beforeEach

Expect(result).Should(Equal(ctrl.Result{}))
Expect(err).Should(Not(HaveOccurred()))

Expect(k8sClient.Get(ctx, memberClusterNamespacedName, &mc)).Should(Succeed())
Copy link
Contributor

Choose a reason for hiding this comment

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

what about the namespace/role/imc?

Copy link
Contributor Author

@Arvindthiru Arvindthiru Jun 30, 2022

Choose a reason for hiding this comment

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

Since we delete the namespace to remove them and gingko's test env doesn't delete it they will all remain kubernetes-sigs/controller-runtime#880 I saw no point in checking if they don't get deleted

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. So it's not possible to test this in the integration test, right? Can we make sure it's tested in the E2E?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The role and imc being deleted is not being checked in the e2e test will add a PR to check that

Expect(result).Should(Equal(ctrl.Result{}))
Expect(err).Should(Not(HaveOccurred()))

Expect(k8sClient.Get(ctx, memberClusterNamespacedName, &mc)).Should(Succeed())
Copy link
Contributor

Choose a reason for hiding this comment

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

I see. So it's not possible to test this in the integration test, right? Can we make sure it's tested in the E2E?

@Arvindthiru Arvindthiru merged commit 0abcf49 into Azure:main Jul 5, 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.

2 participants