Skip to content

Commit 016ab0b

Browse files
committed
Fix benchmark artifact parsing.
* Added a extractor to extract raw logs from json format and then pipe it into benchmark parser. * Also added -alsologtostderr=false -logtostderr=false to reduce noisy logs.
1 parent 2706754 commit 016ab0b

File tree

4 files changed

+92
-1
lines changed

4 files changed

+92
-1
lines changed

hack/jenkins/benchmark-dockerized.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ cd "${GOPATH}/src/k8s.io/kubernetes"
5959
./hack/install-etcd.sh
6060

6161
# Run the benchmark tests and pretty-print the results into a separate file.
62-
make test-integration WHAT="$*" KUBE_TEST_ARGS="-run='XXX' -bench=. -benchmem" \
62+
make test-integration WHAT="$*" KUBE_TEST_ARGS="-run='XXX' -bench=. -benchmem -alsologtostderr=false -logtostderr=false" \
63+
| (go run test/integration/benchmark/extractlog/main.go) \
6364
| tee \
6465
>(prettybench -no-passthrough > "${ARTIFACTS}/BenchmarkResults.txt") \
6566
>(go run test/integration/benchmark/jsonify/main.go "${ARTIFACTS}/BenchmarkResults_benchmark_$(date -u +%Y-%m-%dT%H:%M:%SZ).json" || cat > /dev/null)

test/integration/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ filegroup(
3939
"//test/integration/apimachinery:all-srcs",
4040
"//test/integration/apiserver:all-srcs",
4141
"//test/integration/auth:all-srcs",
42+
"//test/integration/benchmark/extractlog:all-srcs",
4243
"//test/integration/benchmark/jsonify:all-srcs",
4344
"//test/integration/client:all-srcs",
4445
"//test/integration/configmap:all-srcs",
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
2+
3+
go_library(
4+
name = "go_default_library",
5+
srcs = ["main.go"],
6+
importpath = "k8s.io/kubernetes/test/integration/benchmark/extractlog",
7+
visibility = ["//visibility:private"],
8+
)
9+
10+
go_binary(
11+
name = "extractlog",
12+
embed = [":go_default_library"],
13+
visibility = ["//visibility:public"],
14+
)
15+
16+
filegroup(
17+
name = "package-srcs",
18+
srcs = glob(["**"]),
19+
tags = ["automanaged"],
20+
visibility = ["//visibility:private"],
21+
)
22+
23+
filegroup(
24+
name = "all-srcs",
25+
srcs = [":package-srcs"],
26+
tags = ["automanaged"],
27+
visibility = ["//visibility:public"],
28+
)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"bufio"
21+
"encoding/json"
22+
"fmt"
23+
"io"
24+
"os"
25+
)
26+
27+
func main() {
28+
err := extractRawLog(os.Stdin)
29+
if err != nil {
30+
panic(err)
31+
}
32+
}
33+
34+
// A json log entry contains keys such as "Time", "Action", "Package" and "Output".
35+
// We are only interested in "Output", which is the raw log.
36+
type jsonLog struct {
37+
Output string `json:"output,omitempty"`
38+
}
39+
40+
// jsonToRawLog converts a single line of json formatted log to raw log.
41+
// If there is an error, it returns the original input.
42+
func jsonToRawLog(line string) (string, error) {
43+
var log jsonLog
44+
if err := json.Unmarshal([]byte(line), &log); err != nil {
45+
return line, err
46+
}
47+
return log.Output, nil
48+
}
49+
50+
func extractRawLog(r io.Reader) error {
51+
scan := bufio.NewScanner(r)
52+
for scan.Scan() {
53+
l, _ := jsonToRawLog(scan.Text())
54+
// Print the raw log to stdout.
55+
fmt.Println(l)
56+
}
57+
if err := scan.Err(); err != nil {
58+
return err
59+
}
60+
return nil
61+
}

0 commit comments

Comments
 (0)