mirror of
https://github.com/bitnami/containers.git
synced 2026-03-14 06:48:11 +08:00
Merge pull request #2 from bitnami/remove-docker-exec
Test fixes for Jenkins CI
This commit is contained in:
@@ -1,54 +1,56 @@
|
|||||||
#!/usr/bin/env bats
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
CONTAINER_NAME=redis
|
CONTAINER_NAME=bitnami-redis-test
|
||||||
IMAGE_NAME=bitnami/redis
|
IMAGE_NAME=bitnami/redis
|
||||||
SLEEP_TIME=3
|
SLEEP_TIME=3
|
||||||
VOL_PREFIX=/bitnami/$CONTAINER_NAME
|
VOL_PREFIX=/bitnami/redis
|
||||||
HOST_VOL_PREFIX=/tmp/bitnami/$CONTAINER_NAME
|
|
||||||
REDIS_PASSWORD=test_password123
|
REDIS_PASSWORD=test_password123
|
||||||
|
|
||||||
# Check config override from host
|
cleanup_running_containers() {
|
||||||
setup() {
|
|
||||||
mkdir -p $HOST_VOL_PREFIX
|
|
||||||
}
|
|
||||||
|
|
||||||
teardown() {
|
|
||||||
if [ "$(docker ps -a | grep $CONTAINER_NAME)" ]; then
|
if [ "$(docker ps -a | grep $CONTAINER_NAME)" ]; then
|
||||||
docker rm -fv $CONTAINER_NAME
|
docker rm -fv $CONTAINER_NAME
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
cleanup_running_containers
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
cleanup_running_containers
|
||||||
|
}
|
||||||
|
|
||||||
create_container(){
|
create_container(){
|
||||||
docker run -itd --name $CONTAINER_NAME $IMAGE_NAME
|
docker run -d --name $CONTAINER_NAME "$@" $IMAGE_NAME
|
||||||
sleep $SLEEP_TIME
|
sleep $SLEEP_TIME
|
||||||
}
|
}
|
||||||
|
|
||||||
|
redis_client(){
|
||||||
|
docker exec $CONTAINER_NAME redis-cli "$@"
|
||||||
|
}
|
||||||
|
|
||||||
@test "Auth if no password provided" {
|
@test "Auth if no password provided" {
|
||||||
create_container
|
create_container
|
||||||
run docker exec -it $CONTAINER_NAME redis-cli ping
|
run redis_client ping
|
||||||
[[ "$output" =~ "PONG" ]]
|
[[ "$output" =~ "PONG" ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "Auth if password provided" {
|
@test "Auth if password provided" {
|
||||||
docker run -itd --name $CONTAINER_NAME\
|
create_container -e REDIS_PASSWORD=$REDIS_PASSWORD
|
||||||
-e REDIS_PASSWORD=$REDIS_PASSWORD $IMAGE_NAME
|
|
||||||
# Longs sleep because of bnconfig password update
|
# Longs sleep because of bnconfig password update
|
||||||
sleep 10
|
sleep 10
|
||||||
# Can't connect without passw
|
# Can't connect without passw
|
||||||
run docker exec -it $CONTAINER_NAME redis-cli ping
|
run redis_client ping
|
||||||
[[ "$output" =~ "NOAUTH Authentication required" ]]
|
[[ "$output" =~ "NOAUTH Authentication required" ]]
|
||||||
run docker exec -it $CONTAINER_NAME redis-cli -a $REDIS_PASSWORD ping
|
run redis_client -a $REDIS_PASSWORD ping
|
||||||
[[ "$output" =~ "PONG" ]]
|
[[ "$output" =~ "PONG" ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "All the volumes exposed" {
|
@test "All the volumes exposed" {
|
||||||
create_container
|
create_container
|
||||||
docker inspect $CONTAINER_NAME | {
|
run docker inspect $CONTAINER_NAME
|
||||||
run grep "\"Volumes\":" -A 3
|
[[ "$output" =~ "$VOL_PREFIX/logs" ]]
|
||||||
[[ "$output" =~ "$VOL_PREFIX/logs" ]]
|
[[ "$output" =~ "$VOL_PREFIX/conf" ]]
|
||||||
[[ "$output" =~ "$VOL_PREFIX/conf" ]]
|
[[ "$output" =~ "$VOL_PREFIX/data" ]]
|
||||||
[[ "$output" =~ "$VOL_PREFIX/data" ]]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user