Skip to content

Commit

Permalink
Merge pull request spinframework#1507 from lann/improve-go-integratio…
Browse files Browse the repository at this point in the history
…n-test

go: Improve integration test failure
  • Loading branch information
lann authored Aug 15, 2023
2 parents 5d2d037 + 6a94bed commit 1e16d24
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions sdk/go/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ const spinBinary = "../../target/debug/spin"
func retryGet(t *testing.T, url string) *http.Response {
t.Helper()

const maxTries = 120 // (10min/5sec)
const maxTries = 600 // (10min)
for i := 1; i < maxTries; i++ {
// Catch call to `Fail` in other goroutine
if t.Failed() {
t.FailNow()
}
if res, err := http.Get(url); err != nil {
t.Log(err)
} else {
return res
}
time.Sleep(5 * time.Second)
time.Sleep(1 * time.Second)
}
t.Fatal("Get request timeout: ", url)
return nil
Expand All @@ -50,6 +54,15 @@ func startSpin(t *testing.T, spinfile string) *testSpin {
t.Fatal(err)
}

go func() {
cmd.Wait()
if ctx.Err() == nil {
t.Log("spin exited before the test finished:", cmd.ProcessState)
t.Log("stderr:\n", stderr.String())
t.Fail()
}
}()

return &testSpin{
cancel: cancel,
url: fmt.Sprintf("http://%s", url),
Expand Down

0 comments on commit 1e16d24

Please sign in to comment.