|
@@ -20,6 +20,7 @@ import (
|
|
|
"fmt"
|
|
"fmt"
|
|
|
"math/rand"
|
|
"math/rand"
|
|
|
"net/http/httptest"
|
|
"net/http/httptest"
|
|
|
|
|
+ "net/url"
|
|
|
"reflect"
|
|
"reflect"
|
|
|
"testing"
|
|
"testing"
|
|
|
"time"
|
|
"time"
|
|
@@ -339,37 +340,22 @@ func TestModeSwitch(t *testing.T) {
|
|
|
|
|
|
|
|
// Sending set commands
|
|
// Sending set commands
|
|
|
func keepSetting(urlStr string, stop chan bool) {
|
|
func keepSetting(urlStr string, stop chan bool) {
|
|
|
- stopSet := false
|
|
|
|
|
|
|
+ tc := NewTestClient()
|
|
|
i := 0
|
|
i := 0
|
|
|
- c := etcd.NewClient([]string{urlStr})
|
|
|
|
|
|
|
+ value := url.Values(map[string][]string{"value": {"bar"}})
|
|
|
for {
|
|
for {
|
|
|
- key := fmt.Sprintf("%s_%v", "foo", i)
|
|
|
|
|
-
|
|
|
|
|
- result, err := c.Set(key, "bar", 0)
|
|
|
|
|
-
|
|
|
|
|
- if err != nil || result.Node.Key != "/"+key || result.Node.Value != "bar" {
|
|
|
|
|
- select {
|
|
|
|
|
- case <-stop:
|
|
|
|
|
- stopSet = true
|
|
|
|
|
-
|
|
|
|
|
- default:
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ resp, err := tc.PutForm(fmt.Sprintf("%s/v2/keys/foo_%v", urlStr, i), value)
|
|
|
|
|
+ if err == nil {
|
|
|
|
|
+ tc.ReadBody(resp)
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
select {
|
|
select {
|
|
|
case <-stop:
|
|
case <-stop:
|
|
|
- stopSet = true
|
|
|
|
|
-
|
|
|
|
|
|
|
+ stop <- true
|
|
|
|
|
+ return
|
|
|
default:
|
|
default:
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- if stopSet {
|
|
|
|
|
- break
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
i++
|
|
i++
|
|
|
}
|
|
}
|
|
|
- stop <- true
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
type leadterm struct {
|
|
type leadterm struct {
|