Skip to content

Commit

Permalink
Tweak test to use Waiter for quicker timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
kegsay committed Jan 12, 2024
1 parent f015351 commit 2b11d89
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions tests/client_connectivity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/matrix-org/complement-crypto/internal/api"
"github.com/matrix-org/complement-crypto/internal/api/js"
"github.com/matrix-org/complement-crypto/internal/api/rust"
"github.com/matrix-org/complement/helpers"
"github.com/matrix-org/complement/must"
)

Expand Down Expand Up @@ -118,25 +119,26 @@ func TestSigkillBeforeKeysUploadResponse(t *testing.T) {
BaseURL: tc.Deployment.ReverseProxyURLForHS(clientType.HS),
SSURL: tc.Deployment.SlidingSyncURL(t),
})

cmd.WaitDelay = 3 * time.Second
defer close()
var wg sync.WaitGroup
wg.Add(1)

waiter := helpers.NewWaiter()
terminateClient = func() {
terminated.Store(true)
t.Logf("got keys/upload: terminating process")
t.Logf("got keys/upload: terminating process %v", cmd.Process.Pid)
if err := cmd.Process.Kill(); err != nil {
t.Fatalf("failed to kill process: %s", err)
t.Errorf("failed to kill process: %s", err)
return
}
if err := cmd.Wait(); err != nil {
t.Logf("error waiting for process to quit: %v", err)
}
cmd.Wait()
t.Logf("terminated process")
wg.Done()
waiter.Finish()
}
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Start()
wg.Wait()
waiter.Waitf(t, 5*time.Second, "failed to terminate process")
t.Logf("terminated process, making new client")
// now make the same client
cfg.BaseURL = tc.Deployment.ReverseProxyURLForHS(clientType.HS)
Expand Down

0 comments on commit 2b11d89

Please sign in to comment.