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>2018-03-22 21:25:24 +0300
committerNick Thomas <nick@gitlab.com>2018-03-23 20:33:57 +0300
commit8cfda639dbf6735896ca5849ee5671cea71d2986 (patch)
tree3d7e6de87b64f1ede66815ef77ed365722a31297
parent6a521a1140afe9eff59dd2d6fd8b7b25bfd0994b (diff)
Run the acceptance tests both daemonized and not
-rw-r--r--.gitlab-ci.yml3
-rw-r--r--Makefile.util.mk4
-rw-r--r--helpers_test.go14
3 files changed, 17 insertions, 4 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9b75c6ee..41dfb14d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -5,7 +5,10 @@ image: golang:1.8
- make setup
- make verify
- make cover
+ - echo "Running all tests without daemonizing..."
- make test
+ - echo "Running just the acceptance tests daemonized...."
+ - TEST_DAEMONIZE=1 make acceptance
artifacts:
paths:
- bin/gitlab-pages
diff --git a/Makefile.util.mk b/Makefile.util.mk
index 808e2607..ece6e3bb 100644
--- a/Makefile.util.mk
+++ b/Makefile.util.mk
@@ -14,9 +14,13 @@ lint: bin/golint
complexity: .GOPATH/.ok bin/gocyclo
$Q ./bin/gocyclo -over 9 $(allfiles)
+
test: .GOPATH/.ok gitlab-pages
go test $(if $V,-v) $(allpackages)
+acceptance: .GOPATH/.ok gitlab-pages
+ go test $(if $V,-v) $(IMPORT_PATH)
+
bench: .GOPATH/.ok gitlab-pages
go test -bench=. -run=^$$ $(allpackages)
diff --git a/helpers_test.go b/helpers_test.go
index a8d804c2..97374d19 100644
--- a/helpers_test.go
+++ b/helpers_test.go
@@ -9,6 +9,7 @@ import (
"net/http"
"os"
"os/exec"
+ "strconv"
"strings"
"testing"
"time"
@@ -229,10 +230,15 @@ func getPagesArgs(t *testing.T, listeners []ListenSpec, promPort string, extraAr
}
// 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"
+ if daemon, _ := strconv.ParseBool(os.Getenv("TEST_DAEMONIZE")); daemon {
+ 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"
+ } else {
+ t.Log("Privilege-dropping requested but not running as root!")
+ t.FailNow()
+ }
}
args = append(args, extraArgs...)