forked from kubernetes/perf-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compare-resources_test.go
159 lines (143 loc) · 7.66 KB
/
compare-resources_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
Copyright 2015 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package src
import (
"reflect"
"testing"
e2e "k8s.io/kubernetes/test/e2e/framework"
)
func TestResourceCompareSuccess(t *testing.T) {
left := make(e2e.ResourceUsageSummary)
left["90"] = []e2e.SingleContainerSummary{
{Name: "heapster-v10-2r6la/heapster", Cpu: 0.266, Mem: 846700000},
{Name: "kibana-logging-v1-041ex/kibana-logging", Cpu: 0.000, Mem: 61200000},
{Name: "kube-dns-v10-udc0j/etcd", Cpu: 0.008, Mem: 18530000},
{Name: "kube-dns-v10-udc0j/healthz", Cpu: 0.001, Mem: 950000},
{Name: "kube-dns-v10-udc0j/kube2sky", Cpu: 0.005, Mem: 37810000},
{Name: "kube-dns-v10-udc0j/skydns", Cpu: 0.019, Mem: 3290000},
{Name: "kube-proxy-e2e-scalability-minion-0ana/kube-proxy", Cpu: 0.001, Mem: 4430000},
{Name: "kube-proxy-e2e-scalability-minion-0eu6/kube-proxy", Cpu: 0.000, Mem: 4460000},
}
left["99"] = []e2e.SingleContainerSummary{
{Name: "heapster-v10-2r6la/heapster", Cpu: 0.729, Mem: 1333160000},
{Name: "kibana-logging-v1-041ex/kibana-logging", Cpu: 0.000, Mem: 61200000},
{Name: "kube-dns-v10-udc0j/etcd", Cpu: 0.028, Mem: 24640000},
{Name: "kube-dns-v10-udc0j/healthz", Cpu: 0.002, Mem: 970000},
{Name: "kube-dns-v10-udc0j/kube2sky", Cpu: 0.041, Mem: 48220000},
{Name: "kube-dns-v10-udc0j/skydns", Cpu: 0.023, Mem: 3300000},
{Name: "kube-proxy-e2e-scalability-minion-0ana/kube-proxy", Cpu: 0.002, Mem: 4480000},
{Name: "kube-proxy-e2e-scalability-minion-0eu6/kube-proxy", Cpu: 0.002, Mem: 4490000},
}
right := make(e2e.ResourceUsageSummary)
right["90"] = []e2e.SingleContainerSummary{
{Name: "heapster-v10-a7j0p/heapster", Cpu: 0.354, Mem: 1256930000},
{Name: "kibana-logging-v1-9qqsp/kibana-logging", Cpu: 0.000, Mem: 61700000},
{Name: "kube-dns-v10-p15su/etcd", Cpu: 0.008, Mem: 17050000},
{Name: "kube-dns-v10-p15su/healthz", Cpu: 0.001, Mem: 930000},
{Name: "kube-dns-v10-p15su/kube2sky", Cpu: 0.004, Mem: 28330000},
{Name: "kube-dns-v10-p15su/skydns", Cpu: 0.022, Mem: 3340000},
{Name: "kube-proxy-e2e-scalability-minion-0490/kube-proxy", Cpu: 0.001, Mem: 4420000},
{Name: "kube-proxy-e2e-scalability-minion-0n32/kube-proxy", Cpu: 0.001, Mem: 4440000},
}
right["99"] = []e2e.SingleContainerSummary{
{Name: "heapster-v10-a7j0p/heapster", Cpu: 0.772, Mem: 1398390000},
{Name: "kibana-logging-v1-9qqsp/kibana-logging", Cpu: 0.000, Mem: 61700000},
{Name: "kube-dns-v10-p15su/etcd", Cpu: 0.030, Mem: 21900000},
{Name: "kube-dns-v10-p15su/healthz", Cpu: 0.001, Mem: 980000},
{Name: "kube-dns-v10-p15su/kube2sky", Cpu: 0.045, Mem: 43860000},
{Name: "kube-dns-v10-p15su/skydns", Cpu: 0.028, Mem: 3350000},
{Name: "kube-proxy-e2e-scalability-minion-0490/kube-proxy", Cpu: 0.002, Mem: 4450000},
{Name: "kube-proxy-e2e-scalability-minion-0n32/kube-proxy", Cpu: 0.002, Mem: 4490000},
}
if violating := CompareResourceUsages(&left, &right); violating != nil {
t.Errorf("Expected compare to return true, got violating containers: %v", violating)
}
}
func TestResourceCompareDifferentSizes(t *testing.T) {
left := make(e2e.ResourceUsageSummary)
left["90"] = []e2e.SingleContainerSummary{
{Name: "heapster-v10-2r6la/heapster", Cpu: 0.266, Mem: 846700000},
{Name: "kibana-logging-v1-041ex/kibana-logging", Cpu: 0.000, Mem: 61200000},
{Name: "kube-dns-v10-udc0j/etcd", Cpu: 0.008, Mem: 18530000},
{Name: "kube-dns-v10-udc0j/healthz", Cpu: 0.001, Mem: 950000},
{Name: "kube-dns-v10-udc0j/kube2sky", Cpu: 0.005, Mem: 37810000},
{Name: "kube-dns-v10-udc0j/skydns", Cpu: 0.019, Mem: 3290000},
{Name: "kube-proxy-e2e-scalability-minion-0ana/kube-proxy", Cpu: 0.001, Mem: 4430000},
{Name: "kube-proxy-e2e-scalability-minion-0eu6/kube-proxy", Cpu: 0.000, Mem: 4460000},
}
left["99"] = []e2e.SingleContainerSummary{
{Name: "heapster-v10-2r6la/heapster", Cpu: 0.729, Mem: 1333160000},
{Name: "kibana-logging-v1-041ex/kibana-logging", Cpu: 0.000, Mem: 61200000},
{Name: "kube-dns-v10-udc0j/etcd", Cpu: 0.028, Mem: 24640000},
{Name: "kube-dns-v10-udc0j/healthz", Cpu: 0.002, Mem: 970000},
{Name: "kube-dns-v10-udc0j/kube2sky", Cpu: 0.041, Mem: 48220000},
{Name: "kube-dns-v10-udc0j/skydns", Cpu: 0.023, Mem: 3300000},
{Name: "kube-proxy-e2e-scalability-minion-0ana/kube-proxy", Cpu: 0.002, Mem: 4480000},
{Name: "kube-proxy-e2e-scalability-minion-0eu6/kube-proxy", Cpu: 0.002, Mem: 4490000},
}
right := make(e2e.ResourceUsageSummary)
right["90"] = []e2e.SingleContainerSummary{
{Name: "heapster-v10-a7j0p/heapster", Cpu: 0.354, Mem: 1256930000},
{Name: "kibana-logging-v1-9qqsp/kibana-logging", Cpu: 0.000, Mem: 61700000},
{Name: "kube-dns-v10-p15su/etcd", Cpu: 0.008, Mem: 17050000},
{Name: "kube-dns-v10-p15su/healthz", Cpu: 0.001, Mem: 930000},
{Name: "kube-dns-v10-p15su/kube2sky", Cpu: 0.004, Mem: 28330000},
{Name: "kube-dns-v10-p15su/skydns", Cpu: 0.022, Mem: 3340000},
{Name: "kube-proxy-e2e-scalability-minion-0490/kube-proxy", Cpu: 0.001, Mem: 4420000},
{Name: "kube-proxy-e2e-scalability-minion-0n32/kube-proxy", Cpu: 0.001, Mem: 4440000},
}
if violating := CompareResourceUsages(&left, &right); violating != nil {
t.Errorf("Expected compare to return true, got violating containers: %v", violating)
}
if violating := CompareResourceUsages(&right, &left); violating != nil {
t.Errorf("Expected compare to return true, got violating containers: %v", violating)
}
}
func TestResourceCompareFailure(t *testing.T) {
left := make(e2e.ResourceUsageSummary)
left["90"] = []e2e.SingleContainerSummary{
{Name: "heapster-v10-2r6la/heapster", Cpu: 0.266, Mem: 846700000},
{Name: "kibana-logging-v1-041ex/kibana-logging", Cpu: 0.000, Mem: 61200000},
{Name: "kube-dns-v10-udc0j/etcd", Cpu: 0.18, Mem: 18530000},
{Name: "kube-dns-v10-udc0j/healthz", Cpu: 0.001, Mem: 950000},
{Name: "kube-dns-v10-udc0j/kube2sky", Cpu: 0.005, Mem: 37810000},
{Name: "kube-dns-v10-udc0j/skydns", Cpu: 0.019, Mem: 3290000},
{Name: "kube-proxy-e2e-scalability-minion-0ana/kube-proxy", Cpu: 0.001, Mem: 4430000},
{Name: "kube-proxy-e2e-scalability-minion-0eu6/kube-proxy", Cpu: 0.000, Mem: 4460000},
}
right := make(e2e.ResourceUsageSummary)
right["90"] = []e2e.SingleContainerSummary{
{Name: "heapster-v10-a7j0p/heapster", Cpu: 0.354, Mem: 1256930000},
{Name: "kibana-logging-v1-9qqsp/kibana-logging", Cpu: 0.000, Mem: 61700000},
{Name: "kube-dns-v10-p15su/etcd", Cpu: 0.008, Mem: 17050000},
{Name: "kube-dns-v10-p15su/healthz", Cpu: 0.001, Mem: 930000},
{Name: "kube-dns-v10-p15su/kube2sky", Cpu: 0.004, Mem: 28330000},
{Name: "kube-dns-v10-p15su/skydns", Cpu: 0.022, Mem: 3340000},
{Name: "kube-proxy-e2e-scalability-minion-0490/kube-proxy", Cpu: 0.001, Mem: 4420000},
{Name: "kube-proxy-e2e-scalability-minion-0n32/kube-proxy", Cpu: 0.001, Mem: 4440000},
}
expectedViolating := ViolatingResourceUsageData{
"etcd": {
percentile: "90",
leftCPUData: []float64{0.18},
leftMemData: []int64{18530000},
rightCPUData: []float64{0.008},
rightMemData: []int64{17050000},
},
}
if violating := CompareResourceUsages(&left, &right); violating == nil {
t.Errorf("Expected compare to return non empty list of violating results")
} else if !reflect.DeepEqual(violating, expectedViolating) {
t.Errorf("Expected compare to see violating containers:\n%v,\ngot:\n%v", expectedViolating, violating)
}
}