mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdctlv3: test case: make-mirror modify dest prefix
This commit is contained in:
parent
b91d8625c8
commit
e5ff5d92e6
@ -22,6 +22,8 @@ import (
|
|||||||
|
|
||||||
func TestCtlV3MakeMirror(t *testing.T) { testCtl(t, makeMirrorTest) }
|
func TestCtlV3MakeMirror(t *testing.T) { testCtl(t, makeMirrorTest) }
|
||||||
|
|
||||||
|
func TestCtlV3MakeMirrorModifyPrefix(t *testing.T) { testCtl(t, makeMirrorModifyPrefixTest) }
|
||||||
|
|
||||||
func makeMirrorTest(cx ctlCtx) {
|
func makeMirrorTest(cx ctlCtx) {
|
||||||
// set up another cluster to mirror with
|
// set up another cluster to mirror with
|
||||||
cfg := configAutoTLS
|
cfg := configAutoTLS
|
||||||
@ -70,3 +72,54 @@ func makeMirrorTest(cx ctlCtx) {
|
|||||||
cx.t.Fatal(err)
|
cx.t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func makeMirrorModifyPrefixTest(cx ctlCtx) {
|
||||||
|
// set up another cluster to mirror with
|
||||||
|
mirrorcfg := configAutoTLS
|
||||||
|
mirrorcfg.clusterSize = 1
|
||||||
|
mirrorcfg.basePort = 10000
|
||||||
|
mirrorctx := ctlCtx{
|
||||||
|
t: cx.t,
|
||||||
|
cfg: mirrorcfg,
|
||||||
|
dialTimeout: 7 * time.Second,
|
||||||
|
}
|
||||||
|
|
||||||
|
mirrorepc, err := newEtcdProcessCluster(&mirrorctx.cfg)
|
||||||
|
if err != nil {
|
||||||
|
cx.t.Fatalf("could not start etcd process cluster (%v)", err)
|
||||||
|
}
|
||||||
|
mirrorctx.epc = mirrorepc
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if err = mirrorctx.epc.Close(); err != nil {
|
||||||
|
cx.t.Fatalf("error closing etcd processes (%v)", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
cmdArgs := append(cx.PrefixArgs(), "make-mirror", "--prefix", "o_", "--dest-prefix", "d_", fmt.Sprintf("localhost:%d", mirrorcfg.basePort))
|
||||||
|
proc, err := spawnCmd(cmdArgs)
|
||||||
|
if err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
err = proc.Stop()
|
||||||
|
if err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
var kvs = []kv{{"o_key1", "val1"}, {"o_key2", "val2"}, {"o_key3", "val3"}}
|
||||||
|
for i := range kvs {
|
||||||
|
if err = ctlV3Put(cx, kvs[i].key, kvs[i].val, ""); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err = ctlV3Get(cx, []string{"o_", "--prefix"}, kvs...); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var kvs2 = []kv{{"d_key1", "val1"}, {"d_key2", "val2"}, {"d_key3", "val3"}}
|
||||||
|
if err = ctlV3Watch(mirrorctx, []string{"d_", "--rev", "1", "--prefix"}, kvs2...); err != nil {
|
||||||
|
cx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user