basecli

package
v0.8.32 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 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 Dry bool

Dry indicates that run should be a dry run

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

View Source
var RootCmd = &cobra.Command{
	Use:   "iter8",
	Short: "Kubernetes release engineering made simple",
	Long:  globalUsage,
}

RootCmd represents the base command when called without any subcommands

Functions

func ExecTemplate

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 Generate

func Generate() (result *bytes.Buffer, err error)

Generate the k8s experiment manifest

func NewAssertCmd

func NewAssertCmd() *cobra.Command

NewAssertCmd creates an assert command with the assert flagset

func NewReportCmd

func NewReportCmd() *cobra.Command

NewReportCmd creates a new report command

func NewRunCmd

func NewRunCmd() *cobra.Command

NewRunCmd creates a new run command

func RegisterHTMLTemplate

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

RegisterHTMLTemplate registers an HTML template

func RegisterTextTemplate

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

RegisterTextTemplate registers a text template

func RenderGoTpl

func RenderGoTpl(v chartutil.Values, filePath string) (*bytes.Buffer, error)

RenderGoTpl creates output from go.tpl

func RenderTpl

func RenderTpl(k8sExp k8sExperiment, filePath string) (*bytes.Buffer, error)

RenderTpl creates the Kubernetes experiment manifest from k8s.tpl

func ResultFromBytes

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

ResultFromBytes reads experiment result from bytes

func SpecFromBytes

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

SpecFromBytes reads experiment spec from bytes

Types

type AssertOptionsType

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.8.8

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

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

type Experiment struct {
	base.Experiment
}

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

func Build

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

Build an experiment

func (*Experiment) Assert

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

Assert if experiment satisfies conditions

func (*Experiment) Completed

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

func (e *Experiment) HTMLHistCharts() string

HTMLHistCharts returns histogram charts section in HTML report

func (*Experiment) HTMLHistData

func (e *Experiment) HTMLHistData() string

HTMLHistData returns histogram data section in HTML report

func (*Experiment) HistData

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

HistData provides histogram data for all histogram metrics

func (*Experiment) MetricDescriptionHTML added in v0.8.29

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

func (*Experiment) MetricWithUnits added in v0.8.29

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

func (*Experiment) NoFailure

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.8.29

func (e *Experiment) PrintMetricsText() string

PrintMetricsText returns metrics in text report format

func (*Experiment) PrintSLOsText added in v0.8.29

func (e *Experiment) PrintSLOsText() string

PrintSLOsText returns SLOs in text report format

func (*Experiment) RenderStr added in v0.8.29

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

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

func (*Experiment) Report

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

Report creates a report from experiment as per outputFormat

func (*Experiment) Run

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

Run an experiment

func (*Experiment) SLOs added in v0.8.30

func (exp *Experiment) SLOs() bool

SLOs returns true if all versions satisfy SLOs

func (*Experiment) ScalarMetricValueStr added in v0.8.29

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.8.30

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

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

func (*Experiment) SortedVectorMetrics added in v0.8.29

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

SortedVectorMetrics extracts vector metric names from experiment in sorted order

func (*Experiment) VectorMetricValue added in v0.8.29

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

type FileExpIO struct{}

FileExpIO enables reading and writing experiment spec and result files

func (*FileExpIO) ReadResult

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

ReadResult reads experiment result from file

func (*FileExpIO) ReadSpec

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

ReadSpec reads experiment spec from file

func (*FileExpIO) WriteResult

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

WriteResult writes experiment result to file

type ReportOptionsType

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 🇻🇳