2016-05-13 06:51:48 +03:00
|
|
|
// Copyright 2016 The etcd Authors
|
2016-01-28 23:08:05 +03:00
|
|
|
//
|
|
|
|
// 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 (
|
2016-03-05 23:27:46 +03:00
|
|
|
"strings"
|
2016-01-28 23:08:05 +03:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/coreos/etcd/pkg/fileutil"
|
|
|
|
"github.com/coreos/etcd/pkg/testutil"
|
|
|
|
)
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
func TestCtlV2Set(t *testing.T) { testCtlV2Set(t, &configNoTLS, false) }
|
|
|
|
func TestCtlV2SetQuorum(t *testing.T) { testCtlV2Set(t, &configNoTLS, true) }
|
|
|
|
func TestCtlV2SetClientTLS(t *testing.T) { testCtlV2Set(t, &configClientTLS, false) }
|
|
|
|
func TestCtlV2SetPeerTLS(t *testing.T) { testCtlV2Set(t, &configPeerTLS, false) }
|
|
|
|
func TestCtlV2SetTLS(t *testing.T) { testCtlV2Set(t, &configTLS, false) }
|
|
|
|
func testCtlV2Set(t *testing.T, cfg *etcdProcessClusterConfig, quorum bool) {
|
2016-01-28 23:08:05 +03:00
|
|
|
defer testutil.AfterTest(t)
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
epc := setupEtcdctlTest(t, cfg, quorum)
|
2016-02-01 23:20:53 +03:00
|
|
|
defer func() {
|
|
|
|
if errC := epc.Close(); errC != nil {
|
|
|
|
t.Fatalf("error closing etcd processes (%v)", errC)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
key, value := "foo", "bar"
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
if err := etcdctlSet(epc, key, value); err != nil {
|
2016-02-01 23:20:53 +03:00
|
|
|
t.Fatalf("failed set (%v)", err)
|
2016-01-28 23:08:05 +03:00
|
|
|
}
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
if err := etcdctlGet(epc, key, value, quorum); err != nil {
|
2016-02-01 23:20:53 +03:00
|
|
|
t.Fatalf("failed get (%v)", err)
|
|
|
|
}
|
2016-01-28 23:08:05 +03:00
|
|
|
}
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
func TestCtlV2Mk(t *testing.T) { testCtlV2Mk(t, &configNoTLS, false) }
|
|
|
|
func TestCtlV2MkQuorum(t *testing.T) { testCtlV2Mk(t, &configNoTLS, true) }
|
|
|
|
func TestCtlV2MkTLS(t *testing.T) { testCtlV2Mk(t, &configTLS, false) }
|
|
|
|
func testCtlV2Mk(t *testing.T, cfg *etcdProcessClusterConfig, quorum bool) {
|
2016-02-01 23:20:53 +03:00
|
|
|
defer testutil.AfterTest(t)
|
2016-01-30 03:01:46 +03:00
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
epc := setupEtcdctlTest(t, cfg, quorum)
|
2016-01-30 03:01:46 +03:00
|
|
|
defer func() {
|
|
|
|
if errC := epc.Close(); errC != nil {
|
|
|
|
t.Fatalf("error closing etcd processes (%v)", errC)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
key, value := "foo", "bar"
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
if err := etcdctlMk(epc, key, value, true); err != nil {
|
2016-02-01 23:20:53 +03:00
|
|
|
t.Fatalf("failed mk (%v)", err)
|
|
|
|
}
|
2016-03-06 00:26:02 +03:00
|
|
|
if err := etcdctlMk(epc, key, value, false); err != nil {
|
2016-02-01 23:20:53 +03:00
|
|
|
t.Fatalf("failed mk (%v)", err)
|
2016-01-30 03:01:46 +03:00
|
|
|
}
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
if err := etcdctlGet(epc, key, value, quorum); err != nil {
|
2016-02-01 23:20:53 +03:00
|
|
|
t.Fatalf("failed get (%v)", err)
|
2016-01-30 03:01:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
func TestCtlV2Rm(t *testing.T) { testCtlV2Rm(t, &configNoTLS) }
|
|
|
|
func TestCtlV2RmTLS(t *testing.T) { testCtlV2Rm(t, &configTLS) }
|
|
|
|
func testCtlV2Rm(t *testing.T, cfg *etcdProcessClusterConfig) {
|
2016-01-30 03:01:46 +03:00
|
|
|
defer testutil.AfterTest(t)
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
epc := setupEtcdctlTest(t, cfg, true)
|
2016-01-30 03:01:46 +03:00
|
|
|
defer func() {
|
|
|
|
if errC := epc.Close(); errC != nil {
|
|
|
|
t.Fatalf("error closing etcd processes (%v)", errC)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
key, value := "foo", "bar"
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
if err := etcdctlSet(epc, key, value); err != nil {
|
2016-01-30 03:01:46 +03:00
|
|
|
t.Fatalf("failed set (%v)", err)
|
|
|
|
}
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
if err := etcdctlRm(epc, key, value, true); err != nil {
|
2016-02-01 23:20:53 +03:00
|
|
|
t.Fatalf("failed rm (%v)", err)
|
|
|
|
}
|
2016-03-06 00:26:02 +03:00
|
|
|
if err := etcdctlRm(epc, key, value, false); err != nil {
|
2016-02-01 23:20:53 +03:00
|
|
|
t.Fatalf("failed rm (%v)", err)
|
2016-01-30 03:01:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
func TestCtlV2Ls(t *testing.T) { testCtlV2Ls(t, &configNoTLS, false) }
|
|
|
|
func TestCtlV2LsQuorum(t *testing.T) { testCtlV2Ls(t, &configNoTLS, true) }
|
|
|
|
func TestCtlV2LsTLS(t *testing.T) { testCtlV2Ls(t, &configTLS, false) }
|
|
|
|
func testCtlV2Ls(t *testing.T, cfg *etcdProcessClusterConfig, quorum bool) {
|
2016-01-30 03:01:46 +03:00
|
|
|
defer testutil.AfterTest(t)
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
epc := setupEtcdctlTest(t, cfg, quorum)
|
2016-02-01 23:20:53 +03:00
|
|
|
defer func() {
|
|
|
|
if errC := epc.Close(); errC != nil {
|
|
|
|
t.Fatalf("error closing etcd processes (%v)", errC)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
key, value := "foo", "bar"
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
if err := etcdctlSet(epc, key, value); err != nil {
|
2016-02-01 23:20:53 +03:00
|
|
|
t.Fatalf("failed set (%v)", err)
|
|
|
|
}
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
if err := etcdctlLs(epc, key, quorum); err != nil {
|
2016-02-01 23:20:53 +03:00
|
|
|
t.Fatalf("failed ls (%v)", err)
|
2016-01-28 23:08:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
func TestCtlV2Watch(t *testing.T) { testCtlV2Watch(t, &configNoTLS, false) }
|
|
|
|
func TestCtlV2WatchTLS(t *testing.T) { testCtlV2Watch(t, &configTLS, false) }
|
|
|
|
func TestCtlV2WatchWithProxy(t *testing.T) { testCtlV2Watch(t, &configWithProxy, false) }
|
|
|
|
func TestCtlV2WatchWithProxyNoSync(t *testing.T) { testCtlV2Watch(t, &configWithProxy, true) }
|
2016-02-01 23:20:53 +03:00
|
|
|
func testCtlV2Watch(t *testing.T, cfg *etcdProcessClusterConfig, noSync bool) {
|
|
|
|
defer testutil.AfterTest(t)
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
epc := setupEtcdctlTest(t, cfg, true)
|
2016-01-28 23:08:05 +03:00
|
|
|
defer func() {
|
|
|
|
if errC := epc.Close(); errC != nil {
|
|
|
|
t.Fatalf("error closing etcd processes (%v)", errC)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
key, value := "foo", "bar"
|
2016-02-05 23:26:37 +03:00
|
|
|
errc := etcdctlWatch(epc, key, value, noSync)
|
2016-03-06 00:26:02 +03:00
|
|
|
if err := etcdctlSet(epc, key, value); err != nil {
|
2016-01-28 23:08:05 +03:00
|
|
|
t.Fatalf("failed set (%v)", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
select {
|
2016-02-05 23:26:37 +03:00
|
|
|
case err := <-errc:
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("failed watch (%v)", err)
|
|
|
|
}
|
2016-01-29 10:24:04 +03:00
|
|
|
case <-time.After(5 * time.Second):
|
2016-02-05 23:26:37 +03:00
|
|
|
t.Fatalf("watch timed out")
|
2016-02-01 23:20:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
func TestCtlV2GetRoleUser(t *testing.T) { testCtlV2GetRoleUser(t, &configNoTLS) }
|
|
|
|
func TestCtlV2GetRoleUserWithProxy(t *testing.T) { testCtlV2GetRoleUser(t, &configWithProxy) }
|
2016-03-05 00:48:13 +03:00
|
|
|
func testCtlV2GetRoleUser(t *testing.T, cfg *etcdProcessClusterConfig) {
|
|
|
|
defer testutil.AfterTest(t)
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
epc := setupEtcdctlTest(t, cfg, true)
|
2016-03-05 00:48:13 +03:00
|
|
|
defer func() {
|
|
|
|
if err := epc.Close(); err != nil {
|
|
|
|
t.Fatalf("error closing etcd processes (%v)", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2016-03-05 21:29:52 +03:00
|
|
|
if err := etcdctlRoleAdd(epc, "foo"); err != nil {
|
2016-03-05 00:48:13 +03:00
|
|
|
t.Fatalf("failed to add role (%v)", err)
|
|
|
|
}
|
|
|
|
if err := etcdctlUserAdd(epc, "username", "password"); err != nil {
|
|
|
|
t.Fatalf("failed to add user (%v)", err)
|
|
|
|
}
|
|
|
|
if err := etcdctlUserGrant(epc, "username", "foo"); err != nil {
|
|
|
|
t.Fatalf("failed to grant role (%v)", err)
|
|
|
|
}
|
|
|
|
if err := etcdctlUserGet(epc, "username"); err != nil {
|
|
|
|
t.Fatalf("failed to get user (%v)", err)
|
|
|
|
}
|
2016-04-26 22:28:34 +03:00
|
|
|
|
2016-04-12 20:08:10 +03:00
|
|
|
// ensure double grant gives an error; was crashing in 2.3.1
|
|
|
|
regrantArgs := etcdctlPrefixArgs(epc)
|
|
|
|
regrantArgs = append(regrantArgs, "user", "grant", "--roles", "foo", "username")
|
|
|
|
if err := spawnWithExpect(regrantArgs, "duplicate"); err != nil {
|
|
|
|
t.Fatalf("missing duplicate error on double grant role (%v)", err)
|
|
|
|
}
|
2016-03-05 00:48:13 +03:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:15:06 +03:00
|
|
|
func TestCtlV2UserListUsername(t *testing.T) { testCtlV2UserList(t, "username") }
|
|
|
|
func TestCtlV2UserListRoot(t *testing.T) { testCtlV2UserList(t, "root") }
|
|
|
|
func testCtlV2UserList(t *testing.T, username string) {
|
2016-03-05 21:10:31 +03:00
|
|
|
defer testutil.AfterTest(t)
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
epc := setupEtcdctlTest(t, &configWithProxy, false)
|
2016-03-05 21:10:31 +03:00
|
|
|
defer func() {
|
|
|
|
if err := epc.Close(); err != nil {
|
|
|
|
t.Fatalf("error closing etcd processes (%v)", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2016-04-12 21:15:06 +03:00
|
|
|
if err := etcdctlUserAdd(epc, username, "password"); err != nil {
|
2016-03-05 21:10:31 +03:00
|
|
|
t.Fatalf("failed to add user (%v)", err)
|
|
|
|
}
|
2016-04-12 21:15:06 +03:00
|
|
|
if err := etcdctlUserList(epc, username); err != nil {
|
2016-03-05 21:10:31 +03:00
|
|
|
t.Fatalf("failed to list users (%v)", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-05 21:29:52 +03:00
|
|
|
func TestCtlV2RoleList(t *testing.T) {
|
|
|
|
defer testutil.AfterTest(t)
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
epc := setupEtcdctlTest(t, &configWithProxy, false)
|
2016-03-05 21:29:52 +03:00
|
|
|
defer func() {
|
|
|
|
if err := epc.Close(); err != nil {
|
|
|
|
t.Fatalf("error closing etcd processes (%v)", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
if err := etcdctlRoleAdd(epc, "foo"); err != nil {
|
|
|
|
t.Fatalf("failed to add role (%v)", err)
|
|
|
|
}
|
|
|
|
if err := etcdctlRoleList(epc, "foo"); err != nil {
|
|
|
|
t.Fatalf("failed to list roles (%v)", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
func etcdctlPrefixArgs(clus *etcdProcessCluster) []string {
|
2016-03-05 23:27:46 +03:00
|
|
|
endpoints := ""
|
2016-02-01 23:20:53 +03:00
|
|
|
if proxies := clus.proxies(); len(proxies) != 0 {
|
2016-03-24 01:30:58 +03:00
|
|
|
endpoints = proxies[0].cfg.acurl
|
2016-02-01 23:20:53 +03:00
|
|
|
} else if backends := clus.backends(); len(backends) != 0 {
|
2016-03-05 23:27:46 +03:00
|
|
|
es := []string{}
|
|
|
|
for _, b := range backends {
|
2016-03-24 01:30:58 +03:00
|
|
|
es = append(es, b.cfg.acurl)
|
2016-03-05 23:27:46 +03:00
|
|
|
}
|
|
|
|
endpoints = strings.Join(es, ",")
|
2016-02-01 23:20:53 +03:00
|
|
|
}
|
2016-03-05 23:27:46 +03:00
|
|
|
cmdArgs := []string{"../bin/etcdctl", "--endpoints", endpoints}
|
2016-03-24 01:30:58 +03:00
|
|
|
if clus.cfg.clientTLS == clientTLS {
|
2016-02-01 23:20:53 +03:00
|
|
|
cmdArgs = append(cmdArgs, "--ca-file", caPath, "--cert-file", certPath, "--key-file", privateKeyPath)
|
|
|
|
}
|
|
|
|
return cmdArgs
|
|
|
|
}
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
func etcdctlSet(clus *etcdProcessCluster, key, value string) error {
|
|
|
|
cmdArgs := append(etcdctlPrefixArgs(clus), "set", key, value)
|
2016-03-30 22:17:10 +03:00
|
|
|
return spawnWithExpect(cmdArgs, value)
|
2016-02-01 23:20:53 +03:00
|
|
|
}
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
func etcdctlMk(clus *etcdProcessCluster, key, value string, first bool) error {
|
|
|
|
cmdArgs := append(etcdctlPrefixArgs(clus), "mk", key, value)
|
2016-02-01 23:20:53 +03:00
|
|
|
if first {
|
2016-03-30 22:17:10 +03:00
|
|
|
return spawnWithExpect(cmdArgs, value)
|
2016-02-01 23:20:53 +03:00
|
|
|
}
|
2016-03-30 22:17:10 +03:00
|
|
|
return spawnWithExpect(cmdArgs, "Error: 105: Key already exists")
|
2016-02-01 23:20:53 +03:00
|
|
|
}
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
func etcdctlGet(clus *etcdProcessCluster, key, value string, quorum bool) error {
|
|
|
|
cmdArgs := append(etcdctlPrefixArgs(clus), "get", key)
|
|
|
|
if quorum {
|
|
|
|
cmdArgs = append(cmdArgs, "--quorum")
|
|
|
|
}
|
2016-03-30 22:17:10 +03:00
|
|
|
return spawnWithExpect(cmdArgs, value)
|
2016-02-01 23:20:53 +03:00
|
|
|
}
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
func etcdctlRm(clus *etcdProcessCluster, key, value string, first bool) error {
|
|
|
|
cmdArgs := append(etcdctlPrefixArgs(clus), "rm", key)
|
2016-02-01 23:20:53 +03:00
|
|
|
if first {
|
2016-03-30 22:17:10 +03:00
|
|
|
return spawnWithExpect(cmdArgs, "PrevNode.Value: "+value)
|
2016-02-01 23:20:53 +03:00
|
|
|
}
|
|
|
|
return spawnWithExpect(cmdArgs, "Error: 100: Key not found")
|
|
|
|
}
|
|
|
|
|
2016-03-06 00:26:02 +03:00
|
|
|
func etcdctlLs(clus *etcdProcessCluster, key string, quorum bool) error {
|
|
|
|
cmdArgs := append(etcdctlPrefixArgs(clus), "ls")
|
|
|
|
if quorum {
|
|
|
|
cmdArgs = append(cmdArgs, "--quorum")
|
|
|
|
}
|
2016-02-01 23:20:53 +03:00
|
|
|
return spawnWithExpect(cmdArgs, key)
|
|
|
|
}
|
|
|
|
|
2016-02-05 23:26:37 +03:00
|
|
|
func etcdctlWatch(clus *etcdProcessCluster, key, value string, noSync bool) <-chan error {
|
2016-04-13 10:12:29 +03:00
|
|
|
cmdArgs := append(etcdctlPrefixArgs(clus), "watch", "--after-index=1", key)
|
2016-03-06 00:26:02 +03:00
|
|
|
if noSync {
|
|
|
|
cmdArgs = append(cmdArgs, "--no-sync")
|
|
|
|
}
|
2016-02-05 23:26:37 +03:00
|
|
|
errc := make(chan error, 1)
|
|
|
|
go func() {
|
|
|
|
errc <- spawnWithExpect(cmdArgs, value)
|
|
|
|
}()
|
|
|
|
return errc
|
2016-01-28 23:08:05 +03:00
|
|
|
}
|
2016-03-05 00:48:13 +03:00
|
|
|
|
2016-03-05 21:29:52 +03:00
|
|
|
func etcdctlRoleAdd(clus *etcdProcessCluster, role string) error {
|
2016-03-06 00:26:02 +03:00
|
|
|
cmdArgs := append(etcdctlPrefixArgs(clus), "role", "add", role)
|
2016-03-30 22:17:10 +03:00
|
|
|
return spawnWithExpect(cmdArgs, role)
|
2016-03-05 00:48:13 +03:00
|
|
|
}
|
|
|
|
|
2016-03-05 21:29:52 +03:00
|
|
|
func etcdctlRoleList(clus *etcdProcessCluster, expectedRole string) error {
|
2016-03-06 00:26:02 +03:00
|
|
|
cmdArgs := append(etcdctlPrefixArgs(clus), "role", "list")
|
2016-03-30 22:17:10 +03:00
|
|
|
return spawnWithExpect(cmdArgs, expectedRole)
|
2016-03-05 21:29:52 +03:00
|
|
|
}
|
|
|
|
|
2016-03-05 00:48:13 +03:00
|
|
|
func etcdctlUserAdd(clus *etcdProcessCluster, user, pass string) error {
|
2016-03-06 00:26:02 +03:00
|
|
|
cmdArgs := append(etcdctlPrefixArgs(clus), "user", "add", user+":"+pass)
|
2016-03-30 22:17:10 +03:00
|
|
|
return spawnWithExpect(cmdArgs, "User "+user+" created")
|
2016-03-05 00:48:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func etcdctlUserGrant(clus *etcdProcessCluster, user, role string) error {
|
2016-03-06 00:26:02 +03:00
|
|
|
cmdArgs := append(etcdctlPrefixArgs(clus), "user", "grant", "--roles", role, user)
|
2016-03-30 22:17:10 +03:00
|
|
|
return spawnWithExpect(cmdArgs, "User "+user+" updated")
|
2016-03-05 00:48:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func etcdctlUserGet(clus *etcdProcessCluster, user string) error {
|
2016-03-06 00:26:02 +03:00
|
|
|
cmdArgs := append(etcdctlPrefixArgs(clus), "user", "get", user)
|
2016-03-30 22:17:10 +03:00
|
|
|
return spawnWithExpect(cmdArgs, "User: "+user)
|
2016-03-05 00:48:13 +03:00
|
|
|
}
|
|
|
|
|
2016-03-05 21:10:31 +03:00
|
|
|
func etcdctlUserList(clus *etcdProcessCluster, expectedUser string) error {
|
2016-03-06 00:26:02 +03:00
|
|
|
cmdArgs := append(etcdctlPrefixArgs(clus), "user", "list")
|
2016-03-30 22:17:10 +03:00
|
|
|
return spawnWithExpect(cmdArgs, expectedUser)
|
2016-03-05 21:10:31 +03:00
|
|
|
}
|
|
|
|
|
2016-04-26 22:28:34 +03:00
|
|
|
func etcdctlAuthEnable(clus *etcdProcessCluster) error {
|
|
|
|
cmdArgs := append(etcdctlPrefixArgs(clus), "auth", "enable")
|
|
|
|
return spawnWithExpect(cmdArgs, "Authentication Enabled")
|
|
|
|
}
|
|
|
|
|
2016-03-05 00:48:13 +03:00
|
|
|
func mustEtcdctl(t *testing.T) {
|
|
|
|
if !fileutil.Exist("../bin/etcdctl") {
|
|
|
|
t.Fatalf("could not find etcdctl binary")
|
|
|
|
}
|
|
|
|
}
|
2016-03-06 00:26:02 +03:00
|
|
|
|
|
|
|
func setupEtcdctlTest(t *testing.T, cfg *etcdProcessClusterConfig, quorum bool) *etcdProcessCluster {
|
|
|
|
mustEtcdctl(t)
|
|
|
|
if !quorum {
|
|
|
|
cfg = configStandalone(*cfg)
|
|
|
|
}
|
|
|
|
epc, err := newEtcdProcessCluster(cfg)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("could not start etcd process cluster (%v)", err)
|
|
|
|
}
|
|
|
|
return epc
|
|
|
|
}
|