Poll server in Go unit tests
This commit is contained in:
parent
0571264d1f
commit
14ab03cb97
1 changed files with 25 additions and 0 deletions
|
@ -1,7 +1,9 @@
|
|||
package integrationtests
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/mattermost-octo-tasks/server/client"
|
||||
"github.com/mattermost/mattermost-octo-tasks/server/server"
|
||||
|
@ -43,6 +45,29 @@ func (th *TestHelper) InitBasic() *TestHelper {
|
|||
}
|
||||
}()
|
||||
|
||||
for {
|
||||
URL := th.Server.Config().ServerRoot
|
||||
log.Printf("Polling server at %v", URL)
|
||||
resp, err := http.Get(URL)
|
||||
if err != nil {
|
||||
log.Println("Polling failed:", err)
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
continue
|
||||
}
|
||||
resp.Body.Close()
|
||||
|
||||
// Currently returns 404
|
||||
// if resp.StatusCode != http.StatusOK {
|
||||
// log.Println("Not OK:", resp.StatusCode)
|
||||
// continue
|
||||
// }
|
||||
|
||||
// Reached this point: server is up and running!
|
||||
log.Println("Server ping OK, statusCode:", resp.StatusCode)
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
return th
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue