Skip to content

Commit

Permalink
patch: update ci and fix TestDrainers tests
Browse files Browse the repository at this point in the history
- `TestDrainer` tests weren't well made, they led to a race-like condition where a slow running machine will fail some draining tests
- fix metric registry_test.go tests (add default debugger logger)
  • Loading branch information
denopink committed Oct 21, 2024
1 parent cdd32a2 commit fc0d191
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ on:

jobs:
ci:
uses: xmidt-org/shared-go/.github/workflows/ci.yml@5bc4b83f25ff4c944cd6253ba189e50d1997ab3c # v4.1.0
uses: xmidt-org/shared-go/.github/workflows/ci.yml@3d552804b9a20638508bf359cdd2e9b46bc06879 # v4.4.24
with:
copyright-skip: true
lint-skip: true
style-skip: true
# tests-skip: true
release-type: library
style-skip: true
yaml-lint-skip: true
copyright-skip: true
lint-skip: true
release-type: library
release-docker: false
secrets: inherit
9 changes: 5 additions & 4 deletions device/drain/drainer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func testDrainerDrainAll(t *testing.T, deviceCount int) {
select {
case <-done:
// passed
case <-time.After(5 * time.Second):
case <-time.After(10 * time.Second):
assert.Fail("Drain failed to complete")
return
}
Expand Down Expand Up @@ -594,7 +594,7 @@ func testDrainerDrainCancel(t *testing.T) {
select {
case <-done:
// passing
case <-time.After(5 * time.Second):
case <-time.After(10 * time.Second):
assert.Fail("Drain failed to complete")
return
}
Expand Down Expand Up @@ -645,6 +645,7 @@ func testDrainFilter(t *testing.T, deviceTypeOne deviceInfo, deviceTypeTwo devic

stopCalled = false
stop = func() {
time.Sleep(time.Second * 5)
stopCalled = true
}

Expand Down Expand Up @@ -744,7 +745,7 @@ func testDrainFilter(t *testing.T, deviceTypeOne deviceInfo, deviceTypeTwo devic
select {
case <-done:
// passed
case <-time.After(5 * time.Second):
case <-time.After(10 * time.Second):
assert.Fail("Drain failed to complete")
return
}
Expand Down Expand Up @@ -882,7 +883,7 @@ func testDisconnectFilter(t *testing.T, deviceTypeOne deviceInfo, deviceTypeTwo
select {
case <-done:
// passed
case <-time.After(5 * time.Second):
case <-time.After(10 * time.Second):
assert.Fail("Drain failed to complete")
return
}
Expand Down
9 changes: 9 additions & 0 deletions xmetrics/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/xmidt-org/sallust"
)

func testRegistryAsPrometheusProvider(t *testing.T) {
Expand Down Expand Up @@ -38,6 +39,7 @@ func testRegistryAsPrometheusProvider(t *testing.T) {
MaxAge: 15 * time.Hour,
},
},
Logger: sallust.Default(),
}
)

Expand Down Expand Up @@ -143,6 +145,7 @@ func testRegistryAsGoKitProvider(t *testing.T) {
MaxAge: 15 * time.Hour,
},
},
Logger: sallust.Default(),
}
)

Expand Down Expand Up @@ -216,6 +219,7 @@ func testRegistryMissingName(t *testing.T) {
Type: "counter",
},
},
Logger: sallust.Default(),
})
)

Expand Down Expand Up @@ -257,6 +261,7 @@ func testRegistryModules(t *testing.T) {
Type: "gauge",
},
},
Logger: sallust.Default(),
}
)

Expand Down Expand Up @@ -293,6 +298,7 @@ func testRegistryDuplicate(t *testing.T) {
Type: "gauge",
},
},
Logger: sallust.Default(),
}
)

Expand Down Expand Up @@ -330,6 +336,7 @@ func testRegistryDuplicate(t *testing.T) {
Type: "counter",
},
},
Logger: sallust.Default(),
}
)

Expand All @@ -349,6 +356,7 @@ func testRegistryUnsupportedType(t *testing.T) {
Type: "huh?",
},
},
Logger: sallust.Default(),
})
)

Expand All @@ -368,6 +376,7 @@ func testRegistryCounterLabel(t *testing.T) {
LabelNames: []string{"label"},
},
},
Logger: sallust.Default(),
})
)

Expand Down

0 comments on commit fc0d191

Please sign in to comment.