-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
progress_test.go
60 lines (51 loc) · 1.65 KB
/
progress_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//go:build functional
// +build functional
package e2e
import (
"fmt"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
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 ProgressSuite struct {
fixtures.E2ESuite
}
func (s *ProgressSuite) TestDefaultProgress() {
s.Given().
Workflow("@testdata/basic-workflow.yaml").
When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToBeSucceeded).
Then().
ExpectWorkflow(func(t *testing.T, metadata *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.Progress("1/1"), status.Progress)
assert.Equal(t, wfv1.Progress("1/1"), status.Nodes[metadata.Name].Progress)
})
}
func (s *ProgressSuite) TestLoggedProgress() {
toHaveProgress := func(p wfv1.Progress) fixtures.Condition {
return func(wf *wfv1.Workflow) (bool, string) {
return wf.Status.Nodes[wf.Name].Progress == p &&
wf.Status.Nodes.FindByDisplayName("progress").Progress == p, fmt.Sprintf("progress is %s", p)
}
}
s.Given().
Workflow("@testdata/progress-workflow.yaml").
When().
SubmitWorkflow().
WaitForWorkflow(fixtures.ToBeRunning).
WaitForWorkflow(toHaveProgress("0/100"), 20*time.Second).
WaitForWorkflow(toHaveProgress("50/100"), 20*time.Second).
WaitForWorkflow().
Then().
ExpectWorkflow(func(t *testing.T, metadata *metav1.ObjectMeta, status *wfv1.WorkflowStatus) {
assert.Equal(t, wfv1.Progress("100/100"), status.Nodes[metadata.Name].Progress)
})
}
func TestProgressSuite(t *testing.T) {
suite.Run(t, new(ProgressSuite))
}