Skip to content

Commit

Permalink
refactoring the regression test
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Jungblut <tjungblu@redhat.com>
  • Loading branch information
tjungblu committed Sep 7, 2022
1 parent 208d9f9 commit 319968f
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions tests/e2e/ctl_v3_move_leader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,31 @@ import (
"go.etcd.io/etcd/tests/v3/framework/e2e"
)

func TestCtlV3MoveLeaderSecure(t *testing.T) {
testCtlV3MoveLeader(t, *e2e.NewConfigTLS())
}
func TestCtlV3MoveLeaderScenarios(t *testing.T) {
securityParent := map[string]struct {
cfg e2e.EtcdProcessClusterConfig
}{
"Secure": {cfg: *e2e.NewConfigTLS()},
"Insecure": {cfg: *e2e.NewConfigNoTLS()},
}

tests := map[string]struct {
env map[string]string
}{
"happy path": {env: map[string]string{}},
"with env override": {env: map[string]string{"ETCDCTL_ENDPOINTS": "something-else-is-set"}},
}

func TestCtlV3MoveLeaderInsecure(t *testing.T) {
testCtlV3MoveLeader(t, *e2e.NewConfigNoTLS())
for testName, tc := range securityParent {
for subTestName, tx := range tests {
t.Run(testName+" "+subTestName, func(t *testing.T) {
testCtlV3MoveLeader(t, tc.cfg, tx.env)
})
}
}
}

func testCtlV3MoveLeader(t *testing.T, cfg e2e.EtcdProcessClusterConfig) {
func testCtlV3MoveLeader(t *testing.T, cfg e2e.EtcdProcessClusterConfig, envVars map[string]string) {
e2e.BeforeTest(t)

epc := setupEtcdctlTest(t, &cfg, true)
Expand Down Expand Up @@ -90,6 +106,12 @@ func testCtlV3MoveLeader(t *testing.T, cfg e2e.EtcdProcessClusterConfig) {

os.Setenv("ETCDCTL_API", "3")
defer os.Unsetenv("ETCDCTL_API")

for k, v := range envVars {
os.Setenv(k, v)
defer os.Unsetenv(k)
}

cx := ctlCtx{
t: t,
cfg: *e2e.NewConfigNoTLS(),
Expand Down

0 comments on commit 319968f

Please sign in to comment.