mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
tests: Migrate member list tests to common framework
Signed-off-by: Clark <fwyongxing@gmail.com>
This commit is contained in:
parent
a3b410cac7
commit
13d20f8d28
53
tests/common/member_test.go
Normal file
53
tests/common/member_test.go
Normal file
@ -0,0 +1,53 @@
|
||||
// Copyright 2022 The etcd Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go.etcd.io/etcd/tests/v3/framework/testutils"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestMemberList(t *testing.T) {
|
||||
testRunner.BeforeTest(t)
|
||||
|
||||
for _, tc := range clusterTestCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
clus := testRunner.NewCluster(ctx, t, tc.config)
|
||||
defer clus.Close()
|
||||
cc := clus.Client()
|
||||
|
||||
testutils.ExecuteUntil(ctx, t, func() {
|
||||
resp, err := cc.MemberList()
|
||||
if err != nil {
|
||||
t.Fatalf("could not get member list, err: %s", err)
|
||||
}
|
||||
expectNum := len(clus.Members())
|
||||
gotNum := len(resp.Members)
|
||||
if expectNum != gotNum {
|
||||
t.Fatalf("number of members not equal, expect: %d, got: %d", expectNum, gotNum)
|
||||
}
|
||||
for _, m := range resp.Members {
|
||||
if len(m.ClientURLs) == 0 {
|
||||
t.Fatalf("member is not started, memberId:%d, memberName:%s", m.ID, m.Name)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
@ -28,18 +28,6 @@ import (
|
||||
|
||||
func TestCtlV3MemberList(t *testing.T) { testCtl(t, memberListTest) }
|
||||
func TestCtlV3MemberListWithHex(t *testing.T) { testCtl(t, memberListWithHexTest) }
|
||||
func TestCtlV3MemberListNoTLS(t *testing.T) {
|
||||
testCtl(t, memberListTest, withCfg(*e2e.NewConfigNoTLS()))
|
||||
}
|
||||
func TestCtlV3MemberListClientTLS(t *testing.T) {
|
||||
testCtl(t, memberListTest, withCfg(*e2e.NewConfigClientTLS()))
|
||||
}
|
||||
func TestCtlV3MemberListClientAutoTLS(t *testing.T) {
|
||||
testCtl(t, memberListTest, withCfg(*e2e.NewConfigClientAutoTLS()))
|
||||
}
|
||||
func TestCtlV3MemberListPeerTLS(t *testing.T) {
|
||||
testCtl(t, memberListTest, withCfg(*e2e.NewConfigPeerTLS()))
|
||||
}
|
||||
func TestCtlV3MemberRemove(t *testing.T) {
|
||||
testCtl(t, memberRemoveTest, withQuorum(), withNoStrictReconfig())
|
||||
}
|
||||
|
@ -372,3 +372,7 @@ func getOps(ss []string) ([]clientv3.Op, error) {
|
||||
}
|
||||
return ops, nil
|
||||
}
|
||||
|
||||
func (c integrationClient) MemberList() (*clientv3.MemberListResponse, error) {
|
||||
return c.Client.MemberList(c.ctx)
|
||||
}
|
||||
|
@ -70,4 +70,6 @@ type Client interface {
|
||||
RoleDelete(role string) (*clientv3.AuthRoleDeleteResponse, error)
|
||||
|
||||
Txn(compares, ifSucess, ifFail []string, o config.TxnOptions) (*clientv3.TxnResponse, error)
|
||||
|
||||
MemberList() (*clientv3.MemberListResponse, error)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user