etcdserver: update member attribute when apply request

This commit is contained in:
Yicheng Qin
2014-10-24 01:13:47 -07:00
parent 4c9d67aaa2
commit ea0bff80c0
2 changed files with 33 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import (
"math/rand"
"path"
"reflect"
"strconv"
"sync"
"testing"
"time"
@ -384,6 +385,25 @@ func TestApplyRequest(t *testing.T) {
}
}
func TestApplyRequestOnAdminMemberAttributes(t *testing.T) {
cl := newTestCluster([]Member{{ID: 1}})
srv := &EtcdServer{
store: &storeRecorder{},
Cluster: cl,
}
req := pb.Request{
Method: "PUT",
ID: 1,
Path: path.Join(storeMembersPrefix, strconv.FormatUint(1, 16), attributesSuffix),
Val: `{"Name":"abc","ClientURLs":["http://127.0.0.1:4001"]}`,
}
srv.applyRequest(req)
w := Attributes{Name: "abc", ClientURLs: []string{"http://127.0.0.1:4001"}}
if g := cl.Member(1).Attributes; !reflect.DeepEqual(g, w) {
t.Errorf("attributes = %v, want %v", g, w)
}
}
// TODO: test ErrIDRemoved
func TestApplyConfChangeError(t *testing.T) {
nodes := []uint64{1, 2, 3}