Documentation ¶
Index ¶
- Constants
- Variables
- func ProcessContext() context.Context
- type MultiRunResult
- type MultiRunStrategy
- func (m *MultiRunStrategy) CallDaemonRun(ctx context.Context, cl *client.Client) (string, error)
- func (m *MultiRunStrategy) CancelEveryOtherRun()
- func (m *MultiRunStrategy) Collect(ctx context.Context, cl *client.Client, taskId string) error
- func (m *MultiRunStrategy) CurrentCollectedPath(taskId string) string
- func (m *MultiRunStrategy) CurrentRequest() api.RunRequest
- func (m *MultiRunStrategy) CurrentRunId() string
- func (m *MultiRunStrategy) ExitStatus() error
- func (m *MultiRunStrategy) Next(ctx context.Context, cl *client.Client, c *cli.Context) (bool, error)
- func (m *MultiRunStrategy) ProcessComposition(tsk *task.Task) error
- func (m *MultiRunStrategy) ShowResult() error
- func (m *MultiRunStrategy) WaitForTaskCompletion(ctx context.Context, cl *client.Client, taskId string) (*task.Task, error)
Constants ¶
View Source
const ResultFileOpt = "result-file"
Variables ¶
View Source
var BuildCommand = cli.Command{ Name: "build", Usage: "request the daemon to build a test plan", Subcommands: cli.Commands{ &cli.Command{ Name: "composition", Aliases: []string{"c"}, Usage: "builds a composition.", Action: buildCompositionCmd, Flags: []cli.Flag{ &cli.StringFlag{ Name: "file", Aliases: []string{"f"}, Usage: "path to a `COMPOSITION`", Required: true, }, &cli.BoolFlag{ Name: "write-artifacts", Aliases: []string{"w"}, Usage: "write the resulting build artifacts to the composition file", }, &cli.StringFlag{ Name: "link-sdk", Usage: linkSdkUsage, }, &cli.BoolFlag{ Name: "wait", Usage: "wait for the task to complete", }, }, }, &cli.Command{ Name: "single", Aliases: []string{"s"}, Usage: "builds a single group, passing in all necessary input via CLI flags.", Action: buildSingleCmd, Flags: cli.FlagsByName{ &cli.StringSliceFlag{ Name: "build-cfg", Usage: "set a build config parameter", }, &cli.StringFlag{ Name: "builder", Aliases: []string{"b"}, Usage: "specifies the builder to use; values include: 'docker:go', 'exec:go'", Required: true, }, &cli.StringSliceFlag{ Name: "dep", Aliases: []string{"d"}, Usage: "set a dependency mapping", }, &cli.StringFlag{ Name: "link-sdk", Usage: linkSdkUsage, }, &cli.StringFlag{ Name: "plan", Aliases: []string{"p"}, Usage: "specifies the plan to run", Required: true, }, &cli.BoolFlag{ Name: "wait", Usage: "Wait for the task to complete", }, }, }, &cli.Command{ Name: "purge", Aliases: []string{"p"}, Usage: "purge the cache for a builder and testplan", Action: runBuildPurgeCmd, Flags: cli.FlagsByName{ &cli.StringFlag{ Name: "builder", Aliases: []string{"b"}, Usage: "specifies the builder to use; values include: 'docker:go', 'exec:go'", Required: true, }, &cli.StringFlag{ Name: "plan", Aliases: []string{"p"}, Usage: "specifies the plan to run", Required: true, }, }, }, }, }
View Source
var CollectCommand = cli.Command{ Name: "collect", Usage: "collect the output assets of the supplied run into a .tgz archive", Action: collectCommand, ArgsUsage: "[run_id]", Flags: []cli.Flag{ &cli.StringFlag{ Name: "runner", Aliases: []string{"r"}, Usage: "runner to use; values include: 'local:exec', 'local:docker', 'cluster:k8s'", Required: true, }, &cli.StringFlag{ Name: "output", Aliases: []string{"o"}, Usage: "write the output archive to `FILENAME`", }, }, }
CollectCommand is the specification of the `collect` command.
View Source
var DaemonCommand = cli.Command{
Name: "daemon",
Usage: "start a long-running testground daemon process",
Action: daemonCommand,
}
DaemonCommand is the specification of the `daemon` command.
View Source
var DescribeCommand = cli.Command{ Name: "describe", Usage: "describe a test plan", Description: "Loads the test plan manifest from $TESTGROUND_HOME/plans/<plan>, and explains its contents", Flags: []cli.Flag{ &cli.StringFlag{ Name: "plan", Aliases: []string{"p"}, Usage: "describe plan with name `NAME`", Required: true, }, }, Action: describeCommand, }
DescribeCommand is the specification of the `describe` command.
View Source
var ErrNotLinux = fmt.Errorf("the sidecar only supports linux, not %s", runtime.GOOS)
View Source
var HealthcheckCommand = cli.Command{ Name: "healthcheck", Usage: "validate/fix the preconditions for the runner to be able to operate properly", Action: healthcheckCommand, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "fix", Usage: "attempt to fix failing preconditions", }, &cli.StringFlag{ Name: "runner", Usage: "specifies the runner to use; values include: 'local:exec', 'local:docker', 'cluster:k8s'", Required: true, }, }, }
View Source
var LogsCommand = cli.Command{ Name: "logs", Usage: "get the current status for a certain task", Action: logsCommand, Flags: []cli.Flag{ &cli.StringFlag{ Name: "task", Aliases: []string{"t"}, Usage: "the task id", Required: true, }, &cli.BoolFlag{ Name: "follow", Aliases: []string{"f"}, Usage: "stream the logs until the task completes", }, }, }
View Source
var PlanCommand = cli.Command{ Name: "plan", Usage: "manage the plans known to the client", Subcommands: cli.Commands{ &cli.Command{ Name: "create", Usage: "creates a new test plan, using a template from github.com/testground/plan-templates", Flags: []cli.Flag{ &cli.StringFlag{ Name: "remote", Usage: "`URL` of the repo where this plan will be hosted i.e. git@github.com:your/repo", Required: false, }, &cli.StringFlag{ Name: "target", Usage: "use template for target `LANGUAGE`; values: go", Required: false, Value: "go", }, &cli.StringFlag{ Name: "module", Usage: "set `MODULE_NAME`, used for initial templating", Value: "github.com/your/module/name", }, &cli.StringFlag{ Name: "plan", Aliases: []string{"p"}, Usage: "set `NAME` of the plan to create", Required: true, }, }, Action: createCommand, }, &cli.Command{ Name: "import", Usage: "import a plan from the local filesystem or a git repository into $TESTGROUND_HOME", Flags: []cli.Flag{ &cli.StringFlag{ Name: "from", Usage: "the source `URL` of the plan to be imported; either a path, or a Git remote", Required: true, }, &cli.BoolFlag{ Name: "git", Usage: "import from a git repository", Required: false, Value: false, }, &cli.StringFlag{ Name: "name", Usage: "override the `NAME` of the plan directory", Required: false, DefaultText: "automatic", }, }, Action: importCommand, }, &cli.Command{ Name: "rm", Usage: "remove a plan directory from $TESTGROUND_HOME", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "yes", Usage: "confirm removal (without this, the command does nothing)", Required: false, Value: false, }, &cli.StringFlag{ Name: "plan", Aliases: []string{"p"}, Usage: "specifies the name of the plan to create", Required: true, }, }, Action: rmCommand, }, &cli.Command{ Name: "list", Usage: "enumerate all test plans or test cases known to the client", Action: listCommand, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "testcases", Usage: "display testcases", }, }, }, }, }
View Source
var RootCommands = cli.CommandsByName{ &RunCommand, &PlanCommand, &BuildCommand, &DescribeCommand, &SidecarCommand, &DaemonCommand, &CollectCommand, &TerminateCommand, &HealthcheckCommand, &TasksCommand, &StatusCommand, &LogsCommand, &VersionCommand, }
RootCommands collects all subcommands of the testground CLI.
View Source
var RootFlags = []cli.Flag{
&cli.BoolFlag{
Name: "v",
Usage: "verbose output (equivalent to DEBUG log level)",
},
&cli.BoolFlag{
Name: "vv",
Usage: "super verbose output (equivalent to DEBUG log level for now, it may accommodate TRACE in the future)",
},
&cli.StringFlag{
Name: "endpoint",
Usage: "set the daemon endpoint `URI` (overrides .env.toml)",
},
}
View Source
var RunCommand = cli.Command{ Name: "run", Usage: "request the daemon to (build and) run a test case", Subcommands: cli.Commands{ &cli.Command{ Name: "composition", Aliases: []string{"c"}, Usage: "(build and) run a composition", Action: runCompositionCmd, Flags: append( BuildCommand.Subcommands[0].Flags, &cli.BoolFlag{ Name: "ignore-artifacts", Aliases: []string{"i"}, Usage: "ignore any build artifacts present in the composition file", }, &cli.BoolFlag{ Name: "collect", Usage: "collect assets at the end of the run phase; without --collect-file, it writes to <run_id>.tgz", }, &cli.StringFlag{ Name: "collect-file", Aliases: []string{"o"}, Usage: "write the collection output archive to `FILENAME`", }, &cli.StringFlag{ Name: "run-ids", Usage: "run a specific run id, or a comma-separated list of run ids", }, &cli.StringFlag{ Name: ResultFileOpt, Aliases: []string{"O"}, Usage: "write the results csv `FILENAME`", }, &cli.StringFlag{ Name: "metadata-repo", Usage: "repo that triggered this run", }, &cli.StringFlag{ Name: "metadata-branch", Usage: "branch that triggered this run", }, &cli.StringFlag{ Name: "metadata-commit", Usage: "commit that triggered this run", }, ), }, &cli.Command{ Name: "single", Aliases: []string{"s"}, Usage: "(build and) run a single group", Action: runSingleCmd, Flags: append( BuildCommand.Subcommands[1].Flags, &cli.BoolFlag{ Name: "collect", Usage: "collect assets at the end of the run phase.", }, &cli.StringFlag{ Name: "collect-file", Aliases: []string{"o"}, Usage: "destination for the assets if --collect is set", }, &cli.UintFlag{ Name: "instances", Aliases: []string{"i"}, Usage: "number of instances of the test case to run", Required: true, DefaultText: "none", }, &cli.StringFlag{ Name: "runner", Aliases: []string{"r"}, Usage: "runner to use; values include: 'local:exec', 'local:docker', 'cluster:k8s'", Required: true, }, &cli.StringSliceFlag{ Name: "run-cfg", Usage: "override runner configuration", }, &cli.StringFlag{ Name: "testcase", Aliases: []string{"t"}, Usage: "test case to run; must be defined in the test plan manifest", Required: true, }, &cli.StringSliceFlag{ Name: "test-param", Aliases: []string{"tp"}, Usage: "set a test parameter", }, &cli.StringFlag{ Name: "use-build", Aliases: []string{"ub"}, Usage: "build artifact to use (from a previous build)", }, &cli.StringFlag{ Name: "metadata-repo", Usage: "repo that triggered this run", }, &cli.StringFlag{ Name: "metadata-branch", Usage: "branch that triggered this run", }, &cli.StringFlag{ Name: "metadata-commit", Usage: "commit that triggered this run", }, &cli.BoolFlag{ Name: "disable-metrics", Usage: "disable metrics batching", }, ), }, }, }
RunCommand is the specification of the `run` command.
View Source
var SidecarCommand = cli.Command{ Name: "sidecar", Usage: "run the sidecar process", Action: sidecarCommand, OnUsageError: func(c *cli.Context, err error, isSubcommand bool) error { if runtime.GOOS != "linux" { return ErrNotLinux } _, _ = fmt.Fprintf(c.App.Writer, "%s %s\n\n", "Incorrect Usage.", err.Error()) _ = cli.ShowAppHelp(c) return err }, Flags: []cli.Flag{ &cli.StringFlag{ Name: "runner", Usage: "runner that will be scheduling tasks that should be managed by this sidecar; supported: 'local:docker', 'cluster:k8s'", Required: true, }, }, }
View Source
var StatusCommand = cli.Command{ Name: "status", Usage: "get the current status for a certain task", Action: statusCommand, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "extended", Usage: "print extended information such as input and results", }, &cli.StringFlag{ Name: "task", Aliases: []string{"t"}, Usage: "the task id", Required: true, }, }, }
View Source
var TasksCommand = cli.Command{
Name: "tasks",
Usage: "get a list of the existing tasks",
Action: tasksCommand,
Flags: []cli.Flag{},
}
View Source
var TerminateCommand = cli.Command{
Name: "terminate",
Usage: "terminate all jobs and supporting processes of a runner",
Action: terminateCommand,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "runner",
Usage: "runner to terminate; values include: 'local:exec', 'local:docker', 'cluster:k8s'",
},
&cli.StringFlag{
Name: "builder",
Usage: "builder to terminate; values include: 'docker:go', 'docker:generic', 'exec:go'",
},
},
}
View Source
var VersionCommand = cli.Command{
Name: "version",
Usage: "print version numbers",
Action: versionCommand,
}
Functions ¶
func ProcessContext ¶
Types ¶
type MultiRunResult ¶ added in v0.6.0
type MultiRunStrategy ¶ added in v0.6.0
type MultiRunStrategy struct { // Current RunID Index CurrentRunIndex int // Run IDs RunIds []string // Initial Composition Composition *api.Composition // Effective Composition used by the daemon, which contains artifacts EffectiveComposition *api.Composition // Base Request BaseRequest api.RunRequest // Collect Destination CollectDestination string // Composition Destination CompositionDestination string // Results Results []MultiRunResult // Output Stdout io.Writer // contains filtered or unexported fields }
func (*MultiRunStrategy) CallDaemonRun ¶ added in v0.6.0
func (*MultiRunStrategy) CancelEveryOtherRun ¶ added in v0.6.0
func (m *MultiRunStrategy) CancelEveryOtherRun()
func (*MultiRunStrategy) CurrentCollectedPath ¶ added in v0.6.0
func (m *MultiRunStrategy) CurrentCollectedPath(taskId string) string
func (*MultiRunStrategy) CurrentRequest ¶ added in v0.6.0
func (m *MultiRunStrategy) CurrentRequest() api.RunRequest
func (*MultiRunStrategy) CurrentRunId ¶ added in v0.6.0
func (m *MultiRunStrategy) CurrentRunId() string
func (*MultiRunStrategy) ExitStatus ¶ added in v0.6.0
func (m *MultiRunStrategy) ExitStatus() error
func (*MultiRunStrategy) ProcessComposition ¶ added in v0.6.0
func (m *MultiRunStrategy) ProcessComposition(tsk *task.Task) error
func (*MultiRunStrategy) ShowResult ¶ added in v0.6.0
func (m *MultiRunStrategy) ShowResult() error
Click to show internal directories.
Click to hide internal directories.