summaryrefslogtreecommitdiffstats
path: root/clover/cloverctl/src/cloverctl/cmd/create_testplan.go
diff options
context:
space:
mode:
Diffstat (limited to 'clover/cloverctl/src/cloverctl/cmd/create_testplan.go')
-rw-r--r--clover/cloverctl/src/cloverctl/cmd/create_testplan.go22
1 files changed, 12 insertions, 10 deletions
diff --git a/clover/cloverctl/src/cloverctl/cmd/create_testplan.go b/clover/cloverctl/src/cloverctl/cmd/create_testplan.go
index 686d5ba..1d9d8b2 100644
--- a/clover/cloverctl/src/cloverctl/cmd/create_testplan.go
+++ b/clover/cloverctl/src/cloverctl/cmd/create_testplan.go
@@ -9,49 +9,51 @@ package cmd
import (
"fmt"
+ "os"
"gopkg.in/resty.v1"
"io/ioutil"
"github.com/ghodss/yaml"
"github.com/spf13/cobra"
+
)
var testplanCmd = &cobra.Command{
Use: "testplan",
- Short: "Create L7 client emulation test plans from yaml file",
+ Short: "Create jmeter L7 client emulation test plan from yaml file",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
createTestPlan()
- //fmt.Printf("%v\n", cmd.Parent().CommandPath())
},
}
func init() {
createCmd.AddCommand(testplanCmd)
- testplanCmd.Flags().StringVarP(&cloverFile, "file", "f", "", "Input yaml file with test plan params")
+ testplanCmd.Flags().StringVarP(&cloverFile, "file", "f", "",
+ "Input test plan yaml file")
testplanCmd.MarkFlagRequired("file")
}
func createTestPlan() {
+ checkControllerIP()
url := controllerIP + "/jmeter/gen"
in, err := ioutil.ReadFile(cloverFile)
if err != nil {
- fmt.Println("Please specify a valid test plan yaml file")
- return
+ fmt.Println("Please specify a valid yaml file")
+ os.Exit(1)
}
out_json, err := yaml.YAMLToJSON(in)
if err != nil {
- panic(err.Error())
+ fmt.Printf("Invalid yaml: %v\n", err)
+ os.Exit(1)
}
resp, err := resty.R().
SetHeader("Content-Type", "application/json").
SetBody(out_json).
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)
- //fmt.Println(string(out_json))
-
}
-