Skip to content

Commit

Permalink
fix: json marshal vet fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Kush Trivedi <[email protected]>
  • Loading branch information
kushthedude committed Sep 1, 2020
1 parent c7cdf16 commit 8046407
Showing 1 changed file with 56 additions and 56 deletions.
112 changes: 56 additions & 56 deletions clusterloader2/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,30 @@ type TestSuite []TestScenario
// TestScenario defines customized test to be run.
type TestScenario struct {
// Identifier is a unique test scenario name across test suite.
Identifier string `json: identifier`
Identifier string `json:"identifier"`
// ConfigPath defines path to the file containing a single Config definition.
ConfigPath string `json: configPath`
ConfigPath string `json:"configPath"`
// OverridePaths defines what override files should be applied
// to the config specified by the ConfigPath.
OverridePaths []string `json: overridePaths`
OverridePaths []string `json:"overridePaths"`
}

// Config is a structure that represents configuration
// for a single test scenario.
type Config struct {
// Name of the test case.
Name string `json: name`
Name string `json:"name"`
// Deprecated: a number of automanaged namespaces.
// Use Namespace.Number instead.
AutomanagedNamespaces int32 `json: automanagedNamespaces,omitempty`
AutomanagedNamespaces int32 `json:"automanagedNamespaces,omitempty"`
// Namespace is a structure for namespace configuration.
Namespace NamespaceConfig `json: namespace`
Namespace NamespaceConfig `json:"namespace"`
// Steps is a sequence of test steps executed in serial.
Steps []Step `json: steps`
Steps []Step `json:"steps"`
// TuningSets is a collection of tuning sets that can be used by steps.
TuningSets []TuningSet `json: tuningSets`
TuningSets []TuningSet `json:"tuningSets"`
// ChaosMonkey is a config for simulated component failures.
ChaosMonkey ChaosMonkeyConfig `json: chaosMonkey`
ChaosMonkey ChaosMonkeyConfig `json:"chaosMonkey"`
}

// Step represents encapsulation of some actions. These actions could be
Expand All @@ -60,12 +60,12 @@ type Config struct {
type Step struct {
// Phases is a collection of declarative definitions of objects.
// Phases will be executed in parallel.
Phases []Phase `json: phases`
Phases []Phase `json:"phases"`
// Measurements is a collection of parallel measurement calls.
Measurements []Measurement `json: measurements`
Measurements []Measurement `json:"measurements"`
// Name is an optional name for given step. If name is set,
// timer will be run for the step execution.
Name string `json: name`
Name string `json:"name"`
}

// Phase is a structure that declaratively defines state of objects.
Expand All @@ -75,61 +75,61 @@ type Phase struct {
// NamespaceRange defines the set of namespaces in which objects
// should be reconciled.
// If null, objects are assumed to be cluster scoped.
NamespaceRange *NamespaceRange `json: namespaceRange`
NamespaceRange *NamespaceRange `json:"namespaceRange"`
// ReplicasPerNamespace is a number of instances of a given object
// to exist in each of referenced namespaces.
ReplicasPerNamespace int32 `json: replicasPerNamespace`
ReplicasPerNamespace int32 `json:"replicasPerNamespace"`
// TuningSet is the name of TuningSet to be used.
TuningSet string `json: tuningSet`
TuningSet string `json:"tuningSet"`
// ObjectBundle declaratively defines a set of objects.
// For every specified namespace and for every required replica,
// these objects will be reconciled in serial.
ObjectBundle []Object `json: objectBundle`
ObjectBundle []Object `json:"objectBundle"`
}

// Object is a structure that defines the object managed be the tests.
type Object struct {
// Basename is a string from which names of objects will be created.
Basename string `json: basename`
Basename string `json:"basename"`
// ObjectTemplatePath specifies the path to object definition.
ObjectTemplatePath string `json: objectTemplatePath`
ObjectTemplatePath string `json:"objectTemplatePath"`
// TemplateFillMap specifies for each placeholder what value should it be replaced with.
TemplateFillMap map[string]interface{} `json: templateFillMap`
TemplateFillMap map[string]interface{} `json:"templateFillMap"`
// ListUnknownObjectOptions, if set, will result in listing objects that were
// not created directly via ClusterLoader2 before executing Phase. The main
// use case for that is deleting unknown objects using the Phase mechanism,
// e.g. deleting PVs that were created via StatefulSets leveraging all Phase
// functionalities, e.g. respecting given QPS, doing it in parallel with other
// Phases, etc.
ListUnknownObjectOptions *ListUnknownObjectOptions `json: listUnknownObjectOptions`
ListUnknownObjectOptions *ListUnknownObjectOptions `json:"listUnknownObjectOptions"`
}

// ListUnknownObjectOptions struct specifies options for listing unknown objects.
type ListUnknownObjectOptions struct {
LabelSelector *metav1.LabelSelector `json: labelSelector`
LabelSelector *metav1.LabelSelector `json:"labelSelector"`
}

// NamespaceConfig defines namespace parameters.
type NamespaceConfig struct {
// Number is a number of automanaged namespaces.
Number int32 `json: number,omitempty`
Number int32 `json:"number,omitempty"`
// NamePrefix is the name prefix of automanaged namespaces.
// It's optional, if set CL will use it, otherwise generate one with random string.
Prefix string `json: prefix,omitempty`
Prefix string `json:"prefix,omitempty"`
// DeleteStaleNamespaces specifies whether or not delete stale namespaces.
DeleteStaleNamespaces *bool `json: deleteStaleNamespaces,omitempty`
DeleteStaleNamespaces *bool `json:"deleteStaleNamespaces,omitempty"`
// DeleteAutomanangedNamespaces specifies whether or not delete namespaces after a test.
DeleteAutomanagedNamespaces *bool `json: deleteAutomanagedNamespaces,omitempty`
DeleteAutomanagedNamespaces *bool `json:"deleteAutomanagedNamespaces,omitempty"`
// EnableExistingNamespaces enables to use pre-created namespaces in a test.
EnableExistingNamespaces *bool `json: enableExistingNamespaces,omitempty`
EnableExistingNamespaces *bool `json:"enableExistingNamespaces,omitempty"`
}

// NamespaceRange specifies the range of namespaces [Min, Max].
type NamespaceRange struct {
// Min is the lower index of namespace range.
Min int32 `json: min`
Min int32 `json:"min"`
// Max is the upper index of namespace range.
Max int32 `json: max`
Max int32 `json:"max"`
// Basename defines the group of selected namespaces.
// All of the namespaces, with name "<Basename>-<i>"
// where <i> in [Min, Max], will be selected.
Expand All @@ -141,47 +141,47 @@ type NamespaceRange struct {
// It is required to have exactly one of the load structure provided.
type TuningSet struct {
// Name by which the TuningSet will be referenced.
Name string `json: name`
Name string `json:"name"`
// InitialDelay specifies the waiting time before starting phase execution.
InitialDelay Duration `json: initialDelay`
InitialDelay Duration `json:"initialDelay"`
// QPSLoad is a definition for QPSLoad tuning set.
QPSLoad *QPSLoad `json: qpsLoad`
QPSLoad *QPSLoad `json:"qpsLoad"`
// RandomizedLoad is a definition for RandomizedLoad tuning set.
RandomizedLoad *RandomizedLoad `json: randomizedLoad`
RandomizedLoad *RandomizedLoad `json:"randomizedLoad"`
// SteppedLoad is a definition for SteppedLoad tuning set.
SteppedLoad *SteppedLoad `json: steppedLoad`
SteppedLoad *SteppedLoad `json:"steppedLoad"`
// TimeLimitedLoad is a definition for TimeLimitedLoad tuning set.
TimeLimitedLoad *TimeLimitedLoad `json: timeLimitedLoad`
TimeLimitedLoad *TimeLimitedLoad `json:"timeLimitedLoad"`
// RandomizedTimeLimitedLoad is a definition for RandomizedTimeLimitedLoad tuning set.
RandomizedTimeLimitedLoad *RandomizedTimeLimitedLoad `json: randomizedTimeLimitedLoad`
RandomizedTimeLimitedLoad *RandomizedTimeLimitedLoad `json:"randomizedTimeLimitedLoad"`
// ParallelismLimitedLoad is a definition for ParallelismLimitedLoad tuning set.
ParallelismLimitedLoad *ParallelismLimitedLoad `json: parallelismLimitedLoad`
ParallelismLimitedLoad *ParallelismLimitedLoad `json:"parallelismLimitedLoad"`
// GlobalQPSLoad is a definition for GlobalQPSLoad tuning set.
GlobalQPSLoad *GlobalQPSLoad `json: globalQPSLoad`
GlobalQPSLoad *GlobalQPSLoad `json:"globalQPSLoad"`
}

// MeasurementInstanceConfig is a structure that contains the Instance for wrapper measurements along with optional params.
type MeasurementInstanceConfig struct {
// Identifier is a string that identifies a single instance of measurement within a wrapper measurement
Identifier string `json: identifier`
Identifier string `json:"identifier"`
// Params is an optional map which is specific to the measurement instance defined above by the identifier.
// In case the Measurement level params also contain the same configs as defined in this, then while executing that
// particular Measurement Instance, the params defined here would be given higher priority.
Params map[string]interface{} `json: params`
Params map[string]interface{} `json:"params"`
}

// Measurement is a structure that defines the measurement method call.
// This method call will either start or stop process of collecting specific data samples.
type Measurement struct {
// Method is a name of a method registered in the ClusterLoader factory.
Method string `json: method`
Method string `json:"method"`
// Params is a map of {name: value} pairs which will be passed to the measurement method - allowing for injection of arbitrary parameters to it.
Params map[string]interface{} `json: params`
Params map[string]interface{} `json:"params"`

// Exactly one of Identifier or Instances must be supplied.
// Identifier is for single measurements while Instances is for wrapper measurements.
// Identifier is a string that differentiates measurement instances of the same method.
Identifier string `json: identifier`
Identifier string `json:"identifier"`
// MeasurementInstanceConfig contains the Identifier and Params of the measurement.
// It shouldn't be set when Identifier is set.
Instances []MeasurementInstanceConfig
Expand All @@ -190,69 +190,69 @@ type Measurement struct {
// QPSLoad defines a uniform load with a given QPS.
type QPSLoad struct {
// QPS specifies requested qps.
QPS float64 `json: qps`
QPS float64 `json:"qps"`
}

// RandomizedLoad defines a load that is spread randomly
// across a given total time.
type RandomizedLoad struct {
// AverageQPS specifies the expected average qps.
AverageQPS float64 `json: averageQps`
AverageQPS float64 `json:"averageQps"`
}

// SteppedLoad defines a load that generates a burst of
// a given size every X seconds.
type SteppedLoad struct {
// BurstSize specifies the qps peek.
BurstSize int32 `json: burstSize`
BurstSize int32 `json:"burstSize"`
// StepDelay specifies the interval between peeks.
StepDelay Duration `json: stepDelay`
StepDelay Duration `json:"stepDelay"`
}

// TimeLimitedLoad defines a load that spreads operations over given time.
type TimeLimitedLoad struct {
// TimeLimit specifies the limit of the time that operation will be spread over.
TimeLimit Duration `json: timeLimit`
TimeLimit Duration `json:"timeLimit"`
}

// RandomizedTimeLimitedLoad defines a load that randomly spreads operations over given time.
type RandomizedTimeLimitedLoad struct {
// TimeLimit specifies the limit of the time that operation will be spread over.
TimeLimit Duration `json: timeLimit`
TimeLimit Duration `json:"timeLimit"`
}

// ParallelismLimitedLoad defines a load that executes actions with given parallelism.
type ParallelismLimitedLoad struct {
// ParallelismLimit specifies the limit of the parallelism for the action executions.
ParallelismLimit int32 `json: parallelismLimit`
ParallelismLimit int32 `json:"parallelismLimit"`
}

// GlobalQPSLoad defines a uniform load with a given QPS.
// The rate limiter is shared across all phases using this tuning set.
type GlobalQPSLoad struct {
// QPS defines desired average rate of actions.
QPS float64 `json: qps`
QPS float64 `json:"qps"`
// Burst defines maxumim number of actions that can happen at the same time.
Burst int `json: burst`
Burst int `json:"burst"`
}

// ChaosMonkeyConfig descibes simulated component failures.
type ChaosMonkeyConfig struct {
// NodeFailure is a config for simulated node failures.
NodeFailure *NodeFailureConfig `json: nodeFailure`
NodeFailure *NodeFailureConfig `json:"nodeFailure"`
}

// NodeFailureConfig describes simulated node failures.
type NodeFailureConfig struct {
// FailureRate is a percentage of all nodes that could fail simultinously.
FailureRate float64 `json: failureRate`
FailureRate float64 `json:"failureRate"`
// Interval is time between node failures.
Interval Duration `json: interval`
Interval Duration `json:"interval"`
// JitterFactor is factor used to jitter node failures.
// Node will be killed between [Interval, Interval + (1.0 + JitterFactor)].
JitterFactor float64 `json: jitterFactor`
JitterFactor float64 `json:"jitterFactor"`
// SimulatedDowntime is a duration between node is killed and recreated.
SimulatedDowntime Duration `json: simulatedDowntime`
SimulatedDowntime Duration `json:"simulatedDowntime"`
}

// Duration is time.Duration that uses string format (e.g. 1h2m3s) for marshaling.
Expand Down

0 comments on commit 8046407

Please sign in to comment.