mirror of
https://github.com/bitnami/containers.git
synced 2026-02-24 15:17:27 +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
|
||||
|
||||
CONTAINER_NAME=redis
|
||||
CONTAINER_NAME=bitnami-redis-test
|
||||
IMAGE_NAME=bitnami/redis
|
||||
SLEEP_TIME=3
|
||||
VOL_PREFIX=/bitnami/$CONTAINER_NAME
|
||||
HOST_VOL_PREFIX=/tmp/bitnami/$CONTAINER_NAME
|
||||
VOL_PREFIX=/bitnami/redis
|
||||
REDIS_PASSWORD=test_password123
|
||||
|
||||
# Check config override from host
|
||||
setup() {
|
||||
mkdir -p $HOST_VOL_PREFIX
|
||||
}
|
||||
|
||||
teardown() {
|
||||
cleanup_running_containers() {
|
||||
if [ "$(docker ps -a | grep $CONTAINER_NAME)" ]; then
|
||||
docker rm -fv $CONTAINER_NAME
|
||||
fi
|
||||
}
|
||||
|
||||
setup() {
|
||||
cleanup_running_containers
|
||||
}
|
||||
|
||||
teardown() {
|
||||
cleanup_running_containers
|
||||
}
|
||||
|
||||
create_container(){
|
||||
docker run -itd --name $CONTAINER_NAME $IMAGE_NAME
|
||||
docker run -d --name $CONTAINER_NAME "$@" $IMAGE_NAME
|
||||
sleep $SLEEP_TIME
|
||||
}
|
||||
|
||||
redis_client(){
|
||||
docker exec $CONTAINER_NAME redis-cli "$@"
|
||||
}
|
||||
|
||||
@test "Auth if no password provided" {
|
||||
create_container
|
||||
run docker exec -it $CONTAINER_NAME redis-cli ping
|
||||
run redis_client ping
|
||||
[[ "$output" =~ "PONG" ]]
|
||||
}
|
||||
|
||||
@test "Auth if password provided" {
|
||||
docker run -itd --name $CONTAINER_NAME\
|
||||
-e REDIS_PASSWORD=$REDIS_PASSWORD $IMAGE_NAME
|
||||
create_container -e REDIS_PASSWORD=$REDIS_PASSWORD
|
||||
# Longs sleep because of bnconfig password update
|
||||
sleep 10
|
||||
# Can't connect without passw
|
||||
run docker exec -it $CONTAINER_NAME redis-cli ping
|
||||
run redis_client ping
|
||||
[[ "$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" ]]
|
||||
}
|
||||
|
||||
@test "All the volumes exposed" {
|
||||
create_container
|
||||
docker inspect $CONTAINER_NAME | {
|
||||
run grep "\"Volumes\":" -A 3
|
||||
[[ "$output" =~ "$VOL_PREFIX/logs" ]]
|
||||
[[ "$output" =~ "$VOL_PREFIX/conf" ]]
|
||||
[[ "$output" =~ "$VOL_PREFIX/data" ]]
|
||||
}
|
||||
run docker inspect $CONTAINER_NAME
|
||||
[[ "$output" =~ "$VOL_PREFIX/logs" ]]
|
||||
[[ "$output" =~ "$VOL_PREFIX/conf" ]]
|
||||
[[ "$output" =~ "$VOL_PREFIX/data" ]]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user