Skip to content

Commit 28a0901

Browse files
Add deployment.GetFullyQualifiedHomeserverName(t, hsName) to support custom Deployment (matrix-org#780)
*Split off from matrix-org#778 per [discussion](matrix-org#778 (comment) Spawning from a real use-case with a custom `Deployment`/`Deployer` (Element-internal). Introduce `complement.Deployment.GetFullyQualifiedHomeserverName(hsName)` to allow the per-deployment short homeserver aliases like `hs1` to be mapped to something else that's resolvable in your custom deployments context. Example: `hs1` -> `hs1.shard1:8481`. This is useful for situations like the following where you have to specify the via servers in a federated join request during a test: ```go alice.MustJoinRoom(t, bobRoomID, []string{ deployment.GetFullyQualifiedHomeserverName(t, "hs2"), }) ``` ### But why does this have to be part of the `complement.Deployment` interface instead of your own custom deployment? - Tests only have access to the generic `complement.Deployment` interface - We can't derive fully-qualified homeserver names from the existing `complement.Deployment` interface - While we could cheekily cast the generic `complement.Deployment` back to `CustomDeployment` in our own tests (and have the helper in the `CustomDeployment` instead), if we start using something exotic in our out-of-repo Complement tests, the suite of existing Complement tests in this repo will not be compatible. (also see below) ### Motivating custom `Deployment` use case [`complement.Deployment`](https://github.com/matrix-org/complement/blob/d2e04c995666fbeb0948e6a4ed52d3fbb45fbdf7/test_package.go#L21-L69) is an interface that can be backed by anything. For reference, custom deployments were introduced in matrix-org#750. The [default `Deployment` naming scheme in Complement is `hs1`, `hs2`, etc](https://github.com/matrix-org/complement/blob/6b63eff50804beb334ca215650f5027ddf02ae9a/test_package.go#L198). It's really nice and convenient to be able to simply refer to homeservers as `hs1`, etc within a deployment. And using consistent names like this makes tests compatible with each other regardless of which `Deployment` is being used. The built-in `Deployment` in Complement has each homeserver in a Docker container which already has network aliases like `hs1`, `hs2`, etc so no translation is needed from friendly name to resolvable address. When one homeserver needs to federate with the other, it can simply make a request to `https://hs1:8448/...` per [spec on resolving server names](https://spec.matrix.org/v1.13/server-server-api/#resolving-server-names). Right-now, we hard-code `hs1` across the tests when we specify ["via" servers in join requests](https://spec.matrix.org/v1.13/client-server-api/#post_matrixclientv3joinroomidoralias) but that only works if you follow the strict single-deployment naming scheme. https://github.com/matrix-org/complement/blob/6b63eff50804beb334ca215650f5027ddf02ae9a/tests/federation_rooms_invite_test.go#L112 In the current setup of our custom `Deployment`, each `Deployment` is a "shard" application that can deploy multiple homeserver "tenants". We specifically want to test that homeservers between multiple shards can federate with each other as a sanity check (make sure our shards can deploy homeserver tenants correctly). If we keep using the consistent `hs1`, `hs2` naming scheme for each `Deployment` we're going to have conflicts. This is where `deployment.GetFullyQualifiedHomeserverName(t, hsName)` comes in handy. We can call `deployment1.GetFullyQualifiedHomeserverName(t, "hs1")` -> `hs1.shard1` and also `deployment2.GetFullyQualifiedHomeserverName(t, "hs1")` -> `hs1.shard2` to get their unique resolvable addresses in the network. Additionally, the helper removes the constraint of needing the network to strictly resolve `hs1`, `hs2` hostnames to their respective homeservers. Whenever you need to refer to another homeserver, use `deployment.GetFullyQualifiedHomeserverName(hsName)` to take care of the nuance of environment that the given `Deployment` creates. Example of a cross-deployment test: ```go func TestMain(m *testing.M) { complement.TestMain(m, "custom_tests", complement.WithDeployment(internal.MakeCustomDeployment()), ) } func TestCrossShardFederation(t *testing.T) { // Create two shards with their own homeserver tenants shardDeployment1 := complement.Deploy(t, 1) defer shardDeployment1.Destroy(t) shardDeployment2 := complement.Deploy(t, 1) defer shardDeployment2.Destroy(t) alice := shardDeployment1.Register(t, "hs1", helpers.RegistrationOpts{}) bob := shardDeployment2.Register(t, "hs1", helpers.RegistrationOpts{}) aliceRoomID := alice.MustCreateRoom(t, map[string]any{ "preset": "public_chat", }) bobRoomID := bob.MustCreateRoom(t, map[string]any{ "preset": "public_chat", }) t.Run("parallel", func(t *testing.T) { t.Run("shard1 -> shard2", func(t *testing.T) { // Since these tests use the same config, they can be run in parallel t.Parallel() alice.MustJoinRoom(t, bobRoomID, []string{ shardDeployment2.GetFullyQualifiedHomeserverName(t, "hs1"), }) bob.MustSyncUntil(t, client.SyncReq{}, client.SyncJoinedTo(alice.UserID, bobRoomID)) }) t.Run("shard2 -> shard1", func(t *testing.T) { // Since these tests use the same config, they can be run in parallel t.Parallel() bob.MustJoinRoom(t, aliceRoomID, []string{ shardDeployment1.GetFullyQualifiedHomeserverName(t, "hs1"), }) alice.MustSyncUntil(t, client.SyncReq{}, client.SyncJoinedTo(bob.UserID, aliceRoomID)) }) }) } ``` Per the discussion in matrix-org#780 (comment), multiple-deployments per test doesn't work with Complement's `Deployment` implementation yet and the `Deployment` is meant to encapsulate an _entire_ deployment, all servers and network links between them. This was the motivating use case but use at your own discretion until further guidance is given.
1 parent 6b63eff commit 28a0901

47 files changed

Lines changed: 569 additions & 318 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

client/client.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"time"
1919

2020
"github.com/matrix-org/gomatrixserverlib"
21+
"github.com/matrix-org/gomatrixserverlib/spec"
2122
"github.com/tidwall/gjson"
2223
"golang.org/x/crypto/curve25519"
2324

@@ -139,7 +140,11 @@ func (c *CSAPI) CreateRoom(t ct.TestLike, body map[string]interface{}) *http.Res
139140
}
140141

141142
// MustJoinRoom joins the room ID or alias given, else fails the test. Returns the room ID.
142-
func (c *CSAPI) MustJoinRoom(t ct.TestLike, roomIDOrAlias string, serverNames []string) string {
143+
//
144+
// Args:
145+
// - `serverNames`: The list of servers to attempt to join the room through.
146+
// These should be a resolvable addresses within the deployment network.
147+
func (c *CSAPI) MustJoinRoom(t ct.TestLike, roomIDOrAlias string, serverNames []spec.ServerName) string {
143148
t.Helper()
144149
res := c.JoinRoom(t, roomIDOrAlias, serverNames)
145150
mustRespond2xx(t, res)
@@ -153,12 +158,19 @@ func (c *CSAPI) MustJoinRoom(t ct.TestLike, roomIDOrAlias string, serverNames []
153158
}
154159

155160
// JoinRoom joins the room ID or alias given. Returns the raw http response
156-
func (c *CSAPI) JoinRoom(t ct.TestLike, roomIDOrAlias string, serverNames []string) *http.Response {
161+
//
162+
// Args:
163+
// - `serverNames`: The list of servers to attempt to join the room through.
164+
// These should be a resolvable addresses within the deployment network.
165+
func (c *CSAPI) JoinRoom(t ct.TestLike, roomIDOrAlias string, serverNames []spec.ServerName) *http.Response {
157166
t.Helper()
158167
// construct URL query parameters
159-
query := make(url.Values, len(serverNames))
160-
for _, serverName := range serverNames {
161-
query.Add("server_name", serverName)
168+
serverNameStrings := make([]string, len(serverNames))
169+
for i, serverName := range serverNames {
170+
serverNameStrings[i] = string(serverName)
171+
}
172+
query := url.Values{
173+
"server_name": serverNameStrings,
162174
}
163175
// join the room
164176
return c.Do(

federation/handle.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func MakeRespMakeKnock(s *Server, room *ServerRoom, userID string) (resp fclient
117117
// the current server is returned to the joining server.
118118
func SendJoinRequestsHandler(s *Server, w http.ResponseWriter, req *http.Request, expectPartialState bool, omitServersInRoom bool) {
119119
fedReq, errResp := fclient.VerifyHTTPRequest(
120-
req, time.Now(), spec.ServerName(s.serverName), nil, s.keyRing,
120+
req, time.Now(), s.serverName, nil, s.keyRing,
121121
)
122122
if fedReq == nil {
123123
w.WriteHeader(errResp.Code)
@@ -208,7 +208,7 @@ func HandleInviteRequests(inviteCallback func(gomatrixserverlib.PDU)) func(*Serv
208208
// https://matrix.org/docs/spec/server_server/r0.1.4#put-matrix-federation-v2-invite-roomid-eventid
209209
s.mux.Handle("/_matrix/federation/v2/invite/{roomID}/{eventID}", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
210210
fedReq, errResp := fclient.VerifyHTTPRequest(
211-
req, time.Now(), spec.ServerName(s.serverName), nil, s.keyRing,
211+
req, time.Now(), s.serverName, nil, s.keyRing,
212212
)
213213
if fedReq == nil {
214214
w.WriteHeader(errResp.Code)
@@ -236,7 +236,7 @@ func HandleInviteRequests(inviteCallback func(gomatrixserverlib.PDU)) func(*Serv
236236
}
237237

238238
// Sign the event before we send it back
239-
signedEvent := inviteRequest.Event().Sign(s.serverName, s.KeyID, s.Priv)
239+
signedEvent := inviteRequest.Event().Sign(string(s.serverName), s.KeyID, s.Priv)
240240

241241
// Send the response
242242
res := map[string]interface{}{
@@ -263,7 +263,7 @@ func HandleDirectoryLookups() func(*Server) {
263263
b, err := json.Marshal(fclient.RespDirectory{
264264
RoomID: roomID,
265265
Servers: []spec.ServerName{
266-
spec.ServerName(s.serverName),
266+
s.serverName,
267267
},
268268
})
269269
if err != nil {
@@ -432,7 +432,7 @@ func HandleMediaRequests(mediaIds map[string]func(w http.ResponseWriter)) func(*
432432
origin := vars["origin"]
433433
mediaId := vars["mediaId"]
434434

435-
if origin != srv.serverName {
435+
if origin != string(srv.serverName) {
436436
w.WriteHeader(400)
437437
w.Write([]byte("complement: Invalid Origin; Expected " + srv.serverName))
438438
return
@@ -471,7 +471,7 @@ func HandleTransactionRequests(pduCallback func(gomatrixserverlib.PDU), eduCallb
471471

472472
// Check federation signature
473473
fedReq, errResp := fclient.VerifyHTTPRequest(
474-
req, time.Now(), spec.ServerName(srv.serverName), nil, srv.keyRing,
474+
req, time.Now(), srv.serverName, nil, srv.keyRing,
475475
)
476476
if fedReq == nil {
477477
log.Printf(

federation/server.go

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ type Server struct {
4848
// Default: true
4949
UnexpectedRequestsAreErrors bool
5050

51-
Priv ed25519.PrivateKey
52-
KeyID gomatrixserverlib.KeyID
53-
serverName string
51+
Priv ed25519.PrivateKey
52+
KeyID gomatrixserverlib.KeyID
53+
// The homeserver name. This should be a resolvable address in the deployment network
54+
serverName spec.ServerName
5455
listening bool
5556

5657
certPath string
@@ -80,7 +81,7 @@ func NewServer(t ct.TestLike, deployment FederationDeployment, opts ...func(*Ser
8081
mux: mux.NewRouter(),
8182
// The server name will be updated when the caller calls Listen() to include the port number
8283
// of the HTTP server e.g "host.docker.internal:56353"
83-
serverName: deployment.GetConfig().HostnameRunningComplement,
84+
serverName: spec.ServerName(deployment.GetConfig().HostnameRunningComplement),
8485
rooms: make(map[string]*ServerRoom),
8586
aliases: make(map[string]string),
8687
UnexpectedRequestsAreErrors: true,
@@ -142,7 +143,7 @@ func NewServer(t ct.TestLike, deployment FederationDeployment, opts ...func(*Ser
142143
// It is not supported to call ServerName() before Listen() because Listen() modifies the server name.
143144
// Listen() will select a random OS-provided high-numbered port to listen on, which then needs to be
144145
// retrofitted into the server name so containers know how to route to it.
145-
func (s *Server) ServerName() string {
146+
func (s *Server) ServerName() spec.ServerName {
146147
if !s.listening {
147148
ct.Fatalf(s.t, "ServerName() called before Listen() - this is not supported because Listen() chooses a high-numbered port and thus changes the server name. Ensure you Listen() first!")
148149
}
@@ -205,28 +206,31 @@ func (s *Server) FederationClient(deployment FederationDeployment) fclient.Feder
205206
ct.Fatalf(s.t, "FederationClient() called before Listen() - this is not supported because Listen() chooses a high-numbered port and thus changes the server name and thus changes the way federation requests are signed. Ensure you Listen() first!")
206207
}
207208
identity := fclient.SigningIdentity{
208-
ServerName: spec.ServerName(s.ServerName()),
209+
ServerName: s.ServerName(),
209210
KeyID: s.KeyID,
210211
PrivateKey: s.Priv,
211212
}
212-
f := fclient.NewFederationClient(
213+
fedClient := fclient.NewFederationClient(
213214
[]*fclient.SigningIdentity{&identity},
214215
fclient.WithTransport(deployment.RoundTripper()),
215216
)
216-
return f
217+
return fedClient
217218
}
218219

219220
// MustSendTransaction sends the given PDUs/EDUs to the target destination, returning an error if the /send fails or if the response contains an error
220221
// for any sent PDUs. Times out after 10 seconds.
221-
func (s *Server) MustSendTransaction(t ct.TestLike, deployment FederationDeployment, destination string, pdus []json.RawMessage, edus []gomatrixserverlib.EDU) {
222+
//
223+
// Args:
224+
// - `destination`: This should be a resolvable addresses within the deployment network.
225+
func (s *Server) MustSendTransaction(t ct.TestLike, deployment FederationDeployment, destination spec.ServerName, pdus []json.RawMessage, edus []gomatrixserverlib.EDU) {
222226
t.Helper()
223-
cli := s.FederationClient(deployment)
227+
fedClient := s.FederationClient(deployment)
224228
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
225229
defer cancel()
226-
resp, err := cli.SendTransaction(ctx, gomatrixserverlib.Transaction{
230+
resp, err := fedClient.SendTransaction(ctx, gomatrixserverlib.Transaction{
227231
TransactionID: gomatrixserverlib.TransactionID(fmt.Sprintf("complement-%d", time.Now().Nanosecond())),
228232
Origin: spec.ServerName(s.ServerName()),
229-
Destination: spec.ServerName(destination),
233+
Destination: destination,
230234
PDUs: pdus,
231235
EDUs: edus,
232236
})
@@ -319,6 +323,9 @@ func (s *Server) MustCreateEvent(t ct.TestLike, room *ServerRoom, ev Event) goma
319323

320324
// MustJoinRoom will make the server send a make_join and a send_join to join a room
321325
// It returns the resultant room.
326+
//
327+
// Args:
328+
// - `remoteServer`: This should be a resolvable addresses within the deployment network.
322329
func (s *Server) MustJoinRoom(t ct.TestLike, deployment FederationDeployment, remoteServer spec.ServerName, roomID string, userID string, opts ...JoinRoomOpt) *ServerRoom {
323330
t.Helper()
324331
var jr joinRoom
@@ -401,6 +408,9 @@ func (s *Server) MustJoinRoom(t ct.TestLike, deployment FederationDeployment, re
401408
}
402409

403410
// Leaves a room. If this is rejecting an invite then a make_leave request is made first, before send_leave.
411+
//
412+
// Args:
413+
// - `remoteServer`: This should be a resolvable addresses within the deployment network.
404414
func (s *Server) MustLeaveRoom(t ct.TestLike, deployment FederationDeployment, remoteServer spec.ServerName, roomID string, userID string) {
405415
t.Helper()
406416
origin := spec.ServerName(s.serverName)
@@ -449,7 +459,7 @@ func (s *Server) ValidFederationRequest(t ct.TestLike, handler func(fr *fclient.
449459
return func(w http.ResponseWriter, req *http.Request) {
450460
// Check federation signature
451461
fedReq, errResp := fclient.VerifyHTTPRequest(
452-
req, time.Now(), spec.ServerName(s.serverName), nil, s.keyRing,
462+
req, time.Now(), s.serverName, nil, s.keyRing,
453463
)
454464
if fedReq == nil {
455465
ct.Errorf(t,
@@ -495,7 +505,7 @@ func (s *Server) Listen() (cancel func()) {
495505
ct.Fatalf(s.t, "ListenFederationServer: net.Listen failed: %s", err)
496506
}
497507
port := ln.Addr().(*net.TCPAddr).Port
498-
s.serverName += fmt.Sprintf(":%d", port)
508+
s.serverName = spec.ServerName(fmt.Sprintf("%s:%d", s.serverName, port))
499509
s.listening = true
500510

501511
go func() {
@@ -647,7 +657,7 @@ func (f *basicKeyFetcher) FetchKeys(
647657
) {
648658
result := make(map[gomatrixserverlib.PublicKeyLookupRequest]gomatrixserverlib.PublicKeyLookupResult, len(requests))
649659
for req := range requests {
650-
if string(req.ServerName) == f.srv.serverName && req.KeyID == f.srv.KeyID {
660+
if req.ServerName == f.srv.serverName && req.KeyID == f.srv.KeyID {
651661
publicKey := f.srv.Priv.Public().(ed25519.PublicKey)
652662
result[req] = gomatrixserverlib.PublicKeyLookupResult{
653663
ValidUntilTS: spec.AsTimestamp(time.Now().Add(24 * time.Hour)),

federation/server_room.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func (r *ServerRoom) MustHaveMembershipForUser(t ct.TestLike, userID, wantMember
260260
}
261261

262262
// ServersInRoom gets all servers currently joined to the room
263-
func (r *ServerRoom) ServersInRoom() (servers []string) {
263+
func (r *ServerRoom) ServersInRoom() (servers []spec.ServerName) {
264264
serverSet := make(map[string]struct{})
265265

266266
r.StateMutex.RLock()
@@ -282,7 +282,7 @@ func (r *ServerRoom) ServersInRoom() (servers []string) {
282282
r.StateMutex.RUnlock()
283283

284284
for server := range serverSet {
285-
servers = append(servers, server)
285+
servers = append(servers, spec.ServerName(server))
286286
}
287287

288288
return
@@ -498,21 +498,27 @@ func (i *ServerRoomImplDefault) GenerateSendJoinResponse(room *ServerRoom, s *Se
498498
authEvents := room.AuthChainForEvents(stateEvents)
499499

500500
// get servers in room *before* the join event
501-
serversInRoom := []string{s.serverName}
501+
serversInRoom := []spec.ServerName{s.serverName}
502502
if !omitServersInRoom {
503503
serversInRoom = room.ServersInRoom()
504504
}
505505

506+
serversInRoomStrings := make([]string, len(serversInRoom))
507+
for i, serverName := range serversInRoom {
508+
serversInRoomStrings[i] = string(serverName)
509+
}
510+
506511
// insert the join event into the room state
507512
room.AddEvent(joinEvent)
508513
log.Printf("Received send-join of event %s", joinEvent.EventID())
509514

510515
// return state and auth chain
511516
return fclient.RespSendJoin{
512-
Origin: spec.ServerName(s.serverName),
517+
Origin: s.serverName,
513518
AuthEvents: gomatrixserverlib.NewEventJSONsFromEvents(authEvents),
514519
StateEvents: gomatrixserverlib.NewEventJSONsFromEvents(stateEvents),
515520
MembersOmitted: expectPartialState,
516-
ServersInRoom: serversInRoom,
521+
// TODO: It feels like `ServersInRoom` should be `[]spec.ServerName` instead of `[]string`
522+
ServersInRoom: serversInRoomStrings,
517523
}
518524
}

federation/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func TestComplementServerIsSigned(t *testing.T) {
5555
transport := &http.Transport{TLSClientConfig: tc.config}
5656
client := &http.Client{Transport: transport}
5757

58-
resp, err := client.Get("https://" + srv.ServerName())
58+
resp, err := client.Get("https://" + string(srv.ServerName()))
5959
if err != nil {
6060
if tc.wantSuccess {
6161
t.Fatalf("Failed to GET: %s", err)

internal/docker/deployment.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/matrix-org/complement/ct"
1313
"github.com/matrix-org/complement/helpers"
1414
"github.com/matrix-org/gomatrixserverlib"
15+
"github.com/matrix-org/gomatrixserverlib/spec"
1516
)
1617

1718
// Deployment is the complete instantiation of a Blueprint, with running containers
@@ -57,6 +58,16 @@ func (hsDep *HomeserverDeployment) SetEndpoints(baseURL string, fedBaseURL strin
5758
}
5859
}
5960

61+
func (d *Deployment) GetFullyQualifiedHomeserverName(t ct.TestLike, hsName string) spec.ServerName {
62+
_, ok := d.HS[hsName]
63+
if !ok {
64+
ct.Fatalf(t, "Deployment.GetFullyQualifiedHomeserverName - HS name '%s' not found", hsName)
65+
}
66+
// We have network aliases for each Docker container that will resolve the `hsName` to
67+
// the container.
68+
return spec.ServerName(hsName)
69+
}
70+
6071
// DestroyAtCleanup destroys the entire deployment. It should be called at cleanup time for dirty
6172
// deployments only. Handles configuration options for things which should run at container destroy
6273
// time, like post-run scripts and printing logs.

test_main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ func WithCleanup(fn func(config *config.Complement)) opt {
3939
}
4040

4141
// WithDeployment adds a custom mechanism to deploy homeservers.
42+
//
43+
// For test consistency and compatibility, deployers should be creating servers that can
44+
// be referred to as `hs1`, `hs2`, etc as the `hsName` in the `Deployment` interface.
45+
// The actual resolvable address of the homeserver in the network can be something
46+
// different and just needs to be mapped by
47+
// your implementation of `deployment.GetFullyQualifiedHomeserverName(hsName)`.
4248
func WithDeployment(fn func(t ct.TestLike, numServers int, config *config.Complement) Deployment) opt {
4349
return func(co *complementOpts) {
4450
co.customDeployment = fn
@@ -93,6 +99,9 @@ func OldDeploy(t ct.TestLike, blueprint b.Blueprint) Deployment {
9399
// Deploy will deploy the given number of servers or terminate the test.
94100
// This function is the main setup function for all tests as it provides a deployment with
95101
// which tests can interact with.
102+
//
103+
// For test consistency and compatibility, deployers should be creating servers that can
104+
// be referred to as `hs1`, `hs2`, etc as the `hsName` in the `Deployment` interface.
96105
func Deploy(t ct.TestLike, numServers int) Deployment {
97106
t.Helper()
98107
if testPackage == nil {

test_package.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ import (
1515
"github.com/matrix-org/complement/ct"
1616
"github.com/matrix-org/complement/helpers"
1717
"github.com/matrix-org/complement/internal/docker"
18+
"github.com/matrix-org/gomatrixserverlib/spec"
1819
"github.com/sirupsen/logrus"
1920
)
2021

2122
// Deployment provides a way for tests to interact with a set of homeservers.
2223
type Deployment interface {
24+
// Returns the resolvable server name (host) of a homeserver given its short alias
25+
// (e.g., "hs1", "hs2").
26+
//
27+
// In the case of the standard Docker deployment, this will be the same `hs1`, `hs2`
28+
// but may be different for other custom deployments (ex.
29+
// `shardDeployment1.GetFullyQualifiedHomeserverName(t, "hs1")` -> `hs1.shard1:8081`).
30+
GetFullyQualifiedHomeserverName(t ct.TestLike, hsName string) spec.ServerName
2331
// UnauthenticatedClient returns a blank CSAPI client.
2432
UnauthenticatedClient(t ct.TestLike, serverName string) *client.CSAPI
2533
// Register a new user on the given server.

tests/csapi/admin_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/matrix-org/complement/helpers"
1313
"github.com/matrix-org/complement/match"
1414
"github.com/matrix-org/complement/must"
15+
"github.com/matrix-org/gomatrixserverlib/spec"
1516
)
1617

1718
// Check if this homeserver supports Synapse-style admin registration.
@@ -69,7 +70,7 @@ func TestServerNotices(t *testing.T) {
6970
})
7071
})
7172
t.Run("Alice can join the alert room", func(t *testing.T) {
72-
alice.MustJoinRoom(t, roomID, []string{})
73+
alice.MustJoinRoom(t, roomID, []spec.ServerName{})
7374
alice.MustSyncUntil(t, client.SyncReq{}, client.SyncTimelineHasEventID(roomID, eventID))
7475
})
7576
t.Run("Alice can leave the alert room, after joining it", func(t *testing.T) {

tests/csapi/apidoc_presence_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/matrix-org/complement/helpers"
1717
"github.com/matrix-org/complement/match"
1818
"github.com/matrix-org/complement/must"
19+
"github.com/matrix-org/gomatrixserverlib/spec"
1920
)
2021

2122
func TestPresence(t *testing.T) {
@@ -27,7 +28,9 @@ func TestPresence(t *testing.T) {
2728

2829
// to share presence alice and bob must be in a shared room
2930
roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"})
30-
bob.MustJoinRoom(t, roomID, []string{"hs1"})
31+
bob.MustJoinRoom(t, roomID, []spec.ServerName{
32+
deployment.GetFullyQualifiedHomeserverName(t, "hs1"),
33+
})
3134

3235
// sytest: GET /presence/:user_id/status fetches initial status
3336
t.Run("GET /presence/:user_id/status fetches initial status", func(t *testing.T) {

0 commit comments

Comments
 (0)