Skip to content

Commit

Permalink
Merge pull request kubernetes#1203 from qckzr/golint-fix
Browse files Browse the repository at this point in the history
Perf-tests golint checks fix
  • Loading branch information
k8s-ci-robot committed May 5, 2020
2 parents 140f8a9 + 5d15f0f commit d7135d3
Show file tree
Hide file tree
Showing 58 changed files with 300 additions and 300 deletions.
16 changes: 8 additions & 8 deletions clusterloader2/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ type TuningSet struct {
Name string `json: name`
// InitialDelay specifies the waiting time before starting phase execution.
InitialDelay Duration `json: initialDelay`
// QpsLoad is a definition for QpsLoad tuning set.
QpsLoad *QpsLoad `json: qpsLoad`
// QPSLoad is a definition for QPSLoad tuning set.
QPSLoad *QPSLoad `json: qpsLoad`
// RandomizedLoad is a definition for RandomizedLoad tuning set.
RandomizedLoad *RandomizedLoad `json: randomizedLoad`
// SteppedLoad is a definition for SteppedLoad tuning set.
Expand Down Expand Up @@ -187,17 +187,17 @@ type Measurement struct {
Instances []MeasurementInstanceConfig
}

// QpsLoad defines a uniform load with a given QPS.
type QpsLoad struct {
// Qps specifies requested qps.
Qps float64 `json: qps`
// QPSLoad defines a uniform load with a given QPS.
type QPSLoad struct {
// QPS specifies requested 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 specifies the expected average qps.
AverageQPS float64 `json: averageQps`
}

// SteppedLoad defines a load that generates a burst of
Expand Down
16 changes: 8 additions & 8 deletions clusterloader2/cmd/clusterloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ func main() {
klog.Exitf("Framework creation error: %v", err)
}

var prometheusController *prometheus.PrometheusController
var prometheusController *prometheus.Controller
var prometheusFramework *framework.Framework
if clusterLoaderConfig.PrometheusConfig.EnableServer {
// Pass overrides to prometheus controller
clusterLoaderConfig.TestScenario.OverridePaths = testOverridePaths
if prometheusController, err = prometheus.NewPrometheusController(&clusterLoaderConfig); err != nil {
if prometheusController, err = prometheus.NewController(&clusterLoaderConfig); err != nil {
klog.Exitf("Error while creating Prometheus Controller: %v", err)
}
prometheusFramework = prometheusController.GetFramework()
Expand Down Expand Up @@ -320,28 +320,28 @@ func runSingleTest(
junitReporter *ginkgoreporters.JUnitReporter,
suiteSummary *ginkgotypes.SuiteSummary,
) {
testId := getTestId(clusterLoaderConfig.TestScenario)
testID := getTestID(clusterLoaderConfig.TestScenario)
testStart := time.Now()
specSummary := &ginkgotypes.SpecSummary{
ComponentTexts: []string{suiteSummary.SuiteDescription, testId},
ComponentTexts: []string{suiteSummary.SuiteDescription, testID},
}
printTestStart(testId)
printTestStart(testID)
if errList := test.RunTest(f, prometheusFramework, &clusterLoaderConfig); !errList.IsEmpty() {
suiteSummary.NumberOfFailedSpecs++
specSummary.State = ginkgotypes.SpecStateFailed
specSummary.Failure = ginkgotypes.SpecFailure{
Message: errList.String(),
}
printTestResult(testId, "Fail", errList.String())
printTestResult(testID, "Fail", errList.String())
} else {
specSummary.State = ginkgotypes.SpecStatePassed
printTestResult(testId, "Success", "")
printTestResult(testID, "Success", "")
}
specSummary.RunTime = time.Since(testStart)
junitReporter.SpecDidComplete(specSummary)
}

func getTestId(ts api.TestScenario) string {
func getTestID(ts api.TestScenario) string {
if ts.Identifier != "" {
return fmt.Sprintf("%s(%s)", ts.Identifier, ts.ConfigPath)
}
Expand Down
8 changes: 4 additions & 4 deletions clusterloader2/pkg/config/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@ type PrometheusConfig struct {
SnapshotProject string
}

// GetMasterIp returns the first master ip, added for backward compatibility.
// GetMasterIP returns the first master ip, added for backward compatibility.
// TODO(mmatt): Remove this method once all the codebase is migrated to support multiple masters.
func (c *ClusterConfig) GetMasterIp() string {
func (c *ClusterConfig) GetMasterIP() string {
if len(c.MasterIPs) > 0 {
return c.MasterIPs[0]
}
return ""
}

// GetMasterInternalIp returns the first internal master ip, added for backward compatibility.
// GetMasterInternalIP returns the first internal master ip, added for backward compatibility.
// TODO(mmatt): Remove this method once all the codebase is migrated to support multiple masters.
func (c *ClusterConfig) GetMasterInternalIp() string {
func (c *ClusterConfig) GetMasterInternalIP() string {
if len(c.MasterInternalIPs) > 0 {
return c.MasterInternalIPs[0]
}
Expand Down
34 changes: 17 additions & 17 deletions clusterloader2/pkg/framework/client/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,25 +96,25 @@ func IsRetryableNetError(err error) bool {
return false
}

// ApiCallOptions describes how api call errors should be treated, i.e. which errors should be
// APICallOptions describes how api call errors should be treated, i.e. which errors should be
// allowed (ignored) and which should be retried.
type ApiCallOptions struct {
type APICallOptions struct {
shouldAllowError func(error) bool
shouldRetryError func(error) bool
}

// Allow creates an ApiCallOptions that allows (ignores) errors matching the given predicate.
func Allow(allowErrorPredicate func(error) bool) *ApiCallOptions {
return &ApiCallOptions{shouldAllowError: allowErrorPredicate}
// Allow creates an APICallOptions that allows (ignores) errors matching the given predicate.
func Allow(allowErrorPredicate func(error) bool) *APICallOptions {
return &APICallOptions{shouldAllowError: allowErrorPredicate}
}

// Retry creates an ApiCallOptions that retries errors matching the given predicate.
func Retry(retryErrorPredicate func(error) bool) *ApiCallOptions {
return &ApiCallOptions{shouldRetryError: retryErrorPredicate}
// Retry creates an APICallOptions that retries errors matching the given predicate.
func Retry(retryErrorPredicate func(error) bool) *APICallOptions {
return &APICallOptions{shouldRetryError: retryErrorPredicate}
}

// RetryFunction opaques given function into retryable function.
func RetryFunction(f func() error, options ...*ApiCallOptions) wait.ConditionFunc {
func RetryFunction(f func() error, options ...*APICallOptions) wait.ConditionFunc {
var shouldAllowErrorFuncs, shouldRetryErrorFuncs []func(error) bool
for _, option := range options {
if option.shouldAllowError != nil {
Expand Down Expand Up @@ -237,7 +237,7 @@ func WaitForDeleteNamespace(c clientset.Interface, namespace string) error {
}

// ListEvents retrieves events for the object with the given name.
func ListEvents(c clientset.Interface, namespace string, name string, options ...*ApiCallOptions) (obj *apiv1.EventList, err error) {
func ListEvents(c clientset.Interface, namespace string, name string, options ...*APICallOptions) (obj *apiv1.EventList, err error) {
getFunc := func() error {
obj, err = c.CoreV1().Events(namespace).List(metav1.ListOptions{
FieldSelector: "involvedObject.name=" + name,
Expand All @@ -259,7 +259,7 @@ func DeleteStorageClass(c clientset.Interface, name string) error {
}

// CreateObject creates object based on given object description.
func CreateObject(dynamicClient dynamic.Interface, namespace string, name string, obj *unstructured.Unstructured, options ...*ApiCallOptions) error {
func CreateObject(dynamicClient dynamic.Interface, namespace string, name string, obj *unstructured.Unstructured, options ...*APICallOptions) error {
gvk := obj.GroupVersionKind()
gvr, _ := meta.UnsafeGuessKindToResource(gvk)
obj.SetName(name)
Expand All @@ -272,7 +272,7 @@ func CreateObject(dynamicClient dynamic.Interface, namespace string, name string
}

// PatchObject updates (using patch) object with given name, group, version and kind based on given object description.
func PatchObject(dynamicClient dynamic.Interface, namespace string, name string, obj *unstructured.Unstructured, options ...*ApiCallOptions) error {
func PatchObject(dynamicClient dynamic.Interface, namespace string, name string, obj *unstructured.Unstructured, options ...*APICallOptions) error {
gvk := obj.GroupVersionKind()
gvr, _ := meta.UnsafeGuessKindToResource(gvk)
obj.SetName(name)
Expand All @@ -292,7 +292,7 @@ func PatchObject(dynamicClient dynamic.Interface, namespace string, name string,
}

// DeleteObject deletes object with given name, group, version and kind.
func DeleteObject(dynamicClient dynamic.Interface, gvk schema.GroupVersionKind, namespace string, name string, options ...*ApiCallOptions) error {
func DeleteObject(dynamicClient dynamic.Interface, gvk schema.GroupVersionKind, namespace string, name string, options ...*APICallOptions) error {
gvr, _ := meta.UnsafeGuessKindToResource(gvk)
deleteFunc := func() error {
// Delete operation removes object with all of the dependants.
Expand All @@ -305,7 +305,7 @@ func DeleteObject(dynamicClient dynamic.Interface, gvk schema.GroupVersionKind,
}

// GetObject retrieves object with given name, group, version and kind.
func GetObject(dynamicClient dynamic.Interface, gvk schema.GroupVersionKind, namespace string, name string, options ...*ApiCallOptions) (*unstructured.Unstructured, error) {
func GetObject(dynamicClient dynamic.Interface, gvk schema.GroupVersionKind, namespace string, name string, options ...*APICallOptions) (*unstructured.Unstructured, error) {
var obj *unstructured.Unstructured
gvr, _ := meta.UnsafeGuessKindToResource(gvk)
getFunc := func() error {
Expand All @@ -322,11 +322,11 @@ func GetObject(dynamicClient dynamic.Interface, gvk schema.GroupVersionKind, nam
}

func createPatch(current, modified *unstructured.Unstructured) ([]byte, error) {
currentJson, err := current.MarshalJSON()
currentJSON, err := current.MarshalJSON()
if err != nil {
return []byte{}, err
}
modifiedJson, err := modified.MarshalJSON()
modifiedJSON, err := modified.MarshalJSON()
if err != nil {
return []byte{}, err
}
Expand All @@ -336,5 +336,5 @@ func createPatch(current, modified *unstructured.Unstructured) ([]byte, error) {
// if some field has been deleted between `original` and `modified` object
// (e.g. by removing field in object's yaml), we will never remove that field from 'current'.
// TODO(mborsz): Pass here the original object.
return jsonmergepatch.CreateThreeWayJSONMergePatch(nil /* original */, modifiedJson, currentJson, preconditions...)
return jsonmergepatch.CreateThreeWayJSONMergePatch(nil /* original */, modifiedJSON, currentJSON, preconditions...)
}
10 changes: 5 additions & 5 deletions clusterloader2/pkg/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,28 +203,28 @@ func (f *Framework) DeleteNamespaces(namespaces []string) *errors.ErrorList {
}

// CreateObject creates object base on given object description.
func (f *Framework) CreateObject(namespace string, name string, obj *unstructured.Unstructured, options ...*client.ApiCallOptions) error {
func (f *Framework) CreateObject(namespace string, name string, obj *unstructured.Unstructured, options ...*client.APICallOptions) error {
return client.CreateObject(f.dynamicClients.GetClient(), namespace, name, obj, options...)
}

// PatchObject updates object (using patch) with given name using given object description.
func (f *Framework) PatchObject(namespace string, name string, obj *unstructured.Unstructured, options ...*client.ApiCallOptions) error {
func (f *Framework) PatchObject(namespace string, name string, obj *unstructured.Unstructured, options ...*client.APICallOptions) error {
return client.PatchObject(f.dynamicClients.GetClient(), namespace, name, obj)
}

// DeleteObject deletes object with given name and group-version-kind.
func (f *Framework) DeleteObject(gvk schema.GroupVersionKind, namespace string, name string, options ...*client.ApiCallOptions) error {
func (f *Framework) DeleteObject(gvk schema.GroupVersionKind, namespace string, name string, options ...*client.APICallOptions) error {
return client.DeleteObject(f.dynamicClients.GetClient(), gvk, namespace, name)
}

// GetObject retrieves object with given name and group-version-kind.
func (f *Framework) GetObject(gvk schema.GroupVersionKind, namespace string, name string, options ...*client.ApiCallOptions) (*unstructured.Unstructured, error) {
func (f *Framework) GetObject(gvk schema.GroupVersionKind, namespace string, name string, options ...*client.APICallOptions) (*unstructured.Unstructured, error) {
return client.GetObject(f.dynamicClients.GetClient(), gvk, namespace, name)
}

// ApplyTemplatedManifests finds and applies all manifest template files matching the provided
// manifestGlob pattern. It substitutes the template placeholders using the templateMapping map.
func (f *Framework) ApplyTemplatedManifests(manifestGlob string, templateMapping map[string]interface{}, options ...*client.ApiCallOptions) error {
func (f *Framework) ApplyTemplatedManifests(manifestGlob string, templateMapping map[string]interface{}, options ...*client.APICallOptions) error {
// TODO(mm4tt): Consider using the out-of-the-box "kubectl create -f".
manifestGlob = os.ExpandEnv(manifestGlob)
templateProvider := config.NewTemplateProvider(filepath.Dir(manifestGlob))
Expand Down
8 changes: 4 additions & 4 deletions clusterloader2/pkg/measurement/common/bundle/test_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type testMetrics struct {

// Execute supports two actions. start - which sets up all metrics.
// stop - which stops all metrics and collects all measurements.
func (t *testMetrics) Execute(config *measurement.MeasurementConfig) ([]measurement.Summary, error) {
func (t *testMetrics) Execute(config *measurement.Config) ([]measurement.Summary, error) {
var summaries []measurement.Summary
errList := errors.NewErrorList()
action, err := util.GetString(config.Params, "action")
Expand Down Expand Up @@ -243,15 +243,15 @@ func (*testMetrics) String() string {
return testMetricsMeasurementName
}

func createConfig(config *measurement.MeasurementConfig, overrides map[string]interface{}) *measurement.MeasurementConfig {
func createConfig(config *measurement.Config, overrides map[string]interface{}) *measurement.Config {
params := make(map[string]interface{})
for k, v := range config.Params {
params[k] = v
}
for k, v := range overrides {
params[k] = v
}
return &measurement.MeasurementConfig{
return &measurement.Config{
ClusterFramework: config.ClusterFramework,
PrometheusFramework: config.PrometheusFramework,
Params: params,
Expand All @@ -260,7 +260,7 @@ func createConfig(config *measurement.MeasurementConfig, overrides map[string]in
}
}

func execute(m measurement.Measurement, config *measurement.MeasurementConfig) ([]measurement.Summary, error) {
func execute(m measurement.Measurement, config *measurement.Config) ([]measurement.Summary, error) {
if m == nil {
return nil, fmt.Errorf("uninitialized metric")
}
Expand Down
2 changes: 1 addition & 1 deletion clusterloader2/pkg/measurement/common/etcd_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type etcdMetricsMeasurement struct {
// Execute supports two actions:
// - start - Starts collecting etcd metrics.
// - gather - Gathers and prints etcd metrics summary.
func (e *etcdMetricsMeasurement) Execute(config *measurement.MeasurementConfig) ([]measurement.Summary, error) {
func (e *etcdMetricsMeasurement) Execute(config *measurement.Config) ([]measurement.Summary, error) {
// Etcd is only exposed on localhost level. We are using ssh method
if !config.ClusterFramework.GetClusterConfig().SSHToMasterSupported {
klog.Infof("not grabbing etcd metrics through master SSH: unsupported for provider, %s", config.ClusterFramework.GetClusterConfig().Provider)
Expand Down
2 changes: 1 addition & 1 deletion clusterloader2/pkg/measurement/common/metrics_for_e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func createmetricsForE2EMeasurement() measurement.Measurement {
type metricsForE2EMeasurement struct{}

// Execute gathers and prints e2e metrics data.
func (m *metricsForE2EMeasurement) Execute(config *measurement.MeasurementConfig) ([]measurement.Summary, error) {
func (m *metricsForE2EMeasurement) Execute(config *measurement.Config) ([]measurement.Summary, error) {
provider, err := util.GetStringOrDefault(config.Params, "provider", config.ClusterFramework.GetClusterConfig().Provider)
if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions clusterloader2/pkg/measurement/common/probes/probes.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type probesMeasurement struct {
// Execute supports two actions:
// - start - starts probes and sets up monitoring
// - gather - Gathers and prints metrics.
func (p *probesMeasurement) Execute(config *measurement.MeasurementConfig) ([]measurement.Summary, error) {
func (p *probesMeasurement) Execute(config *measurement.Config) ([]measurement.Summary, error) {
if config.CloudProvider == "kubemark" {
klog.Infof("%s: Probes cannot work in Kubemark, skipping the measurement!", p)
return nil, nil
Expand Down Expand Up @@ -146,7 +146,7 @@ func (p *probesMeasurement) String() string {
return p.config.Name
}

func (p *probesMeasurement) initialize(config *measurement.MeasurementConfig) error {
func (p *probesMeasurement) initialize(config *measurement.Config) error {
replicasPerProbe, err := util.GetInt(config.Params, "replicasPerProbe")
if err != nil {
return err
Expand All @@ -157,7 +157,7 @@ func (p *probesMeasurement) initialize(config *measurement.MeasurementConfig) er
return nil
}

func (p *probesMeasurement) start(config *measurement.MeasurementConfig) error {
func (p *probesMeasurement) start(config *measurement.Config) error {
klog.Infof("Starting %s probe...", p)
if !p.startTime.IsZero() {
return fmt.Errorf("measurement %s cannot be started twice", p)
Expand Down Expand Up @@ -224,7 +224,7 @@ func (p *probesMeasurement) createProbesObjects() error {
return p.framework.ApplyTemplatedManifests(path.Join(manifestsPathPrefix, p.config.Manifests), p.templateMapping)
}

func (p *probesMeasurement) waitForProbesReady(config *measurement.MeasurementConfig) error {
func (p *probesMeasurement) waitForProbesReady(config *measurement.Config) error {
klog.Infof("Waiting for Probe %s to become ready...", p)
checkProbesReadyTimeout, err := util.GetDurationOrDefault(config.Params, "checkProbesReadyTimeout", defaultCheckProbesReadyTimeout)
if err != nil {
Expand Down
Loading

0 comments on commit d7135d3

Please sign in to comment.