chore: fix flakey tests
This commit is contained in:
parent
5fca2d9482
commit
a413f9d6af
|
|
@ -508,36 +508,33 @@ func TestGroupQueueBlocksWhenQueueFull(t *testing.T) {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
trackings, waitGroups := execAllGroupActions(t, e, cfg, actions)
|
wg1, tracking1 := e.ExecRequest(&ExecutionRequest{
|
||||||
|
Binding: e.FindBindingWithNoEntity(actions[0]),
|
||||||
|
Cfg: cfg,
|
||||||
|
AuthenticatedUser: auth.UserFromSystem(cfg, "testuser"),
|
||||||
|
})
|
||||||
|
waitUntilExecutionStarted(t, e, tracking1)
|
||||||
|
|
||||||
require.Eventually(t, func() bool {
|
trackings := []string{tracking1}
|
||||||
return countSnapshots(e, trackings, func(snapshot LogEntrySnapshot) bool { return snapshot.Blocked }) == 1 &&
|
waitGroups := []*sync.WaitGroup{wg1}
|
||||||
countSnapshots(e, trackings, func(snapshot LogEntrySnapshot) bool { return snapshot.Queued }) == 2 &&
|
|
||||||
countSnapshots(e, trackings, isRunningSnapshot) == 1
|
|
||||||
}, 2*time.Second, 20*time.Millisecond)
|
|
||||||
|
|
||||||
for _, wg := range waitGroups {
|
for _, action := range actions[1:] {
|
||||||
wg.Wait()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func execAllGroupActions(t *testing.T, e *Executor, cfg *config.Config, actions []*config.Action) ([]string, []*sync.WaitGroup) {
|
|
||||||
t.Helper()
|
|
||||||
|
|
||||||
trackings := make([]string, len(actions))
|
|
||||||
waitGroups := make([]*sync.WaitGroup, len(actions))
|
|
||||||
|
|
||||||
for idx, action := range actions {
|
|
||||||
wg, tracking := e.ExecRequest(&ExecutionRequest{
|
wg, tracking := e.ExecRequest(&ExecutionRequest{
|
||||||
Binding: e.FindBindingWithNoEntity(action),
|
Binding: e.FindBindingWithNoEntity(action),
|
||||||
Cfg: cfg,
|
Cfg: cfg,
|
||||||
AuthenticatedUser: auth.UserFromSystem(cfg, "testuser"),
|
AuthenticatedUser: auth.UserFromSystem(cfg, "testuser"),
|
||||||
})
|
})
|
||||||
trackings[idx] = tracking
|
trackings = append(trackings, tracking)
|
||||||
waitGroups[idx] = wg
|
waitGroups = append(waitGroups, wg)
|
||||||
}
|
}
|
||||||
|
|
||||||
return trackings, waitGroups
|
require.Eventually(t, func() bool {
|
||||||
|
return groupExecutionDistributionMatches(e, trackings, 1, 2, 1)
|
||||||
|
}, 2*time.Second, 20*time.Millisecond)
|
||||||
|
|
||||||
|
for _, wg := range waitGroups {
|
||||||
|
wg.Wait()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func groupExecutionDistributionMatches(e *Executor, trackings []string, wantRunning, wantQueued, wantBlocked int) bool {
|
func groupExecutionDistributionMatches(e *Executor, trackings []string, wantRunning, wantQueued, wantBlocked int) bool {
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,22 @@ var (
|
||||||
Help: "Action execution duration in seconds from start to finish.",
|
Help: "Action execution duration in seconds from start to finish.",
|
||||||
Buckets: []float64{0.1, 0.5, 1, 2, 5, 10, 30, 60, 120, 300, 600},
|
Buckets: []float64{0.1, 0.5, 1, 2, 5, 10, 30, 60, 120, 300, 600},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
executionResultLabels = []string{
|
||||||
|
executionResultSuccess,
|
||||||
|
executionResultFailed,
|
||||||
|
executionResultBlocked,
|
||||||
|
executionResultTimeout,
|
||||||
|
executionResultError,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
for _, result := range executionResultLabels {
|
||||||
|
metricActionExecutionsTotal.WithLabelValues(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func executionResultLabel(entry *InternalLogEntry) string {
|
func executionResultLabel(entry *InternalLogEntry) string {
|
||||||
if entry.Blocked {
|
if entry.Blocked {
|
||||||
return executionResultBlocked
|
return executionResultBlocked
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue