Skip to content

Commit

Permalink
Adding integrations test for the CLI commands related to pipelines. (k…
Browse files Browse the repository at this point in the history
…ubeflow#125)

* 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.

* Adding integrations test for the CLI commands related to pipelines.

* Fix typo

* Addressing code review comments.

* Fixing imported json library in the CLI integration tests.
  • Loading branch information
vicaire authored and k8s-ci-robot committed Nov 8, 2018
1 parent ee6d5ea commit ca58fa3
Show file tree
Hide file tree
Showing 16 changed files with 334 additions and 298 deletions.
19 changes: 19 additions & 0 deletions backend/src/cmd/ml/cmd/client_factory.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"bytes"
"io"
"os"

Expand All @@ -20,10 +21,12 @@ type ClientFactoryInterface interface {
client.RunInterface, error)
Time() util.TimeInterface
Writer() io.Writer
Result() string
}

type ClientFactory struct {
time util.TimeInterface
buffer *bytes.Buffer
writer io.Writer
}

Expand All @@ -34,6 +37,15 @@ func NewClientFactory() *ClientFactory {
}
}

func NewClientFactoryWithByteBuffer() *ClientFactory {
buffer := new(bytes.Buffer)
return &ClientFactory{
time: util.NewRealTime(),
buffer: buffer,
writer: buffer,
}
}

func (f *ClientFactory) CreatePipelineUploadClient(config clientcmd.ClientConfig, debug bool) (
client.PipelineUploadInterface, error) {
return client.NewPipelineUploadClient(config, debug)
Expand Down Expand Up @@ -61,3 +73,10 @@ func (f *ClientFactory) Time() util.TimeInterface {
func (f *ClientFactory) Writer() io.Writer {
return f.writer
}

func (f *ClientFactory) Result() string {
if f.buffer == nil {
return "The writer is set to 'os.Stdout'. The result is not recorded."
}
return (*f.buffer).String()
}
2 changes: 1 addition & 1 deletion backend/src/cmd/ml/cmd/client_factory_fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (f *ClientFactoryFake) Result() string {
return (*f.buffer).String()
}

func getFakeRootCommand() (*RootCommand, *ClientFactoryFake) {
func GetFakeRootCommand() (*RootCommand, *ClientFactoryFake) {
factory := NewClientFactoryFake()
rootCmd := NewRootCmd(factory)
rootCmd = CreateSubCommands(rootCmd, 10)
Expand Down
12 changes: 6 additions & 6 deletions backend/src/cmd/ml/cmd/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func NewJobCreateCmd(root *RootCommand) *cobra.Command {
if err != nil {
return util.ExtractErrorForCLI(err, root.Debug())
}
PrettyPrintResult(root.Writer(), root.NoColor(), root.OutputFormat(), job)
PrettyPrintResult(root.Writer(), root.OutputFormat(), job)
return nil
},
}
Expand Down Expand Up @@ -223,7 +223,7 @@ func NewJobGetCmd(root *RootCommand) *cobra.Command {
if err != nil {
return util.ExtractErrorForCLI(err, root.Debug())
}
PrettyPrintResult(root.Writer(), root.NoColor(), root.OutputFormat(), pkg)
PrettyPrintResult(root.Writer(), root.OutputFormat(), pkg)
return nil
},
}
Expand Down Expand Up @@ -259,7 +259,7 @@ func NewJobListCmd(root *RootCommand, pageSize int32) *cobra.Command {
if err != nil {
return util.ExtractErrorForCLI(err, root.Debug())
}
PrettyPrintResult(root.Writer(), root.NoColor(), root.OutputFormat(), results)
PrettyPrintResult(root.Writer(), root.OutputFormat(), results)
return nil
},
}
Expand Down Expand Up @@ -292,7 +292,7 @@ func NewJobEnableCmd(root *RootCommand) *cobra.Command {
if err != nil {
return util.ExtractErrorForCLI(err, root.Debug())
}
PrettyPrintResult(root.Writer(), root.NoColor(), root.OutputFormat(), "")
PrettyPrintResult(root.Writer(), root.OutputFormat(), "")
return nil
},
}
Expand Down Expand Up @@ -323,7 +323,7 @@ func NewJobDisableCmd(root *RootCommand) *cobra.Command {
if err != nil {
return util.ExtractErrorForCLI(err, root.Debug())
}
PrettyPrintResult(root.Writer(), root.NoColor(), root.OutputFormat(), "")
PrettyPrintResult(root.Writer(), root.OutputFormat(), "")
return nil
},
}
Expand Down Expand Up @@ -354,7 +354,7 @@ func NewJobDeleteCmd(root *RootCommand) *cobra.Command {
if err != nil {
return util.ExtractErrorForCLI(err, root.Debug())
}
PrettyPrintResult(root.Writer(), root.NoColor(), root.OutputFormat(), "")
PrettyPrintResult(root.Writer(), root.OutputFormat(), "")
return nil
},
}
Expand Down
Loading

0 comments on commit ca58fa3

Please sign in to comment.