Skip to content

Commit

Permalink
Run Member tests in parallel
Browse files Browse the repository at this point in the history
On my local machine it brings down execution time from 5m to 32s.

Issue: #18983
Signed-off-by: Aleksander Mistewicz <[email protected]>
  • Loading branch information
AwesomePatrol committed Dec 11, 2024
1 parent 39d9cd7 commit 879c0f0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions tests/common/member_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func TestMemberList(t *testing.T) {

for _, tc := range clusterTestCases() {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
clus := testRunner.NewCluster(ctx, t, config.WithClusterConfig(tc.config))
Expand Down Expand Up @@ -113,6 +115,8 @@ func TestMemberAdd(t *testing.T) {
for _, quorumTc := range quorumTcs {
for _, clusterTc := range clusterTestCases() {
t.Run(learnerTc.name+"/"+quorumTc.name+"/"+clusterTc.name, func(t *testing.T) {
t.Parallel()

ctxTimeout := 10 * time.Second
if quorumTc.waitForQuorum {
ctxTimeout += etcdserver.HealthInterval
Expand Down Expand Up @@ -198,6 +202,8 @@ func TestMemberRemove(t *testing.T) {
continue
}
t.Run(quorumTc.name+"/"+clusterTc.name, func(t *testing.T) {
t.Parallel()

ctx, cancel := context.WithTimeout(context.Background(), 14*time.Second)
defer cancel()
c := clusterTc.config
Expand Down
4 changes: 4 additions & 0 deletions tests/framework/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ package e2e
import (
"context"
"os"
"sync/atomic"
"testing"

"go.etcd.io/etcd/client/pkg/v3/testutil"
"go.etcd.io/etcd/tests/v3/framework/config"
intf "go.etcd.io/etcd/tests/v3/framework/interfaces"
)

var uniqueCount int32

type e2eRunner struct{}

func NewE2eRunner() intf.TestRunner {
Expand Down Expand Up @@ -83,6 +86,7 @@ func (e e2eRunner) NewCluster(ctx context.Context, t testing.TB, opts ...config.
default:
t.Fatalf("PeerTLS config %q not supported", cfg.PeerTLS)
}
e2eConfig.BasePort = 11000 + int(atomic.AddInt32(&uniqueCount, int32(cfg.ClusterSize+2)*5)%8000)
epc, err := NewEtcdProcessCluster(ctx, t, WithConfig(e2eConfig))
if err != nil {
t.Fatalf("could not start etcd integrationCluster: %s", err)
Expand Down
10 changes: 3 additions & 7 deletions tests/framework/integration/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,12 @@ func (c *Cluster) ProtoMembers() []*pb.Member {
}

func (c *Cluster) mustNewMember(t testutil.TB) *Member {
memberNumber := c.LastMemberNum
uniqueNumber := atomic.AddInt32(&UniqueNumber, 1)*10 + int32(c.LastMemberNum)
c.LastMemberNum++

m := MustNewMember(t,
MemberConfig{
Name: fmt.Sprintf("m%v", memberNumber),
MemberNumber: memberNumber,
Name: fmt.Sprintf("m%v", uniqueNumber),
AuthToken: c.Cfg.AuthToken,
PeerTLS: c.Cfg.PeerTLS,
ClientTLS: c.Cfg.ClientTLS,
Expand Down Expand Up @@ -549,7 +548,6 @@ func NewListenerWithAddr(t testutil.TB, addr string) net.Listener {
type Member struct {
config.ServerConfig
UniqNumber int
MemberNumber int
Port string
PeerListeners, ClientListeners []net.Listener
GRPCListener net.Listener
Expand Down Expand Up @@ -591,7 +589,6 @@ type Member struct {
type MemberConfig struct {
Name string
UniqNumber int64
MemberNumber int
PeerTLS *transport.TLSInfo
ClientTLS *transport.TLSInfo
AuthToken string
Expand Down Expand Up @@ -624,8 +621,7 @@ type MemberConfig struct {
func MustNewMember(t testutil.TB, mcfg MemberConfig) *Member {
var err error
m := &Member{
MemberNumber: mcfg.MemberNumber,
UniqNumber: int(atomic.AddInt32(&UniqueCount, 1)),
UniqNumber: int(atomic.AddInt32(&UniqueCount, 1)),
}

peerScheme := SchemeFromTLSInfo(mcfg.PeerTLS)
Expand Down

0 comments on commit 879c0f0

Please sign in to comment.