Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): Rearrange the order of chunk size argument in list command. Closes #2420 #2485

Merged
merged 2 commits into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions cmd/argo/commands/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package commands
import (
"fmt"
"log"
"math"
"os"
"sort"
"strings"
Expand Down Expand Up @@ -62,9 +63,6 @@ func NewListCommand() *cobra.Command {
labelSelector = labelSelector.Add(*req)
}
listOpts.LabelSelector = labelSelector.String()
if listArgs.chunkSize != 0 {
listOpts.Limit = listArgs.chunkSize
}

ctx, apiClient := client.NewAPIClient()
serviceClient := apiClient.NewWorkflowServiceClient()
Expand Down Expand Up @@ -121,6 +119,11 @@ func NewListCommand() *cobra.Command {
}
sort.Sort(workflows)

if listArgs.chunkSize != 0 {
idx := int64(math.Min(float64(listArgs.chunkSize), float64(len(workflows))))
workflows = workflows[0:idx]
}

switch listArgs.output {
case "", "wide":
printTable(workflows, &listArgs)
Expand Down
24 changes: 24 additions & 0 deletions test/e2e/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"regexp"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -180,13 +181,36 @@ func (s *CLISuite) TestRoot() {
})
})
s.Run("List", func() {
const rowCount = 1
for i := 0; i < rowCount*3; i++ {
s.Given().
Workflow("@smoke/basic-generate-name.yaml").
When().
SubmitWorkflow()
}
s.Given().RunCli([]string{"list"}, func(t *testing.T, output string, err error) {
if assert.NoError(t, err) {
assert.Contains(t, output, "NAME")
assert.Contains(t, output, "STATUS")
assert.Contains(t, output, "AGE")
assert.Contains(t, output, "DURATION")
assert.Contains(t, output, "PRIORITY")

// header + rowCount*3 workflows + empty line
assert.Equal(t, 5, len(strings.Split(output, "\n")))
}
})

s.Given().RunCli([]string{"list", "--chunk-size", "1"}, func(t *testing.T, output string, err error) {
if assert.NoError(t, err) {
assert.Contains(t, output, "NAME")
assert.Contains(t, output, "STATUS")
assert.Contains(t, output, "AGE")
assert.Contains(t, output, "DURATION")
assert.Contains(t, output, "PRIORITY")

// header + 1 workflow + empty line
assert.Equal(t, 3, len(strings.Split(output, "\n")))
}
})
})
Expand Down
14 changes: 14 additions & 0 deletions test/e2e/smoke/basic-generate-name.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: basic-
labels:
argo-e2e: true
spec:
entrypoint: run-workflow
templates:
- name: run-workflow
container:
image: cowsay:v1
command: [cowsay, ":) Hello Argo!"]
imagePullPolicy: IfNotPresent