1
1
import { Hash } from '@twake/crypto'
2
- import dockerComposeV1 , { v2 as dockerComposeV2 } from 'docker-compose'
3
2
import express from 'express'
4
3
import fs from 'fs'
5
4
import type * as http from 'http'
@@ -57,7 +56,6 @@ describe('Federation server', () => {
57
56
} )
58
57
59
58
describe ( 'Integration tests' , ( ) => {
60
- let containerNameSuffix : string
61
59
let startedCompose : StartedDockerComposeEnvironment
62
60
let identity1IPAddress : string
63
61
let identity2IPAddress : string
@@ -172,43 +170,17 @@ describe('Federation server', () => {
172
170
syswideCas . addCAs (
173
171
path . join ( pathToTestDataFolder , 'nginx' , 'ssl' , 'ca.pem' )
174
172
)
175
- Promise . allSettled ( [ dockerComposeV1 . version ( ) , dockerComposeV2 . version ( ) ] )
176
- // eslint-disable-next-line @typescript-eslint/promise-function-async
177
- . then ( ( results ) => {
178
- const promiseSucceededIndex = results . findIndex (
179
- ( res ) => res . status === 'fulfilled'
180
- )
181
- if ( promiseSucceededIndex === - 1 ) {
182
- throw new Error ( 'Docker compose is not installed' )
183
- }
184
- containerNameSuffix = promiseSucceededIndex === 0 ? '_' : '-'
185
- return new DockerComposeEnvironment (
186
- path . join ( pathToTestDataFolder ) ,
187
- 'docker-compose.yml'
188
- )
189
- . withEnvironment ( { MYUID : os . userInfo ( ) . uid . toString ( ) } )
190
- . withWaitStrategy (
191
- `postgresql${ containerNameSuffix } 1` ,
192
- Wait . forHealthCheck ( )
193
- )
194
- . withWaitStrategy (
195
- `synapse-federation${ containerNameSuffix } 1` ,
196
- Wait . forHealthCheck ( )
197
- )
198
- . withWaitStrategy (
199
- `synapse-1${ containerNameSuffix } 1` ,
200
- Wait . forHealthCheck ( )
201
- )
202
- . withWaitStrategy (
203
- `synapse-2${ containerNameSuffix } 1` ,
204
- Wait . forHealthCheck ( )
205
- )
206
- . withWaitStrategy (
207
- `synapse-3${ containerNameSuffix } 1` ,
208
- Wait . forHealthCheck ( )
209
- )
210
- . up ( )
211
- } )
173
+ new DockerComposeEnvironment (
174
+ path . join ( pathToTestDataFolder ) ,
175
+ 'docker-compose.yml'
176
+ )
177
+ . withEnvironment ( { MYUID : os . userInfo ( ) . uid . toString ( ) } )
178
+ . withWaitStrategy ( 'postgresql' , Wait . forHealthCheck ( ) )
179
+ . withWaitStrategy ( 'synapse-federation' , Wait . forHealthCheck ( ) )
180
+ . withWaitStrategy ( 'synapse-1' , Wait . forHealthCheck ( ) )
181
+ . withWaitStrategy ( 'synapse-2' , Wait . forHealthCheck ( ) )
182
+ . withWaitStrategy ( 'synapse-3' , Wait . forHealthCheck ( ) )
183
+ . up ( )
212
184
// eslint-disable-next-line @typescript-eslint/promise-function-async
213
185
. then ( ( upResult ) => {
214
186
startedCompose = upResult
@@ -275,10 +247,10 @@ describe('Federation server', () => {
275
247
276
248
beforeAll ( ( done ) => {
277
249
identity1IPAddress = startedCompose
278
- . getContainer ( `identity-server-1${ containerNameSuffix } 1 ` )
250
+ . getContainer ( `identity-server-1` )
279
251
. getIpAddress ( 'test' )
280
252
identity2IPAddress = startedCompose
281
- . getContainer ( `identity-server-2${ containerNameSuffix } 1 ` )
253
+ . getContainer ( `identity-server-2` )
282
254
. getIpAddress ( 'test' )
283
255
284
256
confOriginalContent = fs . readFileSync (
@@ -295,9 +267,8 @@ describe('Federation server', () => {
295
267
'utf-8'
296
268
)
297
269
298
- federationServerContainer = startedCompose . getContainer (
299
- `federation-server${ containerNameSuffix } 1`
300
- )
270
+ federationServerContainer =
271
+ startedCompose . getContainer ( 'federation-server' )
301
272
302
273
federationServerContainer
303
274
. restart ( )
@@ -746,25 +717,19 @@ describe('Federation server', () => {
746
717
'Certificates files for federation server has not been created'
747
718
)
748
719
return Promise . all ( [
749
- startedCompose
750
- . getContainer ( `identity-server-1${ containerNameSuffix } 1` )
751
- . restart ( ) ,
752
- startedCompose
753
- . getContainer ( `identity-server-2${ containerNameSuffix } 1` )
754
- . restart ( ) ,
755
- startedCompose
756
- . getContainer ( `identity-server-3${ containerNameSuffix } 1` )
757
- . restart ( )
720
+ startedCompose . getContainer ( 'identity-server-1' ) . restart ( ) ,
721
+ startedCompose . getContainer ( 'identity-server-2' ) . restart ( ) ,
722
+ startedCompose . getContainer ( 'identity-server-3' ) . restart ( )
758
723
] )
759
724
} )
760
725
// eslint-disable-next-line @typescript-eslint/promise-function-async
761
726
. then ( ( ) => {
762
727
identity1IPAddress = startedCompose
763
- . getContainer ( `identity-server-1${ containerNameSuffix } 1 ` )
728
+ . getContainer ( `identity-server-1` )
764
729
. getIpAddress ( 'test' )
765
730
766
731
identity2IPAddress = startedCompose
767
- . getContainer ( `identity-server-2${ containerNameSuffix } 1 ` )
732
+ . getContainer ( `identity-server-2` )
768
733
. getIpAddress ( 'test' )
769
734
770
735
const testConfig : Config = {
@@ -776,16 +741,16 @@ describe('Federation server', () => {
776
741
database_user : 'twake' ,
777
742
database_password : 'twake!1' ,
778
743
database_host : `${ startedCompose
779
- . getContainer ( `postgresql${ containerNameSuffix } 1 ` )
744
+ . getContainer ( `postgresql` )
780
745
. getHost ( ) } :5432`,
781
746
database_name : 'federation' ,
782
747
ldap_base : 'dc=example,dc=com' ,
783
748
ldap_uri : `ldap://${ startedCompose
784
- . getContainer ( `postgresql${ containerNameSuffix } 1 ` )
749
+ . getContainer ( `postgresql` )
785
750
. getHost ( ) } :389`,
786
751
matrix_database_engine : 'pg' ,
787
752
matrix_database_host : `${ startedCompose
788
- . getContainer ( `postgresql${ containerNameSuffix } 1 ` )
753
+ . getContainer ( `postgresql` )
789
754
. getHost ( ) } :5432`,
790
755
matrix_database_name : 'synapsefederation' ,
791
756
matrix_database_user : 'synapse' ,
0 commit comments