Skip to content

Draft: test: PoC share random port through channels

Jaime Martinez requested to merge 113-use-random-ports-for-acceptance-tests into master

What does this MR do?

I'm experimenting how to initialize pages using a random available port and get the result back using channels.

A few notes:

  • Maybe we can use ListenSpec as pointers and modify when we know the port
  • WaitUntilRequestSucceeds is not working right now
  • need to timeout correctly if the channel never closes
  • can't recall if we run the race detector on acceptance tests

To run locally:

make && go test ./test/acceptance -run TestUnknownHostReturnsNotFound -v
GOBIN=/Users/jaime/dev/gitlab/ee/gitlab-pages/bin go install -v -ldflags='-X "main.VERSION=1.43.0" -X "main.REVISION=e66719fd8"' -tags "continuous_profiler_stackdriver" -buildmode exe gitlab.com/gitlab-org/gitlab-pages
cp -f ./bin/gitlab-pages .
=== RUN   TestUnknownHostReturnsNotFound
    helpers_test.go:236: Running ../../gitlab-pages [-log-verbose=true -listen-http 127.0.0.1:0 -gitlab-retrieval-timeout 50ms -gitlab-retrieval-interval 10ms -gitlab-retrieval-retries 1 -pages-root /Users/jaime/dev/gitlab/ee/gitlab-pages/shared/pages -internal-gitlab-server http://127.0.0.1:49703 -api-secret-key /var/folders/w3/ss43z9595xb8n6fw73gn8pd40000gn/T/gitlab-api-secret372376480]
    helpers_test.go:103: {"api-secret-key":"/var/folders/w3/ss43z9595xb8n6fw73gn8pd40000gn/T/gitlab-api-secret372376480","artifacts-server":"","artifacts-server-timeout":10,"auth-redirect-uri":"","auth-scope":"api","daemon-gid":0,"daemon-uid":0,"default-config-filename":"config","disable-cross-origin-requests":false,"domain":"gitlab-example.com","enable-disk":true,"gitlab-server":"","insecure-ciphers":false,"internal-gitlab-server":"http://127.0.0.1:49703","level":"debug","listen-http":{},"listen-https":{},"listen-https-proxyv2":{},"listen-proxy":{},"log-format":"json","metrics-address":"","msg":"Start daemon with configuration","pages-domain":"gitlab-example.com","pages-root":"/Users/jaime/dev/gitlab/ee/gitlab-pages/shared/pages","pages-status":"","propagate-correlation-id":false,"redirect-http":false,"root-cert":"","root-key":"","status_path":"","time":"2021-09-08T18:32:53+10:00","tls-max-version":"","tls-min-version":"tls1.2","zip-cache-cleanup":30000000000,"zip-cache-expiration":60000000000,"zip-cache-refresh":30000000000,"zip-open-timeout":30000000000}
        {"level":"info","msg":"GitLab Pages Daemon","revision":"e66719fd8","time":"2021-09-08T18:32:53+10:00","version":"1.43.0"}
        {"level":"info","msg":"URL: https://gitlab.com/gitlab-org/gitlab-pages","time":"2021-09-08T18:32:53+10:00"}
    helpers_test.go:103: {"level":"debug","listener":"127.0.0.1:49706","msg":"Set up HTTP listener","port":"49706","time":"2021-09-08T18:32:53+10:00"}
FOUND THE PORT!: "49706"
WE SHOULD HAVE GOT THE PORT... "49706"
THE LISTENER's PORT?: "49706"
    helpers_test.go:449: curl -X GET -H'Host: invalid.invalid' http://127.0.0.1:49706/
    helpers_test.go:103: {"host":"127.0.0.1:49703","level":"trace","msg":"httptrace.ClientTrace.GetConn","time":"2021-09-08T18:32:53+10:00"}
    helpers_test.go:103: {"address":"127.0.0.1:49703","level":"trace","msg":"httptrace.ClientTrace.ConnectStart","network":"tcp","time":"2021-09-08T18:32:53+10:00"}
    helpers_test.go:103: {"address":"127.0.0.1:49703","level":"trace","msg":"httptrace.ClientTrace.ConnectDone","network":"tcp","time":"2021-09-08T18:32:53+10:00"}
        {"idle_time_ms":0,"level":"trace","msg":"httptrace.ClientTrace.GotConn","reused":false,"time":"2021-09-08T18:32:53+10:00","was_idle":false}
    helpers_test.go:572: GitLab domain invalid.invalid source stub served 204
    helpers_test.go:103: {"client_name":"gitlab_internal_api","correlation_id":"01FF28KP8DFN332EE5V1SPJBG6","host":"127.0.0.1:49703","level":"trace","msg":"response from client","path":"/api/v4/internal/pages","req_url":"http://127.0.0.1:49703/api/v4/internal/pages?host=invalid.invalid","res_headers":{"Date":["Wed, 08 Sep 2021 08:32:53 GMT"]},"res_status_code":204,"time":"2021-09-08T18:32:53+10:00"}
    helpers_test.go:103: {"correlation_id":"01FF28KP8DFN332EE5V1SPJBG6","error":null,"level":"debug","lookup_error":"domain does not exist","lookup_name":"invalid.invalid","lookup_paths":null,"msg":"retrieval response sent","requested_domain":"invalid.invalid","time":"2021-09-08T18:32:53+10:00"}
    helpers_test.go:103: {"content_type":"text/html; charset=utf-8","correlation_id":"01FF28KP8DFN332EE5V1SPJBG6","duration_ms":0,"host":"invalid.invalid","level":"info","method":"GET","msg":"access","pages_host":"invalid.invalid","pages_https":false,"proto":"HTTP/1.1","referrer":"","remote_addr":"127.0.0.1:49707","remote_ip":"127.0.0.1","status":404,"system":"http","time":"2021-09-08T18:32:53+10:00","ttfb_ms":0,"uri":"/","user_agent":"Go-http-client/1.1","written_bytes":3067}
--- PASS: TestUnknownHostReturnsNotFound (0.22s)
PASS
ok  	gitlab.com/gitlab-org/gitlab-pages/test/acceptance	0.689s

TODO

Related to #113

Merge request reports