-
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.
fix: Set default value to output parameters if suspend node timeout. F…
…ixes #12230 (#12960) Signed-off-by: oninowang <[email protected]> (cherry picked from commit 3df05eb)
- Loading branch information
Showing
3 changed files
with
150 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
//go:build functional | ||
// +build functional | ||
|
||
package e2e | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
apiv1 "k8s.io/api/core/v1" | ||
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 TestSuspendSitue struct { | ||
fixtures.E2ESuite | ||
} | ||
|
||
func (s *TestSuspendSitue) TestSuspendNodeTimeoutWithoutDefaultValue() { | ||
s.Given().Workflow(` | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
name: suspend-node-timeout-without-default-value | ||
spec: | ||
entrypoint: suspend | ||
templates: | ||
- name: suspend | ||
steps: | ||
- - name: approve | ||
template: approve | ||
- - name: release | ||
template: whalesay | ||
arguments: | ||
parameters: | ||
- name: message | ||
value: "{{steps.approve.outputs.parameters.message}}" | ||
- name: approve | ||
suspend: | ||
duration: 5s | ||
outputs: | ||
parameters: | ||
- name: message | ||
valueFrom: | ||
supplied: {} | ||
- name: whalesay | ||
inputs: | ||
parameters: | ||
- name: message | ||
container: | ||
image: docker/whalesay | ||
command: [cowsay] | ||
args: ["{{inputs.parameters.message}}"] | ||
`). | ||
When(). | ||
SubmitWorkflow(). | ||
WaitForWorkflow(fixtures.ToBeFailed). | ||
Then(). | ||
ExpectWorkflow(func(t *testing.T, metadata *metav1.ObjectMeta, status *wfv1.WorkflowStatus) { | ||
assert.Equal(t, wfv1.WorkflowFailed, status.Phase) | ||
assert.Contains(t, "raw output parameter 'message' has not been set and does not have a default value", status.Message) | ||
}) | ||
} | ||
|
||
func (s *TestSuspendSitue) TestSuspendNodeTimeoutWithDefaultValue() { | ||
s.Given().Workflow(` | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
name: suspend-node-timeout-with-default-value | ||
spec: | ||
entrypoint: suspend | ||
templates: | ||
- name: suspend | ||
steps: | ||
- - name: approve | ||
template: approve | ||
- - name: release | ||
template: whalesay | ||
arguments: | ||
parameters: | ||
- name: message | ||
value: "{{steps.approve.outputs.parameters.message}}" | ||
- name: approve | ||
suspend: | ||
duration: 5s | ||
outputs: | ||
parameters: | ||
- name: message | ||
valueFrom: | ||
default: default message | ||
supplied: {} | ||
- name: whalesay | ||
inputs: | ||
parameters: | ||
- name: message | ||
container: | ||
image: docker/whalesay | ||
command: [cowsay] | ||
args: ["{{inputs.parameters.message}}"] | ||
`). | ||
When(). | ||
SubmitWorkflow(). | ||
WaitForWorkflow(fixtures.ToBeSucceeded). | ||
Then(). | ||
ExpectWorkflow(func(t *testing.T, metadata *metav1.ObjectMeta, status *wfv1.WorkflowStatus) { | ||
assert.Equal(t, wfv1.WorkflowSucceeded, status.Phase) | ||
assert.Equal(t, status.Progress, wfv1.Progress("2/2")) | ||
}). | ||
ExpectWorkflowNode(func(status wfv1.NodeStatus) bool { | ||
return status.Name == "suspend-node-timeout-with-default-value[0].approve" | ||
}, func(t *testing.T, status *wfv1.NodeStatus, pod *apiv1.Pod) { | ||
assert.Equal(t, wfv1.NodeSucceeded, status.Phase) | ||
assert.Equal(t, 1, len(status.Outputs.Parameters)) | ||
assert.Equal(t, "message", status.Outputs.Parameters[0].Name) | ||
assert.Equal(t, wfv1.AnyStringPtr("default message"), status.Outputs.Parameters[0].Value) | ||
}). | ||
ExpectWorkflowNode(func(status wfv1.NodeStatus) bool { | ||
return status.Name == "suspend-node-timeout-with-default-value[1].release" | ||
}, func(t *testing.T, status *wfv1.NodeStatus, pod *apiv1.Pod) { | ||
assert.Equal(t, wfv1.NodeSucceeded, status.Phase) | ||
assert.Equal(t, 1, len(status.Inputs.Parameters)) | ||
assert.Equal(t, "message", status.Inputs.Parameters[0].Name) | ||
assert.Equal(t, wfv1.AnyStringPtr("default message"), status.Inputs.Parameters[0].Value) | ||
}) | ||
} |
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