-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First integration test for the ML Pipeline CLI (Pipeline List). (#81)
* First integration test for the ML Pipeline CLI (Pipeline List). * Fixing an issue with an undefined variable * Adding the --debug flag to help with debugging. * Changing the namespace to Kubeflow.
- Loading branch information
1 parent
2b58a16
commit 7753bc0
Showing
3 changed files
with
78 additions
and
2 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
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
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 | ||
} |