@@ -250,33 +250,65 @@ func (d *Deployer) executePostScript(hsDep *HomeserverDeployment, testName strin
250250 return cmd .CombinedOutput ()
251251}
252252
253- // Restart a homeserver deployment.
254- func (d * Deployer ) Restart (hsDep * HomeserverDeployment , cfg * config.Complement ) error {
253+ func (d * Deployer ) PauseServer (hsDep * HomeserverDeployment ) error {
254+ ctx := context .Background ()
255+ err := d .Docker .ContainerPause (ctx , hsDep .ContainerID )
256+ if err != nil {
257+ return fmt .Errorf ("failed to pause container %s: %s" , hsDep .ContainerID , err )
258+ }
259+ return nil
260+ }
261+
262+ func (d * Deployer ) UnpauseServer (hsDep * HomeserverDeployment ) error {
255263 ctx := context .Background ()
256- secs := int (cfg .SpawnHSTimeout .Seconds ())
264+ err := d .Docker .ContainerUnpause (ctx , hsDep .ContainerID )
265+ if err != nil {
266+ return fmt .Errorf ("failed to unpause container %s: %s" , hsDep .ContainerID , err )
267+ }
268+ return nil
269+ }
270+
271+ func (d * Deployer ) StopServer (hsDep * HomeserverDeployment ) error {
272+ ctx := context .Background ()
273+ secs := int (d .config .SpawnHSTimeout .Seconds ())
257274 err := d .Docker .ContainerStop (ctx , hsDep .ContainerID , container.StopOptions {
258275 Timeout : & secs ,
259276 })
260277 if err != nil {
261- return fmt .Errorf ("Restart: Failed to stop container %s: %s" , hsDep .ContainerID , err )
278+ return fmt .Errorf ("failed to stop container %s: %s" , hsDep .ContainerID , err )
262279 }
280+ return nil
281+ }
263282
264- err = d .Docker .ContainerStart (ctx , hsDep .ContainerID , types.ContainerStartOptions {})
283+ // Restart a homeserver deployment.
284+ func (d * Deployer ) Restart (hsDep * HomeserverDeployment ) error {
285+ if err := d .StopServer (hsDep ); err != nil {
286+ return fmt .Errorf ("Restart: %s" , err )
287+ }
288+ if err := d .StartServer (hsDep ); err != nil {
289+ return fmt .Errorf ("Restart: %s" , err )
290+ }
291+ return nil
292+ }
293+
294+ func (d * Deployer ) StartServer (hsDep * HomeserverDeployment ) error {
295+ ctx := context .Background ()
296+ err := d .Docker .ContainerStart (ctx , hsDep .ContainerID , types.ContainerStartOptions {})
265297 if err != nil {
266- return fmt .Errorf ("Restart: Failed to start container %s: %s" , hsDep .ContainerID , err )
298+ return fmt .Errorf ("failed to start container %s: %s" , hsDep .ContainerID , err )
267299 }
268300
269301 // Wait for the container to be ready.
270302 baseURL , fedBaseURL , err := waitForPorts (ctx , d .Docker , hsDep .ContainerID )
271303 if err != nil {
272- return fmt .Errorf ("Restart: Failed to get ports for container %s: %s" , hsDep .ContainerID , err )
304+ return fmt .Errorf ("failed to get ports for container %s: %s" , hsDep .ContainerID , err )
273305 }
274306 hsDep .SetEndpoints (baseURL , fedBaseURL )
275307
276- stopTime := time .Now ().Add (cfg .SpawnHSTimeout )
308+ stopTime := time .Now ().Add (d . config .SpawnHSTimeout )
277309 _ , err = waitForContainer (ctx , d .Docker , hsDep , stopTime )
278310 if err != nil {
279- return fmt .Errorf ("Restart: Failed to restart container %s: %s" , hsDep .ContainerID , err )
311+ return fmt .Errorf ("failed to wait for container %s: %s" , hsDep .ContainerID , err )
280312 }
281313
282314 return nil
0 commit comments