From b005d9ee3a0c5bb9f1cbcabf1ffe259003337753 Mon Sep 17 00:00:00 2001 From: Jorge Turrado Ferrero Date: Tue, 2 May 2023 17:06:25 +0200 Subject: [PATCH] fix(e2e): Add again the path filter to ignore non e2e tests during the execution (#4510) --- .github/workflows/pr-e2e.yml | 2 ++ tests/run-all.go | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr-e2e.yml b/.github/workflows/pr-e2e.yml index fa06a83d6cd..06b3d1d92e6 100644 --- a/.github/workflows/pr-e2e.yml +++ b/.github/workflows/pr-e2e.yml @@ -130,6 +130,7 @@ jobs: run: make scale-node-pool env: NODE_POOL_SIZE: 4 + TEST_CLUSTER_NAME: keda-pr-run - name: Run end to end tests continue-on-error: true @@ -162,6 +163,7 @@ jobs: run: make scale-node-pool env: NODE_POOL_SIZE: 1 + TEST_CLUSTER_NAME: keda-pr-run - name: React to comment with success uses: dkershner6/reaction-action@v1 diff --git a/tests/run-all.go b/tests/run-all.go index ff637ff45d9..d7d9e4eae61 100644 --- a/tests/run-all.go +++ b/tests/run-all.go @@ -14,6 +14,7 @@ import ( "path/filepath" "regexp" "strings" + "sync" "time" "golang.org/x/sync/semaphore" @@ -78,7 +79,7 @@ func main() { // Execute secuential tests // - sequentialTestResults := executeSequentialTests(ctx, regularTestFiles) + sequentialTestResults := executeSequentialTests(ctx, sequentialTestFiles) // // Uninstall KEDA @@ -129,7 +130,8 @@ func executeTest(ctx context.Context, file string, timeout string, tries int) Te func getRegularTestFiles(e2eRegex string) []string { // We exclude utils and sequential folders and helper files filter := func(path string, file string) bool { - return strings.Contains(path, "utils") || + return !strings.HasPrefix(path, "tests") || // we need this condition to skip non e2e test from execution + strings.Contains(path, "utils") || strings.Contains(path, "sequential") || !strings.HasSuffix(file, "_test.go") } @@ -138,7 +140,8 @@ func getRegularTestFiles(e2eRegex string) []string { func getSequentialTestFiles(e2eRegex string) []string { filter := func(path string, file string) bool { - return !strings.Contains(path, "sequential") || + return !strings.HasPrefix(path, "tests") || // we need this condition to skip non e2e test from execution + !strings.Contains(path, "sequential") || !strings.HasSuffix(file, "_test.go") } return getTestFiles(e2eRegex, filter) @@ -183,6 +186,7 @@ func getTestFiles(e2eRegex string, filter func(path string, file string) bool) [ func executeRegularTests(ctx context.Context, testCases []string) []TestResult { sem := semaphore.NewWeighted(int64(concurrentTests)) + mutex := &sync.RWMutex{} testResults := []TestResult{} // @@ -198,7 +202,9 @@ func executeRegularTests(ctx context.Context, testCases []string) []TestResult { go func(file string) { defer sem.Release(1) testExecution := executeTest(ctx, file, regularTestsTimeout, regularTestsRetries) + mutex.Lock() testResults = append(testResults, testExecution) + mutex.Unlock() }(testFile) }