13647: Use cluster config instead of custom keepstore config.
[arvados.git] / sdk / go / arvadostest / run_servers.go
index 7edc482639e585effa23629552fd3a1bea216be8..5b01db5c4bbda594fe1c5fc5353a47bf2c60e49e 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: Apache-2.0
+
 package arvadostest
 
 import (
@@ -22,6 +26,15 @@ func ResetEnv() {
        }
 }
 
+// APIHost returns the address:port of the current test server.
+func APIHost() string {
+       h := authSettings["ARVADOS_API_HOST"]
+       if h == "" {
+               log.Fatal("arvadostest.APIHost() was called but authSettings is not populated")
+       }
+       return h
+}
+
 // ParseAuthSettings parses auth settings from given input
 func ParseAuthSettings(authScript []byte) {
        scanner := bufio.NewScanner(bytes.NewReader(authScript))
@@ -53,6 +66,9 @@ func chdirToPythonTests() {
        for {
                if err := os.Chdir("sdk/python/tests"); err == nil {
                        pythonTestDir, err = os.Getwd()
+                       if err != nil {
+                               log.Fatal(err)
+                       }
                        return
                }
                if parent, err := os.Getwd(); err != nil || parent == "/" {
@@ -88,20 +104,23 @@ func StopAPI() {
        defer os.Chdir(cwd)
        chdirToPythonTests()
 
-       bgRun(exec.Command("python", "run_test_server.py", "stop"))
+       cmd := exec.Command("python", "run_test_server.py", "stop")
+       bgRun(cmd)
+       // Without Wait, "go test" in go1.10.1 tends to hang. https://github.com/golang/go/issues/24050
+       cmd.Wait()
 }
 
 // StartKeep starts the given number of keep servers,
-// optionally with -enforce-permissions enabled.
-// Use numKeepServers = 2 and enforcePermissions = false under all normal circumstances.
-func StartKeep(numKeepServers int, enforcePermissions bool) {
+// optionally with --keep-blob-signing enabled.
+// Use numKeepServers = 2 and blobSigning = false under all normal circumstances.
+func StartKeep(numKeepServers int, blobSigning bool) {
        cwd, _ := os.Getwd()
        defer os.Chdir(cwd)
        chdirToPythonTests()
 
        cmdArgs := []string{"run_test_server.py", "start_keep", "--num-keep-servers", strconv.Itoa(numKeepServers)}
-       if enforcePermissions {
-               cmdArgs = append(cmdArgs, "--keep-enforce-permissions")
+       if blobSigning {
+               cmdArgs = append(cmdArgs, "--keep-blob-signing")
        }
 
        bgRun(exec.Command("python", cmdArgs...))
@@ -116,12 +135,9 @@ func StopKeep(numKeepServers int) {
        chdirToPythonTests()
 
        cmd := exec.Command("python", "run_test_server.py", "stop_keep", "--num-keep-servers", strconv.Itoa(numKeepServers))
-       cmd.Stdin = nil
-       cmd.Stderr = os.Stderr
-       cmd.Stdout = os.Stderr
-       if err := cmd.Run(); err != nil {
-               log.Fatalf("%+v: %s", cmd.Args, err)
-       }
+       bgRun(cmd)
+       // Without Wait, "go test" in go1.10.1 tends to hang. https://github.com/golang/go/issues/24050
+       cmd.Wait()
 }
 
 // Start cmd, with stderr and stdout redirected to our own