fix: wait for process to exit in acceptance tests
What does this MR do?
I just got an error locally running tests:
--- FAIL: TestPrometheusMetricsCanBeScraped (0.10s)
helpers_test.go:233: Running ../../gitlab-pages [-log-verbose=true -listen-http 127.0.0.1:36000 -listen-http [::1]:36000 -listen-https 127.0.0.1:37000 -listen-https [::1]:37000 -listen-proxy 127.0.0.1:38000 -listen-proxy [::1]:38000 -listen-https-proxyv2 127.0.0.1:39000 -listen-https-proxyv2 [::1]:39000 -root-key /tmp/https-fixture3544403025 -root-cert /tmp/https-fixture3369728277 -gitlab-retrieval-timeout 50ms -gitlab-retrieval-interval 10ms -gitlab-retrieval-retries 1 -max-conns=10 -metrics-address=:42345 -pages-root /home/vlad/gdk/gitlab-pages/shared/pages -internal-gitlab-server http://127.0.0.1:41167 -api-secret-key /tmp/gitlab-api-secret2802249883]
helpers_test.go:103: {"api-secret-key":"/tmp/gitlab-api-secret2802249883","artifacts-server":"","artifacts-server-timeout":10,"auth-redirect-uri":"","auth-scope":"api","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:41167","level":"debug","listen-http":{},"listen-https":{},"listen-https-proxyv2":{},"listen-proxy":{},"log-format":"json","max-conns":10,"max-uri-length":1024,"metrics-address":":42345","msg":"Start Pages with configuration","pages-domain":"gitlab-example.com","pages-root":"/home/vlad/gdk/gitlab-pages/shared/pages","pages-status":"","propagate-correlation-id":false,"redirect-http":false,"root-cert":"/tmp/https-fixture3544403025","root-key":"/tmp/https-fixture3369728277","status_path":"","time":"2021-12-21T12:56:32+01: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","revision":"HEAD","time":"2021-12-21T12:56:32+01:00","version":"dev"}
{"level":"info","msg":"URL: https://gitlab.com/gitlab-org/gitlab-pages","time":"2021-12-21T12:56:32+01:00"}
helpers_test.go:103: {"level":"debug","listener":"127.0.0.1:36000","msg":"Set up HTTP listener","time":"2021-12-21T12:56:32+01:00"}
helpers_test.go:103: {"level":"debug","listener":"[::1]:36000","msg":"Set up HTTP listener","time":"2021-12-21T12:56:32+01:00"}
helpers_test.go:103: {"level":"debug","listener":"127.0.0.1:37000","msg":"Set up HTTPS listener","time":"2021-12-21T12:56:32+01:00"}
helpers_test.go:103: {"level":"debug","listener":"[::1]:37000","msg":"Set up HTTPS listener","time":"2021-12-21T12:56:32+01:00"}
helpers_test.go:103: {"level":"debug","listener":"127.0.0.1:38000","msg":"Set up proxy listener","time":"2021-12-21T12:56:32+01:00"}
helpers_test.go:103: {"level":"debug","listener":"[::1]:38000","msg":"Set up proxy listener","time":"2021-12-21T12:56:32+01:00"}
helpers_test.go:103: {"error":"listen tcp 127.0.0.1:39000: bind: address already in use","level":"fatal","msg":"could not create socket","time":"2021-12-21T12:56:32+01:00"}
helpers_test.go:233: server has shut down already
And we often get similar errors in CI. We thought that the source of these problems was some kind of strange docker interaction or running tests in parallel, but I didn't run tests in parallel locally.
So I just checked if we actually wait for the child process to exit, and it turns out that we don't! It just usually works because pages process terminates itself very quickly, but sometimes it causes a problem.
So I just added the Wait()
call to the cleanup funciton.
TODO
-
I added the Changelog
trailer (e.g.Changelog: feature
) to the commits that need to be included in the changelog -
I added unit tests or they are not required -
I added acceptance tests or they are not required -
I added documentation (or it's not required) -
I followed code review guidelines -
I followed Go Style guidelines
Related to #539 (closed)
Edited by Jaime Martinez