-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
snapshot: add "snapshot" restore/save/member-add tests #9198
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9198 +/- ##
==========================================
+ Coverage 75.75% 75.88% +0.12%
==========================================
Files 363 363
Lines 30158 30158
==========================================
+ Hits 22847 22884 +37
+ Misses 5704 5672 -32
+ Partials 1607 1602 -5
Continue to review full report at Codecov.
|
snapshot/member_test.go
Outdated
"github.com/coreos/etcd/etcdserver" | ||
) | ||
|
||
func TestSnapshotV3RestoreMultiMemberAdd(t *testing.T) { |
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.
probably need add a comment on this e2e test. not sure what it tests from the func name.
snapshot/member_test.go
Outdated
t.Fatal(err) | ||
} | ||
|
||
time.Sleep(3 * time.Second) |
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.
why the sleep here?
snapshot/member_test.go
Outdated
t.Fatal(err) | ||
} | ||
defer cli2.Close() | ||
mresp, err := cli2.MemberList(context.Background()) |
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.
add timeout in context or the test might hang.
snapshot/member_test.go
Outdated
} | ||
for i := range kvs { | ||
var gresp *clientv3.GetResponse | ||
gresp, err = cli2.Get(context.Background(), kvs[i].k) |
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.
timeout on context
snapshot/member_test.go
Outdated
|
||
cfg := embed.NewConfig() | ||
cfg.Name = "3" | ||
cfg.InitialClusterToken = "tkn" |
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.
tkn probably should be a const, i assume other funcs also use it.
snapshot/member_test.go
Outdated
select { | ||
case <-srv.Server.ReadyNotify(): | ||
case <-time.After(10 * time.Second): | ||
t.Fatalf("failed to start embed.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.
failed to start the newly added etcd member
snapshot/member_test.go
Outdated
} | ||
defer cli2.Close() | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) |
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.
probably define 3 seconds as request timeout in our pkg/testutil.
snapshot/v3_snapshot_test.go
Outdated
k, v string | ||
} | ||
|
||
func createSnapshot(t *testing.T, kvs []kv) string { |
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.
createSnapshotFile
probably also comment that the returned string value is the file name
snapshot/v3_snapshot_test.go
Outdated
t.Fatal(err) | ||
} | ||
for i := range kvs { | ||
if _, err = cli.Put(context.Background(), kvs[i].k, kvs[i].v); err != nil { |
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.
context needs timeout.
LGTM after fixing nits. |
Signed-off-by: Gyuho Lee <[email protected]>
Signed-off-by: Gyuho Lee <[email protected]>
For #9151.