From b362ba3a609a72992c3af6e77198ea29ec778428 Mon Sep 17 00:00:00 2001 From: Olivier ORAND Date: Wed, 2 Oct 2024 12:39:38 +0000 Subject: [PATCH] fixup!test: rework to share principles with redis sample - fix --- local.env | 3 +++ run-tests.sh | 4 ++-- setup-prerequisite.sh | 5 +++-- start-cnd-app-locally.sh | 3 +++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/local.env b/local.env index 00a0c77..e7afab7 100644 --- a/local.env +++ b/local.env @@ -1,3 +1,4 @@ +echo "Sourcing local env properties" export CNB_IMAGE_NAME=mongodb-cnb-app export SERVICE_NAME=mongodb export SERVICE_HEALTH_CMD=mongo @@ -6,4 +7,6 @@ export DATABASE_NAME=myCollection export SERVICE_IMAGE="mongo:7.0.14" export SERVICE_HOST="dynamically_generated" export SERVICE_PASSWORD=my-passwwwwwwwword15; +export SERVICE_USERNAME='22032e25-4aba-417f-a394-8bbd78d920cd' +export SERVICE_PASSWORD='StbQ4EovUpwQjD0cT1Hr7PKBG' #export DEBUG=0 \ No newline at end of file diff --git a/run-tests.sh b/run-tests.sh index be9f535..6326936 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -60,13 +60,13 @@ function check_service() { export APP="http://127.0.0.1:8080" set +e exit_status=0 -create_service_output="$(check_service "Create" "curl -sSLf -X POST $APP/myCollection -H 'Content-Length: 0' )" +create_service_output="$(check_service "Create" "curl -sSLf -X POST $APP/myCollection -d bar")" create_service=$? #get_service_output="$(check_service "Get" "curl -sSLf -X GET $APP/foo" )" #get_service=$? -delete_service_output="$(check_service "Delete" "curl -sSLf DELETE $APP/myCollection" )" +delete_service_output="$(check_service "Delete" "curl -sSLf DELETE $APP/myCollection")" delete_service=$? set -e diff --git a/setup-prerequisite.sh b/setup-prerequisite.sh index 9a2b3df..56693ed 100755 --- a/setup-prerequisite.sh +++ b/setup-prerequisite.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash set -e +echo "Processing $0" -service_container_id=$(docker run -d -p $SERVICE_PORT:$SERVICE_PORT \ +service_container_id=$(docker run -d --rm -p $SERVICE_PORT:$SERVICE_PORT \ -e MONGO_INITDB_ROOT_USERNAME="$SERVICE_USERNAME" \ -e MONGO_INITDB_ROOT_PASSWORD="$SERVICE_PASSWORD" \ -e MONGO_INITDB_DATABASE="$DATABASE_NAME" \ @@ -13,5 +14,5 @@ service_container_name="$(docker ps -f "ancestor=$SERVICE_IMAGE" --format "{{.Na SERVICE_CONTAINER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$service_container_name") echo "$SERVICE_CONTAINER_IP: $SERVICE_CONTAINER_IP" export SERVICE_HOST=$SERVICE_CONTAINER_IP -docker exec -i "$service_container_name" 'if mongosh --version;then echo "mongosh available";else echo "mongosh UNAVAILABLE";fi' +echo "Mongosh version: $(docker exec -i $service_container_name mongosh --version)" echo "SERVICE_HOST: $SERVICE_HOST" diff --git a/start-cnd-app-locally.sh b/start-cnd-app-locally.sh index d5cb470..781f760 100755 --- a/start-cnd-app-locally.sh +++ b/start-cnd-app-locally.sh @@ -1,8 +1,11 @@ #!/usr/bin/env bash set -e +echo "Cleanup existing services" for c in cnb-app-container mongodb-service;do + echo "Stopping $c" if docker container stop $c;then + echo "Removing $c" docker container rm -f $c fi done