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

Adding Test Reports Feature #1573

Merged
merged 1 commit into from
Jul 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/kudoctl/cmd/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log"
"os"
"strings"
"testing"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -49,6 +50,7 @@ func newTestCmd() *cobra.Command {
skipClusterDelete := false
parallel := 0
artifactsDir := ""
reportFormat := ""

options := harness.TestSuite{}

Expand Down Expand Up @@ -150,6 +152,10 @@ For more detailed documentation, visit: https://kudo.dev/docs/testing`,
options.ArtifactsDir = artifactsDir
}

if isSet(flags, "report") {
options.ReportFormat = strings.ToLower(reportFormat)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will testutils.RunTests complain if this option isn't "json" or "xml"? I.e. do we need our own validation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... we should put some validation in kuttl for this... I'll create an issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to round out the conversation, there is NO invalid input... The default of "" is no report... but anything else defaults to json and "json" and "xml" are expected but lowercase. We will fix some of this in the kuttl issue listed.

}

if len(args) != 0 {
options.TestDirs = args
}
Expand Down Expand Up @@ -184,6 +190,7 @@ For more detailed documentation, visit: https://kudo.dev/docs/testing`,
testCmd.Flags().StringVar(&kindConfig, "kind-config", "", "Specify the KIND configuration file path (implies --start-kind, cannot be used with --start-control-plane).")
testCmd.Flags().StringVar(&kindContext, "kind-context", "", "Specify the KIND context name to use (default: kind).")
testCmd.Flags().StringVar(&artifactsDir, "artifacts-dir", "", "Directory to output kind logs to (if not specified, the current working directory).")
testCmd.Flags().StringVar(&reportFormat, "report", "", "Specify JSON|XML for report. Report location determined by --artifacts-dir.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should have a default, right? Otherwise you'd have to run it first to see if you get json or XML by default?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default is "" which is no report... by default no report is created.

testCmd.Flags().BoolVar(&startKUDO, "start-kudo", false, "Start KUDO during the test run.")
testCmd.Flags().BoolVar(&skipDelete, "skip-delete", false, "If set, do not delete resources created during tests (helpful for debugging test failures, implies --skip-cluster-delete).")
testCmd.Flags().BoolVar(&skipClusterDelete, "skip-cluster-delete", false, "If set, do not delete the mocked control plane or kind cluster.")
Expand Down