Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't listen on :8448 for the Complement federation server #289

Merged
merged 21 commits into from
Jan 25, 2022

Conversation

kegsay
Copy link
Member

@kegsay kegsay commented Jan 21, 2022

Instead, listen on a random OS-allocated high numbered port then
do a switcheroo on the ServerName so it reads correctly e.g
host.docker.internal:56185. This means the server name will be
invalid if it is read before Server.Listen() is called so we now
guard common access points in Server which rely on the server
name and fail tests if the server is not yet listening when those
functions are called. To further guard against misuse of server
name whilst it isn't valid, turn it into a private field.

As of this PR, it will now (in theory) be possible to scale out tests indefinitely as we no longer have any central point/resource which all tests rely on. This should make it possible to split /tests into more packages which make sense from a Matrix PoV.

Indirectly fixes #60

Instead, listen on a random OS-allocated high numbered port then
do a switcheroo on the `ServerName` so it reads correctly e.g
`host.docker.internal:56185`. This means the server name will be
invalid if it is read before `Server.Listen()` is called so we now
guard common access points in `Server` which rely on the server
name and fail tests if the server is not yet listening when those
functions are called. To further guard against misuse of server
name whilst it isn't valid, turn it into a private field.
@kegsay kegsay added the enhancement New feature or request label Jan 21, 2022
.github/workflows/ci.yaml Outdated Show resolved Hide resolved
internal/federation/server.go Show resolved Hide resolved
internal/federation/handle.go Show resolved Hide resolved
internal/federation/server.go Show resolved Hide resolved
kegsay added a commit to matrix-org/synapse that referenced this pull request Jan 24, 2022
This requires matrix-org/complement#289

We now run Complement on the VM instead of inside a Docker container.
This is to allow Complement to bind to any high-numbered port when it
starts up its own federation servers. We want to do this to allow for
more concurrency when running complement tests. Previously, Complement
only ever bound to `:8448` when running its own federation server. This
prevented multiple federation tests running at the same time as they would
fight each other on the port. This did however allow Complement to run
in Docker, as the host could just port forward `:8448` to allow homeserver
containers to communicate to Complement. Now that we are using random
ports however, we cannot use Docker to run Complement. This ends up
being a good thing because:
 - Running Complement tests locally is closer to how they run in CI.
 - Allows the `CI` env var to be removed in Complement.
 - Slightly speeds up runs as we don't need to pull down the Complement
   image prior to running tests. This assumes GHA caches actions sensibly.
kegsay added a commit to matrix-org/synapse that referenced this pull request Jan 25, 2022
* CI: run Complement on the VM, not inside Docker

This requires matrix-org/complement#289

We now run Complement on the VM instead of inside a Docker container.
This is to allow Complement to bind to any high-numbered port when it
starts up its own federation servers. We want to do this to allow for
more concurrency when running complement tests. Previously, Complement
only ever bound to `:8448` when running its own federation server. This
prevented multiple federation tests running at the same time as they would
fight each other on the port. This did however allow Complement to run
in Docker, as the host could just port forward `:8448` to allow homeserver
containers to communicate to Complement. Now that we are using random
ports however, we cannot use Docker to run Complement. This ends up
being a good thing because:
 - Running Complement tests locally is closer to how they run in CI.
 - Allows the `CI` env var to be removed in Complement.
 - Slightly speeds up runs as we don't need to pull down the Complement
   image prior to running tests. This assumes GHA caches actions sensibly.

* Changelog

* Full stop

* Update .github/workflows/tests.yml

Co-authored-by: Richard van der Hoff <[email protected]>

* Review comments

* Update .github/workflows/tests.yml

Co-authored-by: Richard van der Hoff <[email protected]>

Co-authored-by: Richard van der Hoff <[email protected]>
@kegsay kegsay merged commit 298e5a2 into master Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename 'CI' environment variable to 'COMPLEMENT_IN_DOCKER' or similar
3 participants