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

chore: de-flake TestWorkspaceAgent_Metadata (round 2)#7039

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
ammario merged 1 commit intomainfromfix-flake-1
Apr 6, 2023
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
4 changes: 2 additions & 2 deletionsagent/reaper/reaper_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,7 @@ func TestReap(t *testing.T) {
// Don't run the reaper test in CI. It does weird
// things like forkexecing which may have unintended
// consequences in CI.
if_, ok := os.LookupEnv("CI"); ok {
iftestutil.InCI() {
t.Skip("Detected CI, skipping reaper tests")
}

Expand DownExpand Up@@ -73,7 +73,7 @@ func TestReapInterrupt(t *testing.T) {
// Don't run the reaper test in CI. It does weird
// things like forkexecing which may have unintended
// consequences in CI.
if_, ok := os.LookupEnv("CI"); ok {
iftestutil.InCI() {
t.Skip("Detected CI, skipping reaper tests")
}

Expand Down
10 changes: 7 additions & 3 deletionscoderd/workspaceagents_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1353,16 +1353,20 @@ func TestWorkspaceAgent_Metadata(t *testing.T) {
var update []codersdk.WorkspaceAgentMetadata

check := func(want codersdk.WorkspaceAgentMetadataResult, got codersdk.WorkspaceAgentMetadata) {
require.Greater(t, got.Result.CollectedAt, want.CollectedAt)
require.Equal(t, want.Value, got.Result.Value)
require.Equal(t, want.Error, got.Result.Error)

if testutil.InCI() && (runtime.GOOS == "windows" || testutil.InRaceMode()) {
// Avoid testing timings when flake chance is high.
return
}
require.WithinDuration(t, got.Result.CollectedAt, want.CollectedAt, time.Second)
ageImpliedNow := got.Result.CollectedAt.Add(time.Duration(got.Result.Age) * time.Second)
// We use a long WithinDuration to tolerate slow CI, but we're still making sure
// that Age is within the ballpark.
require.WithinDuration(
t, time.Now(), ageImpliedNow, time.Second*10,
)
require.Equal(t, want.Value, got.Result.Value)
require.Equal(t, want.Error, got.Result.Error)
}

wantMetadata1 := codersdk.WorkspaceAgentMetadataResult{
Expand Down
4 changes: 3 additions & 1 deletionhelm/tests/chart_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,8 @@ import (

"github.com/stretchr/testify/require"
"golang.org/x/xerrors"

"github.com/coder/coder/testutil"
)

// These tests run `helm template` with the values file specified in each test
Expand DownExpand Up@@ -54,7 +56,7 @@ func TestRenderChart(t *testing.T) {
if *UpdateGoldenFiles {
t.Skip("Golden files are being updated. Skipping test.")
}
if_, runningInCI := os.LookupEnv("CI"); runningInCI {
iftestutil.InCI() {
switch runtime.GOOS {
case "windows", "darwin":
t.Skip("Skipping tests on Windows and macOS in CI")
Expand Down
16 changes: 16 additions & 0 deletionstestutil/ci.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
package testutil

import (
"flag"
"os"
)

func InCI() bool {
_, ok := os.LookupEnv("CI")
return ok
}

func InRaceMode() bool {
fl := flag.Lookup("race")
return fl != nil && fl.Value.String() == "true"
}
4 changes: 3 additions & 1 deletiontestutil/duration.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,9 @@

package testutil

import "time"
import (
"time"
)

// Constants for timing out operations, usable for creating contexts
// that timeout or in require.Eventually.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp