diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-11-28 19:03:23 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-11-28 19:03:23 +0300 |
commit | 84a6b46d36c5d83bdc41dda596d7f6bcfe4d67f3 (patch) | |
tree | 13798b7169640e9185144fce6d6a000d4fda1de5 | |
parent | bd16d63cd84f28c3992f45eef9b57c93b3cc572b (diff) |
Use ENV variables to obtain a list of test new source domains
-rw-r--r-- | acceptance_test.go | 7 | ||||
-rw-r--r-- | helpers_test.go | 4 | ||||
-rw-r--r-- | internal/source/domains.go | 22 | ||||
-rw-r--r-- | internal/source/domains_test.go | 5 |
4 files changed, 28 insertions, 10 deletions
diff --git a/acceptance_test.go b/acceptance_test.go index 5faa0e38..6f2e5fb4 100644 --- a/acceptance_test.go +++ b/acceptance_test.go @@ -435,7 +435,9 @@ func TestPageNotAvailableIfNotLoaded(t *testing.T) { func TestPageNotAvailableInDomainSource(t *testing.T) { skipUnlessEnabled(t) - teardown := RunPagesProcessWithoutWait(t, *pagesBinary, listeners, "", "-pages-root=shared/invalid-pages") + + brokenDomain := "GITLAB_NEW_SOURCE_BROKEN_DOMAIN=pages-broken-poc.gitlab.io" + teardown := RunPagesProcessWithEnvs(t, false, *pagesBinary, listeners, "", []string{brokenDomain}, "-pages-root=shared/invalid-pages") defer teardown() waitForRoundtrips(t, listeners, 5*time.Second) @@ -1533,7 +1535,8 @@ func TestGitlabDomainsSource(t *testing.T) { source := NewGitlabDomainsSourceStub(t) defer source.Close() - teardown := RunPagesProcess(t, *pagesBinary, listeners, "", "-gitlab-server", source.URL) + newSourceDomains := "GITLAB_NEW_SOURCE_DOMAINS=new-source-test.gitlab.io,other-test.gitlab.io" + teardown := RunPagesProcessWithEnvs(t, true, *pagesBinary, listeners, "", []string{newSourceDomains}, "-gitlab-server", source.URL) defer teardown() response, err := GetPageFromListener(t, httpListener, "new-source-test.gitlab.io", "/my/pages/project/") diff --git a/helpers_test.go b/helpers_test.go index a61aaa27..b13fb18f 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -147,6 +147,10 @@ func RunPagesProcessWithSSLCertFile(t *testing.T, pagesPath string, listeners [] return runPagesProcess(t, true, pagesPath, listeners, promPort, []string{"SSL_CERT_FILE=" + sslCertFile}, extraArgs...) } +func RunPagesProcessWithEnvs(t *testing.T, wait bool, pagesPath string, listeners []ListenSpec, promPort string, envs []string, extraArgs ...string) (teardown func()) { + return runPagesProcess(t, wait, pagesPath, listeners, promPort, envs, extraArgs...) +} + func RunPagesProcessWithAuth(t *testing.T, pagesPath string, listeners []ListenSpec, promPort string) (teardown func()) { return runPagesProcess(t, true, pagesPath, listeners, promPort, nil, "-auth-client-id=1", "-auth-client-secret=1", diff --git a/internal/source/domains.go b/internal/source/domains.go index 1b847cc9..44c1f30a 100644 --- a/internal/source/domains.go +++ b/internal/source/domains.go @@ -2,20 +2,28 @@ package source import ( "errors" + "os" + "strings" "gitlab.com/gitlab-org/gitlab-pages/internal/domain" "gitlab.com/gitlab-org/gitlab-pages/internal/source/disk" "gitlab.com/gitlab-org/gitlab-pages/internal/source/gitlab" ) -var newSourceDomains = []string{ - "pages-project-poc.gitlab.io", - "pages-namespace-poc.gitlab.io", - "new-source-test.gitlab.io", // used also in acceptance tests - "pages-custom-poc.grzegorz.co", -} +var newSourceDomains []string +var brokenSourceDomain string + +func init() { + testDomains := os.Getenv("GITLAB_NEW_SOURCE_DOMAINS") + if testDomains != "" { + newSourceDomains = strings.Split(testDomains, ",") + } -var brokenSourceDomain = "pages-broken-poc.gitlab.io" + brokenDomain := os.Getenv("GITLAB_NEW_SOURCE_BROKEN_DOMAIN") + if brokenDomain != "" { + brokenSourceDomain = brokenDomain + } +} // Domains struct represents a map of all domains supported by pages. It is // currently using two sources during the transition to the new GitLab domains diff --git a/internal/source/domains_test.go b/internal/source/domains_test.go index 5125f462..6854c359 100644 --- a/internal/source/domains_test.go +++ b/internal/source/domains_test.go @@ -11,9 +11,12 @@ import ( ) func TestHasDomain(t *testing.T) { - testDomain := newSourceDomains[0] + newSourceDomains = []string{"new-source-test.gitlab.io"} + brokenSourceDomain = "pages-broken-poc.gitlab.io" t.Run("when requesting a test domain", func(t *testing.T) { + testDomain := newSourceDomains[0] + newSource := NewMockSource() newSource.On("GetDomain", testDomain). Return(&domain.Domain{Name: testDomain}, nil). |