cmd

package
v0.1.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2018 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AnalyseCmd = &cobra.Command{
	Use:   "analyse <results file>",
	Short: "Analyse the output of a Test Suite run",
	Args: func(cmd *cobra.Command, args []string) error {
		if len(args) != 1 {
			return errors.New("analyse command requires a test results directory as an argument")
		}
		return nil
	},
	Run: func(cmd *cobra.Command, args []string) {
		if results, ts, err := result.UnarchiveResults(args[0]); err != nil {
			log.Fatalf("Problem with loading result information: %v ", err)
		} else {
			AnalyseResults(cmd, ts, results)
		}
	},
}

AnalyseCmd represents the analyse command

View Source
var InitCmd = &cobra.Command{
	Use:   "init <directory>",
	Short: "Scaffold a Test Suite and snippets directory",
	Args: func(cmd *cobra.Command, args []string) error {
		if len(args) != 1 {
			return errors.New("init command requires a directory as an argument")
		}
		return nil
	},
	Run: func(cmd *cobra.Command, args []string) {

		_, err := os.Stat(args[0])
		if !os.IsNotExist(err) {
			log.Fatalf("%v already exists, remove it before running init or use a different directory", args[0])
		}

		path := filepath.Join(args[0], "snippets")
		err = os.MkdirAll(path, os.ModePerm)
		if err != nil {
			log.Fatal(err)
		}

		bytes, err := yaml.Marshal(BuildTestSuite(path))
		if err != nil {
			log.Fatal(err)
		}

		err = ioutil.WriteFile(filepath.Join(args[0], "test-suite.yml"), bytes, 0644)
		if err != nil {
			log.Fatal(err)
		}

		bytes = []byte("<interface><name>Ethernet0/0</name><mtu>1500</mtu></interface>")
		err = ioutil.WriteFile(filepath.Join(path, "edit-config.xml"), bytes, 0644)
		if err != nil {
			log.Fatal(err)
		}
	},
}

InitCmd represents the init command

View Source
var RootCmd = &cobra.Command{
	Use:   os.Args[0],
	Short: "A NETCONF Load Tester",
}

RootCmd represents the base command when called without any subcommands

View Source
var (
	// VERSION passed in as a build variable
	VERSION string
)

Functions

func AnalyseResults added in v0.1.14

func AnalyseResults(cmd *cobra.Command, ts *suite.TestSuite, results []result.NetconfResult)

AnalyseResults Analyse the output of a Test Suite run

func BuildTestSuite added in v0.1.14

func BuildTestSuite(path string) *suite.TestSuite

BuildTestSuite Creates TestSuite scaffold files

func Completion

func Completion(cmd *cobra.Command, args []string)

Completion is a helper function to allow passing arguments to other functions (so that they can be unit tested)

func Execute

func Execute(version string)

Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func Init added in v0.1.14

func Init()

Init Run when initialised

func InitConfig added in v0.1.14

func InitConfig()

InitConfig reads in config file and ENV variables if set.

func OrderAndExcludeErrValues added in v0.1.14

func OrderAndExcludeErrValues(results []result.NetconfResult, latencies map[string]map[string][]float64) int

OrderAndExcludeErrValues Orders the results and removes errors from output. Returns number of errors found.

func SortLatencies added in v0.1.14

func SortLatencies(latencies map[string]map[string][]float64) []string

SortLatencies Sorts keys of latencies Map to allow for ordered iteration of map

func SortResults added in v0.1.14

func SortResults(results []result.NetconfResult)

SortResults Sorts its contents by hostname or operation if duplicate hostnames exist

func StringAddr added in v0.1.14

func StringAddr(v string) *string

StringAddr is a helper routine that allocates a new string value to store v and returns a pointer to it.

func Version

func Version(cmd *cobra.Command, args []string)

Version is a helper function to allow passing arguments to other functions (so that they can be unit tested)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL