Skip to content

Commit

Permalink
Merge pull request etcd-io#16525 from jmhbnz/maintain-testcase-naming…
Browse files Browse the repository at this point in the history
…-standard

Maintain a consistent naming standard for curlv3 tests
  • Loading branch information
ahrtr authored Sep 3, 2023
2 parents 144dcf1 + 7faab4a commit e80c896
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 92 deletions.
6 changes: 3 additions & 3 deletions tests/e2e/v3_cipher_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (
"go.etcd.io/etcd/tests/v3/framework/e2e"
)

func TestV3CurlCipherSuitesValid(t *testing.T) { testV3CurlCipherSuites(t, true) }
func TestV3CurlCipherSuitesMismatch(t *testing.T) { testV3CurlCipherSuites(t, false) }
func testV3CurlCipherSuites(t *testing.T, valid bool) {
func TestCurlV3CipherSuitesValid(t *testing.T) { testCurlV3CipherSuites(t, true) }
func TestCurlV3CipherSuitesMismatch(t *testing.T) { testCurlV3CipherSuites(t, false) }
func testCurlV3CipherSuites(t *testing.T, valid bool) {
cc := e2e.NewConfigClientTLS()
cc.ClusterSize = 1
cc.CipherSuites = []string{
Expand Down
22 changes: 11 additions & 11 deletions tests/e2e/v3_curl_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ import (
"go.etcd.io/etcd/tests/v3/framework/e2e"
)

func TestV3CurlAuth(t *testing.T) {
testCtl(t, testV3CurlAuth)
func TestCurlV3Auth(t *testing.T) {
testCtl(t, testCurlV3Auth)
}
func TestV3CurlAuthClientTLSCertAuth(t *testing.T) {
testCtl(t, testV3CurlAuth, withCfg(*e2e.NewConfigClientTLSCertAuthWithNoCN()))
func TestCurlV3AuthClientTLSCertAuth(t *testing.T) {
testCtl(t, testCurlV3Auth, withCfg(*e2e.NewConfigClientTLSCertAuthWithNoCN()))
}

func testV3CurlAuth(cx ctlCtx) {
func testCurlV3Auth(cx ctlCtx) {
usernames := []string{"root", "nonroot", "nooption"}
pwds := []string{"toor", "pass", "pass"}
options := []*authpb.UserAddOptions{{NoPassword: false}, {NoPassword: false}, nil}
Expand All @@ -51,7 +51,7 @@ func testV3CurlAuth(cx ctlCtx) {
Value: string(user),
Expected: expect.ExpectedResponse{Value: "revision"},
}); err != nil {
cx.t.Fatalf("testV3CurlAuth failed to add user %v (%v)", usernames[i], err)
cx.t.Fatalf("testCurlV3Auth failed to add user %v (%v)", usernames[i], err)
}
}

Expand All @@ -64,7 +64,7 @@ func testV3CurlAuth(cx ctlCtx) {
Value: string(rolereq),
Expected: expect.ExpectedResponse{Value: "revision"},
}); err != nil {
cx.t.Fatalf("testV3CurlAuth failed to create role (%v)", err)
cx.t.Fatalf("testCurlV3Auth failed to create role (%v)", err)
}

//grant root role
Expand All @@ -77,7 +77,7 @@ func testV3CurlAuth(cx ctlCtx) {
Value: string(grantroleroot),
Expected: expect.ExpectedResponse{Value: "revision"},
}); err != nil {
cx.t.Fatalf("testV3CurlAuth failed to grant role (%v)", err)
cx.t.Fatalf("testCurlV3Auth failed to grant role (%v)", err)
}
}

Expand All @@ -87,7 +87,7 @@ func testV3CurlAuth(cx ctlCtx) {
Value: "{}",
Expected: expect.ExpectedResponse{Value: "revision"},
}); err != nil {
cx.t.Fatalf("testV3CurlAuth failed to enable auth (%v)", err)
cx.t.Fatalf("testCurlV3Auth failed to enable auth (%v)", err)
}

for i := 0; i < len(usernames); i++ {
Expand All @@ -101,7 +101,7 @@ func testV3CurlAuth(cx ctlCtx) {
Value: string(putreq),
Expected: expect.ExpectedResponse{Value: "error"},
}); err != nil {
cx.t.Fatalf("testV3CurlAuth failed to put without token (%v)", err)
cx.t.Fatalf("testCurlV3Auth failed to put without token (%v)", err)
}

// auth request
Expand Down Expand Up @@ -141,7 +141,7 @@ func testV3CurlAuth(cx ctlCtx) {
Header: authHeader,
Expected: expect.ExpectedResponse{Value: "revision"},
}); err != nil {
cx.t.Fatalf("testV3CurlAuth failed to auth put with user (%v) (%v)", usernames[i], err)
cx.t.Fatalf("testCurlV3Auth failed to auth put with user (%v) (%v)", usernames[i], err)
}
}
}
4 changes: 2 additions & 2 deletions tests/e2e/v3_curl_kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func testCurlV3KVTxn(cx ctlCtx) {
Value: string(jsonDat),
Expected: expect.ExpectedResponse{Value: expected},
})
require.NoErrorf(cx.t, err, "testV3CurlTxn failed")
require.NoErrorf(cx.t, err, "testCurlV3Txn failed")

// was crashing etcd server
malformed := `{"compare":[{"result":0,"target":1,"key":"Zm9v","TargetUnion":null}],"success":[{"Request":{"RequestPut":{"key":"Zm9v","value":"YmFy"}}}]}`
Expand All @@ -170,7 +170,7 @@ func testCurlV3KVTxn(cx ctlCtx) {
Value: malformed,
Expected: expect.ExpectedResponse{Value: "error"},
})
require.NoErrorf(cx.t, err, "testV3CurlTxn with malformed request failed")
require.NoErrorf(cx.t, err, "testCurlV3Txn with malformed request failed")
}

func testCurlV3KVCompact(cx ctlCtx) {
Expand Down
32 changes: 16 additions & 16 deletions tests/e2e/v3_curl_lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ import (
"go.etcd.io/etcd/tests/v3/framework/e2e"
)

func TestV3CurlLeaseGrantNoTLS(t *testing.T) {
func TestCurlV3LeaseGrantNoTLS(t *testing.T) {
for _, p := range apiPrefix {
testCtl(t, testV3CurlLeaseGrant, withApiPrefix(p), withCfg(*e2e.NewConfigNoTLS()))
testCtl(t, testCurlV3LeaseGrant, withApiPrefix(p), withCfg(*e2e.NewConfigNoTLS()))
}
}
func TestV3CurlLeaseRevokeNoTLS(t *testing.T) {
func TestCurlV3LeaseRevokeNoTLS(t *testing.T) {
for _, p := range apiPrefix {
testCtl(t, testV3CurlLeaseRevoke, withApiPrefix(p), withCfg(*e2e.NewConfigNoTLS()))
testCtl(t, testCurlV3LeaseRevoke, withApiPrefix(p), withCfg(*e2e.NewConfigNoTLS()))
}
}
func TestV3CurlLeaseLeasesNoTLS(t *testing.T) {
func TestCurlV3LeaseLeasesNoTLS(t *testing.T) {
for _, p := range apiPrefix {
testCtl(t, testV3CurlLeaseLeases, withApiPrefix(p), withCfg(*e2e.NewConfigNoTLS()))
testCtl(t, testCurlV3LeaseLeases, withApiPrefix(p), withCfg(*e2e.NewConfigNoTLS()))
}
}
func TestV3CurlLeaseKeepAliveNoTLS(t *testing.T) {
func TestCurlV3LeaseKeepAliveNoTLS(t *testing.T) {
for _, p := range apiPrefix {
testCtl(t, testV3CurlLeaseKeepAlive, withApiPrefix(p), withCfg(*e2e.NewConfigNoTLS()))
testCtl(t, testCurlV3LeaseKeepAlive, withApiPrefix(p), withCfg(*e2e.NewConfigNoTLS()))
}
}

Expand All @@ -49,7 +49,7 @@ type v3cURLTest struct {
expected string
}

func testV3CurlLeaseGrant(cx ctlCtx) {
func testCurlV3LeaseGrant(cx ctlCtx) {
leaseID := e2e.RandomLeaseID()

tests := []v3cURLTest{
Expand All @@ -75,11 +75,11 @@ func testV3CurlLeaseGrant(cx ctlCtx) {
},
}
if err := CURLWithExpected(cx, tests); err != nil {
cx.t.Fatalf("testV3CurlLeaseGrant: %v", err)
cx.t.Fatalf("testCurlV3LeaseGrant: %v", err)
}
}

func testV3CurlLeaseRevoke(cx ctlCtx) {
func testCurlV3LeaseRevoke(cx ctlCtx) {
leaseID := e2e.RandomLeaseID()

tests := []v3cURLTest{
Expand All @@ -95,11 +95,11 @@ func testV3CurlLeaseRevoke(cx ctlCtx) {
},
}
if err := CURLWithExpected(cx, tests); err != nil {
cx.t.Fatalf("testV3CurlLeaseRevoke: %v", err)
cx.t.Fatalf("testCurlV3LeaseRevoke: %v", err)
}
}

func testV3CurlLeaseLeases(cx ctlCtx) {
func testCurlV3LeaseLeases(cx ctlCtx) {
leaseID := e2e.RandomLeaseID()

tests := []v3cURLTest{
Expand All @@ -115,11 +115,11 @@ func testV3CurlLeaseLeases(cx ctlCtx) {
},
}
if err := CURLWithExpected(cx, tests); err != nil {
cx.t.Fatalf("testV3CurlLeaseGrant: %v", err)
cx.t.Fatalf("testCurlV3LeaseGrant: %v", err)
}
}

func testV3CurlLeaseKeepAlive(cx ctlCtx) {
func testCurlV3LeaseKeepAlive(cx ctlCtx) {
leaseID := e2e.RandomLeaseID()

tests := []v3cURLTest{
Expand All @@ -135,7 +135,7 @@ func testV3CurlLeaseKeepAlive(cx ctlCtx) {
},
}
if err := CURLWithExpected(cx, tests); err != nil {
cx.t.Fatalf("testV3CurlLeaseGrant: %v", err)
cx.t.Fatalf("testCurlV3LeaseGrant: %v", err)
}
}

Expand Down
48 changes: 24 additions & 24 deletions tests/e2e/v3_curl_maintenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import (
"go.etcd.io/etcd/tests/v3/framework/e2e"
)

func TestV3CurlMaintenanceAlarmMissiongAlarm(t *testing.T) {
func TestCurlV3MaintenanceAlarmMissiongAlarm(t *testing.T) {
for _, p := range apiPrefix {
testCtl(t, testV3CurlMaintenanceAlarmMissiongAlarm, withApiPrefix(p), withCfg(*e2e.NewConfigNoTLS()))
testCtl(t, testCurlV3MaintenanceAlarmMissiongAlarm, withApiPrefix(p), withCfg(*e2e.NewConfigNoTLS()))
}
}

func testV3CurlMaintenanceAlarmMissiongAlarm(cx ctlCtx) {
func testCurlV3MaintenanceAlarmMissiongAlarm(cx ctlCtx) {
if err := e2e.CURLPost(cx.epc, e2e.CURLReq{
Endpoint: path.Join(cx.apiPrefix, "/maintenance/alarm"),
Value: `{"action": "ACTIVATE"}`,
Expand All @@ -41,11 +41,11 @@ func testV3CurlMaintenanceAlarmMissiongAlarm(cx ctlCtx) {
}
}

func TestV3CurlMaintenanceStatus(t *testing.T) {
testCtl(t, testV3CurlMaintenanceStatus, withCfg(*e2e.NewConfigNoTLS()))
func TestCurlV3MaintenanceStatus(t *testing.T) {
testCtl(t, testCurlV3MaintenanceStatus, withCfg(*e2e.NewConfigNoTLS()))
}

func testV3CurlMaintenanceStatus(cx ctlCtx) {
func testCurlV3MaintenanceStatus(cx ctlCtx) {
clus := cx.epc
args := e2e.CURLPrefixArgsCluster(clus.Cfg, clus.Procs[rand.Intn(clus.Cfg.ClusterSize)], "POST", e2e.CURLReq{
Endpoint: "/v3/maintenance/status",
Expand All @@ -65,11 +65,11 @@ func testV3CurlMaintenanceStatus(cx ctlCtx) {
require.Equal(cx.t, version.Version, actualVersion)
}

func TestV3CurlMaintenanceDefragment(t *testing.T) {
testCtl(t, testV3CurlMaintenanceDefragment, withCfg(*e2e.NewConfigNoTLS()))
func TestCurlV3MaintenanceDefragment(t *testing.T) {
testCtl(t, testCurlV3MaintenanceDefragment, withCfg(*e2e.NewConfigNoTLS()))
}

func testV3CurlMaintenanceDefragment(cx ctlCtx) {
func testCurlV3MaintenanceDefragment(cx ctlCtx) {
if err := e2e.CURLPost(cx.epc, e2e.CURLReq{
Endpoint: "/v3/maintenance/defragment",
Value: "{}",
Expand All @@ -81,11 +81,11 @@ func testV3CurlMaintenanceDefragment(cx ctlCtx) {
}
}

func TestV3CurlMaintenanceHash(t *testing.T) {
testCtl(t, testV3CurlMaintenanceHash, withCfg(*e2e.NewConfigNoTLS()))
func TestCurlV3MaintenanceHash(t *testing.T) {
testCtl(t, testCurlV3MaintenanceHash, withCfg(*e2e.NewConfigNoTLS()))
}

func testV3CurlMaintenanceHash(cx ctlCtx) {
func testCurlV3MaintenanceHash(cx ctlCtx) {
clus := cx.epc
args := e2e.CURLPrefixArgsCluster(clus.Cfg, clus.Procs[rand.Intn(clus.Cfg.ClusterSize)], "POST", e2e.CURLReq{
Endpoint: "/v3/maintenance/hash",
Expand All @@ -102,11 +102,11 @@ func testV3CurlMaintenanceHash(cx ctlCtx) {
}
}

func TestV3CurlMaintenanceHashKV(t *testing.T) {
testCtl(t, testV3CurlMaintenanceHashKV, withCfg(*e2e.NewConfigNoTLS()))
func TestCurlV3MaintenanceHashKV(t *testing.T) {
testCtl(t, testCurlV3MaintenanceHashKV, withCfg(*e2e.NewConfigNoTLS()))
}

func testV3CurlMaintenanceHashKV(cx ctlCtx) {
func testCurlV3MaintenanceHashKV(cx ctlCtx) {
clus := cx.epc
args := e2e.CURLPrefixArgsCluster(clus.Cfg, clus.Procs[rand.Intn(clus.Cfg.ClusterSize)], "POST", e2e.CURLReq{
Endpoint: "/v3/maintenance/hashkv",
Expand All @@ -123,11 +123,11 @@ func testV3CurlMaintenanceHashKV(cx ctlCtx) {
}
}

func TestV3CurlMaintenanceSnapshot(t *testing.T) {
testCtl(t, testV3CurlMaintenanceSnapshot, withCfg(*e2e.NewConfigNoTLS()))
func TestCurlV3MaintenanceSnapshot(t *testing.T) {
testCtl(t, testCurlV3MaintenanceSnapshot, withCfg(*e2e.NewConfigNoTLS()))
}

func testV3CurlMaintenanceSnapshot(cx ctlCtx) {
func testCurlV3MaintenanceSnapshot(cx ctlCtx) {
if err := e2e.CURLPost(cx.epc, e2e.CURLReq{
Endpoint: "/v3/maintenance/snapshot",
Value: "{}",
Expand All @@ -139,11 +139,11 @@ func testV3CurlMaintenanceSnapshot(cx ctlCtx) {
}
}

func TestV3CurlMaintenanceMoveleader(t *testing.T) {
testCtl(t, testV3CurlMaintenanceMoveleader, withCfg(*e2e.NewConfigNoTLS()))
func TestCurlV3MaintenanceMoveleader(t *testing.T) {
testCtl(t, testCurlV3MaintenanceMoveleader, withCfg(*e2e.NewConfigNoTLS()))
}

func testV3CurlMaintenanceMoveleader(cx ctlCtx) {
func testCurlV3MaintenanceMoveleader(cx ctlCtx) {
if err := e2e.CURLPost(cx.epc, e2e.CURLReq{
Endpoint: "/v3/maintenance/transfer-leadership",
Value: `{"targetID": 123}`,
Expand All @@ -155,11 +155,11 @@ func testV3CurlMaintenanceMoveleader(cx ctlCtx) {
}
}

func TestV3CurlMaintenanceDowngrade(t *testing.T) {
testCtl(t, testV3CurlMaintenanceDowngrade, withCfg(*e2e.NewConfigNoTLS()))
func TestCurlV3MaintenanceDowngrade(t *testing.T) {
testCtl(t, testCurlV3MaintenanceDowngrade, withCfg(*e2e.NewConfigNoTLS()))
}

func testV3CurlMaintenanceDowngrade(cx ctlCtx) {
func testCurlV3MaintenanceDowngrade(cx ctlCtx) {
if err := e2e.CURLPost(cx.epc, e2e.CURLReq{
Endpoint: "/v3/maintenance/downgrade",
Value: `{"action": 0, "version": "3.0"}`,
Expand Down
Loading

0 comments on commit e80c896

Please sign in to comment.