1
1
package end2end_carbon
2
2
3
3
import (
4
- "fmt"
5
4
"log"
6
5
"os"
7
6
"os/exec"
@@ -25,7 +24,7 @@ var fm *fakemetrics.FakeMetrics
25
24
const metricsPerSecond = 1000
26
25
27
26
func TestMain (m * testing.M ) {
28
- fmt .Println ("launching docker-dev stack..." )
27
+ log .Println ("launching docker-dev stack..." )
29
28
cmd := exec .Command (docker .Path ("docker/launch.sh" ), "docker-dev" )
30
29
var err error
31
30
@@ -42,19 +41,20 @@ func TestMain(m *testing.M) {
42
41
retcode := m .Run ()
43
42
fm .Close ()
44
43
45
- fmt .Println ("stopping docker-compose stack..." )
44
+ log .Println ("stopping docker-compose stack..." )
46
45
cmd .Process .Signal (syscall .SIGINT )
47
46
// note: even when we don't care about the output, it's best to consume it before calling cmd.Wait()
48
47
// even though the cmd.Wait docs say it will wait for stdout/stderr copying to complete
49
48
// however the docs for cmd.StdoutPipe say "it is incorrect to call Wait before all reads from the pipe have completed"
50
49
tracker .Wait ()
51
- if err := cmd .Wait (); err != nil {
52
- // 130 means ctrl-C (interrupt) which is what we want
53
- if err .Error () == "exit status 130" {
54
- os .Exit (retcode )
55
- }
50
+ err = cmd .Wait ()
51
+
52
+ // 130 means ctrl-C (interrupt) which is what we want
53
+ if err != nil && err .Error () != "exit status 130" {
56
54
log .Printf ("ERROR: could not cleanly shutdown running docker-compose command: %s" , err )
57
55
retcode = 1
56
+ } else {
57
+ log .Println ("docker-compose stack is shut down" )
58
58
}
59
59
60
60
os .Exit (retcode )
@@ -68,8 +68,8 @@ func TestStartup(t *testing.T) {
68
68
}
69
69
select {
70
70
case <- tracker .Match (matchers ):
71
- fmt .Println ("stack now running." )
72
- fmt .Println ("Go to http://localhost:3000 (and login as admin:admin) to see what's going on" )
71
+ log .Println ("stack now running." )
72
+ log .Println ("Go to http://localhost:3000 (and login as admin:admin) to see what's going on" )
73
73
case <- time .After (time .Second * 70 ):
74
74
grafana .PostAnnotation ("TestStartup:FAIL" )
75
75
t .Fatal ("timed out while waiting for all metrictank instances to come up" )
0 commit comments