summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-05-05 03:40:19 -0400
committerGitHub <noreply@github.com>2022-05-05 03:40:19 -0400
commitf1703abea1987b096e0269622e2ad72d1304e878 (patch)
tree40b0f1d2e0c06cf265d0bd4a0d576f6499db697b /test
parentbdaac4b2b6573d0954c58da9968536017160b1ed (diff)
parent8781a3635a045282fac656b2b372ec1010c3b2e4 (diff)
downloadpodman-f1703abea1987b096e0269622e2ad72d1304e878.tar.gz
podman-f1703abea1987b096e0269622e2ad72d1304e878.tar.bz2
podman-f1703abea1987b096e0269622e2ad72d1304e878.zip
Merge pull request #14092 from vrothberg/benchmarks
benchmarks: push/pull
Diffstat (limited to 'test')
-rw-r--r--test/e2e/benchmarks_test.go71
1 files changed, 48 insertions, 23 deletions
diff --git a/test/e2e/benchmarks_test.go b/test/e2e/benchmarks_test.go
index 746dec0a6..ef4d51893 100644
--- a/test/e2e/benchmarks_test.go
+++ b/test/e2e/benchmarks_test.go
@@ -36,11 +36,14 @@ type benchmark struct {
options newBenchmarkOptions
}
+var benchmarkRegistry *podmanRegistry.Registry
+
// Allows for customizing the benchnmark in an easy to extend way.
type newBenchmarkOptions struct {
// Sets the benchmark's init function.
init func()
- // Run a local registry for this benchmark.
+ // Run a local registry for this benchmark. Use `getPortUserPass()` in
+ // the benchmark to get the port, user and password.
needsRegistry bool
}
@@ -53,6 +56,15 @@ func newBenchmark(name string, main func(), options *newBenchmarkOptions) {
allBenchmarks = append(allBenchmarks, bm)
}
+// getPortUserPass returns the port, user and password of the currently running
+// registry.
+func getPortUserPass() (string, string, string) {
+ if benchmarkRegistry == nil {
+ return "", "", ""
+ }
+ return benchmarkRegistry.Port, benchmarkRegistry.User, benchmarkRegistry.Password
+}
+
var _ = Describe("Podman Benchmark Suite", func() {
var (
timedir string
@@ -75,6 +87,15 @@ var _ = Describe("Podman Benchmark Suite", func() {
cleanup := func() {
podmanTest.Cleanup()
os.RemoveAll(timedir)
+
+ // Stop the local registry.
+ if benchmarkRegistry != nil {
+ if err := benchmarkRegistry.Stop(); err != nil {
+ logrus.Errorf("Error stopping registry: %v", err)
+ os.Exit(1)
+ }
+ benchmarkRegistry = nil
+ }
}
totalMemoryInKb := func() (total uint64) {
@@ -109,22 +130,23 @@ var _ = Describe("Podman Benchmark Suite", func() {
// All benchmarks are executed here to have *one* table listing all data.
Measure("Podman Benchmark Suite", func(b Benchmarker) {
+
+ registryOptions := &podmanRegistry.Options{
+ Image: "docker-archive:" + imageTarPath(registry),
+ }
+
for i := range allBenchmarks {
setup()
bm := allBenchmarks[i]
// Start a local registry if requested.
- var registry *podmanRegistry.Registry
if bm.options.needsRegistry {
- reg, err := podmanRegistry.Start()
+ reg, err := podmanRegistry.StartWithOptions(registryOptions)
if err != nil {
logrus.Errorf("Error starting registry: %v", err)
os.Exit(1)
}
- registry = reg
- os.Setenv(podmanRegistry.UserKey, reg.User)
- os.Setenv(podmanRegistry.PassKey, reg.Password)
- os.Setenv(podmanRegistry.PortKey, reg.Port)
+ benchmarkRegistry = reg
}
if bm.options.init != nil {
@@ -139,17 +161,6 @@ var _ = Describe("Podman Benchmark Suite", func() {
mem := totalMemoryInKb()
b.RecordValueWithPrecision("[MEM] "+bm.name, float64(mem), "KB", 1)
- // Stop the local registry.
- if bm.options.needsRegistry {
- os.Unsetenv(podmanRegistry.UserKey)
- os.Unsetenv(podmanRegistry.PassKey)
- os.Unsetenv(podmanRegistry.PortKey)
- if err := registry.Stop(); err != nil {
- logrus.Errorf("Error stopping registry: %v", err)
- os.Exit(1)
- }
- }
-
cleanup()
}
}, numBenchmarkSamples)
@@ -166,11 +177,27 @@ var _ = Describe("Podman Benchmark Suite", func() {
Expect(session).Should(Exit(0))
}, nil)
+ newBenchmark("podman push", func() {
+ port, user, pass := getPortUserPass()
+ session := podmanTest.Podman([]string{"push", "--tls-verify=false", "--creds", user + ":" + pass, UBI_INIT, "localhost:" + port + "/repo/image:tag"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ }, &newBenchmarkOptions{needsRegistry: true})
+
newBenchmark("podman pull", func() {
- session := podmanTest.Podman([]string{"pull", "quay.io/libpod/cirros"})
+ port, user, pass := getPortUserPass()
+ session := podmanTest.Podman([]string{"pull", "--tls-verify=false", "--creds", user + ":" + pass, "localhost:" + port + "/repo/image:tag"})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
- }, nil)
+ }, &newBenchmarkOptions{
+ needsRegistry: true,
+ init: func() {
+ port, user, pass := getPortUserPass()
+ session := podmanTest.Podman([]string{"push", "--tls-verify=false", "--creds", user + ":" + pass, UBI_INIT, "localhost:" + port + "/repo/image:tag"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ },
+ })
newBenchmark("podman load [docker]", func() {
session := podmanTest.Podman([]string{"load", "-i", "./testdata/docker-two-images.tar.xz"})
@@ -197,9 +224,7 @@ var _ = Describe("Podman Benchmark Suite", func() {
}, nil)
newBenchmark("podman login + logout", func() {
- user := os.Getenv(podmanRegistry.UserKey)
- pass := os.Getenv(podmanRegistry.PassKey)
- port := os.Getenv(podmanRegistry.PortKey)
+ port, user, pass := getPortUserPass()
session := podmanTest.Podman([]string{"login", "-u", user, "-p", pass, "--tls-verify=false", "localhost:" + port})
session.WaitWithDefaultTimeout()