-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow parallel HTTP requests (#7113)
* feat: Allow parallel HTTP requests
- Loading branch information
Showing
5 changed files
with
230 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
//go:build functional | ||
// +build functional | ||
|
||
package e2e | ||
|
||
import ( | ||
"sort" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" | ||
"github.com/argoproj/argo-workflows/v3/test/e2e/fixtures" | ||
) | ||
|
||
type AgentSuite struct { | ||
fixtures.E2ESuite | ||
} | ||
|
||
func (s *AgentSuite) TestParallel() { | ||
s.Given(). | ||
Workflow(`apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
name: http-template-par | ||
workflowMetadata: | ||
labels: | ||
workflows.argoproj.io/test: "true" | ||
spec: | ||
entrypoint: main | ||
templates: | ||
- name: main | ||
steps: | ||
- - name: one | ||
template: http | ||
arguments: | ||
parameters: [{name: url, value: "http://httpstat.us/200?sleep=5000"}] | ||
- name: two | ||
template: http | ||
arguments: | ||
parameters: [{name: url, value: "http://httpstat.us/200?sleep=5000"}] | ||
- name: three | ||
template: http | ||
arguments: | ||
parameters: [{name: url, value: "http://httpstat.us/200?sleep=5000"}] | ||
- name: four | ||
template: http | ||
arguments: | ||
parameters: [{name: url, value: "http://httpstat.us/200?sleep=5000"}] | ||
- name: http | ||
inputs: | ||
parameters: | ||
- name: url | ||
http: | ||
url: "{{inputs.parameters.url}}" | ||
`). | ||
When(). | ||
SubmitWorkflow(). | ||
WaitForWorkflow(time.Minute). | ||
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)*time.Second) | ||
|
||
var finishedTimes []time.Time | ||
for _, node := range status.Nodes { | ||
if node.Type != wfv1.NodeTypeHTTP { | ||
continue | ||
} | ||
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 window | ||
assert.True(t, finishedTimes[3].Sub(finishedTimes[0]) < time.Duration(2)*time.Second) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.