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

First integration test for the ML Pipeline CLI (Pipeline List). #81

Merged
merged 4 commits into from
Nov 7, 2018
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
7 changes: 6 additions & 1 deletion backend/src/cmd/ml/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ const (

func main() {
flag.Parse()
rootCmd, _ := GetRealRootCommand()
rootCmd.Execute()
}

func GetRealRootCommand() (*cmd.RootCommand, *cmd.ClientFactory) {
clientFactory := cmd.NewClientFactory()
rootCmd := cmd.NewRootCmd(clientFactory)
rootCmd = cmd.CreateSubCommands(rootCmd, defaultPageSize)
rootCmd.Execute()
return rootCmd, clientFactory
}
2 changes: 1 addition & 1 deletion backend/src/common/client/api_server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ func CreateErrorFromAPIStatus(error string, code int32) error {
}

func CreateErrorCouldNotRecoverAPIStatus(err error) error {
return fmt.Errorf("Could not parse the error returned from the server. Most likely, the CLI is not able to reach the service. Use the '--debug' flag to print the raw error from the server: %v",
return fmt.Errorf("Issue calling the service. Use the '--debug' flag to see the HTTP request/response. Raw error from the client: %v",
err.Error())
}
71 changes: 71 additions & 0 deletions backend/test/cli_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package test

import (
"testing"

"github.com/golang/glog"
"github.com/kubeflow/pipelines/backend/src/cmd/ml/cmd"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)

const (
defaultPageSize = int32(10)
)

func GetRealRootCommand() (*cmd.RootCommand, *cmd.ClientFactory) {
clientFactory := cmd.NewClientFactory()
rootCmd := cmd.NewRootCmd(clientFactory)
rootCmd = cmd.CreateSubCommands(rootCmd, defaultPageSize)
return rootCmd, clientFactory
}

type CLIIntegrationTest struct {
suite.Suite
namespace string
}

// Check the cluster namespace has Kubeflow pipelines installed and ready.
func (c *CLIIntegrationTest) SetupTest() {
c.namespace = *namespace

// Wait for the system to be ready.
err := waitForReady(c.namespace, *initializeTimeout)
if err != nil {
glog.Exitf("Cluster namespace '%s' is still not ready after timeout. Error: %s", c.namespace,
err.Error())
}
}

func (c *CLIIntegrationTest) TearDownTest() {
// Nothing to do.
}

func (c *CLIIntegrationTest) TestPipelineListSuccess() {
t := c.T()
rootCmd, _ := GetRealRootCommand()
args := []string{"pipeline", "list"}
args = addCommonArgs(args, c.namespace)
rootCmd.Command().SetArgs(args)
_, err := rootCmd.Command().ExecuteC()
assert.Nil(t, err)
}

func (c *CLIIntegrationTest) TestPipelineListFailureInvalidArgument() {
t := c.T()
rootCmd, _ := GetRealRootCommand()
args := []string{"pipeline", "list", "askjdfskldjf"}
args = addCommonArgs(args, c.namespace)
rootCmd.Command().SetArgs(args)
_, err := rootCmd.Command().ExecuteC()
assert.NotNil(t, err)
}

func TestPipelineAPI(t *testing.T) {
suite.Run(t, new(CLIIntegrationTest))
}

func addCommonArgs(args []string, namespace string) []string {
args = append(args, "--debug", "--namespace", namespace)
return args
}