Skip to content

Commit

Permalink
fix(e2e): Add again the path filter to ignore non e2e tests during th…
Browse files Browse the repository at this point in the history
…e execution (kedacore#4510)
  • Loading branch information
JorTurFer authored May 2, 2023
1 parent afe2c5e commit b005d9e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pr-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions tests/run-all.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"path/filepath"
"regexp"
"strings"
"sync"
"time"

"golang.org/x/sync/semaphore"
Expand Down Expand Up @@ -78,7 +79,7 @@ func main() {
// Execute secuential tests
//

sequentialTestResults := executeSequentialTests(ctx, regularTestFiles)
sequentialTestResults := executeSequentialTests(ctx, sequentialTestFiles)

//
// Uninstall KEDA
Expand Down Expand Up @@ -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")
}
Expand All @@ -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)
Expand Down Expand Up @@ -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{}

//
Expand All @@ -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)
}

Expand Down

0 comments on commit b005d9e

Please sign in to comment.