Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: switch to quartz for time testing#48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
spikecurtis merged 1 commit intomainfromspike/quartz
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletionsgo.mod
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,9 @@ replace tailscale.com => github.com/coder/tailscale v1.1.1-0.20240702054557-aa55

require (
cdr.dev/slog v1.6.2-0.20240126064726-20367d4aede6
github.com/benbjohnson/clock v1.3.5
github.com/breml/rootcerts v0.2.11
github.com/coder/coder/v2 v2.10.1-0.20240703121105-f6639b788f7b
github.com/coder/quartz v0.1.0
github.com/fatih/color v1.17.0
github.com/go-chi/chi/v5 v5.1.0
github.com/google/uuid v1.6.0
Expand DownExpand Up@@ -61,7 +61,6 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/charmbracelet/lipgloss v0.8.0 // indirect
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0 // indirect
github.com/coder/quartz v0.1.0 // indirect
github.com/coder/retry v1.5.1 // indirect
github.com/coder/serpent v0.7.0 // indirect
github.com/coder/terraform-provider-coder v0.23.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletionsgo.sum
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -97,8 +97,6 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o=
github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E=
Expand Down
10 changes: 5 additions & 5 deletionslogger.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ import (
"sync"
"time"

"github.com/benbjohnson/clock"
"github.com/fatih/color"
"github.com/google/uuid"
appsv1 "k8s.io/api/apps/v1"
Expand All@@ -20,6 +19,7 @@ import (
"cdr.dev/slog"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/agentsdk"
"github.com/coder/quartz"

// *Never* remove this. Certificates are not bundled as part
// of the container, so this is necessary for all connections
Expand All@@ -29,7 +29,7 @@ import (

type podEventLoggerOptions struct {
client kubernetes.Interface
clockclock.Clock
clockquartz.Clock
coderURL *url.URL

logger slog.Logger
Expand All@@ -49,7 +49,7 @@ func newPodEventLogger(ctx context.Context, opts podEventLoggerOptions) (*podEve
opts.logDebounce = 30 * time.Second
}
if opts.clock == nil {
opts.clock =clock.New()
opts.clock =quartz.NewReal()
}

logCh := make(chan agentLog, 512)
Expand DownExpand Up@@ -388,7 +388,7 @@ type agentLog struct {
type logQueuer struct {
mu sync.Mutex
logger slog.Logger
clockclock.Clock
clockquartz.Clock
q chan agentLog

coderURL *url.URL
Expand DownExpand Up@@ -525,7 +525,7 @@ func (l *logQueuer) loggerTimeout(agentToken string) {
type agentLoggerLifecycle struct {
scriptLogger agentsdk.ScriptLogger

closeTimer *clock.Timer
closeTimer *quartz.Timer
close func()
}

Expand Down
12 changes: 6 additions & 6 deletionslogger_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,7 +11,6 @@ import (
"testing"
"time"

"github.com/benbjohnson/clock"
"github.com/go-chi/chi/v5"
"github.com/hashicorp/yamux"
"github.com/stretchr/testify/require"
Expand All@@ -30,6 +29,7 @@ import (
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/agentsdk"
"github.com/coder/coder/v2/testutil"
"github.com/coder/quartz"
)

func TestReplicaSetEvents(t *testing.T) {
Expand All@@ -43,7 +43,7 @@ func TestReplicaSetEvents(t *testing.T) {
namespace := "test-namespace"
client := fake.NewSimpleClientset()

cMock :=clock.NewMock()
cMock :=quartz.NewMock(t)
reporter, err := newPodEventLogger(ctx, podEventLoggerOptions{
client: client,
coderURL: agentURL,
Expand DownExpand Up@@ -140,7 +140,7 @@ func TestPodEvents(t *testing.T) {
namespace := "test-namespace"
client := fake.NewSimpleClientset()

cMock :=clock.NewMock()
cMock :=quartz.NewMock(t)
reporter, err := newPodEventLogger(ctx, podEventLoggerOptions{
client: client,
coderURL: agentURL,
Expand DownExpand Up@@ -284,7 +284,7 @@ func Test_logQueuer(t *testing.T) {
api := newFakeAgentAPI(t)
agentURL, err := url.Parse(api.server.URL)
require.NoError(t, err)
clock :=clock.NewMock()
clock :=quartz.NewMock(t)
ttl := time.Second

ch := make(chan agentLog)
Expand All@@ -300,7 +300,7 @@ func Test_logQueuer(t *testing.T) {
},
}

ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
go lq.work(ctx)

Expand DownExpand Up@@ -335,7 +335,7 @@ func Test_logQueuer(t *testing.T) {
logs = testutil.RequireRecvCtx(ctx, t, api.logs)
require.Len(t, logs, 1)

clock.Add(2 *ttl)
clock.Advance(ttl)
// wait for the client to disconnect
_ = testutil.RequireRecvCtx(ctx, t, api.disconnect)
})
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp