github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/deploy/test-in-docker/test.sh (about) 1 #!/bin/bash 2 3 S_PATH=$(cd "$(dirname "$0")"; pwd -P) 4 AISTORE_PATH=$(cd "$S_PATH/../../.."; pwd -P) 5 CONTAINER_NAME=docker_test 6 CLD_PROVIDER=0 7 RUN_FLAGS="" 8 GIT_COMMIT="" 9 10 for i in "$@"; do 11 case ${i} in 12 --name=*) 13 CONTAINER_NAME="${i#*=}" 14 # container name is supposed to be the same as the name of git branch 15 GIT_COMMIT="[$CONTAINER_NAME] "$(git log -n 1 ${CONTAINER_NAME} --format="%s #%h") 16 shift # past argument=value 17 ;; 18 19 --aws=*) 20 ENV_DIR="${i#*=}" 21 ENV_DIR="${ENV_DIR/#\~/$HOME}" 22 if [[ ! -d ${ENV_DIR} ]]; then 23 echo "${ENV_DIR} is not directory" 24 exit 1 25 fi 26 27 TMP_FILE=${ENV_DIR}/.aws.env 28 cat ${ENV_DIR}/credentials > ${TMP_FILE} 29 cat ${ENV_DIR}/config >> ${TMP_FILE} 30 31 sed -i 's/\[default\]//g' ${TMP_FILE} 32 sed -i 's/ = /=/g' ${TMP_FILE} 33 sed -i 's/aws_access_key_id/AWS_ACCESS_KEY_ID/g' ${TMP_FILE} 34 sed -i 's/aws_secret_access_key/AWS_SECRET_ACCESS_KEY/g' ${TMP_FILE} 35 sed -i 's/region/AWS_REGION/g' ${TMP_FILE} 36 37 RUN_FLAGS="${RUN_FLAGS} --env-file ${TMP_FILE}" 38 CLD_PROVIDER=1 39 40 shift # past argument=value 41 ;; 42 43 -g|--gcp) 44 CLD_PROVIDER=2 45 shift # past argument 46 ;; 47 48 *) 49 echo "Invalid usage" 50 exit 1 51 esac 52 done 53 54 if [ "$(docker ps -q -f name=${CONTAINER_NAME}$)" ]; then 55 echo "Container with ${CONTAINER_NAME} name already exists/running" 56 exit 1 57 fi 58 59 function cleanup { 60 rm -f ${AISTORE_PATH}/.dockerignore 61 } 62 trap cleanup EXIT INT TERM 63 64 set -e # don't allow errors in build and volume creation 65 echo ".git" > ${AISTORE_PATH}/.dockerignore 66 docker volume create ${CONTAINER_NAME} # mount filesystem for docker so AIS can see that 67 docker build -t test-docker -f ${S_PATH}/Dockerfile ${AISTORE_PATH} \ 68 --build-arg cld_provider=${CLD_PROVIDER} 69 cleanup 70 set +e # now we can allow fails 71 72 docker run -it ${RUN_FLAGS} \ 73 -v ${CONTAINER_NAME}:/tmp \ 74 --ulimit nofile=100000:100000 \ 75 --name=${CONTAINER_NAME} \ 76 --privileged \ 77 test-docker # image 78 79 echo -e "\n${GIT_COMMIT}" 80 if [ $? -ne 0 ]; then 81 echo -e "\nSome tests did not pass :(" 82 else 83 echo -e "\nALL TESTS PASSED!" 84 fi 85 86 # Removing container and volume 87 docker rm -f ${CONTAINER_NAME} > /dev/null 2>&1 88 docker volume rm ${CONTAINER_NAME} > /dev/null 2>&1