diff options
Diffstat (limited to 'test/xdsserver_test.go')
-rw-r--r-- | test/xdsserver_test.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/test/xdsserver_test.go b/test/xdsserver_test.go index ba56321..b8e98b5 100644 --- a/test/xdsserver_test.go +++ b/test/xdsserver_test.go @@ -69,12 +69,14 @@ func Copy(src, dst string) error { func initEnv(launchProcess bool) { if launchProcess { + /*kill xds-server if needed*/ cmd := exec.Command("killall", "-9", "xds-server") if err := cmd.Start(); err != nil { log.Fatal(err) } cmd.Wait() } + /*set environment variable*/ rootTestLog := "/tmp/xds-server-test" if err := os.Setenv(envRootCfgDir, rootTestLog); err != nil { log.Fatal(err) @@ -92,12 +94,14 @@ func initEnv(launchProcess bool) { if err := os.Setenv("XDS_LOG_SILLY", "1"); err != nil { log.Fatal(err) } + /*remove and recreate working directories*/ os.RemoveAll(rootTestLog) os.MkdirAll(rootTestLog, 0755) logDir = rootTestLog + "/logs/" os.MkdirAll(logDir, 0755) } +/*prepare xds-server process*/ func launchXdsServer(proc **os.Process) *os.File { logFile := logDir + logFileXdsServer file, err := os.OpenFile(logFile, os.O_CREATE|os.O_WRONLY, 0644) @@ -142,7 +146,6 @@ func getHTTPClient(lvl int) (*common.HTTPClient, *os.File) { } func NewIoSocketClient(url, clientID string) (*IOSockClient, error) { - var err error sCli := &IOSockClient{ @@ -152,7 +155,6 @@ func NewIoSocketClient(url, clientID string) (*IOSockClient, error) { Transport: "websocket", Header: make(map[string][]string), }, - //ServerDiscoChan: make(chan Disconnection, 1), } sCli.Options.Header["XDS-SID"] = []string{clientID} @@ -174,6 +176,8 @@ func NewIoSocketClient(url, clientID string) (*IOSockClient, error) { return sCli, nil } func TestMain(m *testing.M) { + /* useful for debugging, preventing from launching xds-server + * it can be launch separetly */ launchProcess := true log.Printf("TestMain: launchProcess is %v, so launching xds-server", launchProcess) initEnv(launchProcess) @@ -183,6 +187,7 @@ func TestMain(m *testing.M) { if launchProcess { fileXdsServer = launchXdsServer(&proc) go func(p *os.Process) { + log.Print("xds-server is launching") if status, err := p.Wait(); err != nil { log.Fatalf("status=%v\n err=%v\n", status, err) } @@ -208,6 +213,3 @@ func TestMain(m *testing.M) { res := m.Run() defer os.Exit(res) } - -func init() { -} |