1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
package acceptance_test
import (
"flag"
"fmt"
"log"
"os"
"testing"
"gitlab.com/gitlab-org/gitlab-pages/internal/fixture"
)
const (
objectStorageMockServer = "127.0.0.1:37003"
)
var (
pagesBinary = flag.String("gitlab-pages-binary", "../../gitlab-pages", "Path to the gitlab-pages binary")
// TODO: Use TCP port 0 everywhere to avoid conflicts. The binary could output
// the actual port (and type of listener) for us to read in place of the
// hardcoded values below.
listeners = []ListenSpec{
{"http", "127.0.0.1", "37000"},
{"http", "::1", "37000"},
{"https", "127.0.0.1", "37001"},
{"https", "::1", "37001"},
{"proxy", "127.0.0.1", "37002"},
{"proxy", "::1", "37002"},
}
httpListener = listeners[0]
httpsListener = listeners[2]
proxyListener = listeners[4]
)
func TestMain(m *testing.M) {
flag.Parse()
if testing.Short() {
log.Println("Acceptance tests disabled")
os.Exit(0)
}
if _, err := os.Stat(*pagesBinary); os.IsNotExist(err) {
log.Fatalf("Couldn't find gitlab-pages binary at %s\n", *pagesBinary)
}
if ok := TestCertPool.AppendCertsFromPEM([]byte(fixture.Certificate)); !ok {
fmt.Println("Failed to load cert!")
}
os.Exit(m.Run())
}
func skipUnlessEnabled(t *testing.T, conditions ...string) {
t.Helper()
for _, condition := range conditions {
switch condition {
case "not-inplace-chroot":
if os.Getenv("TEST_DAEMONIZE") == "inplace" {
t.Log("Not supported with -daemon-inplace-chroot")
t.SkipNow()
}
default:
t.Error("Unknown condition:", condition)
t.FailNow()
}
}
}
|