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

Added e2e tests for single member restoration #451

Merged
merged 3 commits into from
Nov 8, 2022

Conversation

aaronfern
Copy link
Contributor

@aaronfern aaronfern commented Oct 20, 2022

How to categorize this PR?

/area testing
/kind enhancement

What this PR does / why we need it:
This PR Adds a few e2e tests for the multi node scenario to test single node restoration.

It adds the following tests:

  1. Deletion of one member pod
  2. Deletion of member dir of one member
  3. Corruption of DB file of one member

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Release note:

Added e2e tests to check single member restoration in multi node setup

@aaronfern aaronfern requested a review from a team as a code owner October 20, 2022 05:38
@gardener-robot gardener-robot added area/testing Testing related kind/enhancement Enhancement, improvement, extension needs/review Needs review size/s Size of pull request is small (see gardener-robot robot/bots/size.py) labels Oct 20, 2022
@gardener-robot-ci-2 gardener-robot-ci-2 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Oct 20, 2022
@gardener-robot gardener-robot added size/m Size of pull request is medium (see gardener-robot robot/bots/size.py) and removed size/s Size of pull request is small (see gardener-robot robot/bots/size.py) labels Oct 20, 2022
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 20, 2022
@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Oct 20, 2022
test/e2e/utils.go Outdated Show resolved Hide resolved
test/e2e/etcd_multi_node_test.go Outdated Show resolved Hide resolved
test/e2e/etcd_multi_node_test.go Outdated Show resolved Hide resolved
@abdasgupta abdasgupta added this to the v0.14.0 milestone Oct 31, 2022
@@ -138,6 +152,56 @@ var _ = Describe("Etcd", func() {
})
})

func deleteMemberDir(ctx context.Context, cl client.Client, logger logr.Logger, etcd *v1alpha1.Etcd, podName string) {
Expect(deleteDir(kubeconfigPath, namespace, podName, "backup-restore", "/var/etcd/data/new.etcd/member")).To(Succeed())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Expect(deleteDir(kubeconfigPath, namespace, podName, "backup-restore", "/var/etcd/data/new.etcd/member")).To(Succeed())
ExpectWithOffset(1, deleteDir(kubeconfigPath, namespace, podName, "backup-restore", "/var/etcd/data/new.etcd/member")).To(Succeed())


func checkUnreadySts(ctx context.Context, cl client.Client, logger logr.Logger, etcd *v1alpha1.Etcd) {
logger.Info("waiting for sts to become unready", "statefulSetName", "etcd-aws")
Eventually(func() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Eventually(func() error {
EventuallyWithOffset(2, func() error {

@@ -105,6 +106,19 @@ var _ = Describe("Etcd", func() {
// K8s job zeroDownTimeValidator will fail, if there is any downtime in Etcd cluster health.
checkEtcdZeroDownTimeValidatorJob(ctx, cl, client.ObjectKeyFromObject(job), objLogger)

By("Single member restoration")
objLogger.Info("Delete one member pod")
deletePodAndCheckSts(ctx, cl, logger, etcd, "etcd-aws-2")
Copy link
Contributor

Choose a reason for hiding this comment

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

Pls pass objLogger instead of logger , because it already contains etcd obj info.

By("Single member restoration")
objLogger.Info("Delete one member pod")
deletePodAndCheckSts(ctx, cl, logger, etcd, "etcd-aws-2")
checkEtcdReady(ctx, cl, logger, etcd, multiNodeEtcdTimeout)
Copy link
Contributor

Choose a reason for hiding this comment

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

Pls pass objLogger instead of logger , because it already contains etcd obj info.


objLogger.Info("Delete member dir of one member pod")
deleteMemberDir(ctx, cl, logger, etcd, "etcd-aws-2")
checkEtcdReady(ctx, cl, logger, etcd, multiNodeEtcdTimeout)
Copy link
Contributor

Choose a reason for hiding this comment

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

Pls pass objLogger instead of logger , because it already contains etcd obj info.

}

func corruptMemberDBFile(ctx context.Context, cl client.Client, logger logr.Logger, etcd *v1alpha1.Etcd, podName string) {
Expect(corruptDBFile(kubeconfigPath, namespace, podName, "backup-restore", "/var/etcd/data/new.etcd/member/snap/db")).To(Succeed())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Expect(corruptDBFile(kubeconfigPath, namespace, podName, "backup-restore", "/var/etcd/data/new.etcd/member/snap/db")).To(Succeed())
ExpectWithOffset(1, corruptDBFile(kubeconfigPath, namespace, podName, "backup-restore", "/var/etcd/data/new.etcd/member/snap/db")).To(Succeed())

func corruptMemberDBFile(ctx context.Context, cl client.Client, logger logr.Logger, etcd *v1alpha1.Etcd, podName string) {
Expect(corruptDBFile(kubeconfigPath, namespace, podName, "backup-restore", "/var/etcd/data/new.etcd/member/snap/db")).To(Succeed())
checkUnreadySts(ctx, cl, logger, etcd)
checkReadySts(ctx, cl, logger, etcd)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here also

Suggested change
checkReadySts(ctx, cl, logger, etcd)
checkEtcdReady(ctx, cl, logger, etcd, multiNodeEtcdTimeout)

}

func checkUnreadySts(ctx context.Context, cl client.Client, logger logr.Logger, etcd *v1alpha1.Etcd) {
logger.Info("waiting for sts to become unready", "statefulSetName", "etcd-aws")
Copy link
Contributor

Choose a reason for hiding this comment

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

Pls ignore statefulSetName info and pass objLogger

}
return nil
}, multiNodeEtcdTimeout, pollingInterval).Should(BeNil())
logger.Info("sts is unready", "statefulSetName", "etcd-aws")
Copy link
Contributor

Choose a reason for hiding this comment

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

Pls ignore sts name here also


func checkReadySts(ctx context.Context, cl client.Client, logger logr.Logger, etcd *v1alpha1.Etcd) {
logger.Info("waiting for sts to become ready again", "statefulSetName", "etcd-aws")
Eventually(func() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Eventually(func() error {
EventuallyWithOffset(2, func() error {

@gardener-robot gardener-robot added the needs/changes Needs (more) changes label Nov 2, 2022
@abdasgupta abdasgupta modified the milestones: v0.14.0, v0.15.0 Nov 8, 2022
@abdasgupta abdasgupta merged commit 7eda408 into gardener:master Nov 8, 2022
@gardener-robot gardener-robot added the status/closed Issue is closed (either delivered or triaged) label Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing Testing related kind/enhancement Enhancement, improvement, extension needs/changes Needs (more) changes needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) needs/review Needs review size/m Size of pull request is medium (see gardener-robot robot/bots/size.py) status/closed Issue is closed (either delivered or triaged)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants