@@ -27,15 +27,31 @@ import (
2727 "go.etcd.io/etcd/client/v3"
2828)
2929
30- func TestCtlV3MoveLeaderSecure (t * testing.T ) {
31- testCtlV3MoveLeader (t , * newConfigTLS ())
32- }
30+ func TestCtlV3MoveLeaderScenarios (t * testing.T ) {
31+ securityParent := map [string ]struct {
32+ cfg etcdProcessClusterConfig
33+ }{
34+ "Secure" : {cfg : * newConfigTLS ()},
35+ "Insecure" : {cfg : * newConfigNoTLS ()},
36+ }
3337
34- func TestCtlV3MoveLeaderInsecure (t * testing.T ) {
35- testCtlV3MoveLeader (t , * newConfigNoTLS ())
38+ tests := map [string ]struct {
39+ env map [string ]string
40+ }{
41+ "happy path" : {env : map [string ]string {}},
42+ "with env" : {env : map [string ]string {"ETCDCTL_ENDPOINTS" : "something-else-is-set" }},
43+ }
44+
45+ for testName , tc := range securityParent {
46+ for subTestName , tx := range tests {
47+ t .Run (testName + " " + subTestName , func (t * testing.T ) {
48+ testCtlV3MoveLeader (t , tc .cfg , tx .env )
49+ })
50+ }
51+ }
3652}
3753
38- func testCtlV3MoveLeader (t * testing.T , cfg etcdProcessClusterConfig ) {
54+ func testCtlV3MoveLeader (t * testing.T , cfg etcdProcessClusterConfig , envVars map [ string ] string ) {
3955 BeforeTest (t )
4056
4157 epc := setupEtcdctlTest (t , & cfg , true )
@@ -94,6 +110,7 @@ func testCtlV3MoveLeader(t *testing.T, cfg etcdProcessClusterConfig) {
94110 cfg : * newConfigNoTLS (),
95111 dialTimeout : 7 * time .Second ,
96112 epc : epc ,
113+ envMap : envVars ,
97114 }
98115
99116 tests := []struct {
@@ -108,6 +125,10 @@ func testCtlV3MoveLeader(t *testing.T, cfg etcdProcessClusterConfig) {
108125 []string {cx .epc .EndpointsV3 ()[leadIdx ]},
109126 fmt .Sprintf ("Leadership transferred from %s to %s" , types .ID (leaderID ), types .ID (transferee )),
110127 },
128+ { // request to all endpoints
129+ cx .epc .EndpointsV3 (),
130+ fmt .Sprintf ("Leadership transferred" ),
131+ },
111132 }
112133 for i , tc := range tests {
113134 prefix := cx .prefixArgs (tc .eps )
0 commit comments