Skip to content

Commit

Permalink
Try using SIGUSR2 instead of SIGKILL for CI to work?
Browse files Browse the repository at this point in the history
  • Loading branch information
kegsay committed Jan 15, 2024
1 parent afb8afa commit 9722c83
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/client_connectivity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"
"os"
"os/exec"
"strconv"
"sync"
"sync/atomic"
"testing"
Expand Down Expand Up @@ -125,13 +126,12 @@ func TestSigkillBeforeKeysUploadResponse(t *testing.T) {
terminateClient = func() {
terminated.Store(true)
t.Logf("got keys/upload: terminating process %v", cmd.Process.Pid)
if err := cmd.Process.Kill(); err != nil {
kill := exec.Command("kill", "-USR2", strconv.Itoa(cmd.Process.Pid))
t.Logf(kill.String())
if err := kill.Run(); err != nil {
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)
}
t.Logf("terminated process")
waiter.Finish()
}
Expand Down
13 changes: 13 additions & 0 deletions tests/templates/sigkill_before_keys_upload_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"time"

"github.com/matrix-org/complement-crypto/internal/api"
Expand All @@ -24,7 +26,18 @@ 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{
Expand Down

0 comments on commit 9722c83

Please sign in to comment.