Skip to content

Commit fc562bd

Browse files
committed
fix tests bump deps
1 parent 67b4c27 commit fc562bd

33 files changed

+706
-415
lines changed

server/v2/tests/delete_handler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ func TestV2DeleteKey(t *testing.T) {
2424
resp, err = tests.DeleteForm(fmt.Sprintf("http://%s%s", s.URL(), "/v2/keys/foo/bar"), url.Values{})
2525
body := tests.ReadBody(resp)
2626
assert.Nil(t, err, "")
27-
assert.Equal(t, string(body), `{"action":"delete","node":{"key":"/foo/bar","modifiedIndex":2,"createdIndex":1}}`, "")
27+
assert.Equal(t, string(body), `{"action":"delete","node":{"key":"/foo/bar","prevValue":"XXX","modifiedIndex":2,"createdIndex":1}}`, "")
2828
})
2929
}

tests/functional/multi_node_kill_all_and_recovery_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func TestMultiNodeKillAllAndRecovery(t *testing.T) {
6565
t.Fatalf("Recovery error: %s", err)
6666
}
6767

68-
if result.ModifiedIndex != 16 {
69-
t.Fatalf("recovery failed! [%d/16]", result.ModifiedIndex)
68+
if result.Node.ModifiedIndex != 16 {
69+
t.Fatalf("recovery failed! [%d/16]", result.Node.ModifiedIndex)
7070
}
7171
}

tests/functional/remove_node_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ func TestRemoveNode(t *testing.T) {
3535
fmt.Println("send remove to node3 and wait for its exiting")
3636
etcds[2].Wait()
3737

38-
resp, err := c.Get("_etcd/machines", false)
38+
resp, err := c.Get("_etcd/machines", false, false)
3939

4040
if err != nil {
4141
panic(err)
4242
}
4343

44-
if len(resp.Kvs) != 2 {
44+
if len(resp.Node.Nodes) != 2 {
4545
t.Fatal("cannot remove peer")
4646
}
4747

@@ -59,14 +59,14 @@ func TestRemoveNode(t *testing.T) {
5959

6060
time.Sleep(time.Second)
6161

62-
resp, err = c.Get("_etcd/machines", false)
62+
resp, err = c.Get("_etcd/machines", false, false)
6363

6464
if err != nil {
6565
panic(err)
6666
}
6767

68-
if len(resp.Kvs) != 3 {
69-
t.Fatalf("add peer fails #1 (%d != 3)", len(resp.Kvs))
68+
if len(resp.Node.Nodes) != 3 {
69+
t.Fatalf("add peer fails #1 (%d != 3)", len(resp.Node.Nodes))
7070
}
7171
}
7272

@@ -78,13 +78,13 @@ func TestRemoveNode(t *testing.T) {
7878

7979
client.Do(rmReq)
8080

81-
resp, err := c.Get("_etcd/machines", false)
81+
resp, err := c.Get("_etcd/machines", false, false)
8282

8383
if err != nil {
8484
panic(err)
8585
}
8686

87-
if len(resp.Kvs) != 2 {
87+
if len(resp.Node.Nodes) != 2 {
8888
t.Fatal("cannot remove peer")
8989
}
9090

@@ -102,14 +102,14 @@ func TestRemoveNode(t *testing.T) {
102102

103103
time.Sleep(time.Second)
104104

105-
resp, err = c.Get("_etcd/machines", false)
105+
resp, err = c.Get("_etcd/machines", false, false)
106106

107107
if err != nil {
108108
panic(err)
109109
}
110110

111-
if len(resp.Kvs) != 3 {
112-
t.Fatalf("add peer fails #2 (%d != 3)", len(resp.Kvs))
111+
if len(resp.Node.Nodes) != 3 {
112+
t.Fatalf("add peer fails #2 (%d != 3)", len(resp.Node.Nodes))
113113
}
114114
}
115115
}

tests/functional/simple_multi_node_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,26 @@ func templateTestSimpleMultiNode(t *testing.T, tls bool) {
3939

4040
// Test Set
4141
result, err := c.Set("foo", "bar", 100)
42+
node := result.Node
4243

43-
if err != nil || result.Key != "/foo" || result.Value != "bar" || result.TTL < 95 {
44+
if err != nil || node.Key != "/foo" || node.Value != "bar" || node.TTL < 95 {
4445
if err != nil {
4546
t.Fatal(err)
4647
}
4748

48-
t.Fatalf("Set 1 failed with %s %s %v", result.Key, result.Value, result.TTL)
49+
t.Fatalf("Set 1 failed with %s %s %v", node.Key, node.Value, node.TTL)
4950
}
5051

5152
time.Sleep(time.Second)
5253

5354
result, err = c.Set("foo", "bar", 100)
55+
node = result.Node
5456

55-
if err != nil || result.Key != "/foo" || result.Value != "bar" || result.PrevValue != "bar" || result.TTL < 95 {
57+
if err != nil || node.Key != "/foo" || node.Value != "bar" || node.PrevValue != "bar" || node.TTL < 95 {
5658
if err != nil {
5759
t.Fatal(err)
5860
}
59-
t.Fatalf("Set 2 failed with %s %s %v", result.Key, result.Value, result.TTL)
61+
t.Fatalf("Set 2 failed with %s %s %v", node.Key, node.Value, node.TTL)
6062
}
6163

6264
}

tests/functional/simple_snapshot_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ func TestSimpleSnapshot(t *testing.T) {
3030
// issue first 501 commands
3131
for i := 0; i < 501; i++ {
3232
result, err := c.Set("foo", "bar", 100)
33+
node := result.Node
3334

34-
if err != nil || result.Key != "/foo" || result.Value != "bar" || result.TTL < 95 {
35+
if err != nil || node.Key != "/foo" || node.Value != "bar" || node.TTL < 95 {
3536
if err != nil {
3637
t.Fatal(err)
3738
}
3839

39-
t.Fatalf("Set failed with %s %s %v", result.Key, result.Value, result.TTL)
40+
t.Fatalf("Set failed with %s %s %v", node.Key, node.Value, node.TTL)
4041
}
4142
}
4243

@@ -62,13 +63,14 @@ func TestSimpleSnapshot(t *testing.T) {
6263
// issue second 501 commands
6364
for i := 0; i < 501; i++ {
6465
result, err := c.Set("foo", "bar", 100)
66+
node := result.Node
6567

66-
if err != nil || result.Key != "/foo" || result.Value != "bar" || result.TTL < 95 {
68+
if err != nil || node.Key != "/foo" || node.Value != "bar" || node.TTL < 95 {
6769
if err != nil {
6870
t.Fatal(err)
6971
}
7072

71-
t.Fatalf("Set failed with %s %s %v", result.Key, result.Value, result.TTL)
73+
t.Fatalf("Set failed with %s %s %v", node.Key, node.Value, node.TTL)
7274
}
7375
}
7476

tests/functional/single_node_recovery_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ func TestSingleNodeRecovery(t *testing.T) {
2828
c.SyncCluster()
2929
// Test Set
3030
result, err := c.Set("foo", "bar", 100)
31+
node := result.Node
3132

32-
if err != nil || result.Key != "/foo" || result.Value != "bar" || result.TTL < 95 {
33+
if err != nil || node.Key != "/foo" || node.Value != "bar" || node.TTL < 95 {
3334
if err != nil {
3435
t.Fatal(err)
3536
}
3637

37-
t.Fatalf("Set 1 failed with %s %s %v", result.Key, result.Value, result.TTL)
38+
t.Fatalf("Set 1 failed with %s %s %v", node.Key, node.Value, node.TTL)
3839
}
3940

4041
time.Sleep(time.Second)
@@ -50,16 +51,18 @@ func TestSingleNodeRecovery(t *testing.T) {
5051

5152
time.Sleep(time.Second)
5253

53-
result, err = c.Get("foo", false)
54+
result, err = c.Get("foo", false, false)
55+
node = result.Node
56+
5457
if err != nil {
5558
t.Fatal("get fail: " + err.Error())
5659
return
5760
}
5861

59-
if err != nil || result.Key != "/foo" || result.Value != "bar" || result.TTL > 99 {
62+
if err != nil || node.Key != "/foo" || node.Value != "bar" || node.TTL > 99 {
6063
if err != nil {
6164
t.Fatal(err)
6265
}
63-
t.Fatalf("Recovery Get failed with %s %s %v", result.Key, result.Value, result.TTL)
66+
t.Fatalf("Recovery Get failed with %s %s %v", node.Key, node.Value, node.TTL)
6467
}
6568
}

tests/functional/single_node_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,39 @@ func TestSingleNode(t *testing.T) {
2828
c.SyncCluster()
2929
// Test Set
3030
result, err := c.Set("foo", "bar", 100)
31+
node := result.Node
3132

32-
if err != nil || result.Key != "/foo" || result.Value != "bar" || result.TTL < 95 {
33+
if err != nil || node.Key != "/foo" || node.Value != "bar" || node.TTL < 95 {
3334
if err != nil {
3435
t.Fatal("Set 1: ", err)
3536
}
3637

37-
t.Fatalf("Set 1 failed with %s %s %v", result.Key, result.Value, result.TTL)
38+
t.Fatalf("Set 1 failed with %s %s %v", node.Key, node.Value, node.TTL)
3839
}
3940

4041
time.Sleep(time.Second)
4142

4243
result, err = c.Set("foo", "bar", 100)
44+
node = result.Node
4345

44-
if err != nil || result.Key != "/foo" || result.Value != "bar" || result.PrevValue != "bar" || result.TTL != 100 {
46+
if err != nil || node.Key != "/foo" || node.Value != "bar" || node.PrevValue != "bar" || node.TTL != 100 {
4547
if err != nil {
4648
t.Fatal("Set 2: ", err)
4749
}
48-
t.Fatalf("Set 2 failed with %s %s %v", result.Key, result.Value, result.TTL)
50+
t.Fatalf("Set 2 failed with %s %s %v", node.Key, node.Value, node.TTL)
4951
}
5052

5153
// Add a test-and-set test
5254

5355
// First, we'll test we can change the value if we get it write
5456
result, err = c.CompareAndSwap("foo", "foobar", 100, "bar", 0)
57+
node = result.Node
5558

56-
if err != nil || result.Key != "/foo" || result.Value != "foobar" || result.PrevValue != "bar" || result.TTL != 100 {
59+
if err != nil || node.Key != "/foo" || node.Value != "foobar" || node.PrevValue != "bar" || node.TTL != 100 {
5760
if err != nil {
5861
t.Fatal(err)
5962
}
60-
t.Fatalf("Set 3 failed with %s %s %v", result.Key, result.Value, result.TTL)
63+
t.Fatalf("Set 3 failed with %s %s %v", node.Key, node.Value, node.TTL)
6164
}
6265

6366
// Next, we'll make sure we can't set it without the correct prior value

tests/functional/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func Set(stop chan bool) {
4444

4545
result, err := c.Set(key, "bar", 0)
4646

47-
if err != nil || result.Key != "/"+key || result.Value != "bar" {
47+
if err != nil || result.Node.Key != "/"+key || result.Node.Value != "bar" {
4848
select {
4949
case <-stop:
5050
stopSet = true

tests/functional/v1_migration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,5 @@ func TestV1ClusterMigration(t *testing.T) {
9999
body = tests.ReadBody(resp)
100100
assert.Nil(t, err, "")
101101
assert.Equal(t, resp.StatusCode, 200, "")
102-
assert.Equal(t, string(body), `{"action":"get","key":"/foo","value":"one","modifiedIndex":9}`)
102+
assert.Equal(t, string(body), `{"action":"get","node":{"key":"/foo","value":"one","modifiedIndex":9,"createdIndex":9}}`)
103103
}

third_party/github.com/coreos/go-etcd/etcd/add_child.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@ package etcd
22

33
// Add a new directory with a random etcd-generated key under the given path.
44
func (c *Client) AddChildDir(key string, ttl uint64) (*Response, error) {
5-
return c.post(key, "", ttl)
5+
raw, err := c.post(key, "", ttl)
6+
7+
if err != nil {
8+
return nil, err
9+
}
10+
11+
return raw.toResponse()
612
}
713

814
// Add a new file with a random etcd-generated key under the given path.
915
func (c *Client) AddChild(key string, value string, ttl uint64) (*Response, error) {
10-
return c.post(key, value, ttl)
16+
raw, err := c.post(key, value, ttl)
17+
18+
if err != nil {
19+
return nil, err
20+
}
21+
22+
return raw.toResponse()
1123
}

0 commit comments

Comments
 (0)