Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: run harness tests in parallel #669

Merged
merged 3 commits into from
Jun 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions tests/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"path"
"runtime"
"strings"
"sync"
)

const TESTS_FOLDER = "tests/integration"
Expand All @@ -24,16 +25,27 @@ func main() {
log.Println(len(testNames), " tests to run")
buildFakeTerraformRegistry()
destroyMode := os.Getenv("DESTROY_MODE")

var wg sync.WaitGroup
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing fancy. Running each test inside a go-routine.
Waits for all tests to finish.
If a test fails halts and exits (all tests stop).


for _, testName := range testNames {
if destroyMode == "DESTROY_ONLY" {
terraformDestory(testName)
} else {
success, err := runTest(testName, destroyMode != "NO_DESTROY")
if !success {
log.Fatalln("Halting due to test failure:", err)
wg.Add(1)

go func(testName string) {
if destroyMode == "DESTROY_ONLY" {
terraformDestory(testName)
} else {
success, err := runTest(testName, destroyMode != "NO_DESTROY")
if !success {
log.Fatalln("Halting due to test failure:", err)
}
}
}

wg.Done()
}(testName)
}

wg.Wait()
}
func compileProvider() error {
cmd := exec.Command("go", "build")
Expand Down