Commit 03fc8ba4 authored by gmarek's avatar gmarek

Metrics in e2e tests are using printer framework to print themselves

parent f293dff5
...@@ -161,6 +161,21 @@ func (f *Framework) afterEach() { ...@@ -161,6 +161,21 @@ func (f *Framework) afterEach() {
summaries = append(summaries, f.logsSizeVerifier.GetSummary()) summaries = append(summaries, f.logsSizeVerifier.GetSummary())
} }
if testContext.GatherMetricsAfterTest {
// TODO: enable Scheduler and ControllerManager metrics grabbing when Master's Kubelet will be registered.
grabber, err := metrics.NewMetricsGrabber(f.Client, true, false, false, true)
if err != nil {
Logf("Failed to create MetricsGrabber. Skipping metrics gathering.")
} else {
received, err := grabber.Grab(nil)
if err != nil {
Logf("MetricsGrabber failed grab metrics. Skipping metrics gathering.")
} else {
summaries = append(summaries, (*metricsForE2E)(&received))
}
}
}
outputTypes := strings.Split(testContext.OutputPrintType, ",") outputTypes := strings.Split(testContext.OutputPrintType, ",")
for _, printType := range outputTypes { for _, printType := range outputTypes {
switch printType { switch printType {
...@@ -177,37 +192,6 @@ func (f *Framework) afterEach() { ...@@ -177,37 +192,6 @@ func (f *Framework) afterEach() {
} }
} }
if testContext.GatherMetricsAfterTest {
// TODO: enable Scheduler and ControllerManager metrics grabbing when Master's Kubelet will be registered.
grabber, err := metrics.NewMetricsGrabber(f.Client, true, false, false, true)
if err != nil {
Logf("Failed to create MetricsGrabber. Skipping metrics gathering.")
} else {
received, err := grabber.Grab(nil)
if err != nil {
Logf("MetricsGrabber failed grab metrics. Skipping metrics gathering.")
} else {
buf := bytes.Buffer{}
for interestingMetric := range InterestingApiServerMetrics {
buf.WriteString(fmt.Sprintf("For %v:\n", interestingMetric))
for _, sample := range received.ApiServerMetrics[interestingMetric] {
buf.WriteString(fmt.Sprintf("\t%v\n", metrics.PrintSample(sample)))
}
}
for kubelet, grabbed := range received.KubeletMetrics {
buf.WriteString(fmt.Sprintf("For %v:\n", kubelet))
for interestingMetric := range InterestingKubeletMetrics {
buf.WriteString(fmt.Sprintf("\tFor %v:\n", interestingMetric))
for _, sample := range grabbed[interestingMetric] {
buf.WriteString(fmt.Sprintf("\t\t%v\n", metrics.PrintSample(sample)))
}
}
}
Logf("%v", buf.String())
}
}
}
// Paranoia-- prevent reuse! // Paranoia-- prevent reuse!
f.Namespace = nil f.Namespace = nil
f.Client = nil f.Client = nil
......
...@@ -29,6 +29,7 @@ import ( ...@@ -29,6 +29,7 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
client "k8s.io/kubernetes/pkg/client/unversioned" client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/master/ports" "k8s.io/kubernetes/pkg/master/ports"
"k8s.io/kubernetes/pkg/metrics"
"k8s.io/kubernetes/pkg/util/sets" "k8s.io/kubernetes/pkg/util/sets"
"github.com/prometheus/common/expfmt" "github.com/prometheus/common/expfmt"
...@@ -46,7 +47,33 @@ const ( ...@@ -46,7 +47,33 @@ const (
apiCallLatencyLargeThreshold time.Duration = 1 * time.Second apiCallLatencyLargeThreshold time.Duration = 1 * time.Second
) )
var InterestingApiServerMetrics = sets.NewString( type metricsForE2E metrics.MetricsCollection
func (m *metricsForE2E) PrintHumanReadable() string {
buf := bytes.Buffer{}
for _, interestingMetric := range InterestingApiServerMetrics {
buf.WriteString(fmt.Sprintf("For %v:\n", interestingMetric))
for _, sample := range (*m).ApiServerMetrics[interestingMetric] {
buf.WriteString(fmt.Sprintf("\t%v\n", metrics.PrintSample(sample)))
}
}
for kubelet, grabbed := range (*m).KubeletMetrics {
buf.WriteString(fmt.Sprintf("For %v:\n", kubelet))
for _, interestingMetric := range InterestingKubeletMetrics {
buf.WriteString(fmt.Sprintf("\tFor %v:\n", interestingMetric))
for _, sample := range grabbed[interestingMetric] {
buf.WriteString(fmt.Sprintf("\t\t%v\n", metrics.PrintSample(sample)))
}
}
}
return buf.String()
}
func (m *metricsForE2E) PrintJSON() string {
return "JSON printer not implemented for Metrics"
}
var InterestingApiServerMetrics = []string{
"apiserver_request_count", "apiserver_request_count",
"apiserver_request_latencies_bucket", "apiserver_request_latencies_bucket",
"etcd_helper_cache_entry_count", "etcd_helper_cache_entry_count",
...@@ -62,9 +89,9 @@ var InterestingApiServerMetrics = sets.NewString( ...@@ -62,9 +89,9 @@ var InterestingApiServerMetrics = sets.NewString(
"process_resident_memory_bytes", "process_resident_memory_bytes",
"process_start_time_seconds", "process_start_time_seconds",
"process_virtual_memory_bytes", "process_virtual_memory_bytes",
) }
var InterestingKubeletMetrics = sets.NewString( var InterestingKubeletMetrics = []string{
"container_cpu_system_seconds_total", "container_cpu_system_seconds_total",
"container_cpu_user_seconds_total", "container_cpu_user_seconds_total",
"container_fs_io_time_weighted_seconds_total", "container_fs_io_time_weighted_seconds_total",
...@@ -86,7 +113,7 @@ var InterestingKubeletMetrics = sets.NewString( ...@@ -86,7 +113,7 @@ var InterestingKubeletMetrics = sets.NewString(
"process_resident_memory_bytes", "process_resident_memory_bytes",
"process_start_time_seconds", "process_start_time_seconds",
"process_virtual_memory_bytes", "process_virtual_memory_bytes",
) }
// Dashboard metrics // Dashboard metrics
type LatencyMetric struct { type LatencyMetric struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment