From 23b29cf28d2c9c0090ff416fe5e157952d35cda6 Mon Sep 17 00:00:00 2001 From: Kegan Dougal <7190048+kegsay@users.noreply.github.com> Date: Mon, 15 Jan 2024 09:09:49 +0000 Subject: [PATCH] Try to get mitmproxy logs --- .github/workflows/tests.yaml | 5 +++++ tests/client_connectivity_test.go | 9 +++------ .../sigkill_before_keys_upload_response.go | 13 ------------- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 4344253..35f601c 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -42,6 +42,8 @@ jobs: run: | sudo apt-get update && sudo apt-get install -y libolm3 libolm-dev go install -v github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest + cat /etc/hosts + ping -c 1 host.docker.internal # Install whatever version of the JS SDK is in package.json - name: Build JS SDK @@ -113,6 +115,9 @@ jobs: COMPLEMENT_SHARE_ENV_PREFIX: PASS_ PASS_SYNAPSE_COMPLEMENT_DATABASE: sqlite DOCKER_BUILDKIT: 1 + + - run: | + docker ps | grep mitm | grep -Eo '[^ ]*$' | xargs docker logs - name: Upload logs uses: actions/upload-artifact@v2 diff --git a/tests/client_connectivity_test.go b/tests/client_connectivity_test.go index 0d233bd..b2202d9 100644 --- a/tests/client_connectivity_test.go +++ b/tests/client_connectivity_test.go @@ -5,7 +5,6 @@ import ( "net/http" "os" "os/exec" - "strconv" "sync" "sync/atomic" "testing" @@ -120,15 +119,13 @@ func TestSigkillBeforeKeysUploadResponse(t *testing.T) { BaseURL: tc.Deployment.ReverseProxyURLForHS(clientType.HS), SSURL: tc.Deployment.SlidingSyncURL(t), }) - cmd.WaitDelay = 10 * time.Second + cmd.WaitDelay = 3 * time.Second defer close() waiter := helpers.NewWaiter() terminateClient = func() { terminated.Store(true) t.Logf("got keys/upload: terminating process %v", cmd.Process.Pid) - kill := exec.Command("kill", "-USR2", strconv.Itoa(cmd.Process.Pid)) - t.Logf(kill.String()) - if err := kill.Run(); err != nil { + if err := cmd.Process.Kill(); err != nil { t.Errorf("failed to kill process: %s", err) return } @@ -138,7 +135,7 @@ func TestSigkillBeforeKeysUploadResponse(t *testing.T) { cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.Start() - waiter.Waitf(t, 20*time.Second, "failed to terminate process") + 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) diff --git a/tests/templates/sigkill_before_keys_upload_response.go b/tests/templates/sigkill_before_keys_upload_response.go index 58780dd..9f5bc0e 100644 --- a/tests/templates/sigkill_before_keys_upload_response.go +++ b/tests/templates/sigkill_before_keys_upload_response.go @@ -3,8 +3,6 @@ package main import ( "fmt" "os" - "os/signal" - "syscall" "time" "github.com/matrix-org/complement-crypto/internal/api" @@ -26,18 +24,7 @@ func (t *MockT) Fatalf(f string, args ...any) { } func (t *MockT) Name() string { return "inline_script" } -func ProcessSignal() { - sigch := make(chan os.Signal, 2) - signal.Notify(sigch, syscall.SIGUSR2) - for { - signalType := <-sigch - fmt.Println("Received signal SIGUSR2 from channel : ", signalType) - panic("terminating...") - } -} - func main() { - go ProcessSignal() time.Sleep(time.Second) t := &MockT{} cfg := api.ClientCreationOpts{