File: helpers.bash

package info (click to toggle)
podman 5.7.0%2Bds2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,824 kB
  • sloc: sh: 4,700; python: 2,798; perl: 1,885; ansic: 1,484; makefile: 977; ruby: 42; csh: 8
file content (36 lines) | stat: -rw-r--r-- 913 bytes parent folder | download | duplicates (2)
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
ENGINE_A=${ENGINE_A:-podman}
ENGINE_B=${ENGINE_B:-docker}
RUNS=${RUNS:-100}
NUM_CONTAINERS=${NUM_CONTAINERS:-100}
IMAGE=${IMAGE:-docker.io/library/alpine:latest}

BOLD="$(tput bold)"
RESET="$(tput sgr0)"

function echo_bold() {
    echo "${BOLD}$1${RESET}"
}

function pull_image() {
	echo_bold "... pulling $IMAGE"
	$ENGINE_A pull $IMAGE -q > /dev/null
	$ENGINE_B pull $IMAGE -q > /dev/null
}

function setup() {
	echo_bold "---------------------------------------------------"
	echo_bold "... comparing $ENGINE_A with $ENGINE_B"
	echo_bold "... cleaning up previous containers and images"
	$ENGINE_A system prune -f > /dev/null
	$ENGINE_B system prune -f > /dev/null
	pull_image
	echo ""
}

function create_containers() {
	echo_bold "... creating $NUM_CONTAINERS containers"
	for i in $(eval echo "{0..$NUM_CONTAINERS}"); do
		$ENGINE_A create $IMAGE >> /dev/null
		$ENGINE_B create $IMAGE >> /dev/null
	done
}