|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|
|
|
package main
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
@ -36,7 +37,8 @@ The tests to be run are defined in the chart that was installed.
|
|
|
|
|
|
|
|
|
|
|
|
func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|
|
|
func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
|
|
|
client := action.NewReleaseTesting(cfg)
|
|
|
|
client := action.NewReleaseTesting(cfg)
|
|
|
|
var outfmt output.Format
|
|
|
|
var outfmt = output.Table
|
|
|
|
|
|
|
|
var outputLogs bool
|
|
|
|
|
|
|
|
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "test [RELEASE]",
|
|
|
|
Use: "test [RELEASE]",
|
|
|
@ -44,17 +46,34 @@ func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command
|
|
|
|
Long: releaseTestHelp,
|
|
|
|
Long: releaseTestHelp,
|
|
|
|
Args: require.ExactArgs(1),
|
|
|
|
Args: require.ExactArgs(1),
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
rel, err := client.Run(args[0])
|
|
|
|
client.Namespace = settings.Namespace()
|
|
|
|
if err != nil {
|
|
|
|
rel, runErr := client.Run(args[0])
|
|
|
|
|
|
|
|
// We only return an error if we weren't even able to get the
|
|
|
|
|
|
|
|
// release, otherwise we keep going so we can print status and logs
|
|
|
|
|
|
|
|
// if requested
|
|
|
|
|
|
|
|
if runErr != nil && rel == nil {
|
|
|
|
|
|
|
|
return runErr
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err := outfmt.Write(out, &statusPrinter{rel, settings.Debug}); err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if outputLogs {
|
|
|
|
|
|
|
|
// Print a newline to stdout to separate the output
|
|
|
|
|
|
|
|
fmt.Fprintln(out)
|
|
|
|
|
|
|
|
if err := client.GetPodLogs(out, rel); err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return outfmt.Write(out, &statusPrinter{rel, settings.Debug})
|
|
|
|
return runErr
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
f := cmd.Flags()
|
|
|
|
f := cmd.Flags()
|
|
|
|
f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)")
|
|
|
|
f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)")
|
|
|
|
|
|
|
|
f.BoolVar(&outputLogs, "logs", false, "Dump the logs from test pods (this runs after all tests are complete, but before any cleanup)")
|
|
|
|
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
}
|
|
|
|