Skip to content

Commit

Permalink
Simplify process spawning in integration tests (#3759)
Browse files Browse the repository at this point in the history
* [feat] refactoring: use proper bracketing of services

* [chore] some minor cleanups and more comments

* [fix] class continuation in the right place

* [wip] some print statements and more experimentations around interrupt
signals

* Add bracketed service spawning

* Use codensity spawner

* Pass service map to liveness check

* Reimplement timeout using Async

* Use a static service map

Since service ports are allocated statically, there is no point anymore
in dynamically reconfiguring the environment when a new backend is
spawned. This simplifies the logic dramatically.

* Use traverseConcurrentlyCodensity

* Cleanup and fix warnings

* Add CHANGELOG entry

* Minor cleanups

---------

Co-authored-by: Magnus Viernickel <magnus.viernickel@wire.com>
  • Loading branch information
pcapriotti and MangoIV authored Dec 8, 2023
1 parent f0043e6 commit 2c657ce
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 227 deletions.
1 change: 1 addition & 0 deletions changelog.d/5-internal/integration-proper-cleanup
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Simplify process spawning of dynamic backends in integration tests
15 changes: 9 additions & 6 deletions integration/test/Testlib/Env.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,26 @@ mkGlobalEnv cfgFile = do
& Cassandra.setContacts intConfig.cassandra.host []
& Cassandra.setPortNumber (fromIntegral intConfig.cassandra.port)
cassClient <- Cassandra.init cassSettings
let resources = backendResources (Map.elems intConfig.dynamicBackends)
resourcePool <-
liftIO $
createBackendResourcePool
(Map.elems intConfig.dynamicBackends)
resources
intConfig.rabbitmq
cassClient
let sm =
Map.fromList $
[ (intConfig.backendOne.originDomain, intConfig.backendOne.beServiceMap),
(intConfig.backendTwo.originDomain, intConfig.backendTwo.beServiceMap)
]
<> [(berDomain resource, resourceServiceMap resource) | resource <- resources]
tempDir <- Codensity $ withSystemTempDirectory "test"
timeOutSeconds <-
liftIO $
fromMaybe 10 . (readMaybe @Int =<<) <$> (lookupEnv "TEST_TIMEOUT_SECONDS")
pure
GlobalEnv
{ gServiceMap =
Map.fromList
[ (intConfig.backendOne.originDomain, intConfig.backendOne.beServiceMap),
(intConfig.backendTwo.originDomain, intConfig.backendTwo.beServiceMap)
],
{ gServiceMap = sm,
gDomain1 = intConfig.backendOne.originDomain,
gDomain2 = intConfig.backendTwo.originDomain,
gDynamicDomains = (.domain) <$> Map.elems intConfig.dynamicBackends,
Expand Down
Loading

0 comments on commit 2c657ce

Please sign in to comment.