Skip to content

Commit

Permalink
Run Member{Add,Remove} 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: etcd-io#18983
Signed-off-by: Aleksander Mistewicz <[email protected]>
  • Loading branch information
AwesomePatrol committed Dec 10, 2024
1 parent 39d9cd7 commit bda32aa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 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 = 20000

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

0 comments on commit bda32aa

Please sign in to comment.