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 negative tests for restore of snapshots #173

Merged
merged 4 commits into from
Sep 4, 2019

Conversation

ashwani2k
Copy link
Collaborator

@ashwani2k ashwani2k commented Jul 3, 2019

What this PR does / why we need it:
Added more negative tests for restore of snapshots.
Following test been added -

  1. Restore with embedded etcd quota not set
  2. Restore with invalid cluster URL
  3. Restore with invalid restore directory
  4. Restore with snapdir and snapname set to ""
  5. Restore with invalid snapdir and snapname
  6. Restore with no delta snapshots
  7. Restore with corrupted snapstore
  8. Restore with etcd client is unavailable
  9. Restore with etcd data dir not cleaned up before restore
  10. Restore with snapshotter running in parallel

Which issue(s) this PR fixes:
Fixes partially #73 #104

Special notes for your reviewer:
Enhanced the populate script to capture delete of keys.
Some refactoring is done to segregate the tests into 2 categories -

  1. Running restore with pre-loaded snapstore
  2. Running restore with dynamic load for specific negative scenarios

Release note:

Added negative tests for restoration of snapshots.

@CLAassistant
Copy link

CLAassistant commented Jul 3, 2019

CLA assistant check
All committers have signed the CLA.

@swapnilgm swapnilgm added area/quality Output qualification (tests, checks, scans, automation in general, etc.) related component/etcd-backup-restore ETCD Backup & Restore exp/intermediate Issue that requires some project experience kind/test Test needs/lgtm Needs approval for merging 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 platform/all priority/normal status/in-progress Issue is in progress/work labels Jul 4, 2019
Copy link
Collaborator

@amshuman-kr amshuman-kr left a comment

Choose a reason for hiding this comment

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

Some very small changes and a few naive questions :-)

Overall LGTM

pkg/snapshot/restorer/restorer_suite_test.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Show resolved Hide resolved
}
logger.Infoln("starting restore while snapshotter is running")
err = rstr.Restore(RestoreOptions)
Expect(err).Should(HaveOccurred())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we add a check that the existing etcd data is left untouched?

return fmt.Errorf("entry not found for key %s", resKey)
//handles deleted keys as every 10th key is deleted during populate etcd call
if math.Mod(float64(currKey), 10) == 0 {
continue //it should continue as key was put for action delete
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we check that it is indeed deleted/not there?

Copy link
Collaborator

@shreyas-s-rao shreyas-s-rao left a comment

Choose a reason for hiding this comment

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

@ashwani2k Thanks for the well-written and much-needed PR to improve test coverage. I have a few suggestions. Please make the necessary changes:

  • Negative test separation: Ginkgo allows to run or skip specific specs or spec containers (Describe, Context, etc). You can change the text passed to the second Describe function to something like NEGATIVE: For Dynamic Loads and Negative Scenarios, and then pass the flag --focus="NEGATIVE\:.*" to run only negative tests, or --skip to skip them. This way, we can omit the --randomizeAllSpecs flag while running the negative tests in a separate command within the unit test script. As the negative tests for restoration don't use the pre-populated snapstore, there will not be a time-overhead as well. This also makes it easy to debug when tests fail, as we'll know whether negative or non-negative tests failed.

pkg/snapshot/restorer/restorer_suite_test.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Outdated Show resolved Hide resolved
pkg/snapshot/restorer/restorer_test.go Outdated Show resolved Hide resolved
@ashwani2k ashwani2k force-pushed the improve-restore-tests branch 3 times, most recently from dc5cb5d to 9901518 Compare August 2, 2019 10:45
@ashwani2k ashwani2k force-pushed the improve-restore-tests branch from 9901518 to 7758833 Compare August 9, 2019 11:22
@ashwani2k ashwani2k force-pushed the improve-restore-tests branch from 7758833 to caf9c6b Compare September 4, 2019 05:40
Copy link
Collaborator

@shreyas-s-rao shreyas-s-rao left a comment

Choose a reason for hiding this comment

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

@ashwani2k Thanks for addressing all the suggestions! LGTM 👍🏼

@shreyas-s-rao shreyas-s-rao added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) reviewed/lgtm Has approval for merging and removed needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) status/in-progress Issue is in progress/work needs/lgtm Needs approval for merging needs/review Needs review labels Sep 4, 2019
@gardener-robot-ci-1 gardener-robot-ci-1 added 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 Sep 4, 2019
@shreyas-s-rao shreyas-s-rao merged commit c815c3d into gardener:master Sep 4, 2019
@gardener-robot gardener-robot added priority/3 Priority (lower number equals higher priority) and removed priority/3 Priority (lower number equals higher priority) labels Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/quality Output qualification (tests, checks, scans, automation in general, etc.) related component/etcd-backup-restore ETCD Backup & Restore exp/intermediate Issue that requires some project experience kind/test Test needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) platform/all reviewed/lgtm Has approval for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants