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

status_test.go « acceptance « test - gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6fb2efe0e8d77664c6ee90f254fd41c975bdeef4 (plain)
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
package acceptance_test

import (
	"net/http"
	"testing"
	"time"

	"github.com/stretchr/testify/require"
)

func TestStatusPage(t *testing.T) {
	RunPagesProcessWithStubGitLabServer(t,
		withListeners([]ListenSpec{httpListener}),
		withExtraArgument("pages-status", "/@statuscheck"),
	)

	rsp, err := GetPageFromListener(t, httpListener, "group.gitlab-example.com", "@statuscheck")
	require.NoError(t, err)
	defer rsp.Body.Close()
	require.Equal(t, http.StatusOK, rsp.StatusCode)
}

func TestStatusNotYetReady(t *testing.T) {
	listeners := supportedListeners()

	RunPagesProcessWithStubGitLabServer(t,
		withoutWait,
		withExtraArgument("pages-status", "/@statuscheck"),
		withExtraArgument("pages-root", "../../shared/invalid-pages"),
		withStubOptions(&stubOpts{
			statusReadyCount: 100,
		}),
	)

	waitForRoundtrips(t, listeners, time.Duration(len(listeners))*time.Second)

	// test status on all supported listeners
	for _, spec := range listeners {
		rsp, err := GetPageFromListener(t, spec, "group.gitlab-example.com", "@statuscheck")
		require.NoError(t, err)
		defer rsp.Body.Close()
		require.Equal(t, http.StatusServiceUnavailable, rsp.StatusCode)

		rsp2, err2 := GetPageFromListener(t, httpListener, "group.gitlab-example.com", "index.html")
		require.NoError(t, err2)
		defer rsp2.Body.Close()
		require.Equal(t, http.StatusServiceUnavailable, rsp2.StatusCode, "page should not be served")
	}
}