forked from kubernetes-sigs/cri-tools
-
Notifications
You must be signed in to change notification settings - Fork 5
/
image.go
96 lines (74 loc) · 2.71 KB
/
image.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
/*
Copyright 2017 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 benchmark
import (
"github.com/kubernetes-sigs/cri-tools/pkg/framework"
internalapi "k8s.io/cri-api/pkg/apis"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = framework.KubeDescribe("Container", func() {
f := framework.NewDefaultCRIFramework()
var ic internalapi.ImageManagerService
BeforeEach(func() {
ic = f.CRIClient.CRIImageClient
})
Context("benchmark about operations on Image", func() {
var err error
testImageList := []string{
"busybox:1.26.2-uclibc",
"busybox:1-uclibc",
"busybox:1",
"busybox:1-glibc",
"busybox:1-musl",
}
AfterEach(func() {
for _, imageName := range testImageList {
imageSpec := &runtimeapi.ImageSpec{
Image: imageName,
}
ic.RemoveImage(imageSpec)
}
})
Measure("benchmark about basic operations on Image", func(b Benchmarker) {
imageSpec := &runtimeapi.ImageSpec{
Image: testImageList[0],
}
operation := b.Time("pull Image", func() {
framework.PullPublicImage(ic, testImageList[0], nil)
})
Expect(operation.Minutes()).Should(BeNumerically("<", 1), "pull Image shouldn't take too long.")
operation = b.Time("Image status", func() {
_, err = ic.ImageStatus(imageSpec)
})
framework.ExpectNoError(err, "failed to get image status: %v", err)
Expect(operation.Seconds()).Should(BeNumerically("<", 2), "get image status shouldn't take too long.")
operation = b.Time("remove Image", func() {
err = ic.RemoveImage(imageSpec)
})
framework.ExpectNoError(err, "failed to remove image: %v", err)
Expect(operation.Seconds()).Should(BeNumerically("<", 2), "remove Image shouldn't take too long.")
}, defaultOperationTimes)
Measure("benchmark about listing Image", func(b Benchmarker) {
for _, imageName := range testImageList {
framework.PullPublicImage(ic, imageName, nil)
}
operation := b.Time("list Container", func() {
_, err = ic.ListImages(nil)
})
framework.ExpectNoError(err, "failed to list Image: %v", err)
Expect(operation.Seconds()).Should(BeNumerically("<", 2), "list Image shouldn't take too long.")
}, defaultOperationTimes)
})
})