add network endpoint for crashTest

This commit is contained in:
Guillaume J. Charmes 2013-04-28 03:54:22 -07:00
parent ebe157ebb5
commit 20c2a4f80f
1 changed files with 20 additions and 0 deletions

View File

@ -1,8 +1,10 @@
package main
import (
"fmt"
"io"
"log"
"net"
"os"
"os/exec"
"path"
@ -39,17 +41,35 @@ func crashTest() error {
return err
}
var endpoint string
if ep := os.Getenv("TEST_ENDPOINT"); ep == "" {
endpoint = "192.168.56.1:7979"
} else {
endpoint = ep
}
conn, _ := net.Dial("tcp", endpoint)
restartCount := 0
totalTestCount := 1
for {
daemon, err := runDaemon()
if err != nil {
return err
}
if conn != nil {
fmt.Fprintf(conn, "RESTART: %d\n", restartCount)
}
restartCount++
// time.Sleep(5000 * time.Millisecond)
var stop bool
go func() error {
stop = false
for i := 0; i < 100 && !stop; i++ {
func() error {
if conn != nil {
fmt.Fprintf(conn, "TEST: %d\n", totalTestCount)
}
totalTestCount++
cmd := exec.Command(DOCKER_PATH, "run", "base", "echo", "hello", "world")
log.Printf("%d", i)
outPipe, err := cmd.StdoutPipe()