Skip to content

Commit

Permalink
Run integration tests in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Jun 14, 2024
1 parent 71b8272 commit 5e1e7fc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 18 additions & 1 deletion cmd/soroban-rpc/internal/integrationtest/infrastructure/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os/signal"
"path"
"path/filepath"
"regexp"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -50,6 +51,7 @@ type TestConfig struct {
HistoryArchiveURL string
TestPorts *TestPorts
OnlyRPC bool
NoParallel bool
}

type TestPorts struct {
Expand Down Expand Up @@ -143,13 +145,15 @@ func NewTest(t *testing.T, cfg *TestConfig) *Test {
Sequence: 0,
}

parallel := true
sqlLitePath := ""
if cfg != nil {
i.historyArchiveURL = cfg.HistoryArchiveURL
i.rpcContainerVersion = cfg.UseReleasedRPCVersion
i.protocolVersion = cfg.ProtocolVersion
sqlLitePath = cfg.UseSQLitePath
i.onlyRPC = cfg.OnlyRPC
parallel = !cfg.NoParallel
if cfg.TestPorts != nil {
i.testPorts = *cfg.TestPorts
} else {
Expand All @@ -159,6 +163,9 @@ func NewTest(t *testing.T, cfg *TestConfig) *Test {
} else {
i.testPorts = NewTestPorts(t)
}
if parallel {
t.Parallel()
}

if i.protocolVersion == 0 {
// Default to the maximum supported protocol version
Expand Down Expand Up @@ -410,14 +417,24 @@ func (i *Test) createDaemon(env map[string]string) *daemon.Daemon {
return daemon.MustNew(&cfg)
}

var nonAlphanumericRegex = regexp.MustCompile("[^a-zA-Z0-9]+")

func (i *Test) getComposeProjectName() string {
alphanumeric := nonAlphanumericRegex.ReplaceAllString(i.t.Name(), "")
return strings.ToLower(alphanumeric)
}

func (i *Test) getComposeCommand(args ...string) *exec.Cmd {
integrationYaml := filepath.Join(GetCurrentDirectory(), "docker", "docker-compose.yml")
configFiles := []string{"-f", integrationYaml}
if i.runRPCInContainer() {
rpcYaml := filepath.Join(GetCurrentDirectory(), "docker", "docker-compose.rpc.yml")
configFiles = append(configFiles, "-f", rpcYaml)
}
cmdline := append(configFiles, args...)
// Use separate projects to run them in parallel
projectName := i.getComposeProjectName()
cmdline := append([]string{"-p", projectName}, configFiles...)
cmdline = append(cmdline, args...)
cmd := exec.Command("docker-compose", cmdline...)

cmd.Env = os.Environ()
Expand Down
2 changes: 2 additions & 0 deletions cmd/soroban-rpc/internal/integrationtest/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func testMigrateFromVersion(t *testing.T, version string) {
TestPorts: &ports,
OnlyRPC: true,
UseSQLitePath: sqliteFile,
// We don't want to mark the test as parallel twice since it causes a panic
NoParallel: true,
})

// make sure that the transaction submitted before and its events exist in current RPC
Expand Down

0 comments on commit 5e1e7fc

Please sign in to comment.