Skip to content

Commit

Permalink
Merge pull request #3107 from oasisprotocol/tjanez/test-runner-parall…
Browse files Browse the repository at this point in the history
…el-bug

go/oasis-test-runner/cmd: Sort scenarios for correct parallel execution
  • Loading branch information
tjanez authored Jul 14, 2020
2 parents f51688e + 4e244df commit e48871e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions .changelog/3104.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/oasis-test-runner/cmd: Sort scenarios for correct parallel execution
12 changes: 11 additions & 1 deletion go/oasis-test-runner/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,26 @@ func runRoot(cmd *cobra.Command, args []string) error {
}
}

// Sort requested scenarios to enable consistent partitioning for parallel
// job execution.
sort.Slice(toRun, func(i, j int) bool { return toRun[i].Name() < toRun[j].Name() })

excludeMap := make(map[string]bool)
if excludeEnv := os.Getenv("OASIS_EXCLUDE_E2E"); excludeEnv != "" {
for _, v := range strings.Split(excludeEnv, ",") {
excludeMap[strings.ToLower(v)] = true
}
}

// Run the required test scenarios.
// Get parallel job execution parameters.
parallelJobCount := viper.GetInt(cfgParallelJobCount)
parallelJobIndex := viper.GetInt(cfgParallelJobIndex)
if parallelJobIndex < 0 || parallelJobIndex >= parallelJobCount {
return fmt.Errorf(
"root: invalid value of %s flag: %d (should be in range [0, %d))",
cfgParallelJobIndex, parallelJobIndex, parallelJobCount,
)
}

// Parse test parameters passed by CLI.
var toRunExploded map[string][]scenario.Scenario
Expand Down

0 comments on commit e48871e

Please sign in to comment.