Skip to content

Commit

Permalink
fix: mismatch score found at TestClientEnqueueWithGroupOption
Browse files Browse the repository at this point in the history
  • Loading branch information
kanzihuang committed Mar 21, 2024
1 parent a4802c1 commit 1c3bdbc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,11 @@ func TestClientEnqueueWithGroupOption(t *testing.T) {
},
},
{
desc: "With Group and ProcessIn options",
desc: "With Group and ProcessAt options",
task: task,
opts: []Option{
Group("mygroup"),
ProcessIn(30 * time.Minute),
ProcessAt(now.Add(30 * time.Minute)),
},
wantInfo: &TaskInfo{
Queue: "default",
Expand Down
27 changes: 18 additions & 9 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/redis/go-redis/v9"
"os"
"runtime"
"sync"
"syscall"
"testing"
"time"
Expand Down Expand Up @@ -119,44 +120,52 @@ func TestServer(t *testing.T) {

func TestServerRun(t *testing.T) {
if runtime.GOOS == "windows" {
// because Sending Interrupt on Windows is not implemented
t.Skip("because Sending Interrupt on Windows is not implemented")
return
}

// https://github.com/go-redis/redis/issues/1029
ignoreOpt := goleak.IgnoreTopFunction("github.com/redis/go-redis/v9/internal/pool.(*ConnPool).reaper")
defer goleak.VerifyNone(t, ignoreOpt)

srv := NewServer(RedisClientOpt{Addr: ":6379"}, Config{LogLevel: testLogLevel})

done := make(chan struct{})
go func() {
mux := NewServeMux()
srv := NewServer(RedisClientOpt{Addr: ":6379"}, Config{LogLevel: testLogLevel})
if err := srv.Run(mux); err != nil {
t.Fatal(err)
}
done <- struct{}{}
}()
time.Sleep(1 * time.Second)

// Make sure server exits when receiving TERM signal.
go func() {
p, err := os.FindProcess(os.Getpid())
if err != nil {
t.Error("FindProcess:", err)
t.Error(err)
return
}
err = p.Signal(syscall.SIGTERM)
if err != nil {
t.Error(err)
t.Error("Signal:", err)
return
}
}()

wg := sync.WaitGroup{}
wg.Add(1)
go func() {
defer wg.Done()
select {
case <-time.After(10 * time.Second):
panic("server did not stop after receiving TERM signal")
case <-done:
}
}()

mux := NewServeMux()
if err := srv.Run(mux); err != nil {
t.Fatal(err)
}
done <- struct{}{}
wg.Wait()
}

func TestServerShutdown(t *testing.T) {
Expand Down

0 comments on commit 1c3bdbc

Please sign in to comment.