Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2017-03-08 18:19:46 +0300
committerNick Thomas <nick@gitlab.com>2017-03-08 18:44:50 +0300
commit934a76c536c7de5b3dba17e6b110f60d002cfbc6 (patch)
tree1d773a835458ef803934eefea825e3c64eed8f28 /helpers_test.go
parent91734e88d1763f69e66cec5ea7e5c5cf8c099e7f (diff)
Run the tests with gitlab-pages daemonised in the CI environment
Diffstat (limited to 'helpers_test.go')
-rw-r--r--helpers_test.go25
1 files changed, 20 insertions, 5 deletions
diff --git a/helpers_test.go b/helpers_test.go
index e7fd744e..99a44ea1 100644
--- a/helpers_test.go
+++ b/helpers_test.go
@@ -1,6 +1,7 @@
package main
import (
+ "bytes"
"crypto/tls"
"fmt"
"io/ioutil"
@@ -15,6 +16,16 @@ import (
"github.com/stretchr/testify/assert"
)
+type tWriter struct {
+ t *testing.T
+}
+
+func (t *tWriter) Write(b []byte) (int, error) {
+ t.t.Log(string(bytes.TrimRight(b, "\r\n")))
+
+ return len(b), nil
+}
+
var chdirSet = false
func setUpTests() {
@@ -131,6 +142,8 @@ func RunPagesProcess(t *testing.T, pagesPath string, listeners []ListenSpec, pro
args, tempfiles := getPagesArgs(t, listeners, promPort)
cmd := exec.Command(pagesPath, args...)
+ cmd.Stdout = &tWriter{t}
+ cmd.Stderr = &tWriter{t}
cmd.Start()
t.Logf("Running %s %v", pagesPath, args)
@@ -144,10 +157,10 @@ func RunPagesProcess(t *testing.T, pagesPath string, listeners []ListenSpec, pro
for _, spec := range listeners {
spec.WaitUntilListening()
}
- time.Sleep(50 * time.Millisecond)
+ time.Sleep(500 * time.Millisecond)
return func() {
- cmd.Process.Kill()
+ cmd.Process.Signal(os.Interrupt)
cmd.Process.Wait()
for _, tempfile := range tempfiles {
os.Remove(tempfile)
@@ -176,9 +189,11 @@ func getPagesArgs(t *testing.T, listeners []ListenSpec, promPort string) (args,
args = append(args, "-metrics-address", promPort)
}
- if os.Geteuid() == 0 && os.Getenv("SUDO_UID") != "" && os.Getenv("SUDO_GID") != "" {
- t.Log("Pages process will drop privileges")
- args = append(args, "-daemon-uid", os.Getenv("SUDO_UID"), "-daemon-gid", os.Getenv("SUDO_GID"))
+ // At least one of `-daemon-uid` and `-daemon-gid` must be non-zero
+ if os.Geteuid() == 0 {
+ t.Log("Running pages as a daemon")
+ args = append(args, "-daemon-uid", "0")
+ args = append(args, "-daemon-gid", "65534") // Root user can switch to "nobody"
}
return