cmd

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Copyright © 2021 Iter8 authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// Completed states that the experiment is complete
	Completed = "completed"
	// NoFailure states that none of the tasks in the experiment have failed
	NoFailure = "nofailure"
	// SLOs states that all app versions participating in the experiment satisfies SLOs
	SLOs = "slos"
	// SLOsByPrefix is used for ensuring that a specific app version participating in the
	// experiment satisfies SLOs
	SLOsByPrefix = "slosby"
)
View Source
const (
	// TextOutputFormat is the output format used to create text output
	TextOutputFormatKey = "text"

	// HTMLOutputFormat is the output format used to create html output
	HTMLOutputFormatKey = "html"
)

Variables

View Source
var AssertOptions = AssertOptionsType{}

AssertOptions stores the options used by the assert command

View Source
var GenOptions = values.Options{}

GenOptions are the options used by the gen subcommands. They store values that can be combined with templates for generating experiment.yaml files Kubernetes manifests.

View Source
var ReportOptions = ReportOptionsType{
	OutputFormat: TextOutputFormatKey,
}

ReportOptions stores the options used by thee report command

Functions

func ExecTemplate added in v0.9.0

func ExecTemplate(t executable, exp *Experiment) error

ExecTemplate executes text or html template using experiment as the data

func Execute

func Execute()

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

func NewAssertCmd added in v0.9.0

func NewAssertCmd() *cobra.Command

NewAssertCmd creates an assert command with the assert flagset

func NewReportCmd added in v0.9.0

func NewReportCmd() *cobra.Command

NewReportCmd creates a new report command

func NewRunCmd added in v0.9.0

func NewRunCmd() *cobra.Command

NewRunCmd creates a new run command

func RegisterHTMLTemplate added in v0.9.0

func RegisterHTMLTemplate(name string, tpl *ht.Template)

RegisterHTMLTemplate registers an HTML template

func RegisterTextTemplate added in v0.9.0

func RegisterTextTemplate(name string, tpl *template.Template)

RegisterTextTemplate registers a text template

func ResultFromBytes added in v0.9.0

func ResultFromBytes(b []byte) (*base.ExperimentResult, error)

ResultFromBytes reads experiment result from bytes

func SpecFromBytes added in v0.9.0

func SpecFromBytes(b []byte) (base.ExperimentSpec, error)

SpecFromBytes reads experiment spec from bytes

Types

type AssertOptionsType added in v0.9.0

type AssertOptionsType struct {
	// Conds is the list of conditions that are asserted
	Conds []string
	// Timeout for assert conditions to be satisfied
	Timeout time.Duration
}

AssertOptionsType is used to store the options used by the assert command

type BuildInfo added in v0.9.0

type BuildInfo struct {
	// Version is the current semver.
	Version string `json:"version,omitempty"`
	// GitCommit is the git sha1.
	GitCommit string `json:"git_commit,omitempty"`
	// GitTreeState is the state of the git tree.
	GitTreeState string `json:"git_tree_state,omitempty"`
	// GoVersion is the version of the Go compiler used to compile Iter8.
	GoVersion string `json:"go_version,omitempty"`
}

BuildInfo describes the compile time information.

type ExpIO added in v0.9.0

type ExpIO interface {
	// ReadSpec reads the experiment spec
	ReadSpec() (base.ExperimentSpec, error)
	// ReadResult reads the experiment result
	ReadResult() (*base.ExperimentResult, error)
	// WriteResult writes the experiment result
	WriteResult(r *Experiment) error
}

ExpIO enables interacting with experiment spec and result stored externally

type Experiment added in v0.9.0

type Experiment struct {
	base.Experiment
}

Experiment type that includes a list of runnable tasks derived from the experiment spec

func Build added in v0.9.0

func Build(withResult bool, expio ExpIO) (*Experiment, error)

Build an experiment

func (*Experiment) Assert added in v0.9.0

func (exp *Experiment) Assert(conditions []string, to time.Duration) (bool, error)

Assert if experiment satisfies conditions

func (*Experiment) Completed added in v0.9.0

func (exp *Experiment) Completed() bool

Completed returns true if the experiment is complete if the result stanza is missing, this function returns false

func (*Experiment) HTMLHistCharts added in v0.9.0

func (e *Experiment) HTMLHistCharts() string

HTMLHistCharts returns histogram charts section in HTML report

func (*Experiment) HTMLHistData added in v0.9.0

func (e *Experiment) HTMLHistData() string

HTMLHistData returns histogram data section in HTML report

func (*Experiment) HistData added in v0.9.0

func (e *Experiment) HistData() []histograms

HistData provides histogram data for all histogram metrics

func (*Experiment) MetricDescriptionHTML added in v0.9.0

func (e *Experiment) MetricDescriptionHTML(metricName string) (string, error)

func (*Experiment) MetricWithUnits added in v0.9.0

func (e *Experiment) MetricWithUnits(metricName string) (string, error)

func (*Experiment) NoFailure added in v0.9.0

func (exp *Experiment) NoFailure() bool

NoFailure returns true if no task int he experiment has failed if the result stanza is missing, this function returns false

func (*Experiment) PrintMetricsText added in v0.9.0

func (e *Experiment) PrintMetricsText() string

PrintMetricsText returns metrics in text report format

func (*Experiment) PrintSLOsText added in v0.9.0

func (e *Experiment) PrintSLOsText() string

PrintSLOsText returns SLOs in text report format

func (*Experiment) RenderStr added in v0.9.0

func (e *Experiment) RenderStr(what string) (string, error)

RenderStrHTML is a helper method for rendering strings Used in HTML template

func (*Experiment) Report added in v0.9.0

func (exp *Experiment) Report(outputFormat string) error

Report creates a report from experiment as per outputFormat

func (*Experiment) Run added in v0.9.0

func (e *Experiment) Run(expio ExpIO) error

Run an experiment

func (*Experiment) SLOs added in v0.9.0

func (exp *Experiment) SLOs() bool

SLOs returns true if all versions satisfy SLOs

func (*Experiment) ScalarMetricValueStr added in v0.9.0

func (e *Experiment) ScalarMetricValueStr(j int, mn string) string

ScalarMetricValueStr extracts metric value string for given version and scalar metric name

func (*Experiment) SortedScalarAndSLOMetrics added in v0.9.0

func (e *Experiment) SortedScalarAndSLOMetrics() []string

SortedScalarAndSLOMetrics extracts scalar and SLO metric names from experiment in sorted order

func (*Experiment) SortedVectorMetrics added in v0.9.0

func (e *Experiment) SortedVectorMetrics() []string

SortedVectorMetrics extracts vector metric names from experiment in sorted order

func (*Experiment) VectorMetricValue added in v0.9.0

func (e *Experiment) VectorMetricValue(i int, m string) []float64

VectorMetricValue gets the value of the given vector metric for the given version If it is a histogram metric, then its values are sampled from the histogram

type FileExpIO added in v0.9.0

type FileExpIO struct{}

FileExpIO enables reading and writing experiment spec and result files

func (*FileExpIO) ReadResult added in v0.9.0

func (f *FileExpIO) ReadResult() (*base.ExperimentResult, error)

ReadResult reads experiment result from file

func (*FileExpIO) ReadSpec added in v0.9.0

func (f *FileExpIO) ReadSpec() (base.ExperimentSpec, error)

ReadSpec reads experiment spec from file

func (*FileExpIO) WriteResult added in v0.9.0

func (f *FileExpIO) WriteResult(r *Experiment) error

WriteResult writes experiment result to file

type ReportOptionsType added in v0.9.0

type ReportOptionsType struct {
	// OutputFormat holds the output format to be used by report
	OutputFormat string
}

ReportOptionsType enables options for the report command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳