From 0dc14d1771cbc139f1d7af796f8c84e0662d3e11 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Mon, 3 Oct 2016 11:29:48 -0700 Subject: [PATCH] e2e: test 'https' scheme endpoints --- e2e/ctl_v3_test.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/e2e/ctl_v3_test.go b/e2e/ctl_v3_test.go index b390e1760..d52a5ae8c 100644 --- a/e2e/ctl_v3_test.go +++ b/e2e/ctl_v3_test.go @@ -37,6 +37,18 @@ func ctlV3Version(cx ctlCtx) error { return spawnWithExpect(cmdArgs, version.Version) } +// TestCtlV3DialWithHTTPScheme ensures that client handles endpoints with HTTPS scheme. +func TestCtlV3DialWithHTTPScheme(t *testing.T) { + testCtl(t, dialWithSchemeTest, withCfg(configClientTLS)) +} + +func dialWithSchemeTest(cx ctlCtx) { + cmdArgs := append(cx.prefixArgs(cx.epc.endpoints()), "put", "foo", "bar") + if err := spawnWithExpect(cmdArgs, "OK"); err != nil { + cx.t.Fatal(err) + } +} + type ctlCtx struct { t *testing.T cfg etcdProcessClusterConfig @@ -141,12 +153,12 @@ func testCtl(t *testing.T, testFunc func(ctlCtx), opts ...ctlOption) { } } -func (cx *ctlCtx) PrefixArgs() []string { +func (cx *ctlCtx) prefixArgs(eps []string) []string { if len(cx.epc.proxies()) > 0 { // TODO: add proxy check as in v2 panic("v3 proxy not implemented") } - cmdArgs := []string{ctlBinPath, "--endpoints", strings.Join(cx.epc.grpcEndpoints(), ","), "--dial-timeout", cx.dialTimeout.String()} + cmdArgs := []string{ctlBinPath, "--endpoints", strings.Join(eps, ","), "--dial-timeout", cx.dialTimeout.String()} if cx.epc.cfg.clientTLS == clientTLS { if cx.epc.cfg.isClientAutoTLS { cmdArgs = append(cmdArgs, "--insecure-transport=false", "--insecure-skip-tls-verify") @@ -162,6 +174,10 @@ func (cx *ctlCtx) PrefixArgs() []string { return cmdArgs } +func (cx *ctlCtx) PrefixArgs() []string { + return cx.prefixArgs(cx.epc.grpcEndpoints()) +} + func isGRPCTimedout(err error) bool { return strings.Contains(err.Error(), "grpc: timed out trying to connect") }