Skip to content

Commit

Permalink
fix: TestParallel 503 with external url (#9265)
Browse files Browse the repository at this point in the history
Signed-off-by: Saravanan Balasubramanian <[email protected]>
  • Loading branch information
sarabala1979 authored Aug 1, 2022
1 parent fd6c7a7 commit 0c24ca1
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions test/e2e/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ spec:
- - name: one
template: http
arguments:
parameters: [{name: url, value: "https://httpstat.us/200?sleep=5000"}]
parameters: [{name: url, value: "https://argoproj.github.io"}]
- name: two
template: http
arguments:
parameters: [{name: url, value: "https://httpstat.us/200?sleep=5000"}]
parameters: [{name: url, value: "https://argoproj.github.io"}]
- name: three
template: http
arguments:
parameters: [{name: url, value: "https://httpstat.us/200?sleep=5000"}]
parameters: [{name: url, value: "https://argoproj.github.io"}]
- name: four
template: http
arguments:
parameters: [{name: url, value: "https://httpstat.us/200?sleep=5000"}]
parameters: [{name: url, value: "https://argoproj.github.io"}]
- name: http
inputs:
parameters:
Expand All @@ -59,29 +59,37 @@ spec:
`).
When().
SubmitWorkflow().
WaitForWorkflow(time.Minute).
WaitForWorkflow(fixtures.ToBeCompleted).
Then().
ExpectWorkflow(func(t *testing.T, _ *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.WorkflowSucceeded, status.Phase)
// Ensure that the workflow ran for less than 20 seconds (5 seconds per task, 4 tasks)
assert.True(t, status.FinishedAt.Sub(status.StartedAt.Time) < time.Duration(20*fixtures.EnvFactor)*time.Second)
// Ensure that the workflow ran for less than 10 seconds
assert.True(t, status.FinishedAt.Sub(status.StartedAt.Time) < time.Duration(10*fixtures.EnvFactor)*time.Second)

var finishedTimes []time.Time
var startTimes []time.Time
for _, node := range status.Nodes {
if node.Type != wfv1.NodeTypeHTTP {
continue
}
startTimes = append(startTimes, node.StartedAt.Time)
finishedTimes = append(finishedTimes, node.FinishedAt.Time)
}

if assert.Len(t, finishedTimes, 4) {
sort.Slice(finishedTimes, func(i, j int) bool {
return finishedTimes[i].Before(finishedTimes[j])
})

// Everything finished with a two second tolerance window
assert.True(t, finishedTimes[3].Sub(finishedTimes[0]) < time.Duration(2)*time.Second)
}
if assert.Len(t, startTimes, 4) {
sort.Slice(startTimes, func(i, j int) bool {
return startTimes[i].Before(startTimes[j])
})
// Everything started with same time
assert.True(t, startTimes[3].Sub(startTimes[0]) == 0)
}
})
}

Expand Down

0 comments on commit 0c24ca1

Please sign in to comment.