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:
authorJaime Martinez <jmartinez@gitlab.com>2020-09-14 04:29:20 +0300
committerJaime Martinez <jmartinez@gitlab.com>2020-09-15 07:49:29 +0300
commit6fa2497adfcb2a3ce8b119b7caa6a1f0ff4a30f9 (patch)
treecb7492862834b58e10c1e6fd4843d1cdf5c27820
parent297d3a48c553b54093462068ff28543236be6649 (diff)
Move setup to helper function
-rw-r--r--acceptance_test.go23
-rw-r--r--helpers_test.go15
-rw-r--r--metrics/metrics.go2
3 files changed, 24 insertions, 16 deletions
diff --git a/acceptance_test.go b/acceptance_test.go
index 03e9ec01..f652f9ad 100644
--- a/acceptance_test.go
+++ b/acceptance_test.go
@@ -447,21 +447,14 @@ func TestHttpsOnlyDomainDisabled(t *testing.T) {
func TestPrometheusMetricsCanBeScraped(t *testing.T) {
skipUnlessEnabled(t)
- listener := []ListenSpec{{"http", "127.0.0.1", "37003"}}
- var apiCalled bool
- source := NewGitlabDomainsSourceStub(t, &apiCalled)
- defer source.Close()
-
- gitLabAPISecretKey := CreateGitLabAPISecretKeyFixtureFile(t)
-
- pagesArgs := []string{"-gitlab-server", source.URL, "-api-secret-key", gitLabAPISecretKey, "-domain-config-source", "gitlab"}
- teardown := RunPagesProcessWithEnvs(t, true, *pagesBinary, listener, ":42345", []string{}, pagesArgs...)
+ teardown := RunPagesProcessWithStubGitLabServer(t, true, *pagesBinary, listeners, ":42345", []string{})
defer teardown()
// need to call an actual resource to populate certain metrics e.g. gitlab_pages_domains_source_api_requests_total
- _, err := GetPageFromListener(t, listener[0], "new-source-test.gitlab.io", "")
+ res, err := GetPageFromListener(t, httpListener, "new-source-test.gitlab.io", "/my/pages/project/")
require.NoError(t, err)
+ require.Equal(t, http.StatusOK, res.StatusCode)
resp, err := http.Get("http://localhost:42345/metrics")
require.NoError(t, err)
@@ -478,13 +471,13 @@ func TestPrometheusMetricsCanBeScraped(t *testing.T) {
require.Contains(t, string(body), "gitlab_pages_last_domain_update_seconds gauge")
require.Contains(t, string(body), "gitlab_pages_domains_configuration_update_duration gauge")
// end TODO
- require.Contains(t, string(body), "gitlab_pages_domains_source_cache_hit 3")
- require.Contains(t, string(body), "gitlab_pages_domains_source_cache_miss 2")
- require.Contains(t, string(body), "gitlab_pages_domains_source_failures_total 0")
+ require.Contains(t, string(body), "gitlab_pages_domains_source_cache_hit")
+ require.Contains(t, string(body), "gitlab_pages_domains_source_cache_miss")
+ require.Contains(t, string(body), "gitlab_pages_domains_source_failures_total")
require.Contains(t, string(body), "gitlab_pages_serverless_requests 0")
require.Contains(t, string(body), "gitlab_pages_serverless_latency_sum 0")
- require.Contains(t, string(body), "gitlab_pages_disk_serving_file_size_bytes_sum 0")
- require.Contains(t, string(body), "gitlab_pages_serving_time_seconds_sum 0")
+ require.Contains(t, string(body), "gitlab_pages_disk_serving_file_size_bytes_sum")
+ require.Contains(t, string(body), "gitlab_pages_serving_time_seconds_sum")
require.Contains(t, string(body), `gitlab_pages_domains_source_api_requests_total{status_code="200"}`)
require.Contains(t, string(body), `gitlab_pages_domains_source_api_call_duration{status_code="200"}`)
// TODO: add test when Zip is enabled https://gitlab.com/gitlab-org/gitlab-pages/-/issues/443
diff --git a/helpers_test.go b/helpers_test.go
index 926fc372..d08869fd 100644
--- a/helpers_test.go
+++ b/helpers_test.go
@@ -163,6 +163,21 @@ func RunPagesProcessWithEnvs(t *testing.T, wait bool, pagesPath string, listener
return runPagesProcess(t, wait, pagesPath, listeners, promPort, envs, extraArgs...)
}
+func RunPagesProcessWithStubGitLabServer(t *testing.T, wait bool, pagesPath string, listeners []ListenSpec, promPort string, envs []string, extraArgs ...string) (teardown func()) {
+ var apiCalled bool
+ source := NewGitlabDomainsSourceStub(t, &apiCalled)
+
+ gitLabAPISecretKey := CreateGitLabAPISecretKeyFixtureFile(t)
+ pagesArgs := append([]string{"-gitlab-server", source.URL, "-api-secret-key", gitLabAPISecretKey, "-domain-config-source", "gitlab"}, extraArgs...)
+
+ cleanup := runPagesProcess(t, wait, pagesPath, listeners, promPort, envs, pagesArgs...)
+
+ return func() {
+ source.Close()
+ cleanup()
+ }
+}
+
func RunPagesProcessWithAuth(t *testing.T, pagesPath string, listeners []ListenSpec, promPort string) func() {
configFile, cleanup := defaultConfigFileWith(t,
"auth-server=https://gitlab-auth.com",
diff --git a/metrics/metrics.go b/metrics/metrics.go
index c2bf6566..9923043b 100644
--- a/metrics/metrics.go
+++ b/metrics/metrics.go
@@ -4,8 +4,8 @@ import (
"github.com/prometheus/client_golang/prometheus"
)
+// TODO: remove disk source metrics https://gitlab.com/gitlab-org/gitlab-pages/-/issues/382
var (
- // TODO: remove disk source metrics https://gitlab.com/gitlab-org/gitlab-pages/-/issues/382
// DomainsServed counts the total number of sites served
DomainsServed = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "gitlab_pages_served_domains",