diff options
Diffstat (limited to 'clover/cloverctl/src/cloverctl/cmd/get_testresult.go')
-rw-r--r-- | clover/cloverctl/src/cloverctl/cmd/get_testresult.go | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/clover/cloverctl/src/cloverctl/cmd/get_testresult.go b/clover/cloverctl/src/cloverctl/cmd/get_testresult.go new file mode 100644 index 0000000..12d47c3 --- /dev/null +++ b/clover/cloverctl/src/cloverctl/cmd/get_testresult.go @@ -0,0 +1,56 @@ +// Copyright (c) Authors of Clover +// +// All rights reserved. This program and the accompanying materials +// are made available under the terms of the Apache License, Version 2.0 +// which accompanies this distribution, and is available at +// http://www.apache.org/licenses/LICENSE-2.0 + +package cmd + +import ( + "fmt" + "gopkg.in/resty.v1" + "github.com/spf13/cobra" +) + +var JmeterResult string + +var testresultCmd = &cobra.Command{ + Use: "testresult", + Short: "Get test results from L7 client emulation", + Long: ``, + Run: func(cmd *cobra.Command, args []string) { + getResult() + }, +} + +func init() { + getCmd.AddCommand(testresultCmd) + testresultCmd.Flags().StringVarP(&JmeterResult, "r", "r", "", "Result to retrieve - use 'log' or 'results'") + testresultCmd.MarkFlagRequired("r") + +} + + +func getResult() { + switch JmeterResult { + case "results": + url := controllerIP + "/jmeter/results/results" + resp, err := resty.R(). + Get(url) + if err != nil { + panic(err.Error()) + } + fmt.Printf("\nResponse Body: %v\n", resp) + case "log": + url := controllerIP + "/jmeter/results/log" + resp, err := resty.R(). + Get(url) + if err != nil { + panic(err.Error()) + } + fmt.Printf("\nResponse Body: %v\n", resp) + default: + fmt.Println("Unrecoginized jmeter result type - use 'log' or 'results'") + } +} |