mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
wip commit
This commit is contained in:
parent
522a833ab2
commit
40a574a8ca
@ -65,7 +65,7 @@ func TestMultiNodeKillAllAndRecovery(t *testing.T) {
|
||||
t.Fatalf("Recovery error: %s", err)
|
||||
}
|
||||
|
||||
if result.Index != 16 {
|
||||
t.Fatalf("recovery failed! [%d/16]", result.Index)
|
||||
if result.ModifiedIndex != 16 {
|
||||
t.Fatalf("recovery failed! [%d/16]", result.ModifiedIndex)
|
||||
}
|
||||
}
|
||||
|
@ -35,13 +35,13 @@ func TestRemoveNode(t *testing.T) {
|
||||
fmt.Println("send remove to node3 and wait for its exiting")
|
||||
etcds[2].Wait()
|
||||
|
||||
resp, err := c.Get("_etcd/machines")
|
||||
resp, err := c.Get("_etcd/machines", false)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if len(resp) != 2 {
|
||||
if len(resp.Kvs) != 2 {
|
||||
t.Fatal("cannot remove peer")
|
||||
}
|
||||
|
||||
@ -59,14 +59,14 @@ func TestRemoveNode(t *testing.T) {
|
||||
|
||||
time.Sleep(time.Second)
|
||||
|
||||
resp, err = c.Get("_etcd/machines")
|
||||
resp, err = c.Get("_etcd/machines", false)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if len(resp) != 3 {
|
||||
t.Fatalf("add peer fails #1 (%d != 3)", len(resp))
|
||||
if len(resp.Kvs) != 3 {
|
||||
t.Fatalf("add peer fails #1 (%d != 3)", len(resp.Kvs))
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,13 +78,13 @@ func TestRemoveNode(t *testing.T) {
|
||||
|
||||
client.Do(rmReq)
|
||||
|
||||
resp, err := c.Get("_etcd/machines")
|
||||
resp, err := c.Get("_etcd/machines", false)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if len(resp) != 2 {
|
||||
if len(resp.Kvs) != 2 {
|
||||
t.Fatal("cannot remove peer")
|
||||
}
|
||||
|
||||
@ -102,14 +102,14 @@ func TestRemoveNode(t *testing.T) {
|
||||
|
||||
time.Sleep(time.Second)
|
||||
|
||||
resp, err = c.Get("_etcd/machines")
|
||||
resp, err = c.Get("_etcd/machines", false)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if len(resp) != 3 {
|
||||
t.Fatalf("add peer fails #2 (%d != 3)", len(resp))
|
||||
if len(resp.Kvs) != 3 {
|
||||
t.Fatalf("add peer fails #2 (%d != 3)", len(resp.Kvs))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,18 +50,18 @@ func TestSingleNodeRecovery(t *testing.T) {
|
||||
|
||||
time.Sleep(time.Second)
|
||||
|
||||
results, err := c.Get("foo")
|
||||
results, err := c.Get("foo", false)
|
||||
if err != nil {
|
||||
t.Fatal("get fail: " + err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
result = results[0]
|
||||
kv := results.Kvs[0]
|
||||
|
||||
if err != nil || result.Key != "/foo" || result.Value != "bar" || result.TTL > 99 {
|
||||
if err != nil || kv.Key != "/foo" || kv.Value != "bar" || kv.TTL > 99 {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Fatalf("Recovery Get failed with %s %s %v", result.Key, result.Value, result.TTL)
|
||||
t.Fatalf("Recovery Get failed with %s %s %v", kv.Key, kv.Value, kv.TTL)
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func TestSingleNode(t *testing.T) {
|
||||
// Add a test-and-set test
|
||||
|
||||
// First, we'll test we can change the value if we get it write
|
||||
result, match, err := c.TestAndSet("foo", "bar", "foobar", 100)
|
||||
result, match, err := c.CompareAndSwap("foo", "foobar", 100, "foo", 0)
|
||||
|
||||
if err != nil || result.Key != "/foo" || result.Value != "foobar" || result.PrevValue != "bar" || result.TTL != 100 || !match {
|
||||
if err != nil {
|
||||
@ -61,16 +61,9 @@ func TestSingleNode(t *testing.T) {
|
||||
}
|
||||
|
||||
// Next, we'll make sure we can't set it without the correct prior value
|
||||
_, _, err = c.TestAndSet("foo", "bar", "foofoo", 100)
|
||||
_, _, err = c.CompareAndSwap("foo", "foofoo", 100, "bar", 0)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("Set 4 expecting error when setting key with incorrect previous value")
|
||||
}
|
||||
|
||||
// Finally, we'll make sure a blank previous value still counts as a test-and-set and still has to match
|
||||
_, _, err = c.TestAndSet("foo", "", "barbar", 100)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("Set 5 expecting error when setting key with blank (incorrect) previous value")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user