-
Notifications
You must be signed in to change notification settings - Fork 50
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
Conversation
test/e2e/etcd_multi_node_test.go
Outdated
@@ -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()) |
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.
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()) |
test/e2e/etcd_multi_node_test.go
Outdated
|
||
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 { |
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.
Eventually(func() error { | |
EventuallyWithOffset(2, func() error { |
test/e2e/etcd_multi_node_test.go
Outdated
@@ -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") |
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.
Pls pass objLogger instead of logger
, because it already contains etcd
obj info.
test/e2e/etcd_multi_node_test.go
Outdated
By("Single member restoration") | ||
objLogger.Info("Delete one member pod") | ||
deletePodAndCheckSts(ctx, cl, logger, etcd, "etcd-aws-2") | ||
checkEtcdReady(ctx, cl, logger, etcd, multiNodeEtcdTimeout) |
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.
Pls pass objLogger instead of logger
, because it already contains etcd
obj info.
test/e2e/etcd_multi_node_test.go
Outdated
|
||
objLogger.Info("Delete member dir of one member pod") | ||
deleteMemberDir(ctx, cl, logger, etcd, "etcd-aws-2") | ||
checkEtcdReady(ctx, cl, logger, etcd, multiNodeEtcdTimeout) |
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.
Pls pass objLogger instead of logger
, because it already contains etcd
obj info.
test/e2e/etcd_multi_node_test.go
Outdated
} | ||
|
||
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()) |
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.
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()) |
test/e2e/etcd_multi_node_test.go
Outdated
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) |
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.
Here also
checkReadySts(ctx, cl, logger, etcd) | |
checkEtcdReady(ctx, cl, logger, etcd, multiNodeEtcdTimeout) |
test/e2e/etcd_multi_node_test.go
Outdated
} | ||
|
||
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") |
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.
Pls ignore statefulSetName
info and pass objLogger
test/e2e/etcd_multi_node_test.go
Outdated
} | ||
return nil | ||
}, multiNodeEtcdTimeout, pollingInterval).Should(BeNil()) | ||
logger.Info("sts is unready", "statefulSetName", "etcd-aws") |
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.
Pls ignore sts name here also
test/e2e/etcd_multi_node_test.go
Outdated
|
||
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 { |
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.
Eventually(func() error { | |
EventuallyWithOffset(2, func() error { |
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:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Release note: