diff options
author | earrage <eddie.arrage@huawei.com> | 2018-11-05 11:49:36 -0800 |
---|---|---|
committer | earrage <eddie.arrage@huawei.com> | 2018-11-05 16:24:29 -0800 |
commit | 265bdb46e6875cb5c75e6db8e98a38775da69391 (patch) | |
tree | 526c69d2af7ca2538a0bb6ca86b0fdd062d844a2 /clover/cloverctl/src/cloverctl/cmd/start_testplan.go | |
parent | ad43226c30daec6b5d4a1379650994427361a3f8 (diff) |
Add ability to read controller nodeport IP from file
- Formalize use of cloverctl config file using viper
- Default name of config file is '.cloverctl.yaml'
- Look for file in home directory or relative to
cloverctl executable
- Single value in config is for 'ControllerIP: <IP Address>'
- Still try and retrieve port value of clover-controller nodeport
automatically
- Still try and retrieve IP address of clover-controller LB if
GKE environment is being used and override config file value if found
in current kube context
- Improve error messaging if controller connect fails
- Clean up the CLI help output
- Modify jmeter 'get testresult' command to avoid the use
of flags and use arguments instead
Change-Id: Id95d1b3d1079ac84996681db62da1f9b6b8a88b5
Signed-off-by: earrage <eddie.arrage@huawei.com>
Diffstat (limited to 'clover/cloverctl/src/cloverctl/cmd/start_testplan.go')
-rw-r--r-- | clover/cloverctl/src/cloverctl/cmd/start_testplan.go | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/clover/cloverctl/src/cloverctl/cmd/start_testplan.go b/clover/cloverctl/src/cloverctl/cmd/start_testplan.go index b516ad6..9e664c0 100644 --- a/clover/cloverctl/src/cloverctl/cmd/start_testplan.go +++ b/clover/cloverctl/src/cloverctl/cmd/start_testplan.go @@ -9,6 +9,7 @@ package cmd import ( "fmt" + "os" "strings" "gopkg.in/resty.v1" "github.com/spf13/cobra" @@ -18,20 +19,21 @@ import ( var testplanstartCmd = &cobra.Command{ Use: "testplan", - Short: "Start a test for a given test plan", + Short: "Start test for configured test plan", Long: `Specify number of slaves to use with '-s' flag. Default is 0 slaves, -which runs tests only from jmeter-master.`, +which runs tests from jmeter-master only.`, Run: func(cmd *cobra.Command, args []string) { startTest() - //fmt.Printf("%v\n", cmd.Parent().CommandPath()) }, } var num_slaves int func init() { startCmd.AddCommand(testplanstartCmd) - testplanstartCmd.PersistentFlags().StringVarP(&cloverFile, "file", "f", "", "Currently unused") - testplanstartCmd.PersistentFlags().IntVarP(&num_slaves, "slaves", "s", 0, "Number of slaves to use") + testplanstartCmd.PersistentFlags().StringVarP(&cloverFile, "file", "f", "", + "Currently unused") + testplanstartCmd.PersistentFlags().IntVarP(&num_slaves, "slaves", "s", 0, + "Number of slaves to use") } func startTest() { @@ -39,21 +41,24 @@ func startTest() { ips := cloverkube.GetPodsIP("clover-jmeter-slave", "default") fmt.Printf("\njmeter-slaves found: %s\n", ips) if num_slaves > len(ips) { - fmt.Printf("Number of slaves specified must be less than found: %d\n", len(ips)) + fmt.Printf("Number of slaves specified must be less than found: %d\n", + len(ips)) return } ip_list := strings.Join(ips[0:num_slaves], ",") + checkControllerIP() url := controllerIP + "/jmeter/start" resp, err := resty.R(). SetHeader("Content-Type", "application/json"). - SetBody(fmt.Sprintf(`{"num_slaves":"%d", "slave_list":"%s"}`, num_slaves, ip_list)). + SetBody(fmt.Sprintf(`{"num_slaves":"%d", "slave_list":"%s"}`, num_slaves, + ip_list)). Post(url) if err != nil { - panic(err.Error()) + fmt.Printf("Cannot connect to controller: %v\n", err) + os.Exit(1) } fmt.Printf("\n%v\n", resp) - } |