MCPcopy
hub / github.com/etcd-io/etcd / testClusterUsingDiscovery

Function testClusterUsingDiscovery

tests/e2e/discovery_test.go:43–82  ·  view source on GitHub ↗
(t *testing.T, size int, peerTLS bool)

Source from the content-addressed store, hash-verified

41func TestTLSClusterOf3UsingDiscovery(t *testing.T) { testClusterUsingDiscovery(t, 3, true) }
42
43func testClusterUsingDiscovery(t *testing.T, size int, peerTLS bool) {
44 e2e.BeforeTest(t)
45
46 if !fileutil.Exist(e2e.BinPath.EtcdLastRelease) {
47 t.Skipf("%q does not exist", e2e.BinPath.EtcdLastRelease)
48 }
49
50 dc, err := e2e.NewEtcdProcessCluster(context.TODO(), t,
51 e2e.WithBasePort(2000),
52 e2e.WithVersion(e2e.LastVersion),
53 e2e.WithClusterSize(1),
54 e2e.WithEnableV2(true),
55 )
56 if err != nil {
57 t.Fatalf("could not start etcd process cluster (%v)", err)
58 }
59 defer dc.Close()
60
61 dcc := MustNewHTTPClient(t, dc.EndpointsHTTP(), nil)
62 dkapi := client.NewKeysAPI(dcc)
63 ctx, cancel := context.WithTimeout(context.Background(), integration.RequestTimeout)
64 _, err = dkapi.Create(ctx, "/_config/size", fmt.Sprintf("%d", size))
65 require.NoError(t, err)
66 cancel()
67
68 c, err := e2e.NewEtcdProcessCluster(context.TODO(), t,
69 e2e.WithBasePort(3000),
70 e2e.WithClusterSize(size),
71 e2e.WithIsPeerTLS(peerTLS),
72 e2e.WithDiscovery(dc.EndpointsHTTP()[0]+"/v2/keys"),
73 )
74 if err != nil {
75 t.Fatalf("could not start etcd process cluster (%v)", err)
76 }
77 defer c.Close()
78
79 kubectl := []string{e2e.BinPath.Etcdctl, "--endpoints", strings.Join(c.EndpointsGRPC(), ",")}
80 require.NoError(t, e2e.SpawnWithExpect(append(kubectl, "put", "key", "value"), expect.ExpectedResponse{Value: "OK"}))
81 require.NoError(t, e2e.SpawnWithExpect(append(kubectl, "get", "key"), expect.ExpectedResponse{Value: "value"}))
82}
83
84func MustNewHTTPClient(t testutil.TB, eps []string, tls *transport.TLSInfo) client.Client {
85 cfgtls := transport.TLSInfo{}

Calls 7

CloseMethod · 0.95
EndpointsHTTPMethod · 0.95
CreateMethod · 0.95
EndpointsGRPCMethod · 0.95
MustNewHTTPClientFunction · 0.85
BeforeTestMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…