Documentation ¶
Overview ¶
Package base defines Iter8's experiment, task and metric data structures. It contains the core logic for running an experiment.
Index ¶
- Constants
- Variables
- func BoolPointer(b bool) *bool
- func CompletePath(prefix string, suffix string) string
- func CreateExperimentYaml(t *testing.T, template string, url string, output string)
- func CreateTemplate(tplString string) (*template.Template, error)
- func FuncMapWithToYAML() template.FuncMap
- func GetTrackingHandler(breadcrumb *bool) func(w http.ResponseWriter, r *http.Request)
- func IntPointer(i int) *int
- func MockMetricsServer(input MockMetricsServerInput)
- func PutExperimentResultToMetricsService(metricsServerURL, namespace, experiment string, ...) error
- func ReadConfig(configEnv string, conf interface{}, setDefaults func()) error
- func RunExperiment(driver Driver) error
- func SplitApplication(applicationKey string) (namespace string, name string)
- func StartHTTPMock(t *testing.T)
- func StringPointer(s string) *string
- func ToYAML(v interface{}) string
- func Uniq(list interface{}) []interface{}
- type Driver
- type Experiment
- type ExperimentMetadata
- type ExperimentResult
- type ExperimentSpec
- type GHZResult
- type HTTPResult
- type Insights
- type KubeDriver
- type MetricsServerCallback
- type MockMetricsServerInput
- type Summary
- type Task
- type TaskMeta
- type VersionInfo
Constants ¶
const ( // MetricsServerURL is the URL of the metrics server MetricsServerURL = "METRICS_SERVER_URL" // TestResultPath is the path to the PUT /testResult endpoint TestResultPath = "/testResult" // AbnDashboard is the path to the GET /abnDashboard endpoint AbnDashboard = "/abnDashboard" // HTTPDashboardPath is the path to the GET /httpDashboard endpoint HTTPDashboardPath = "/httpDashboard" // GRPCDashboardPath is the path to the GET /grpcDashboard endpoint GRPCDashboardPath = "/grpcDashboard" )
const ( // ExperimentFile is the name of the experiment file ExperimentFile = "experiment.yaml" // ExperimentTemplateFile is the name of the template that will produce the experiment file ExperimentTemplateFile = "experiment.tpl" )
const (
// CollectGRPCTaskName is the name of this task which performs load generation and metrics collection for gRPC services.
CollectGRPCTaskName = "grpc"
)
const (
// CollectHTTPTaskName is the name of this task which performs load generation and metrics collection.
CollectHTTPTaskName = "http"
)
const (
// NotifyTaskName is the task name
NotifyTaskName = "notify"
)
const (
// ReadinessTaskName is the task name
ReadinessTaskName = "ready"
)
const (
// RunTaskName is the name of the run task which performs running of a shell script
RunTaskName = "run"
)
Variables ¶
var MajorMinor = "v1.1"
MajorMinor is the minor version of Iter8 set this manually whenever the major or minor version changes
var Version = "v1.1.0"
Version is the semantic version of Iter8 (with the `v` prefix) Version is intended to be set using LDFLAGS at build time
Functions ¶
func BoolPointer ¶ added in v0.9.3
BoolPointer takes bool as input, creates a new variable with the input value, and returns a pointer to the variable
func CompletePath ¶
CompletePath is a helper function for converting file paths, specified relative to the caller of this function, into absolute ones. CompletePath is useful in tests and enables deriving the absolute path of experiment YAML files.
func CreateExperimentYaml ¶ added in v0.13.11
CreateExperimentYaml creates an experiment.yaml file from a template and a URL
func CreateTemplate ¶ added in v0.12.6
CreateTemplate creates a template from a string
func FuncMapWithToYAML ¶ added in v0.12.6
FuncMapWithToYAML return sprig text function map with a toYaml function
func GetTrackingHandler ¶ added in v0.13.11
func GetTrackingHandler(breadcrumb *bool) func(w http.ResponseWriter, r *http.Request)
GetTrackingHandler creates a handler for fhttp.DynamicHTTPServer that sets a variable to true This can be used to verify that the handler was called.
func IntPointer ¶ added in v0.15.0
IntPointer takes an int as input, creates a new variable with the input value, and returns a pointer to the variable
func MockMetricsServer ¶ added in v0.16.0
func MockMetricsServer(input MockMetricsServerInput)
MockMetricsServer is a mock metrics server use the callback functions in the MockMetricsServerInput to test if those endpoints are called
func PutExperimentResultToMetricsService ¶ added in v0.16.0
func PutExperimentResultToMetricsService(metricsServerURL, namespace, experiment string, experimentResult *ExperimentResult) error
PutExperimentResultToMetricsService sends the test result to the metrics service
func ReadConfig ¶ added in v0.15.0
ReadConfig reads yaml formatted configuration information into conf from the file specified by environment variable configEnv The function setDefaults is called to set any default values if desired
func RunExperiment ¶ added in v0.9.3
RunExperiment runs an experiment
func SplitApplication ¶ added in v0.15.0
SplitApplication is a utility function that returns the namespace and name from a key of the form "namespace/name"
func StartHTTPMock ¶ added in v0.16.0
StartHTTPMock activates and cleanups httpmock
func StringPointer ¶ added in v0.8.8
StringPointer takes string as input, creates a new variable with the input value, and returns a pointer to the variable
Types ¶
type Driver ¶ added in v0.9.3
type Driver interface { // Read the experiment Read() (*Experiment, error) // Write the experiment Write(e *Experiment) error // GetRevision returns the experiment revision GetRevision() int }
Driver enables interacting with experiment result stored externally
type Experiment ¶
type Experiment struct { Metadata ExperimentMetadata `json:"metadata" yaml:"metadata"` // Spec is the sequence of tasks that constitute this experiment Spec ExperimentSpec `json:"spec" yaml:"spec"` // Result is the current results from this experiment. // The experiment may not have completed in which case results may be partial. Result *ExperimentResult `json:"result" yaml:"result"` // contains filtered or unexported fields }
Experiment struct containing spec and result
func BuildExperiment ¶ added in v0.9.3
func BuildExperiment(driver Driver) (*Experiment, error)
BuildExperiment builds an experiment
func (*Experiment) Completed ¶ added in v0.9.3
func (exp *Experiment) Completed() bool
Completed returns true if the experiment is complete
func (*Experiment) NoFailure ¶ added in v0.9.3
func (exp *Experiment) NoFailure() bool
NoFailure returns true if no task in the experiment has failed
type ExperimentMetadata ¶ added in v0.16.0
type ExperimentMetadata struct { // Name is the name of the experiment Name string `json:"name" yaml:"name"` // Namespace is the namespace the experiment was deployed in Namespace string `json:"namespace" yaml:"namespace"` }
ExperimentMetadata species the name and namespace of the experiment Used in http and grpc tasks to send the name and namespace to the metrics server
type ExperimentResult ¶
type ExperimentResult struct { // Name is the name of this experiment Name string `json:"name,omitempty" yaml:"name,omitempty"` // Namespace is the namespace of this experiment Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` // Revision of this experiment Revision int `json:"revision,omitempty" yaml:"revision,omitempty"` // StartTime is the time when the experiment run started StartTime time.Time `json:"startTime" yaml:"startTime"` // NumCompletedTasks is the number of completed tasks NumCompletedTasks int `json:"numCompletedTasks" yaml:"numCompletedTasks"` // Failure is true if any of its tasks failed Failure bool `json:"failure" yaml:"failure"` // Insights produced in this experiment Insights *Insights `json:"insights,omitempty" yaml:"insights,omitempty"` // Iter8Version is the version of Iter8 CLI that created this result object Iter8Version string `json:"iter8Version" yaml:"iter8Version"` }
ExperimentResult defines the current results from the experiment
type ExperimentSpec ¶ added in v0.8.29
type ExperimentSpec []Task
ExperimentSpec specifies the set of tasks in this experiment
func (*ExperimentSpec) UnmarshalJSON ¶ added in v0.8.29
func (s *ExperimentSpec) UnmarshalJSON(data []byte) error
UnmarshalJSON will unmarshal an experiment spec from bytes This is a custom JSON unmarshaler
type GHZResult ¶ added in v0.16.0
GHZResult is the raw data sent to the metrics server This data will be transformed into httpDashboard when getGHZGrafana is called Key is the endpoint
type HTTPResult ¶ added in v0.16.0
type HTTPResult map[string]*fhttp.HTTPRunnerResults
HTTPResult is the raw data sent to the metrics server This data will be transformed into httpDashboard when getHTTPGrafana is called Key is the endpoint
type Insights ¶
type Insights struct { // NumVersions is the number of app versions detected by Iter8 NumVersions int `json:"numVersions" yaml:"numVersions"` // VersionNames is list of version identifiers if known VersionNames []VersionInfo `json:"versionNames" yaml:"versionNames"` // TaskData is a map of task names to the data produced by said task TaskData map[string]interface{} `json:"taskData" yaml:"taskData"` }
Insights records the number of versions in this experiment
func (*Insights) TrackVersionStr ¶ added in v0.11.12
TrackVersionStr creates a string of version name/track for display purposes
type KubeDriver ¶ added in v0.10.4
type KubeDriver struct { // EnvSettings provides generic Kubernetes options *cli.EnvSettings // contains filtered or unexported fields }
KubeDriver embeds Kube configuration, and enables interaction with a Kubernetes cluster through Kube APIs
func NewFakeKubeDriver ¶ added in v0.10.4
func NewFakeKubeDriver(s *cli.EnvSettings, objects ...runtime.Object) *KubeDriver
NewFakeKubeDriver creates and returns a new KubeDriver with fake clients
func NewKubeDriver ¶ added in v0.10.4
func NewKubeDriver(s *cli.EnvSettings) *KubeDriver
NewKubeDriver creates and returns a new KubeDriver
type MetricsServerCallback ¶ added in v0.16.0
MetricsServerCallback is a callback function for when the particular metrics server endpoint is called
type MockMetricsServerInput ¶ added in v0.16.0
type MockMetricsServerInput struct { MetricsServerURL string // PUT /testResult ExperimentResultCallback MetricsServerCallback // GET /grpcDashboard GRPCDashboardCallback MetricsServerCallback // GET /httpDashboard HTTPDashboardCallback MetricsServerCallback }
MockMetricsServerInput is the input for MockMetricsServer() allows the user to provide callbacks when particular endpoints are called
type Summary ¶ added in v0.17.0
type Summary struct { // Timestamp is when the summary was created // For example: 2022-08-09 15:10:36.569745 -0400 EDT m=+12.599643189 TimeStamp string `json:"timeStamp" yaml:"timeStamp"` // Completed is whether or not the experiment has completed Completed bool `json:"completed" yaml:"completed"` // NoTaskFailures is whether or not the experiment had any tasks that failed NoTaskFailures bool `json:"noTaskFailures" yaml:"noTaskFailures"` // NumTasks is the number of tasks in the experiment NumTasks int `json:"numTasks" yaml:"numTasks"` // NumCompletedTasks is the number of completed tasks in the experiment NumCompletedTasks int `json:"numCompletedTasks" yaml:"numCompletedTasks"` // Experiment is the experiment struct Experiment *Experiment `json:"experiment" yaml:"experiment"` }
Summary is the data that is given to the payload template Summary is a subset of the data contained in Experiment
type Task ¶
type Task interface {
// contains filtered or unexported methods
}
Task is the building block of an experiment spec An experiment spec is a sequence of tasks
type TaskMeta ¶ added in v0.8.29
type TaskMeta struct { // Task is the name of the task Task *string `json:"task,omitempty" yaml:"task,omitempty"` // Run is the script used in a run task // Specify either Task or Run but not both Run *string `json:"run,omitempty" yaml:"run,omitempty"` // If is the condition used to determine if this task needs to run // If the condition is not satisfied, then it is skipped in an experiment If *string `json:"if,omitempty" yaml:"if,omitempty"` }
TaskMeta provides common fields used across all tasks
type VersionInfo ¶ added in v0.11.12
type VersionInfo struct { // Version name Version string `json:"version" yaml:"version"` // Track identifier assigned to version Track string `json:"track" yaml:"track"` }
VersionInfo is basic information about a version
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package internal provides gRPC code used for testing load-test-grpc
|
Package internal provides gRPC code used for testing load-test-grpc |
helloworld/helloworld
Package helloworld implements the helloworld grpc service.
|
Package helloworld implements the helloworld grpc service. |
Package log enables logging for Iter8.
|
Package log enables logging for Iter8. |