Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(e2e): run e2e tests in parallel #54

Merged
merged 5 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test:
go test -race ./...

test-e2e:
go test -race -mod=readonly --failfast -timeout=25m -v $(PACKAGES_E2E) -count=1 --tags=e2e
go test -mod=readonly --failfast -timeout=25m -v $(PACKAGES_E2E) -count=1 --parallel 12 --tags=e2e

build-docker:
$(DOCKER) build --tag babylonlabs-io/vigilante -f Dockerfile \
Expand Down
2 changes: 2 additions & 0 deletions e2etest/atomicslasher_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
// TestAtomicSlasher verifies the behavior of the atomic slasher by setting up delegations,
// sending slashing transactions, and ensuring that slashing is detected and executed correctly.
func TestAtomicSlasher(t *testing.T) {
t.Parallel()
// segwit is activated at height 300. It's needed by staking/slashing tx
numMatureOutputs := uint32(300)

Expand Down Expand Up @@ -139,6 +140,7 @@ func TestAtomicSlasher(t *testing.T) {
// TestAtomicSlasher_Unbonding tests the atomic slasher's handling of unbonding BTC delegations,
// including the creation and detection of unbonding slashing transactions.
func TestAtomicSlasher_Unbonding(t *testing.T) {
t.Parallel()
// segwit is activated at height 300. It's needed by staking/slashing tx
numMatureOutputs := uint32(300)

Expand Down
25 changes: 5 additions & 20 deletions e2etest/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,7 @@ func (m *Manager) RunBitcoindResource(
fmt.Sprintf("%s/:/data/.bitcoin", bitcoindCfgPath),
},
ExposedPorts: []string{
"8332",
"8333",
"28332",
"28333",
"18443",
"18444",
"18443/tcp",
},
Cmd: []string{
"-regtest",
Expand All @@ -173,13 +168,9 @@ func (m *Manager) RunBitcoindResource(
},
func(config *docker.HostConfig) {
config.PortBindings = map[docker.Port][]docker.PortBinding{
"8332/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"8333/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"28332/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"28333/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"18443/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"18444/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"18443/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}}, // only expose what we need
}
config.PublishAllPorts = false // because in dockerfile they already expose them
},
noRestart,
)
Expand Down Expand Up @@ -222,20 +213,14 @@ func (m *Manager) RunBabylondResource(
fmt.Sprintf("%s/:/home/", mounthPath),
},
ExposedPorts: []string{
"1317",
"2345",
"9090",
"26656",
"26657",
"9090/tcp", // only expose what we need
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

"26657/tcp",
},
Cmd: cmd,
},
func(config *docker.HostConfig) {
config.PortBindings = map[docker.Port][]docker.PortBinding{
"1317/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"2345/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"9090/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"26656/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
"26657/tcp": {{HostIP: "", HostPort: strconv.Itoa(randomAvailablePort(t))}},
}
},
Expand Down
1 change: 1 addition & 0 deletions e2etest/monitor_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

// TestMonitorBootstrap - validates that after a restart monitor bootstraps from DB
func TestMonitorBootstrap(t *testing.T) {
t.Parallel()
numMatureOutputs := uint32(150)

tm := StartManager(t, numMatureOutputs, 2)
Expand Down
3 changes: 3 additions & 0 deletions e2etest/reporter_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func (tm *TestManager) GenerateAndSubmitBlockNBlockStartingFromDepth(t *testing.
}

func TestReporter_BoostrapUnderFrequentBTCHeaders(t *testing.T) {
t.Parallel()
// no need to much mature outputs, we are not going to submit transactions in this test
numMatureOutputs := uint32(150)

Expand Down Expand Up @@ -117,6 +118,7 @@ func TestReporter_BoostrapUnderFrequentBTCHeaders(t *testing.T) {
}

func TestRelayHeadersAndHandleRollbacks(t *testing.T) {
t.Parallel()
// no need to much mature outputs, we are not going to submit transactions in this test
numMatureOutputs := uint32(150)

Expand Down Expand Up @@ -168,6 +170,7 @@ func TestRelayHeadersAndHandleRollbacks(t *testing.T) {
}

func TestHandleReorgAfterRestart(t *testing.T) {
t.Parallel()
// no need to much mature outputs, we are not going to submit transactions in this test
numMatureOutputs := uint32(150)

Expand Down
4 changes: 4 additions & 0 deletions e2etest/slasher_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
)

func TestSlasher_GracefulShutdown(t *testing.T) {
t.Parallel()
numMatureOutputs := uint32(300)

tm := StartManager(t, numMatureOutputs, defaultEpochInterval)
Expand Down Expand Up @@ -65,6 +66,7 @@ func TestSlasher_GracefulShutdown(t *testing.T) {
}

func TestSlasher_Slasher(t *testing.T) {
t.Parallel()
// segwit is activated at height 300. It's needed by staking/slashing tx
numMatureOutputs := uint32(300)

Expand Down Expand Up @@ -133,6 +135,7 @@ func TestSlasher_Slasher(t *testing.T) {
}

func TestSlasher_SlashingUnbonding(t *testing.T) {
t.Parallel()
// segwit is activated at height 300. It's needed by staking/slashing tx
numMatureOutputs := uint32(300)

Expand Down Expand Up @@ -219,6 +222,7 @@ func TestSlasher_SlashingUnbonding(t *testing.T) {
}

func TestSlasher_Bootstrapping(t *testing.T) {
t.Parallel()
// segwit is activated at height 300. It's needed by staking/slashing tx
numMatureOutputs := uint32(300)

Expand Down
2 changes: 2 additions & 0 deletions e2etest/submitter_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
)

func TestSubmitterSubmission(t *testing.T) {
t.Parallel()
r := rand.New(rand.NewSource(time.Now().Unix()))
numMatureOutputs := uint32(300)

Expand Down Expand Up @@ -97,6 +98,7 @@ func TestSubmitterSubmission(t *testing.T) {
}

func TestSubmitterSubmissionReplace(t *testing.T) {
t.Parallel()
r := rand.New(rand.NewSource(time.Now().Unix()))
numMatureOutputs := uint32(300)

Expand Down
1 change: 0 additions & 1 deletion e2etest/test_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func StartManager(t *testing.T, numMatureOutputsInWallet uint32, epochInterval u
cfg := defaultVigilanteConfig()

cfg.BTC.Endpoint = fmt.Sprintf("127.0.0.1:%s", bitcoind.GetPort("18443/tcp"))
cfg.BTC.ZmqSeqEndpoint = fmt.Sprintf("tcp:// 127.0.0.1:%s", bitcoind.GetPort("28333/tcp"))

testRpcClient, err := rpcclient.New(&rpcclient.ConnConfig{
Host: cfg.BTC.Endpoint,
Expand Down
1 change: 1 addition & 0 deletions e2etest/unbondingwatcher_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
)

func TestUnbondingWatcher(t *testing.T) {
t.Parallel()
// segwit is activated at height 300. It's needed by staking/slashing tx
numMatureOutputs := uint32(300)

Expand Down
Loading