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 package main
import ( import (
"fmt"
"io" "io"
"log" "log"
"net"
"os" "os"
"os/exec" "os/exec"
"path" "path"
@ -39,17 +41,35 @@ func crashTest() error {
return err 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 { for {
daemon, err := runDaemon() daemon, err := runDaemon()
if err != nil { if err != nil {
return err return err
} }
if conn != nil {
fmt.Fprintf(conn, "RESTART: %d\n", restartCount)
}
restartCount++
// time.Sleep(5000 * time.Millisecond) // time.Sleep(5000 * time.Millisecond)
var stop bool var stop bool
go func() error { go func() error {
stop = false stop = false
for i := 0; i < 100 && !stop; i++ { for i := 0; i < 100 && !stop; i++ {
func() error { func() error {
if conn != nil {
fmt.Fprintf(conn, "TEST: %d\n", totalTestCount)
}
totalTestCount++
cmd := exec.Command(DOCKER_PATH, "run", "base", "echo", "hello", "world") cmd := exec.Command(DOCKER_PATH, "run", "base", "echo", "hello", "world")
log.Printf("%d", i) log.Printf("%d", i)
outPipe, err := cmd.StdoutPipe() outPipe, err := cmd.StdoutPipe()