From df785ea9e53ef2c2037f74511d79982520e09dbc Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 16 Nov 2023 18:54:04 +0000 Subject: [PATCH] Add docs and proper cleanup function --- README.md | 1 + go.mod | 4 ++-- go.sum | 4 ++-- internal/deploy/deploy.go | 1 + tests/main_test.go | 8 +++----- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d11c182..ae4f894 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ If you get failing tests, JS SDK logs to file as does Rust SDK in `./tests`, whi - `COMPLEMENT_CRYPTO_TEST_CLIENT_MATRIX` : Comma separated clients to run. Default: `jj,jr,rj,rr` Control which kinds of clients to make for tests. `r` creates Rust client. `j` creates JS clients. The default runs all permutations. +- `COMPLEMENT_CRYPTO_TCPDUMP`: If `1`, will execute `tcpdump` automatically when the servers are running on the dynamic ports being used. To run this, `go test` must be run with `sudo -E` (preserve env vars for configuration) e.g `COMPLEMENT_BASE_IMAGE=homeserver:latest sudo -E go test ./tests`. Listens for synapse and sliding sync traffic. ### Test hitlist diff --git a/go.mod b/go.mod index 0bcb2d8..a85a0de 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,9 @@ require ( github.com/chromedp/cdproto v0.0.0-20231025043423-5615e204d422 github.com/chromedp/chromedp v0.9.3 github.com/docker/go-connections v0.4.0 - github.com/matrix-org/complement v0.0.0-20231030161126-e811566d9bb6 + github.com/matrix-org/complement v0.0.0-20231116184323-62f59c436d00 github.com/testcontainers/testcontainers-go v0.26.0 + golang.org/x/exp v0.0.0-20230905200255-921286631fa9 ) require ( @@ -58,7 +59,6 @@ require ( github.com/tklauser/numcpus v0.6.1 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect golang.org/x/crypto v0.14.0 // indirect - golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.13.0 // indirect diff --git a/go.sum b/go.sum index 4d0718a..d8af832 100644 --- a/go.sum +++ b/go.sum @@ -83,8 +83,8 @@ github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0V github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/matrix-org/complement v0.0.0-20231030161126-e811566d9bb6 h1:CooPBAdWBGghbspoZj83k12XC/6c/ofmTg52R8Zy5NU= -github.com/matrix-org/complement v0.0.0-20231030161126-e811566d9bb6/go.mod h1:UQqYuClBEPysOJJU4MKWVSna3ev8q56aV6OeYm0lk3g= +github.com/matrix-org/complement v0.0.0-20231116184323-62f59c436d00 h1:nljG6wWK2IgqNFCkGXllzsDEm7EDNEcUn3XyoUSVouI= +github.com/matrix-org/complement v0.0.0-20231116184323-62f59c436d00/go.mod h1:MpFg8YqIgcfReuwX5x0HyIsxkekKyUvbXxY6ey9LeE0= github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530 h1:kHKxCOLcHH8r4Fzarl4+Y3K5hjothkVW5z7T1dUM11U= github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s= github.com/matrix-org/gomatrixserverlib v0.0.0-20230921171121-0466775328c7 h1:NhPNNFLHwdDb/upeicBh1GkxX/sFinEp5HF1WBqPtiY= diff --git a/internal/deploy/deploy.go b/internal/deploy/deploy.go index 6b02753..09568b5 100644 --- a/internal/deploy/deploy.go +++ b/internal/deploy/deploy.go @@ -46,6 +46,7 @@ func (d *SlidingSyncDeployment) Teardown() { } } if d.tcpdump != nil { + fmt.Println("Killing tcpdump...") d.tcpdump.Process.Signal(os.Interrupt) } } diff --git a/tests/main_test.go b/tests/main_test.go index 2c9f039..7368406 100644 --- a/tests/main_test.go +++ b/tests/main_test.go @@ -43,17 +43,15 @@ func TestMain(m *testing.M) { testClientMatrix = append(testClientMatrix, testCase) } ssMutex = &sync.Mutex{} - defer func() { // always teardown even if panicking + api.SetupJSLogs("js_sdk.log") // rust sdk logs on its own + complement.TestMainWithCleanup(m, "crypto", func() { // always teardown even if panicking ssMutex.Lock() if ssDeployment != nil { ssDeployment.Teardown() } ssMutex.Unlock() api.WriteJSLogs() - }() - api.SetupJSLogs("js_sdk.log") // rust sdk logs on its own - complement.TestMain(m, "crypto") - + }) } func Deploy(t *testing.T) *deploy.SlidingSyncDeployment {