Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3103 from oasisprotocol/tjanez/oasis-test-runner-…
Browse files Browse the repository at this point in the history
…limit-regex

go/oasis-test-runner/cmd: Limit scenario name regex matching
tjanez authored and ptrus committed Jul 14, 2020

Verified

This commit was signed with the committer’s verified signature.
ptrus Peter Us
2 parents db0c32b + fecdd17 commit 4d61fbf
Showing 4 changed files with 22 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .buildkite/longtests.pipeline.yml
Original file line number Diff line number Diff line change
@@ -27,6 +27,9 @@ docker_plugin_default_config: &docker_plugin_default_config
- "CARGO_INSTALL_ROOT=/root/.cargo"
- "GOPROXY=https://proxy.golang.org/"
- "SLACK_WEBHOOK_URL"
- "METRICS_PUSH_ADDR"
- "BUILDKITE_PIPELINE_NAME"
- "BUILDKITE_BUILD_NUMBER"
propagate-environment: true
unconfined: true

5 changes: 4 additions & 1 deletion .buildkite/scripts/daily_txsource.sh
Original file line number Diff line number Diff line change
@@ -6,7 +6,10 @@ set -euxo pipefail

if [[ $BUILDKITE_RETRY_COUNT == 0 ]]; then
rm -rf /var/tmp/longtests/*
./.buildkite/scripts/test_e2e.sh -t e2e/runtime/txsource-multi
./.buildkite/scripts/test_e2e.sh \
--metrics.address $METRICS_PUSH_ADDR \
--metrics.labels instance=$BUILDKITE_PIPELINE_NAME-$BUILDKITE_BUILD_NUMBER \
--test e2e/runtime/txsource-multi
else
curl -H "Content-Type: application/json" \
-X POST \
5 changes: 5 additions & 0 deletions .changelog/3103.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
go/oasis-test-runner/cmd: Limit scenario name regex matching

Prevent oasis-test-runner to match too many scenarios for a given
scenario name regex by ensuring the given scenario name regex matches
the whole scenario name.
18 changes: 10 additions & 8 deletions go/oasis-test-runner/cmd/root.go
Original file line number Diff line number Diff line change
@@ -271,15 +271,17 @@ func runRoot(cmd *cobra.Command, args []string) error {

// Enumerate requested scenarios.
toRun := common.GetDefaultScenarios() // Run all default scenarios if not set.
if vec := viper.GetStringSlice(common.CfgTest); len(vec) > 0 {
if scNameRegexes := viper.GetStringSlice(common.CfgTest); len(scNameRegexes) > 0 {
matched := make(map[scenario.Scenario]bool)
for _, v := range vec {
name := strings.ToLower(v)
for _, scNameRegex := range scNameRegexes {
// Make sure the given scenario name regex matches the whole scenario name, not just
// a substring.
regex := fmt.Sprintf("^%s$", scNameRegex)

var anyMatched bool
for scName, scenario := range common.GetScenarios() {
var match bool
match, err = regexp.MatchString(name, scName)
match, err = regexp.MatchString(regex, scName)
if err != nil {
return fmt.Errorf("root: bad scenario name regexp: %w", err)
}
@@ -289,11 +291,11 @@ func runRoot(cmd *cobra.Command, args []string) error {
}
}
if !anyMatched {
logger.Error("unknown scenario",
"scenario", name,
logger.Error("no scenario matches regex",
"scenario_regex", scNameRegex,
)
return fmt.Errorf("root: unknown scenario: %s\nAvailable scenarios:\n%s",
name, strings.Join(common.GetScenarioNames(), "\n"),
return fmt.Errorf("root: no scenario matches regex: %s\nAvailable scenarios:\n%s",
scNameRegex, strings.Join(common.GetScenarioNames(), "\n"),
)
}
}

0 comments on commit 4d61fbf

Please sign in to comment.