Skip to content

Remove messy Destroy test clean-up in TestPartialStateJoin#895

Open
MadLittleMods wants to merge 4 commits into
mainfrom
madlittlemods/remove-messy-TestPartialStateJoin-cleanup2
Open

Remove messy Destroy test clean-up in TestPartialStateJoin#895
MadLittleMods wants to merge 4 commits into
mainfrom
madlittlemods/remove-messy-TestPartialStateJoin-cleanup2

Conversation

@MadLittleMods

@MadLittleMods MadLittleMods commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Remove messy Destroy test clean-up in TestPartialStateJoin

Follow-up to #894 which removes another part of the clean-up code in this file and #880 which introduces a better way to avoid the test pollution and obsoletes the need for all of this cleanup logic. See the PR description there for a more complete context on why.

Destroy(...) was originally introduced in this context:

Since the partial state join tests reuse the same homeserver deployment, it is important that each test leaves the homeserver in an acceptable state for subsequent tests. In particular, we must allow in-progress partial-state joins to complete before tearing down Complement servers, otherwise the homeserver may mark Complement hostname:port combinations as offline and refuse to contact them in subsequent tests.

-- #570

But thanks to #880 we no longer use the same hostname:port for engineered homeservers anymore.

Todo

Pull Request Checklist

defer cancel()
serverRoom := createTestRoom(t, server, alice.GetDefaultRoomVersion(t))
psjResult := beginPartialStateJoin(t, server, serverRoom, alice)
defer psjResult.Destroy(t)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing all of the Destroy usage since it's no longer necessary

Comment on lines +4364 to +4366
case <-sendResponseWaiter.Done():
// Happy-path now that we're done waiting, continue serving the request now
case <-req.Context().Done():

@MadLittleMods MadLittleMods Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of relying on Destroy to finish the waiter to allow this to continue (instead of waiting forever), we instead rely on engineered homeserver being closed and all of the in-flight requests being cancelled (req.Context().Done()).

We still have a 60 second timeout like before.


// The caller is about to tear down the Complement homeserver. Leave the room, so
// that the homeserver under test stops sending it presence updates.
psj.Server.WithWaitForLeave(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#894 removes the WithWaitForLeave(...) part of Destroy(...)

This PR removes the need for finishing the waiters.

Which means Destroy(...) doesn't do anything anymore and we can remove it altogether. Less to think about.

// wait is skipped when `user` had already left the room (per their own
// homeserver, so the action produces no new leave) or when this server isn't in
// the room (so the leave won't be federated to us).
func (s *server) WithWaitForLeave(

@MadLittleMods MadLittleMods Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The WithWaitForLeave changes in the diff disappear once #894 is merged

This PR builds on that one so they are also included here for now.

@MadLittleMods MadLittleMods marked this pull request as ready for review July 13, 2026 22:49
@MadLittleMods MadLittleMods requested review from a team as code owners July 13, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant