Skip to content

Commit 2601d92

Browse files
authored
e2e: regex test filter (#1117)
Signed-off-by: Jan Wozniak <wozniak.jan@gmail.com>
1 parent 30b956b commit 2601d92

File tree

2 files changed

+38
-20
lines changed

2 files changed

+38
-20
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ test: fmt vet test-certs
7979
e2e-test:
8080
go run -tags e2e ./tests/run-all.go
8181

82+
e2e-test-setup:
83+
ONLY_SETUP=true go run -tags e2e ./tests/run-all.go
84+
8285
e2e-test-local:
8386
SKIP_SETUP=true go run -tags e2e ./tests/run-all.go
8487

tests/run-all.go

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"os"
1212
"os/exec"
1313
"path/filepath"
14+
"regexp"
1415
"strings"
1516
"sync"
1617
"time"
@@ -37,6 +38,7 @@ type TestResult struct {
3738
func main() {
3839
ctx := context.Background()
3940
skipSetup := os.Getenv("SKIP_SETUP") == "true"
41+
onlySetup := os.Getenv("ONLY_SETUP") == "true"
4042
//
4143
// Install KEDA HTTP Add-on
4244
//
@@ -50,27 +52,29 @@ func main() {
5052
}
5153
}
5254

53-
//
54-
// Execute tests
55-
//
56-
testResults := executeTestCases(ctx)
57-
58-
//
59-
// Uninstall KEDA
60-
//
61-
if !skipSetup {
62-
passed := uninstallKeda(ctx)
63-
if !passed {
64-
os.Exit(1)
55+
if !onlySetup {
56+
//
57+
// Execute tests
58+
//
59+
testResults := executeTestCases(ctx)
60+
61+
//
62+
// Uninstall KEDA
63+
//
64+
if !skipSetup {
65+
passed := uninstallKeda(ctx)
66+
if !passed {
67+
os.Exit(1)
68+
}
6569
}
66-
}
6770

68-
//
69-
// Generate execution outcome
70-
//
71-
exitCode := evaluateExecution(testResults)
71+
//
72+
// Generate execution outcome
73+
//
74+
exitCode := evaluateExecution(testResults)
7275

73-
os.Exit(exitCode)
76+
os.Exit(exitCode)
77+
}
7478
}
7579

7680
func executeTest(ctx context.Context, file string, timeout string, tries int) TestResult {
@@ -102,14 +106,25 @@ func executeTest(ctx context.Context, file string, timeout string, tries int) Te
102106
func getTestFiles() []string {
103107
testFiles := []string{}
104108

105-
err := filepath.Walk("tests",
109+
e2eRegex := os.Getenv("E2E_TEST_REGEX")
110+
if e2eRegex == "" {
111+
e2eRegex = ".*"
112+
}
113+
regex, err := regexp.Compile(e2eRegex)
114+
if err != nil {
115+
fmt.Printf("Error compiling regex: %s\n", err)
116+
os.Exit(1)
117+
}
118+
119+
err = filepath.Walk("tests",
106120
func(path string, info os.FileInfo, err error) error {
107121
if err != nil {
108122
return err
109123
}
110124

111125
if strings.Contains(path, "checks") &&
112-
strings.HasSuffix(info.Name(), "_test.go") {
126+
strings.HasSuffix(info.Name(), "_test.go") &&
127+
regex.MatchString(info.Name()) {
113128
testFiles = append(testFiles, path)
114129
}
115130
return nil

0 commit comments

Comments
 (0)