Skip to content

Commit 6cad278

Browse files
committed
Remove dependency for benchmark integration tests from e2e fw
1 parent 22a4c2c commit 6cad278

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

test/integration/benchmark/jsonify/BUILD

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ go_library(
55
srcs = ["main.go"],
66
importpath = "k8s.io/kubernetes/test/integration/benchmark/jsonify",
77
visibility = ["//visibility:private"],
8-
deps = [
9-
"//test/e2e/perftype:go_default_library",
10-
"//vendor/golang.org/x/tools/benchmark/parse:go_default_library",
11-
],
8+
deps = ["//vendor/golang.org/x/tools/benchmark/parse:go_default_library"],
129
)
1310

1411
go_binary(

test/integration/benchmark/jsonify/main.go

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,36 @@ import (
2424
"os"
2525

2626
benchparse "golang.org/x/tools/benchmark/parse"
27-
"k8s.io/kubernetes/test/e2e/perftype"
2827
)
2928

29+
// TODO(random-liu): Replace this with prometheus' data model.
30+
31+
// The following performance data structures are generalized and well-formatted.
32+
// They can be pretty printed in json format and be analyzed by other performance
33+
// analyzing tools, such as Perfdash (k8s.io/contrib/perfdash).
34+
35+
// DataItem is the data point.
36+
type DataItem struct {
37+
// Data is a map from bucket to real data point (e.g. "Perc90" -> 23.5). Notice
38+
// that all data items with the same label combination should have the same buckets.
39+
Data map[string]float64 `json:"data"`
40+
// Unit is the data unit. Notice that all data items with the same label combination
41+
// should have the same unit.
42+
Unit string `json:"unit"`
43+
// Labels is the labels of the data item.
44+
Labels map[string]string `json:"labels,omitempty"`
45+
}
46+
47+
// PerfData contains all data items generated in current test.
48+
type PerfData struct {
49+
// Version is the version of the metrics. The metrics consumer could use the version
50+
// to detect metrics version change and decide what version to support.
51+
Version string `json:"version"`
52+
DataItems []DataItem `json:"dataItems"`
53+
// Labels is the labels of the dataset.
54+
Labels map[string]string `json:"labels,omitempty"`
55+
}
56+
3057
func main() {
3158
err := run()
3259
if err != nil {
@@ -42,7 +69,7 @@ func run() error {
4269
if err != nil {
4370
return err
4471
}
45-
data := perftype.PerfData{Version: "v1"}
72+
data := PerfData{Version: "v1"}
4673
for _, benchMarks := range benchmarkSet {
4774
for _, benchMark := range benchMarks {
4875
data.DataItems = appendIfMeasured(data.DataItems, benchMark, benchparse.NsPerOp, "time", "μs", benchMark.NsPerOp/1000.0)
@@ -63,11 +90,11 @@ func run() error {
6390
return ioutil.WriteFile(os.Args[1], formatted.Bytes(), 0664)
6491
}
6592

66-
func appendIfMeasured(items []perftype.DataItem, benchmark *benchparse.Benchmark, metricType int, metricName string, unit string, value float64) []perftype.DataItem {
93+
func appendIfMeasured(items []DataItem, benchmark *benchparse.Benchmark, metricType int, metricName string, unit string, value float64) []DataItem {
6794
if metricType != 0 && (benchmark.Measured&metricType) == 0 {
6895
return items
6996
}
70-
return append(items, perftype.DataItem{
97+
return append(items, DataItem{
7198
Unit: unit,
7299
Labels: map[string]string{
73100
"benchmark": benchmark.Name,

0 commit comments

Comments
 (0)