@@ -82,25 +82,42 @@ func GetGlobalConfig() *DeisTestConfig {
8282 return & envCfg
8383}
8484
85+ func doCurl (url string ) ([]byte , error ) {
86+ response , err := http .Get (url )
87+ if err != nil {
88+ return nil , err
89+ }
90+
91+ body , err := ioutil .ReadAll (response .Body )
92+
93+ if ! strings .Contains (string (body ), "Powered by Deis" ) {
94+ return nil , fmt .Errorf ("App not started" )
95+ }
96+
97+ return body , nil
98+ }
99+
85100// Curl connects to a Deis endpoint to see if the example app is running.
86101func Curl (t * testing.T , params * DeisTestConfig ) {
87102 url := "http://" + params .AppName + "." + params .Domain
88- // FIXME: make an initial request to nginx to remove stale worker
89- _ , err := http .Get (url )
90- if err != nil {
91- t .Fatalf ("not reachable:\n %v" , err )
103+
104+ // FIXME: try the curl a few times
105+ for i := 0 ; i < 20 ; i ++ {
106+ body , err := doCurl (url )
107+ if err == nil {
108+ fmt .Println (string (body ))
109+ return
110+ }
111+ time .Sleep (1 * time .Second )
92112 }
93- // FIXME: sleep a bit before curling
94- time . Sleep ( 5000 * time . Millisecond )
95- response , err := http . Get (url )
113+
114+ // once more to fail with an error
115+ body , err := doCurl (url )
96116 if err != nil {
97- t .Fatalf ( "not reachable: \n %v" , err )
117+ t .Fatal ( err )
98118 }
99- body , err := ioutil .ReadAll (response .Body )
100119 fmt .Println (string (body ))
101- if ! strings .Contains (string (body ), "Powered by Deis" ) {
102- t .Fatalf ("App not started" )
103- }
120+
104121}
105122
106123// AuthCancel tests whether `deis auth:cancel` destroys a user's account.
0 commit comments