mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
e2e: make-mirror
This commit is contained in:
parent
29dfca883f
commit
6eb25751ec
72
e2e/ctl_v3_make_mirror_test.go
Normal file
72
e2e/ctl_v3_make_mirror_test.go
Normal file
@ -0,0 +1,72 @@
|
||||
// Copyright 2016 CoreOS, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestCtlV3MakeMirror(t *testing.T) { testCtl(t, makeMirrorTest) }
|
||||
|
||||
func makeMirrorTest(cx ctlCtx) {
|
||||
// set up another cluster to mirror with
|
||||
cfg := configAutoTLS
|
||||
cfg.clusterSize = 1
|
||||
cfg.basePort = 10000
|
||||
cx2 := ctlCtx{
|
||||
t: cx.t,
|
||||
cfg: cfg,
|
||||
dialTimeout: 7 * time.Second,
|
||||
}
|
||||
|
||||
epc, err := newEtcdProcessCluster(&cx2.cfg)
|
||||
if err != nil {
|
||||
cx.t.Fatalf("could not start etcd process cluster (%v)", err)
|
||||
}
|
||||
cx2.epc = epc
|
||||
|
||||
defer func() {
|
||||
if err = cx2.epc.Close(); err != nil {
|
||||
cx.t.Fatalf("error closing etcd processes (%v)", err)
|
||||
}
|
||||
}()
|
||||
|
||||
cmdArgs := append(cx.PrefixArgs(), "make-mirror", fmt.Sprintf("localhost:%d", cfg.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{{"key1", "val1"}, {"key2", "val2"}, {"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{"key", "--prefix"}, kvs...); err != nil {
|
||||
cx.t.Fatal(err)
|
||||
}
|
||||
if err = ctlV3Watch(cx2, []string{"key", "--rev", "1", "--prefix"}, kvs...); err != nil {
|
||||
cx.t.Fatal(err)
|
||||
}
|
||||
}
|
@ -130,6 +130,7 @@ type etcdProcessConfig struct {
|
||||
|
||||
type etcdProcessClusterConfig struct {
|
||||
clusterSize int
|
||||
basePort int
|
||||
proxySize int
|
||||
clientTLS clientConnType
|
||||
isPeerTLS bool
|
||||
@ -196,6 +197,10 @@ func newEtcdProcess(cfg *etcdProcessConfig) (*etcdProcess, error) {
|
||||
}
|
||||
|
||||
func (cfg *etcdProcessClusterConfig) etcdProcessConfigs() []*etcdProcessConfig {
|
||||
if cfg.basePort == 0 {
|
||||
cfg.basePort = etcdProcessBasePort
|
||||
}
|
||||
|
||||
clientScheme := "http"
|
||||
if cfg.clientTLS == clientTLS {
|
||||
clientScheme = "https"
|
||||
@ -210,7 +215,7 @@ func (cfg *etcdProcessClusterConfig) etcdProcessConfigs() []*etcdProcessConfig {
|
||||
for i := 0; i < cfg.clusterSize; i++ {
|
||||
var curls []string
|
||||
var curl, curltls string
|
||||
port := etcdProcessBasePort + 2*i
|
||||
port := cfg.basePort + 2*i
|
||||
|
||||
switch cfg.clientTLS {
|
||||
case clientNonTLS, clientTLS:
|
||||
@ -255,7 +260,7 @@ func (cfg *etcdProcessClusterConfig) etcdProcessConfigs() []*etcdProcessConfig {
|
||||
}
|
||||
}
|
||||
for i := 0; i < cfg.proxySize; i++ {
|
||||
port := etcdProcessBasePort + 2*cfg.clusterSize + i + 1
|
||||
port := cfg.basePort + 2*cfg.clusterSize + i + 1
|
||||
curl := url.URL{Scheme: clientScheme, Host: fmt.Sprintf("localhost:%d", port)}
|
||||
name := fmt.Sprintf("testname-proxy%d", i)
|
||||
dataDirPath, derr := ioutil.TempDir("", name+".etcd")
|
||||
|
Loading…
x
Reference in New Issue
Block a user