Skip to content

Commit

Permalink
fix blackbox tests
Browse files Browse the repository at this point in the history
Signed-off-by: Alexei Dodon <[email protected]>
  • Loading branch information
adodon2go committed Jul 8, 2024
1 parent 12e54c0 commit 038f95e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
9 changes: 6 additions & 3 deletions test/blackbox/helpers_redis.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ ZB_PATH=${ROOT_DIR}/bin/zb-${OS}-${ARCH}
TEST_DATA_DIR=${BATS_FILE_TMPDIR}/test/data

function redis_start() {
docker run -d --name redis_server -p 6379:6379 redis
local cname="$1"
local free_port="$2"
docker run -d --name ${cname} -p ${free_port}:6379 redis
}

function redis_stop() {
docker stop redis_server
docker rm -f redis_server
local cname="$1"
docker stop ${cname}
docker rm -f ${cname}
}
10 changes: 7 additions & 3 deletions test/blackbox/redis_local.bats
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ function setup_file() {
fi

# Setup redis server
redis_start
redis_port=$(get_free_port)
redis_start redis_server_local ${redis_port}

# Setup zot server
local zot_root_dir=${BATS_FILE_TMPDIR}/zot
Expand All @@ -49,7 +50,7 @@ function setup_file() {
"cacheDriver": {
"name": "redis",
"rootDir": "${zot_root_dir}/_redis",
"url": "redis://localhost:6379"
"url": "redis://localhost:${redis_port}"
}
},
"http": {
Expand All @@ -63,6 +64,9 @@ function setup_file() {
"extensions": {
"ui": {
"enable": true
},
"search": {
"enable": true
}
}
}
Expand Down Expand Up @@ -111,5 +115,5 @@ EOF

function teardown_file() {
zot_stop_all
redis_stop
redis_stop redis_server_local
}
22 changes: 8 additions & 14 deletions test/blackbox/redis_s3.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ load helpers_redis
load helpers_cloud

function verify_prerequisites() {
if [ ! $(command -v curl) ]; then
echo "you need to install curl as a prerequisite to running the tests" >&3
return 1
fi

if [ ! $(command -v jq) ]; then
echo "you need to install jq as a prerequisite to running the tests" >&3
return 1
fi

if [ ! $(command -v docker) ]; then
echo "you need to install docker as a prerequisite to running the tests" >&3
return 1
Expand All @@ -32,7 +22,8 @@ function setup_file() {
fi

# Setup redis server
redis_start
redis_port=$(get_free_port)
redis_start redis_server ${redis_port}

# Setup zot server
local zot_root_dir=${BATS_FILE_TMPDIR}/zot
Expand All @@ -52,7 +43,7 @@ function setup_file() {
"cacheDriver": {
"name": "redis",
"rootDir": "${zot_root_dir}/_redis",
"url": "redis://localhost:6379"
"url": "redis://localhost:${redis_port}"
},
"storageDriver": {
"name": "s3",
Expand All @@ -75,12 +66,15 @@ function setup_file() {
"extensions": {
"ui": {
"enable": true
},
"search": {
"enable": true
}
}
}
EOF

awslocal s3 --region "us-east-2" mb s3://zot-storage
awslocal s3 ls s3://zot-storage || awslocal s3 --region "us-east-2" mb s3://zot-storage

zot_serve ${ZOT_PATH} ${zot_sync_ondemand_config_file}
wait_zot_reachable ${zot_port}
Expand Down Expand Up @@ -123,5 +117,5 @@ EOF

function teardown_file() {
zot_stop_all
redis_stop
redis_stop redis_server
}

0 comments on commit 038f95e

Please sign in to comment.