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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/snapshot/restorer/restorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func (r *Restorer) Restore(ro RestoreOptions) error {
r.logger.Infof("Quota size for etcd must be greater than 0. Input EmbeddedEtcdQuotaBytes: %d. Defaulting to 8GB.", ro.EmbeddedEtcdQuotaBytes)
ro.EmbeddedEtcdQuotaBytes = int64(8 * 1024 * 1024 * 1024)
}
ro.RestoreDataDir = path.Clean(ro.RestoreDataDir)
if err := r.restoreFromBaseSnapshot(ro); err != nil {
return fmt.Errorf("failed to restore from the base snapshot :%v", err)
}
Expand Down
16 changes: 16 additions & 0 deletions pkg/snapshot/restorer/restorer_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"math"
"os"
"path"
"strconv"
"sync"
"testing"
Expand Down Expand Up @@ -101,6 +102,21 @@ func cleanUp() {

err = os.RemoveAll(snapstoreDir)
Expect(err).ShouldNot(HaveOccurred())

//for the negative scenario for invalid restoredir set to "" we need to cleanup the member folder in the working directory
restoreDir := path.Clean("")
info, err := os.Stat(fmt.Sprintf("%s/%s", restoreDir, "member"))
shreyas-s-rao marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
if os.IsNotExist(err) {
return
} else {
Expect(err).ShouldNot(HaveOccurred())
}
}
if info.IsDir() {
err = os.RemoveAll(info.Name())
Expect(err).ShouldNot(HaveOccurred())
}
}

// startEmbeddedEtcd starts an embedded etcd server
Expand Down
2 changes: 1 addition & 1 deletion pkg/snapshot/restorer/restorer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ var _ = Describe("Running Restorer", func() {
DeltaSnapList: deltaSnapList,
}
err = rstr.Restore(restoreOptions)
Expect(err).Should(HaveOccurred())
Expect(err).ShouldNot(HaveOccurred())

})
})
Expand Down