|
|
@@ -54,11 +54,11 @@ func TestDoLocalAction(t *testing.T) {
|
|
|
wactions []action
|
|
|
}{
|
|
|
{
|
|
|
- pb.Request{Method: "GET", Id: 1, Wait: true},
|
|
|
+ pb.Request{Method: "GET", ID: 1, Wait: true},
|
|
|
Response{Watcher: &stubWatcher{}}, nil, []action{action{name: "Watch"}},
|
|
|
},
|
|
|
{
|
|
|
- pb.Request{Method: "GET", Id: 1},
|
|
|
+ pb.Request{Method: "GET", ID: 1},
|
|
|
Response{Event: &store.Event{}}, nil,
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -68,7 +68,7 @@ func TestDoLocalAction(t *testing.T) {
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
- pb.Request{Method: "BADMETHOD", Id: 1},
|
|
|
+ pb.Request{Method: "BADMETHOD", ID: 1},
|
|
|
Response{}, ErrUnknownMethod, []action{},
|
|
|
},
|
|
|
}
|
|
|
@@ -100,11 +100,11 @@ func TestDoBadLocalAction(t *testing.T) {
|
|
|
wactions []action
|
|
|
}{
|
|
|
{
|
|
|
- pb.Request{Method: "GET", Id: 1, Wait: true},
|
|
|
+ pb.Request{Method: "GET", ID: 1, Wait: true},
|
|
|
[]action{action{name: "Watch"}},
|
|
|
},
|
|
|
{
|
|
|
- pb.Request{Method: "GET", Id: 1},
|
|
|
+ pb.Request{Method: "GET", ID: 1},
|
|
|
[]action{action{name: "Get"}},
|
|
|
},
|
|
|
}
|
|
|
@@ -135,7 +135,7 @@ func TestApply(t *testing.T) {
|
|
|
}{
|
|
|
// POST ==> Create
|
|
|
{
|
|
|
- pb.Request{Method: "POST", Id: 1},
|
|
|
+ pb.Request{Method: "POST", ID: 1},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -146,7 +146,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
// POST ==> Create, with expiration
|
|
|
{
|
|
|
- pb.Request{Method: "POST", Id: 1, Expiration: 1337},
|
|
|
+ pb.Request{Method: "POST", ID: 1, Expiration: 1337},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -157,7 +157,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
// POST ==> Create, with dir
|
|
|
{
|
|
|
- pb.Request{Method: "POST", Id: 1, Dir: true},
|
|
|
+ pb.Request{Method: "POST", ID: 1, Dir: true},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -168,7 +168,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
// PUT ==> Set
|
|
|
{
|
|
|
- pb.Request{Method: "PUT", Id: 1},
|
|
|
+ pb.Request{Method: "PUT", ID: 1},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -179,7 +179,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
// PUT ==> Set, with dir
|
|
|
{
|
|
|
- pb.Request{Method: "PUT", Id: 1, Dir: true},
|
|
|
+ pb.Request{Method: "PUT", ID: 1, Dir: true},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -190,7 +190,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
// PUT with PrevExist=true ==> Update
|
|
|
{
|
|
|
- pb.Request{Method: "PUT", Id: 1, PrevExist: boolp(true)},
|
|
|
+ pb.Request{Method: "PUT", ID: 1, PrevExist: boolp(true)},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -201,7 +201,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
// PUT with PrevExist=false ==> Create
|
|
|
{
|
|
|
- pb.Request{Method: "PUT", Id: 1, PrevExist: boolp(false)},
|
|
|
+ pb.Request{Method: "PUT", ID: 1, PrevExist: boolp(false)},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -213,7 +213,7 @@ func TestApply(t *testing.T) {
|
|
|
// PUT with PrevExist=true *and* PrevIndex set ==> Update
|
|
|
// TODO(jonboulle): is this expected?!
|
|
|
{
|
|
|
- pb.Request{Method: "PUT", Id: 1, PrevExist: boolp(true), PrevIndex: 1},
|
|
|
+ pb.Request{Method: "PUT", ID: 1, PrevExist: boolp(true), PrevIndex: 1},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -225,7 +225,7 @@ func TestApply(t *testing.T) {
|
|
|
// PUT with PrevExist=false *and* PrevIndex set ==> Create
|
|
|
// TODO(jonboulle): is this expected?!
|
|
|
{
|
|
|
- pb.Request{Method: "PUT", Id: 1, PrevExist: boolp(false), PrevIndex: 1},
|
|
|
+ pb.Request{Method: "PUT", ID: 1, PrevExist: boolp(false), PrevIndex: 1},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -236,7 +236,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
// PUT with PrevIndex set ==> CompareAndSwap
|
|
|
{
|
|
|
- pb.Request{Method: "PUT", Id: 1, PrevIndex: 1},
|
|
|
+ pb.Request{Method: "PUT", ID: 1, PrevIndex: 1},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -247,7 +247,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
// PUT with PrevValue set ==> CompareAndSwap
|
|
|
{
|
|
|
- pb.Request{Method: "PUT", Id: 1, PrevValue: "bar"},
|
|
|
+ pb.Request{Method: "PUT", ID: 1, PrevValue: "bar"},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -258,7 +258,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
// PUT with PrevIndex and PrevValue set ==> CompareAndSwap
|
|
|
{
|
|
|
- pb.Request{Method: "PUT", Id: 1, PrevIndex: 1, PrevValue: "bar"},
|
|
|
+ pb.Request{Method: "PUT", ID: 1, PrevIndex: 1, PrevValue: "bar"},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -269,7 +269,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
// DELETE ==> Delete
|
|
|
{
|
|
|
- pb.Request{Method: "DELETE", Id: 1},
|
|
|
+ pb.Request{Method: "DELETE", ID: 1},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -280,7 +280,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
// DELETE with PrevIndex set ==> CompareAndDelete
|
|
|
{
|
|
|
- pb.Request{Method: "DELETE", Id: 1, PrevIndex: 1},
|
|
|
+ pb.Request{Method: "DELETE", ID: 1, PrevIndex: 1},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -291,7 +291,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
// DELETE with PrevValue set ==> CompareAndDelete
|
|
|
{
|
|
|
- pb.Request{Method: "DELETE", Id: 1, PrevValue: "bar"},
|
|
|
+ pb.Request{Method: "DELETE", ID: 1, PrevValue: "bar"},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -302,7 +302,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
// DELETE with PrevIndex *and* PrevValue set ==> CompareAndDelete
|
|
|
{
|
|
|
- pb.Request{Method: "DELETE", Id: 1, PrevIndex: 5, PrevValue: "bar"},
|
|
|
+ pb.Request{Method: "DELETE", ID: 1, PrevIndex: 5, PrevValue: "bar"},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -313,7 +313,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
// QGET ==> Get
|
|
|
{
|
|
|
- pb.Request{Method: "QGET", Id: 1},
|
|
|
+ pb.Request{Method: "QGET", ID: 1},
|
|
|
Response{Event: &store.Event{}},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -324,7 +324,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
// SYNC ==> DeleteExpiredKeys
|
|
|
{
|
|
|
- pb.Request{Method: "SYNC", Id: 1},
|
|
|
+ pb.Request{Method: "SYNC", ID: 1},
|
|
|
Response{},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -334,7 +334,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
- pb.Request{Method: "SYNC", Id: 1, Time: 12345},
|
|
|
+ pb.Request{Method: "SYNC", ID: 1, Time: 12345},
|
|
|
Response{},
|
|
|
[]action{
|
|
|
action{
|
|
|
@@ -345,7 +345,7 @@ func TestApply(t *testing.T) {
|
|
|
},
|
|
|
// Unknown method - error
|
|
|
{
|
|
|
- pb.Request{Method: "BADMETHOD", Id: 1},
|
|
|
+ pb.Request{Method: "BADMETHOD", ID: 1},
|
|
|
Response{err: ErrUnknownMethod},
|
|
|
[]action{},
|
|
|
},
|
|
|
@@ -409,7 +409,7 @@ func testServer(t *testing.T, ns int64) {
|
|
|
for i := 1; i <= 10; i++ {
|
|
|
r := pb.Request{
|
|
|
Method: "PUT",
|
|
|
- Id: int64(i),
|
|
|
+ ID: int64(i),
|
|
|
Path: "/foo",
|
|
|
Val: "bar",
|
|
|
}
|
|
|
@@ -448,10 +448,10 @@ func testServer(t *testing.T, ns int64) {
|
|
|
|
|
|
func TestDoProposal(t *testing.T) {
|
|
|
tests := []pb.Request{
|
|
|
- pb.Request{Method: "POST", Id: 1},
|
|
|
- pb.Request{Method: "PUT", Id: 1},
|
|
|
- pb.Request{Method: "DELETE", Id: 1},
|
|
|
- pb.Request{Method: "GET", Id: 1, Quorum: true},
|
|
|
+ pb.Request{Method: "POST", ID: 1},
|
|
|
+ pb.Request{Method: "PUT", ID: 1},
|
|
|
+ pb.Request{Method: "DELETE", ID: 1},
|
|
|
+ pb.Request{Method: "GET", ID: 1, Quorum: true},
|
|
|
}
|
|
|
|
|
|
for i, tt := range tests {
|
|
|
@@ -502,7 +502,7 @@ func TestDoProposalCancelled(t *testing.T) {
|
|
|
done := make(chan struct{})
|
|
|
var err error
|
|
|
go func() {
|
|
|
- _, err = srv.Do(ctx, pb.Request{Method: "PUT", Id: 1})
|
|
|
+ _, err = srv.Do(ctx, pb.Request{Method: "PUT", ID: 1})
|
|
|
close(done)
|
|
|
}()
|
|
|
cancel()
|
|
|
@@ -543,7 +543,7 @@ func TestDoProposalStopped(t *testing.T) {
|
|
|
done := make(chan struct{})
|
|
|
var err error
|
|
|
go func() {
|
|
|
- _, err = srv.Do(ctx, pb.Request{Method: "PUT", Id: 1})
|
|
|
+ _, err = srv.Do(ctx, pb.Request{Method: "PUT", ID: 1})
|
|
|
close(done)
|
|
|
}()
|
|
|
srv.Stop()
|
|
|
@@ -711,7 +711,7 @@ func TestTriggerSnap(t *testing.T) {
|
|
|
|
|
|
s.Start()
|
|
|
for i := 0; int64(i) < s.SnapCount; i++ {
|
|
|
- s.Do(ctx, pb.Request{Method: "PUT", Id: 1})
|
|
|
+ s.Do(ctx, pb.Request{Method: "PUT", ID: 1})
|
|
|
}
|
|
|
time.Sleep(time.Millisecond)
|
|
|
s.Stop()
|