mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Fix v1 cluster migration test.
This commit is contained in:
parent
ccc27a61f5
commit
954217fb73
@ -8,7 +8,7 @@ import (
|
||||
// Removes a key from the store.
|
||||
func DeleteKeyHandler(w http.ResponseWriter, req *http.Request, s Server) error {
|
||||
vars := mux.Vars(req)
|
||||
key := vars["key"]
|
||||
key := "/" + vars["key"]
|
||||
c := s.Store().CommandFactory().CreateDeleteCommand(key, false)
|
||||
return s.Dispatch(c, w, req)
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
// Retrieves the value for a given key.
|
||||
func GetKeyHandler(w http.ResponseWriter, req *http.Request, s Server) error {
|
||||
vars := mux.Vars(req)
|
||||
key := vars["key"]
|
||||
key := "/" + vars["key"]
|
||||
|
||||
// Retrieve the key from the store.
|
||||
event, err := s.Store().Get(key, false, false)
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
// Sets the value for a given key.
|
||||
func SetKeyHandler(w http.ResponseWriter, req *http.Request, s Server) error {
|
||||
vars := mux.Vars(req)
|
||||
key := vars["key"]
|
||||
key := "/" + vars["key"]
|
||||
|
||||
req.ParseForm()
|
||||
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
func WatchKeyHandler(w http.ResponseWriter, req *http.Request, s Server) error {
|
||||
var err error
|
||||
vars := mux.Vars(req)
|
||||
key := vars["key"]
|
||||
key := "/" + vars["key"]
|
||||
|
||||
// Create a command to watch from a given index (default 0).
|
||||
var sinceIndex uint64 = 0
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
func DeleteHandler(w http.ResponseWriter, req *http.Request, s Server) error {
|
||||
vars := mux.Vars(req)
|
||||
key := vars["key"]
|
||||
key := "/" + vars["key"]
|
||||
recursive := (req.FormValue("recursive") == "true")
|
||||
|
||||
c := s.Store().CommandFactory().CreateDeleteCommand(key, recursive)
|
||||
|
@ -18,7 +18,7 @@ func GetHandler(w http.ResponseWriter, req *http.Request, s Server) error {
|
||||
var event *store.Event
|
||||
|
||||
vars := mux.Vars(req)
|
||||
key := vars["key"]
|
||||
key := "/" + vars["key"]
|
||||
|
||||
// Help client to redirect the request to the current leader
|
||||
if req.FormValue("consistent") == "true" && s.State() != raft.Leader {
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
|
||||
func PostHandler(w http.ResponseWriter, req *http.Request, s Server) error {
|
||||
vars := mux.Vars(req)
|
||||
key := vars["key"]
|
||||
key := "/" + vars["key"]
|
||||
|
||||
value := req.FormValue("value")
|
||||
expireTime, err := store.TTL(req.FormValue("ttl"))
|
||||
|
@ -15,7 +15,7 @@ func PutHandler(w http.ResponseWriter, req *http.Request, s Server) error {
|
||||
var c raft.Command
|
||||
|
||||
vars := mux.Vars(req)
|
||||
key := vars["key"]
|
||||
key := "/" + vars["key"]
|
||||
|
||||
req.ParseForm()
|
||||
|
||||
|
@ -87,17 +87,17 @@ func TestV1ClusterMigration(t *testing.T) {
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
time.Sleep(120 * time.Second)
|
||||
|
||||
// Ensure deleted message is removed.
|
||||
resp, err := tests.Get("http://localhost:4001/v2/keys/message")
|
||||
tests.ReadBody(resp)
|
||||
body := tests.ReadBody(resp)
|
||||
assert.Nil(t, err, "")
|
||||
assert.Equal(t, resp.StatusCode, 404, "")
|
||||
assert.Equal(t, resp.StatusCode, 400, )
|
||||
assert.Equal(t, string(body), `{"errorCode":100,"message":"Key Not Found","cause":"/message","index":11}`+"\n")
|
||||
|
||||
// Ensure TTL'd message is removed.
|
||||
resp, err = tests.Get("http://localhost:4001/v2/keys/foo")
|
||||
tests.ReadBody(resp)
|
||||
body = tests.ReadBody(resp)
|
||||
assert.Nil(t, err, "")
|
||||
assert.Equal(t, resp.StatusCode, 404, "")
|
||||
assert.Equal(t, resp.StatusCode, 200, "")
|
||||
assert.Equal(t, string(body), `{"action":"get","key":"/foo","value":"one","modifiedIndex":9}`)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user