[go: up one dir, main page]

Skip to content

Make the acceptance tests bind to a random port

Per this comment in the source code: https://gitlab.com/gitlab-org/gitlab-pages/blob/master/acceptance_test.go#L22

// TODO: Use TCP port 0 everywhere to avoid conflicts. The binary could output
// the actual port (and type of listener) for us to read in place of the
// hardcoded values below.

We now have structured logging in gitlab-pages and this debug output:

     		time="2018-03-23T17:20:52Z" level=debug msg="Set up HTTP listener" listener="127.0.0.1:37000"
    		time="2018-03-23T17:20:52Z" level=debug msg="Set up HTTP listener" listener="[::1]:37000"
    		time="2018-03-23T17:20:52Z" level=debug msg="Set up HTTPS listener" listener="127.0.0.1:37001"
    		time="2018-03-23T17:20:52Z" level=debug msg="Set up HTTPS listener" listener="[::1]:37001"
    		time="2018-03-23T17:20:52Z" level=debug msg="Set up proxy listener" listener="127.0.0.1:37002"
    		time="2018-03-23T17:20:52Z" level=debug msg="Set up proxy listener" listener="[::1]:37002"

Meaning that we should be able to start gitlab-pages with -listen-http 127.0.0.1:0 and get back log output that can be parsed to tell us what port to connect to in our tests.

We can make this even easier by switching to json-formatted logs in the tests. Either way, we'll need to use the -log-verbose flag as well.