Rename MetricsForE2E for golint failure

This renames MetricsForE2E to ComponentCollection for solving golint
failure.
This commit is contained in:
Kenichi Omichi 2019-08-07 07:08:18 +00:00
parent a8d71390cf
commit 47a4d1a8ec
5 changed files with 12 additions and 13 deletions

View File

@ -556,7 +556,6 @@ staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder
test/e2e/common test/e2e/common
test/e2e/framework/metrics
test/e2e/lifecycle/bootstrap test/e2e/lifecycle/bootstrap
test/e2e/storage/vsphere test/e2e/storage/vsphere
test/e2e_kubeadm test/e2e_kubeadm

View File

@ -250,7 +250,7 @@ func gatherMetrics(f *framework.Framework) {
if err != nil { if err != nil {
e2elog.Logf("MetricsGrabber failed grab metrics. Skipping metrics gathering.") e2elog.Logf("MetricsGrabber failed grab metrics. Skipping metrics gathering.")
} else { } else {
summary = (*e2emetrics.MetricsForE2E)(&received) summary = (*e2emetrics.ComponentCollection)(&received)
e2elog.Logf(summary.PrintHumanReadable()) e2elog.Logf(summary.PrintHumanReadable())
} }
} }

View File

@ -372,8 +372,8 @@ func (f *Framework) AfterEach() {
if err != nil { if err != nil {
e2elog.Logf("MetricsGrabber failed to grab some of the metrics: %v", err) e2elog.Logf("MetricsGrabber failed to grab some of the metrics: %v", err)
} }
(*e2emetrics.MetricsForE2E)(&received).ComputeClusterAutoscalerMetricsDelta(f.clusterAutoscalerMetricsBeforeTest) (*e2emetrics.ComponentCollection)(&received).ComputeClusterAutoscalerMetricsDelta(f.clusterAutoscalerMetricsBeforeTest)
f.TestSummaries = append(f.TestSummaries, (*e2emetrics.MetricsForE2E)(&received)) f.TestSummaries = append(f.TestSummaries, (*e2emetrics.ComponentCollection)(&received))
} }
} }

View File

@ -33,10 +33,10 @@ const (
caFunctionMetricLabel = "function" caFunctionMetricLabel = "function"
) )
// MetricsForE2E is metrics collection of components. // ComponentCollection is metrics collection of components.
type MetricsForE2E Collection type ComponentCollection Collection
func (m *MetricsForE2E) filterMetrics() { func (m *ComponentCollection) filterMetrics() {
apiServerMetrics := make(APIServerMetrics) apiServerMetrics := make(APIServerMetrics)
for _, metric := range interestingAPIServerMetrics { for _, metric := range interestingAPIServerMetrics {
apiServerMetrics[metric] = (*m).APIServerMetrics[metric] apiServerMetrics[metric] = (*m).APIServerMetrics[metric]
@ -78,7 +78,7 @@ func printSample(sample *model.Sample) string {
} }
// PrintHumanReadable returns e2e metrics with JSON format. // PrintHumanReadable returns e2e metrics with JSON format.
func (m *MetricsForE2E) PrintHumanReadable() string { func (m *ComponentCollection) PrintHumanReadable() string {
buf := bytes.Buffer{} buf := bytes.Buffer{}
for _, interestingMetric := range interestingAPIServerMetrics { for _, interestingMetric := range interestingAPIServerMetrics {
buf.WriteString(fmt.Sprintf("For %v:\n", interestingMetric)) buf.WriteString(fmt.Sprintf("For %v:\n", interestingMetric))
@ -126,14 +126,14 @@ func PrettyPrintJSON(metrics interface{}) string {
} }
// PrintJSON returns e2e metrics with JSON format. // PrintJSON returns e2e metrics with JSON format.
func (m *MetricsForE2E) PrintJSON() string { func (m *ComponentCollection) PrintJSON() string {
m.filterMetrics() m.filterMetrics()
return PrettyPrintJSON(m) return PrettyPrintJSON(m)
} }
// SummaryKind returns the summary of e2e metrics. // SummaryKind returns the summary of e2e metrics.
func (m *MetricsForE2E) SummaryKind() string { func (m *ComponentCollection) SummaryKind() string {
return "MetricsForE2E" return "ComponentCollection"
} }
func makeKey(a, b model.LabelValue) string { func makeKey(a, b model.LabelValue) string {
@ -142,7 +142,7 @@ func makeKey(a, b model.LabelValue) string {
// ComputeClusterAutoscalerMetricsDelta computes the change in cluster // ComputeClusterAutoscalerMetricsDelta computes the change in cluster
// autoscaler metrics. // autoscaler metrics.
func (m *MetricsForE2E) ComputeClusterAutoscalerMetricsDelta(before Collection) { func (m *ComponentCollection) ComputeClusterAutoscalerMetricsDelta(before Collection) {
if beforeSamples, found := before.ClusterAutoscalerMetrics[caFunctionMetric]; found { if beforeSamples, found := before.ClusterAutoscalerMetrics[caFunctionMetric]; found {
if afterSamples, found := m.ClusterAutoscalerMetrics[caFunctionMetric]; found { if afterSamples, found := m.ClusterAutoscalerMetrics[caFunctionMetric]; found {
beforeSamplesMap := make(map[string]*model.Sample) beforeSamplesMap := make(map[string]*model.Sample)

View File

@ -180,7 +180,7 @@ func gatherTestSuiteMetrics() error {
return fmt.Errorf("failed to grab metrics: %v", err) return fmt.Errorf("failed to grab metrics: %v", err)
} }
metricsForE2E := (*e2emetrics.MetricsForE2E)(&received) metricsForE2E := (*e2emetrics.ComponentCollection)(&received)
metricsJSON := metricsForE2E.PrintJSON() metricsJSON := metricsForE2E.PrintJSON()
if TestContext.ReportDir != "" { if TestContext.ReportDir != "" {
filePath := path.Join(TestContext.ReportDir, "MetricsForE2ESuite_"+time.Now().Format(time.RFC3339)+".json") filePath := path.Join(TestContext.ReportDir, "MetricsForE2ESuite_"+time.Now().Format(time.RFC3339)+".json")