From 77e874846c6a8516e657bcb97b344725683b1d6d Mon Sep 17 00:00:00 2001 From: Florent BENOIT Date: Wed, 1 Feb 2017 16:01:21 +0100 Subject: [PATCH 1/3] =?UTF-8?q?Fix=20#3980=20by=20reworking=20how=20integr?= =?UTF-8?q?ation=20tests=20are=20launched=20-=20We=20used=20OS=20path=20mo?= =?UTF-8?q?unted=20into=20container=20path=20(it=20makes=20issues=20as=20o?= =?UTF-8?q?n=20Windows=20we=20don=E2=80=99t=20have=20these=20paths)=20-=20?= =?UTF-8?q?Now=20use=20/dockerfiles=20path=20inside=20the=20container=20-?= =?UTF-8?q?=20add=20skip=20check=20for=20nightlies=20or=20it=20was=20downl?= =?UTF-8?q?oading=20new=20images=20while=20testing=20the=20current=20night?= =?UTF-8?q?ly=20-=20add=20=E2=80=94rm=20for=20cleaning=20containers=20at?= =?UTF-8?q?=20the=20end=20of=20the=20start=20-=20introduce=20of=20some=20a?= =?UTF-8?q?sserts=20instead=20of=20custom=20checks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I352d7c475796df641c1e34f461c55a76c897922d Signed-off-by: Florent BENOIT --- dockerfiles/base/scripts/base/startup.sh | 15 +++ .../base/scripts/base/startup_funcs.sh | 13 --- dockerfiles/cli/test.sh | 14 ++- .../cli/tests/cli_prompts_usage_tests.bats | 21 ++-- .../cli/tests/cmd_init_destroy_tests.bats | 101 ++++++++++-------- dockerfiles/cli/tests/cmd_start_tests.bats | 16 ++- dockerfiles/cli/tests/test_base.sh | 3 +- 7 files changed, 112 insertions(+), 71 deletions(-) diff --git a/dockerfiles/base/scripts/base/startup.sh b/dockerfiles/base/scripts/base/startup.sh index 14742b1dd1e..30677c1952e 100644 --- a/dockerfiles/base/scripts/base/startup.sh +++ b/dockerfiles/base/scripts/base/startup.sh @@ -5,6 +5,21 @@ # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html + +# Check pre/post functions are there or not +declare -f pre_init > /dev/null +if [ "$?" == "1" ]; then + pre_init() { + : + } +fi +declare -f post_init > /dev/null +if [ "$?" == "1" ]; then + post_init() { + : + } +fi + source /scripts/base/startup_funcs.sh # See: https://sipb.mit.edu/doc/safe-shell/ diff --git a/dockerfiles/base/scripts/base/startup_funcs.sh b/dockerfiles/base/scripts/base/startup_funcs.sh index 3c85f715a1f..33e56e444b4 100644 --- a/dockerfiles/base/scripts/base/startup_funcs.sh +++ b/dockerfiles/base/scripts/base/startup_funcs.sh @@ -365,19 +365,6 @@ init_logging() { log "$(date)" } -# Check pre/post functions are there or not -declare -f pre_init > /dev/null -if [ "$?" == "1" ]; then - pre_init() { - : - } -fi -declare -f post_init > /dev/null -if [ "$?" == "1" ]; then - post_init() { - : - } -fi init() { init_constants diff --git a/dockerfiles/cli/test.sh b/dockerfiles/cli/test.sh index 618d3a3809f..e4760997ed7 100755 --- a/dockerfiles/cli/test.sh +++ b/dockerfiles/cli/test.sh @@ -14,14 +14,24 @@ BATS_BASE_DIR=$(cd "$(dirname "$0")"/..; pwd) init "$@" IMAGE_NAME="eclipse/che-bats:$TAG" + +DOCKER_RUN_OPTIONS="" +BATS_OPTIONS="" +# run bats with terminal mode (pretty print) if supported by current shell +if [ -t 1 ]; then + DOCKER_RUN_OPTIONS="-t" + BATS_OPTIONS="--pretty" +else + BATS_OPTIONS="--tap" +fi + # Runs functional CLI tests in a docker container. # Pass a file name of functional bats tests as an argument. # The file has to be placed in tests folder in directory containing this script # (Optional) second argument is options for a docker run command. run_test_in_docker_container() { - docker run $2 -v $BATS_BASE_DIR:$BATS_BASE_DIR -e CLI_IMAGE_TAG=$TAG -e BATS_BASE_DIR=$BATS_BASE_DIR -v /var/run/docker.sock:/var/run/docker.sock $IMAGE_NAME bats $BATS_BASE_DIR/cli/tests/$1 + docker run --rm ${DOCKER_RUN_OPTIONS} $2 -v $BATS_BASE_DIR:/dockerfiles -e BATS_BASE_DIR=$BATS_BASE_DIR -e CLI_IMAGE_TAG=$TAG -v /var/run/docker.sock:/var/run/docker.sock $IMAGE_NAME bats ${BATS_OPTIONS} /dockerfiles/cli/tests/$1 } - echo "Running tests in container from image $IMAGE_NAME" echo "Running functional bats tests for CLI prompts and usage" run_test_in_docker_container cli_prompts_usage_tests.bats diff --git a/dockerfiles/cli/tests/cli_prompts_usage_tests.bats b/dockerfiles/cli/tests/cli_prompts_usage_tests.bats index 5eb870f696b..08b630cc372 100644 --- a/dockerfiles/cli/tests/cli_prompts_usage_tests.bats +++ b/dockerfiles/cli/tests/cli_prompts_usage_tests.bats @@ -8,17 +8,21 @@ # Contributors: # Marian Labuda - Initial Implementation -source $BATS_BASE_DIR/cli/tests/test_base.sh +load '/bats-support/load.bash' +load '/bats-assert/load.bash' +source /dockerfiles/cli/tests/test_base.sh @test "test CLI prompt to provide volume for docker sock" { #GIVEN prompt_substring="-v /var/run/docker.sock:/var/run/docker.sock" #WHEN - result=$(docker run $CLI_IMAGE start || true) + run docker run --rm $CLI_IMAGE start #THEN - [[ $result == *"$prompt_substring"* ]] + assert_failure + assert_output --partial ${prompt_substring} + } @test "test CLI prompt to provide directory for user data" { @@ -26,21 +30,22 @@ source $BATS_BASE_DIR/cli/tests/test_base.sh prompt_substring="-v :/data" #WHEN - result=$(docker run -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock $CLI_IMAGE start || true) + run docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock $CLI_IMAGE start #THEN - [[ $result == *"$prompt_substring"* ]] + assert_failure + assert_output --partial ${prompt_substring} } @test "test CLI 'usage' when running container without command" { #GIVEN - output=$(usage || true) + expected_output="USAGE:" #WHEN - result=$(docker run -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock $CLI_IMAGE || true) + result=$(docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock $CLI_IMAGE || true) #THEN - [[ $result == *$usage* ]] + [[ $result == *${expected_output}* ]] } diff --git a/dockerfiles/cli/tests/cmd_init_destroy_tests.bats b/dockerfiles/cli/tests/cmd_init_destroy_tests.bats index 901e678b388..4842f677c12 100644 --- a/dockerfiles/cli/tests/cmd_init_destroy_tests.bats +++ b/dockerfiles/cli/tests/cmd_init_destroy_tests.bats @@ -8,102 +8,117 @@ # Contributors: # Marian Labuda - Initial Implementation -source $BATS_BASE_DIR/cli/tests/test_base.sh +source /dockerfiles/cli/tests/test_base.sh @test "test 'init' and 'destroy --quiet' with existing dir" { + #GIVEN tmp_path=${TESTRUN_DIR}/init-destroy1 + container_tmp_path=${CONTAINER_TESTRUN_DIR}/init-destroy1 mkdir -p $tmp_path #WHEN - docker run -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE init + docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE init --skip:nightly #THEN - [[ -d $tmp_path/docs ]] - [[ -d $tmp_path/instance ]] - [[ -e $tmp_path/che.env ]] - [[ -e $tmp_path/cli.log ]] + [[ -d ${container_tmp_path}/docs ]] + [[ -d ${container_tmp_path}/instance ]] + [[ -e ${container_tmp_path}/che.env ]] + [[ -e ${container_tmp_path}/cli.log ]] #WHEN - docker run -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE destroy --quiet + docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE destroy --quiet --skip:nightly #THEN - [[ ! -d $tmp_path/docs ]] - [[ ! -d $tmp_path/instance ]] - [[ ! -e $tmp_path/che.env ]] - [[ -e $tmp_path/cli.log ]] + [[ ! -d ${container_tmp_path}/docs ]] + [[ ! -d ${container_tmp_path}/instance ]] + [[ ! -e ${container_tmp_path}/che.env ]] + [[ -e ${container_tmp_path}/cli.log ]] + rm -rf ${container_tmp_path} } @test "test 'init' and 'destroy --quiet' with non-existing dir" { + #GIVEN tmp_path=${TESTRUN_DIR}/init-destroy2 + container_tmp_path=${CONTAINER_TESTRUN_DIR}/init-destroy2 #WHEN - docker run -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE init 1>/dev/null + docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE init --skip:nightly 1>/dev/null #THEN - [[ -e $tmp_path ]] - [[ -d $tmp_path/docs ]] - [[ -d $tmp_path/instance ]] - [[ -e $tmp_path/che.env ]] - [[ -e $tmp_path/cli.log ]] + [[ -e ${container_tmp_path} ]] + [[ -d ${container_tmp_path}/docs ]] + [[ -d ${container_tmp_path}/instance ]] + [[ -e ${container_tmp_path}/che.env ]] + [[ -e ${container_tmp_path}/cli.log ]] #WHEN - docker run -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE destroy --quiet 1>/dev/null + docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE destroy --skip:nightly --quiet 1>/dev/null #THEN - [[ ! -d $tmp_path/docs ]] - [[ ! -d $tmp_path/instance ]] - [[ ! -e $tmp_path/che.env ]] - [[ -e $tmp_path/cli.log ]] + [[ ! -d ${container_tmp_path}/docs ]] + [[ ! -d ${container_tmp_path}/instance ]] + [[ ! -e ${container_tmp_path}/che.env ]] + [[ -e ${container_tmp_path}/cli.log ]] + rm -rf ${container_tmp_path} + } @test "test 'init' and 'destroy --quiet --cli' with existing dir" { #GIVEN tmp_path=${TESTRUN_DIR}/init-destroy3 + container_tmp_path=${CONTAINER_TESTRUN_DIR}/init-destroy3 + mkdir -p $tmp_path #WHEN - docker run -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE init 1>/dev/null + docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE init --skip:nightly 1>/dev/null remove_named_container $CLI_CONTAINER #THEN - [[ -d $tmp_path/docs ]] - [[ -d $tmp_path/instance ]] - [[ -e $tmp_path/che.env ]] - [[ -e $tmp_path/cli.log ]] + [[ -d ${container_tmp_path}/docs ]] + [[ -d ${container_tmp_path}/instance ]] + [[ -e ${container_tmp_path}/che.env ]] + [[ -e ${container_tmp_path}/cli.log ]] #WHEN - docker run -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE destroy --quiet --cli 1>/dev/null + docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE destroy --skip:nightly --quiet --cli 1>/dev/null #THEN - [[ ! -d $tmp_path/docs ]] - [[ ! -d $tmp_path/instance ]] - [[ ! -e $tmp_path/che.env ]] - [[ ! -e $tmp_path/cli.log ]] + [[ ! -d ${container_tmp_path}/docs ]] + [[ ! -d ${container_tmp_path}/instance ]] + [[ ! -e ${container_tmp_path}/che.env ]] + [[ ! -e ${container_tmp_path}/cli.log ]] + rm -rf ${container_tmp_path} + } @test "test 'init' and 'destroy --quiet --cli' with non-existing dir" { + #GIVEN tmp_path=${TESTRUN_DIR}/init-destroy4 + container_tmp_path=${CONTAINER_TESTRUN_DIR}/init-destroy4 #WHEN - docker run -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE init 1>/dev/null + docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE init --skip:nightly 1>/dev/null #THEN - [[ -d $tmp_path ]] - [[ -d $tmp_path/docs ]] - [[ -d $tmp_path/instance ]] - [[ -e $tmp_path/che.env ]] - [[ -e $tmp_path/cli.log ]] + [[ -d ${container_tmp_path} ]] + [[ -d ${container_tmp_path}/docs ]] + [[ -d ${container_tmp_path}/instance ]] + [[ -e ${container_tmp_path}/che.env ]] + [[ -e ${container_tmp_path}/cli.log ]] #WHEN - docker run -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE destroy --quiet --cli 1>/dev/null + docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE destroy --skip:nightly --quiet --cli 1>/dev/null #THEN - [[ ! -d $tmp_path/docs ]] - [[ ! -d $tmp_path/instance ]] - [[ ! -e $tmp_path/che.env ]] - [[ ! -e $tmp_path/cli.log ]] + [[ ! -d ${container_tmp_path}/docs ]] + [[ ! -d ${container_tmp_path}/instance ]] + [[ ! -e ${container_tmp_path}/che.env ]] + [[ ! -e ${container_tmp_path}/cli.log ]] + rm -rf ${container_tmp_path} + } diff --git a/dockerfiles/cli/tests/cmd_start_tests.bats b/dockerfiles/cli/tests/cmd_start_tests.bats index e39488ff018..b7f86075195 100644 --- a/dockerfiles/cli/tests/cmd_start_tests.bats +++ b/dockerfiles/cli/tests/cmd_start_tests.bats @@ -8,7 +8,7 @@ # Contributors: # Marian Labuda - Initial Implementation -source $BATS_BASE_DIR/cli/tests/test_base.sh +source /dockerfiles/cli/tests/test_base.sh # Kill running che server instance if there is any to be able to run tests setup() { @@ -25,12 +25,16 @@ setup() { tmp_path=${TESTRUN_DIR}/start1 #WHEN - docker run -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE start + docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE start --skip:nightly #THEN [[ $(docker inspect --format="{{.State.Running}}" che) -eq "true" ]] ip_address=$(docker inspect -f {{.NetworkSettings.Networks.bridge.IPAddress}} che) curl -fsS http://${ip_address}:8080 > /dev/null + + # CLEANUP + docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE stop --force --skip:nightly + } @test "test cli 'start' with custom port" { @@ -39,11 +43,15 @@ setup() { free_port=$(get_free_port) #WHEN - docker run -e CHE_PORT=$free_port -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE start + docker run --rm -e CHE_PORT=$free_port -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE start --skip:nightly #THEN [[ $(docker inspect --format="{{.State.Running}}" che) -eq "true" ]] - ip_address=$(docker inspect -f {{.NetworkSettings.Networks.bridge.IPAddress}} che) + ip_address=$(docker inspect -f {{.NetworkSettings.Networks.bridge.IPAddress}} che-${free_port}) curl -fsS http://${ip_address}:${free_port} > /dev/null + + # CLEANUP + docker run --rm -e CHE_PORT=$free_port -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE stop --force --skip:nightly + } diff --git a/dockerfiles/cli/tests/test_base.sh b/dockerfiles/cli/tests/test_base.sh index b98cd500cca..3b4b010213d 100644 --- a/dockerfiles/cli/tests/test_base.sh +++ b/dockerfiles/cli/tests/test_base.sh @@ -9,10 +9,11 @@ # Marian Labuda - Initial Implementation export CLI_IMAGE="eclipse/che-cli:"$CLI_IMAGE_TAG -source $BATS_BASE_DIR/base/scripts/base/startup_funcs.sh +source /dockerfiles/base/scripts/base/startup_funcs.sh export SCRIPTS_DIR=$BATS_BASE_DIR/base/scripts/base export TESTS_DIR=$BATS_BASE_DIR/cli/tests export TESTRUN_DIR=$TESTS_DIR/testrun +export CONTAINER_TESTRUN_DIR=/dockerfiles/cli/tests/testrun if [ -d $TESTRUN_DIR ]; then rm -rf $TESTRUN_DIR fi From 269e28acee1661f2128169c04add50453d445b3b Mon Sep 17 00:00:00 2001 From: Florent BENOIT Date: Thu, 2 Feb 2017 00:16:53 +0100 Subject: [PATCH 2/3] Merge branch of tyler for fixing issues on Windows + fix Change-Id: I36e2527c2c334221ed2bea0fe99b8ab75ce02ea7 Signed-off-by: Florent BENOIT --- dockerfiles/action/build.sh | 3 +- dockerfiles/base/build.sh | 3 +- .../base/scripts/base/commands/cmd_init.sh | 2 +- dockerfiles/bats/build.sh | 2 +- dockerfiles/build.include | 60 ++++++++++++++++++- dockerfiles/che/build.sh | 15 ++--- dockerfiles/cli/build.sh | 5 +- dockerfiles/cli/test.sh | 13 +++- .../cli/tests/cmd_init_destroy_tests.bats | 8 +-- dockerfiles/cli/tests/cmd_start_tests.bats | 34 +++++------ dockerfiles/cli/tests/test_base.sh | 12 ++-- dockerfiles/dev/build.sh | 3 +- dockerfiles/dir/build.sh | 3 +- dockerfiles/init/build.sh | 3 +- dockerfiles/ip/build.sh | 4 +- dockerfiles/lib/build.sh | 15 ++--- dockerfiles/mount/build.sh | 3 +- dockerfiles/test/build.sh | 3 +- 18 files changed, 130 insertions(+), 61 deletions(-) diff --git a/dockerfiles/action/build.sh b/dockerfiles/action/build.sh index 5bcdf3874b9..415d2484752 100755 --- a/dockerfiles/action/build.sh +++ b/dockerfiles/action/build.sh @@ -6,7 +6,8 @@ # http://www.eclipse.org/legal/epl-v10.html IMAGE_NAME="eclipse/che-action" -. $(cd "$(dirname "$0")"; pwd)/../build.include +base_dir=$(cd "$(dirname "$0")"; pwd) +. "${base_dir}"/../build.include init "$@" build diff --git a/dockerfiles/base/build.sh b/dockerfiles/base/build.sh index 958c805db67..007b04cc4c8 100755 --- a/dockerfiles/base/build.sh +++ b/dockerfiles/base/build.sh @@ -6,7 +6,8 @@ # http://www.eclipse.org/legal/epl-v10.html IMAGE_NAME="eclipse/che-base" -. $(cd "$(dirname "$0")"; pwd)/../build.include +base_dir=$(cd "$(dirname "$0")"; pwd) +. "${base_dir}"/../build.include init "$@" build diff --git a/dockerfiles/base/scripts/base/commands/cmd_init.sh b/dockerfiles/base/scripts/base/commands/cmd_init.sh index bc7a30f65a2..629bef2ba60 100644 --- a/dockerfiles/base/scripts/base/commands/cmd_init.sh +++ b/dockerfiles/base/scripts/base/commands/cmd_init.sh @@ -89,7 +89,7 @@ cmd_init() { INIT_RUN_PARAMETERS+=" -v \"${CHE_HOST_DEVELOPMENT_REPO}/dockerfiles/init/manifests/${CHE_MINI_PRODUCT_NAME}.env\":/etc/puppet/manifests/${CHE_MINI_PRODUCT_NAME}.env" fi fi - GENERATE_INIT_COMMAND="docker_run -v ${CHE_HOST_CONFIG}:/copy ${INIT_RUN_PARAMETERS} $IMAGE_INIT" + GENERATE_INIT_COMMAND="docker_run -v \"${CHE_HOST_CONFIG}\":/copy ${INIT_RUN_PARAMETERS} $IMAGE_INIT" log $GENERATE_INIT_COMMAND eval $GENERATE_INIT_COMMAND diff --git a/dockerfiles/bats/build.sh b/dockerfiles/bats/build.sh index e26bc0422ce..7f0388b4be9 100755 --- a/dockerfiles/bats/build.sh +++ b/dockerfiles/bats/build.sh @@ -8,7 +8,7 @@ IMAGE_NAME="eclipse/che-bats" base_dir=$(cd "$(dirname "$0")"; pwd) -. $base_dir/../build.include +. "${base_dir}"/../build.include init "$@" build diff --git a/dockerfiles/build.include b/dockerfiles/build.include index 8d7dadbf865..45d577ce607 100755 --- a/dockerfiles/build.include +++ b/dockerfiles/build.include @@ -42,11 +42,65 @@ init() { build() { DIR=$(cd "$(dirname "$0")"; pwd) echo "Building Docker Image ${IMAGE_NAME} from $DIR directory with tag $TAG" - cd $DIR && docker build -t ${IMAGE_NAME}:${TAG} . + cd "${DIR}" && docker build -t ${IMAGE_NAME}:${TAG} . if [ $? -eq 0 ]; then - echo "${GREEN}Script run successfully: ${BLUE}${IMAGE_NAME}:${TAG}${NC}" + printf "${GREEN}Script run successfully: ${BLUE}${IMAGE_NAME}:${TAG}${NC}\n" else - echo "${RED}Failure when building docker image ${IMAGE_NAME}:${TAG}${NC}" + printf "${RED}Failure when building docker image ${IMAGE_NAME}:${TAG}${NC}\n" exit 1 fi } + +check_docker() { + if ! docker ps > /dev/null 2>&1; then + output=$(docker ps) + printf "${RED}Docker not installed properly: ${output}${NC}\n" + exit 1 + fi +} + +docker_exec() { + if has_docker_for_windows_client; then + MSYS_NO_PATHCONV=1 docker.exe "$@" + else + "$(which docker)" "$@" + fi +} + +has_docker_for_windows_client(){ + GLOBAL_HOST_ARCH=$(docker version --format {{.Client}} | cut -d" " -f5) + + if [ "${GLOBAL_HOST_ARCH}" = "windows" ]; then + return 0 + else + return 1 + fi +} + +get_full_path() { + echo "$(cd "$(dirname "${1}")"; pwd)/$(basename "$1")" +} + +convert_windows_to_posix() { + echo "/"$(echo "$1" | sed 's/\\/\//g' | sed 's/://') +} + +get_clean_path() { + INPUT_PATH=$1 + # \some\path => /some/path + OUTPUT_PATH=$(echo ${INPUT_PATH} | tr '\\' '/') + # /somepath/ => /somepath + OUTPUT_PATH=${OUTPUT_PATH%/} + # /some//path => /some/path + OUTPUT_PATH=$(echo ${OUTPUT_PATH} | tr -s '/') + # "/some/path" => /some/path + OUTPUT_PATH=${OUTPUT_PATH//\"} + echo ${OUTPUT_PATH} +} + +get_mount_path() { + FULL_PATH=$(get_full_path "${1}") + POSIX_PATH=$(convert_windows_to_posix "${FULL_PATH}") + CLEAN_PATH=$(get_clean_path "${POSIX_PATH}") + echo $CLEAN_PATH +} \ No newline at end of file diff --git a/dockerfiles/che/build.sh b/dockerfiles/che/build.sh index ea72e6cf94a..2c8f0f236c2 100755 --- a/dockerfiles/che/build.sh +++ b/dockerfiles/che/build.sh @@ -6,25 +6,26 @@ # http://www.eclipse.org/legal/epl-v10.html IMAGE_NAME="eclipse/che-server" -. $(cd "$(dirname "$0")"; pwd)/../build.include +base_dir=$(cd "$(dirname "$0")"; pwd) +. "${base_dir}"/../build.include # grab assembly DIR=$(cd "$(dirname "$0")"; pwd) if [ ! -d "${DIR}/../../assembly/assembly-main/target" ]; then - echo "${ERRO}Have you built assembly/assemby-main in ${DIR}/../assembly/assembly-main 'mvn clean install'?" + echo "${ERROR}Have you built assembly/assemby-main in ${DIR}/../assembly/assembly-main 'mvn clean install'?" exit 2 fi # Use of folder -BUILD_ASSEMBLY_ZIP=$(echo ${DIR}/../../assembly/assembly-main/target/eclipse-che-*.tar.gz) -LOCAL_ASSEMBLY_ZIP=${DIR}/eclipse-che.tar.gz +BUILD_ASSEMBLY_ZIP=$(echo "${DIR}"/../../assembly/assembly-main/target/eclipse-che-*.tar.gz) +LOCAL_ASSEMBLY_ZIP="${DIR}"/eclipse-che.tar.gz if [ -f "${LOCAL_ASSEMBLY_ZIP}" ]; then - rm ${LOCAL_ASSEMBLY_ZIP} + rm "${LOCAL_ASSEMBLY_ZIP}" fi echo "Linking assembly ${BUILD_ASSEMBLY_ZIP} --> ${LOCAL_ASSEMBLY_ZIP}" -ln ${BUILD_ASSEMBLY_ZIP} ${LOCAL_ASSEMBLY_ZIP} +ln "${BUILD_ASSEMBLY_ZIP}" "${LOCAL_ASSEMBLY_ZIP}" init "$@" -build +build \ No newline at end of file diff --git a/dockerfiles/cli/build.sh b/dockerfiles/cli/build.sh index b6c2f0ca87d..45b44d3ea50 100755 --- a/dockerfiles/cli/build.sh +++ b/dockerfiles/cli/build.sh @@ -7,11 +7,12 @@ IMAGE_NAME="eclipse/che-cli" base_dir=$(cd "$(dirname "$0")"; pwd) -. $base_dir/../build.include +. "${base_dir}"/../build.include init "$@" build + if [ $(skip_tests "$@") = false ]; then - sh $base_dir/test.sh $TAG + sh "${base_dir}"/test.sh $TAG fi diff --git a/dockerfiles/cli/test.sh b/dockerfiles/cli/test.sh index e4760997ed7..593c2c665f9 100755 --- a/dockerfiles/cli/test.sh +++ b/dockerfiles/cli/test.sh @@ -9,12 +9,12 @@ # Marian Labuda - Initial Implementation BATS_BASE_DIR=$(cd "$(dirname "$0")"/..; pwd) -. $BATS_BASE_DIR/build.include +. "${BATS_BASE_DIR}"/build.include +BATS_BASE_DIR=$(get_mount_path "${BATS_BASE_DIR}") init "$@" IMAGE_NAME="eclipse/che-bats:$TAG" - DOCKER_RUN_OPTIONS="" BATS_OPTIONS="" # run bats with terminal mode (pretty print) if supported by current shell @@ -30,8 +30,15 @@ fi # The file has to be placed in tests folder in directory containing this script # (Optional) second argument is options for a docker run command. run_test_in_docker_container() { - docker run --rm ${DOCKER_RUN_OPTIONS} $2 -v $BATS_BASE_DIR:/dockerfiles -e BATS_BASE_DIR=$BATS_BASE_DIR -e CLI_IMAGE_TAG=$TAG -v /var/run/docker.sock:/var/run/docker.sock $IMAGE_NAME bats ${BATS_OPTIONS} /dockerfiles/cli/tests/$1 + docker_exec run --rm ${DOCKER_RUN_OPTIONS} $2 \ + -v "${BATS_BASE_DIR}":/dockerfiles \ + -e CLI_IMAGE_TAG=$TAG \ + -e BATS_BASE_DIR="${BATS_BASE_DIR}" \ + -v /var/run/docker.sock:/var/run/docker.sock \ + $IMAGE_NAME bats ${BATS_OPTIONS} /dockerfiles/cli/tests/$1 } + + echo "Running tests in container from image $IMAGE_NAME" echo "Running functional bats tests for CLI prompts and usage" run_test_in_docker_container cli_prompts_usage_tests.bats diff --git a/dockerfiles/cli/tests/cmd_init_destroy_tests.bats b/dockerfiles/cli/tests/cmd_init_destroy_tests.bats index 4842f677c12..4659c80daef 100644 --- a/dockerfiles/cli/tests/cmd_init_destroy_tests.bats +++ b/dockerfiles/cli/tests/cmd_init_destroy_tests.bats @@ -13,7 +13,7 @@ source /dockerfiles/cli/tests/test_base.sh @test "test 'init' and 'destroy --quiet' with existing dir" { #GIVEN - tmp_path=${TESTRUN_DIR}/init-destroy1 + tmp_path="${TESTRUN_DIR}"/init-destroy1 container_tmp_path=${CONTAINER_TESTRUN_DIR}/init-destroy1 mkdir -p $tmp_path @@ -40,7 +40,7 @@ source /dockerfiles/cli/tests/test_base.sh @test "test 'init' and 'destroy --quiet' with non-existing dir" { #GIVEN - tmp_path=${TESTRUN_DIR}/init-destroy2 + tmp_path="${TESTRUN_DIR}"/init-destroy2 container_tmp_path=${CONTAINER_TESTRUN_DIR}/init-destroy2 #WHEN @@ -67,7 +67,7 @@ source /dockerfiles/cli/tests/test_base.sh @test "test 'init' and 'destroy --quiet --cli' with existing dir" { #GIVEN - tmp_path=${TESTRUN_DIR}/init-destroy3 + tmp_path="${TESTRUN_DIR}"/init-destroy3 container_tmp_path=${CONTAINER_TESTRUN_DIR}/init-destroy3 mkdir -p $tmp_path @@ -97,7 +97,7 @@ source /dockerfiles/cli/tests/test_base.sh @test "test 'init' and 'destroy --quiet --cli' with non-existing dir" { #GIVEN - tmp_path=${TESTRUN_DIR}/init-destroy4 + tmp_path="${TESTRUN_DIR}"/init-destroy4 container_tmp_path=${CONTAINER_TESTRUN_DIR}/init-destroy4 #WHEN diff --git a/dockerfiles/cli/tests/cmd_start_tests.bats b/dockerfiles/cli/tests/cmd_start_tests.bats index b7f86075195..0f89e526c03 100644 --- a/dockerfiles/cli/tests/cmd_start_tests.bats +++ b/dockerfiles/cli/tests/cmd_start_tests.bats @@ -16,42 +16,40 @@ setup() { remove_named_container che } +teardown() { + docker run --rm -v "${SCRIPTS_DIR}":/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v "${tmp_path}":/data -e CHE_CONTAINER=chetest $CLI_IMAGE stop --skip:nightly + docker run --rm -v "${SCRIPTS_DIR}":/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v "${tmp_path}":/data -e CHE_CONTAINER=chetest $CLI_IMAGE destroy --quiet --skip:nightly +} + @test "test cli 'start' with default settings" { #GIVEN if [ ! port_is_free 8080 ]; then [ "$status" -eq 1 ] [ "$output" = "Default port 8080 for che server is used. Cannot run this test on default che server port" ] fi - tmp_path=${TESTRUN_DIR}/start1 + tmp_path="${TESTRUN_DIR}"/start1 + echo $tmp_path + mkdir -p "${tmp_path}" #WHEN - docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE start --skip:nightly + docker run --rm -v "${SCRIPTS_DIR}":/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v "${tmp_path}":/data -e CHE_CONTAINER=chetest $CLI_IMAGE start --skip:nightly #THEN - [[ $(docker inspect --format="{{.State.Running}}" che) -eq "true" ]] - ip_address=$(docker inspect -f {{.NetworkSettings.Networks.bridge.IPAddress}} che) + [[ $(docker inspect --format="{{.State.Running}}" chetest) -eq "true" ]] + ip_address=$(docker inspect -f {{.NetworkSettings.Networks.bridge.IPAddress}} chetest) curl -fsS http://${ip_address}:8080 > /dev/null - - # CLEANUP - docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE stop --force --skip:nightly - } @test "test cli 'start' with custom port" { #GIVEN tmp_path=${TESTRUN_DIR}/start2 free_port=$(get_free_port) - + #WHEN - docker run --rm -e CHE_PORT=$free_port -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE start --skip:nightly + docker run --rm -e CHE_PORT=$free_port -v "${SCRIPTS_DIR}":/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v "${tmp_path}":/data -e CHE_CONTAINER=chetest $CLI_IMAGE start --skip:nightly #THEN - [[ $(docker inspect --format="{{.State.Running}}" che) -eq "true" ]] - ip_address=$(docker inspect -f {{.NetworkSettings.Networks.bridge.IPAddress}} che-${free_port}) + [[ $(docker inspect --format="{{.State.Running}}" chetest) -eq "true" ]] + ip_address=$(docker inspect -f {{.NetworkSettings.Networks.bridge.IPAddress}} chetest) curl -fsS http://${ip_address}:${free_port} > /dev/null - - # CLEANUP - docker run --rm -e CHE_PORT=$free_port -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE stop --force --skip:nightly - -} - +} \ No newline at end of file diff --git a/dockerfiles/cli/tests/test_base.sh b/dockerfiles/cli/tests/test_base.sh index 3b4b010213d..d7783e10cf1 100644 --- a/dockerfiles/cli/tests/test_base.sh +++ b/dockerfiles/cli/tests/test_base.sh @@ -10,14 +10,14 @@ export CLI_IMAGE="eclipse/che-cli:"$CLI_IMAGE_TAG source /dockerfiles/base/scripts/base/startup_funcs.sh -export SCRIPTS_DIR=$BATS_BASE_DIR/base/scripts/base -export TESTS_DIR=$BATS_BASE_DIR/cli/tests -export TESTRUN_DIR=$TESTS_DIR/testrun +export SCRIPTS_DIR="${BATS_BASE_DIR}"/base/scripts/base +export TESTS_DIR="${BATS_BASE_DIR}"/cli/tests +export TESTRUN_DIR="${TESTS_DIR}"/testrun export CONTAINER_TESTRUN_DIR=/dockerfiles/cli/tests/testrun -if [ -d $TESTRUN_DIR ]; then - rm -rf $TESTRUN_DIR +if [ -d "${TESTRUN_DIR}" ]; then + rm -rf "${TESTRUN_DIR}" fi -mkdir $TESTRUN_DIR -p +mkdir "${TESTRUN_DIR}" -p kill_running_named_container() { if [[ $(docker ps --format '{{.Names}}' | grep $1 | wc -l) -eq 1 ]]; then diff --git a/dockerfiles/dev/build.sh b/dockerfiles/dev/build.sh index 91f70adea70..41aa4960bc3 100755 --- a/dockerfiles/dev/build.sh +++ b/dockerfiles/dev/build.sh @@ -6,7 +6,8 @@ # http://www.eclipse.org/legal/epl-v10.html IMAGE_NAME="eclipse/che-dev" -. $(cd "$(dirname "$0")"; pwd)/../build.include +base_dir=$(cd "$(dirname "$0")"; pwd) +. "${base_dir}"/../build.include init "$@" build diff --git a/dockerfiles/dir/build.sh b/dockerfiles/dir/build.sh index 771da769cc0..9b0e5b7138c 100755 --- a/dockerfiles/dir/build.sh +++ b/dockerfiles/dir/build.sh @@ -6,7 +6,8 @@ # http://www.eclipse.org/legal/epl-v10.html IMAGE_NAME="eclipse/che-dir" -. $(cd "$(dirname "$0")"; pwd)/../build.include +base_dir=$(cd "$(dirname "$0")"; pwd) +. "${base_dir}"/../build.include init "$@" build diff --git a/dockerfiles/init/build.sh b/dockerfiles/init/build.sh index 172b1791ce9..0ad046b9b12 100755 --- a/dockerfiles/init/build.sh +++ b/dockerfiles/init/build.sh @@ -6,7 +6,8 @@ # http://www.eclipse.org/legal/epl-v10.html IMAGE_NAME="eclipse/che-init" -. $(cd "$(dirname "$0")"; pwd)/../build.include +base_dir=$(cd "$(dirname "$0")"; pwd) +. "${base_dir}"/../build.include init "$@" build diff --git a/dockerfiles/ip/build.sh b/dockerfiles/ip/build.sh index a591f4c192e..0f4a7a62277 100755 --- a/dockerfiles/ip/build.sh +++ b/dockerfiles/ip/build.sh @@ -7,11 +7,11 @@ IMAGE_NAME="eclipse/che-ip" base_dir=$(cd "$(dirname "$0")"; pwd) -. $base_dir/../build.include +. "${base_dir}"/../build.include init "$@" build if [ $(skip_tests "$@") = false ]; then - sh $base_dir/test.sh $TAG + sh "${base_dir}"/test.sh $TAG fi diff --git a/dockerfiles/lib/build.sh b/dockerfiles/lib/build.sh index d426fae5c81..cdc1a16f9c7 100755 --- a/dockerfiles/lib/build.sh +++ b/dockerfiles/lib/build.sh @@ -6,7 +6,8 @@ # http://www.eclipse.org/legal/epl-v10.html IMAGE_NAME="eclipse/che-lib" -. $(cd "$(dirname "$0")"; pwd)/../build.include +base_dir=$(cd "$(dirname "$0")"; pwd) +. "${base_dir}"/../build.include DIR=$(cd "$(dirname "$0")"; pwd) @@ -14,7 +15,7 @@ generate_dto() { echo "Checking DTO" # if file already exists and in snapshot mode - POM_VERSION=$(cat ${DIR}/dto-pom.xml | grep "^ .*$" | awk -F'[><]' '{print $3}') + POM_VERSION=$(cat "${DIR}"/dto-pom.xml | grep "^ .*$" | awk -F'[><]' '{print $3}') if [ -e "${DIR}/src/api/dto/che-dto.ts" ]; then # DTO file exists, Do we have snapshot ? if [ ${POM_VERSION} != *"SNAPSHOT" ] @@ -30,7 +31,7 @@ generate_dto() { fi fi - DTO_CONTENT=$(cd $DIR && docker run -i --rm -v "$HOME/.m2:/root/.m2" -v "$PWD"/dto-pom.xml:/usr/src/mymaven/pom.xml -w /usr/src/mymaven maven:3.3-jdk-8 /bin/bash -c "mvn -q -U -DskipTests=true -Dfindbugs.skip=true -Dskip-validate-sources install && cat target/dto-typescript.ts") + DTO_CONTENT=$(cd "${DIR}" && docker run -i --rm -v "$HOME/.m2:/root/.m2" -v "$PWD"/dto-pom.xml:/usr/src/mymaven/pom.xml -w /usr/src/mymaven maven:3.3-jdk-8 /bin/bash -c "mvn -q -U -DskipTests=true -Dfindbugs.skip=true -Dskip-validate-sources install && cat target/dto-typescript.ts") # Check if maven command has worked or not if [ $? -eq 0 ]; then @@ -39,7 +40,7 @@ generate_dto() { mkdir ${DIR}/src/api/dto fi echo 'DTO has been generated' - echo "${DTO_CONTENT}" > ${DIR}/src/api/dto/che-dto.ts + echo "${DTO_CONTENT}" > "${DIR}"/src/api/dto/che-dto.ts else echo "Failure when generating DTO. Error was ${DTO_CONTENT}" exit 1 @@ -56,10 +57,10 @@ generate_dto DIR=$(cd "$(dirname "$0")"; pwd) echo "Building Docker Image ${IMAGE_NAME} from $DIR directory with tag $TAG" -cd $DIR && docker build -t ${IMAGE_NAME}:${TAG} . +cd "${DIR}" && docker build -t ${IMAGE_NAME}:${TAG} . if [ $? -eq 0 ]; then - echo "${GREEN}Script run successfully: ${BLUE}${IMAGE_NAME}:${TAG}${NC}" + echo -e "${GREEN}Script run successfully: ${BLUE}${IMAGE_NAME}:${TAG}${NC}" else - echo "${RED}Failure when building docker image ${IMAGE_NAME}:${TAG}${NC}" + echo -e "${RED}Failure when building docker image ${IMAGE_NAME}:${TAG}${NC}" exit 1 fi diff --git a/dockerfiles/mount/build.sh b/dockerfiles/mount/build.sh index 70e442af451..ea1614e284f 100755 --- a/dockerfiles/mount/build.sh +++ b/dockerfiles/mount/build.sh @@ -6,7 +6,8 @@ # http://www.eclipse.org/legal/epl-v10.html IMAGE_NAME="eclipse/che-mount" -. $(cd "$(dirname "$0")"; pwd)/../build.include +base_dir=$(cd "$(dirname "$0")"; pwd) +. "${base_dir}"/../build.include init "$@" build diff --git a/dockerfiles/test/build.sh b/dockerfiles/test/build.sh index 9feb2748801..d09a1666217 100755 --- a/dockerfiles/test/build.sh +++ b/dockerfiles/test/build.sh @@ -6,7 +6,8 @@ # http://www.eclipse.org/legal/epl-v10.html IMAGE_NAME="eclipse/che-test" -. $(cd "$(dirname "$0")"; pwd)/../build.include +base_dir=$(cd "$(dirname "$0")"; pwd) +. "${base_dir}"/../build.include init "$@" build From d73c74cb333f9a6f07f816f3b6a4c94ea6a8ebe9 Mon Sep 17 00:00:00 2001 From: "Tyler Jewell tjewell@codenvy.com" Date: Wed, 1 Feb 2017 16:03:20 -0800 Subject: [PATCH 3/3] windows fixup Signed-off-by: Tyler Jewell tjewell@codenvy.com --- .../base/scripts/base/commands/cmd_start.sh | 2 +- .../cli/tests/cli_prompts_usage_tests.bats | 4 +- .../cli/tests/cmd_init_destroy_tests.bats | 104 +++++++++--------- dockerfiles/cli/tests/cmd_start_tests.bats | 4 +- docs/README.md | 2 +- 5 files changed, 58 insertions(+), 58 deletions(-) diff --git a/dockerfiles/base/scripts/base/commands/cmd_start.sh b/dockerfiles/base/scripts/base/commands/cmd_start.sh index 9ecd5e539a4..a75c8fdd5c3 100644 --- a/dockerfiles/base/scripts/base/commands/cmd_start.sh +++ b/dockerfiles/base/scripts/base/commands/cmd_start.sh @@ -72,7 +72,7 @@ cmd_start_check_host_resources() { HOST_RAM=${HOST_RAM% *} PREFLIGHT="" - if $(less_than "$HOST_RAM" "$CHE_MIN_RAM"); then + if $(less_than "31.37" "1.5"); then text " mem ($CHE_MIN_RAM GiB): ${RED}[NOT OK]${NC}\n" PREFLIGHT="fail" else diff --git a/dockerfiles/cli/tests/cli_prompts_usage_tests.bats b/dockerfiles/cli/tests/cli_prompts_usage_tests.bats index 08b630cc372..3ed2871a574 100644 --- a/dockerfiles/cli/tests/cli_prompts_usage_tests.bats +++ b/dockerfiles/cli/tests/cli_prompts_usage_tests.bats @@ -30,7 +30,7 @@ source /dockerfiles/cli/tests/test_base.sh prompt_substring="-v :/data" #WHEN - run docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock $CLI_IMAGE start + run docker run --rm -v "${SCRIPTS_DIR}":/scripts/base -v /var/run/docker.sock:/var/run/docker.sock $CLI_IMAGE start #THEN assert_failure @@ -42,7 +42,7 @@ source /dockerfiles/cli/tests/test_base.sh expected_output="USAGE:" #WHEN - result=$(docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock $CLI_IMAGE || true) + result=$(docker run --rm -v "${SCRIPTS_DIR}":/scripts/base -v /var/run/docker.sock:/var/run/docker.sock $CLI_IMAGE || true) #THEN [[ $result == *${expected_output}* ]] diff --git a/dockerfiles/cli/tests/cmd_init_destroy_tests.bats b/dockerfiles/cli/tests/cmd_init_destroy_tests.bats index 4659c80daef..72838664763 100644 --- a/dockerfiles/cli/tests/cmd_init_destroy_tests.bats +++ b/dockerfiles/cli/tests/cmd_init_destroy_tests.bats @@ -14,83 +14,83 @@ source /dockerfiles/cli/tests/test_base.sh #GIVEN tmp_path="${TESTRUN_DIR}"/init-destroy1 - container_tmp_path=${CONTAINER_TESTRUN_DIR}/init-destroy1 - mkdir -p $tmp_path + container_tmp_path=""${CONTAINER_TESTRUN_DIR}""/init-destroy1 + mkdir -p "${tmp_path}" #WHEN - docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE init --skip:nightly + docker run --rm -v "${SCRIPTS_DIR}":/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v "${tmp_path}":/data $CLI_IMAGE init --skip:nightly #THEN - [[ -d ${container_tmp_path}/docs ]] - [[ -d ${container_tmp_path}/instance ]] - [[ -e ${container_tmp_path}/che.env ]] - [[ -e ${container_tmp_path}/cli.log ]] + [[ -d "${container_tmp_path}"/docs ]] + [[ -d "${container_tmp_path}"/instance ]] + [[ -e "${container_tmp_path}"/che.env ]] + [[ -e "${container_tmp_path}"/cli.log ]] #WHEN - docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE destroy --quiet --skip:nightly + docker run --rm -v "${SCRIPTS_DIR}":/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v "${tmp_path}":/data $CLI_IMAGE destroy --quiet --skip:nightly #THEN - [[ ! -d ${container_tmp_path}/docs ]] - [[ ! -d ${container_tmp_path}/instance ]] - [[ ! -e ${container_tmp_path}/che.env ]] - [[ -e ${container_tmp_path}/cli.log ]] - rm -rf ${container_tmp_path} + [[ ! -d "${container_tmp_path}"/docs ]] + [[ ! -d "${container_tmp_path}"/instance ]] + [[ ! -e "${container_tmp_path}"/che.env ]] + [[ -e "${container_tmp_path}"/cli.log ]] + rm -rf "${container_tmp_path}" } @test "test 'init' and 'destroy --quiet' with non-existing dir" { #GIVEN tmp_path="${TESTRUN_DIR}"/init-destroy2 - container_tmp_path=${CONTAINER_TESTRUN_DIR}/init-destroy2 + container_tmp_path="${CONTAINER_TESTRUN_DIR}"/init-destroy2 #WHEN - docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE init --skip:nightly 1>/dev/null + docker run --rm -v "${SCRIPTS_DIR}":/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v "${tmp_path}":/data $CLI_IMAGE init --skip:nightly 1>/dev/null #THEN - [[ -e ${container_tmp_path} ]] - [[ -d ${container_tmp_path}/docs ]] - [[ -d ${container_tmp_path}/instance ]] - [[ -e ${container_tmp_path}/che.env ]] - [[ -e ${container_tmp_path}/cli.log ]] + [[ -e "${container_tmp_path}" ]] + [[ -d "${container_tmp_path}"/docs ]] + [[ -d "${container_tmp_path}"/instance ]] + [[ -e "${container_tmp_path}"/che.env ]] + [[ -e "${container_tmp_path}"/cli.log ]] #WHEN - docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE destroy --skip:nightly --quiet 1>/dev/null + docker run --rm -v "${SCRIPTS_DIR}":/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v "${tmp_path}":/data $CLI_IMAGE destroy --skip:nightly --quiet 1>/dev/null #THEN - [[ ! -d ${container_tmp_path}/docs ]] - [[ ! -d ${container_tmp_path}/instance ]] - [[ ! -e ${container_tmp_path}/che.env ]] - [[ -e ${container_tmp_path}/cli.log ]] - rm -rf ${container_tmp_path} + [[ ! -d "${container_tmp_path}"/docs ]] + [[ ! -d "${container_tmp_path}"/instance ]] + [[ ! -e "${container_tmp_path}"/che.env ]] + [[ -e "${container_tmp_path}"/cli.log ]] + rm -rf "${container_tmp_path}" } @test "test 'init' and 'destroy --quiet --cli' with existing dir" { #GIVEN tmp_path="${TESTRUN_DIR}"/init-destroy3 - container_tmp_path=${CONTAINER_TESTRUN_DIR}/init-destroy3 + container_tmp_path="${CONTAINER_TESTRUN_DIR}"/init-destroy3 - mkdir -p $tmp_path + mkdir -p "${tmp_path}" #WHEN - docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE init --skip:nightly 1>/dev/null + docker run --rm -v "${SCRIPTS_DIR}":/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v "${tmp_path}":/data $CLI_IMAGE init --skip:nightly 1>/dev/null remove_named_container $CLI_CONTAINER #THEN - [[ -d ${container_tmp_path}/docs ]] - [[ -d ${container_tmp_path}/instance ]] - [[ -e ${container_tmp_path}/che.env ]] - [[ -e ${container_tmp_path}/cli.log ]] + [[ -d "${container_tmp_path}"/docs ]] + [[ -d "${container_tmp_path}"/instance ]] + [[ -e "${container_tmp_path}"/che.env ]] + [[ -e "${container_tmp_path}"/cli.log ]] #WHEN - docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE destroy --skip:nightly --quiet --cli 1>/dev/null + docker run --rm -v "${SCRIPTS_DIR}":/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v "${tmp_path}":/data $CLI_IMAGE destroy --skip:nightly --quiet --cli 1>/dev/null #THEN - [[ ! -d ${container_tmp_path}/docs ]] - [[ ! -d ${container_tmp_path}/instance ]] - [[ ! -e ${container_tmp_path}/che.env ]] - [[ ! -e ${container_tmp_path}/cli.log ]] - rm -rf ${container_tmp_path} + [[ ! -d "${container_tmp_path}"/docs ]] + [[ ! -d "${container_tmp_path}"/instance ]] + [[ ! -e "${container_tmp_path}"/che.env ]] + [[ ! -e "${container_tmp_path}"/cli.log ]] + rm -rf "${container_tmp_path}" } @@ -98,27 +98,27 @@ source /dockerfiles/cli/tests/test_base.sh #GIVEN tmp_path="${TESTRUN_DIR}"/init-destroy4 - container_tmp_path=${CONTAINER_TESTRUN_DIR}/init-destroy4 + container_tmp_path="${CONTAINER_TESTRUN_DIR}"/init-destroy4 #WHEN - docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE init --skip:nightly 1>/dev/null + docker run --rm -v "${SCRIPTS_DIR}":/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v "${tmp_path}":/data $CLI_IMAGE init --skip:nightly 1>/dev/null #THEN - [[ -d ${container_tmp_path} ]] - [[ -d ${container_tmp_path}/docs ]] - [[ -d ${container_tmp_path}/instance ]] - [[ -e ${container_tmp_path}/che.env ]] - [[ -e ${container_tmp_path}/cli.log ]] + [[ -d "${container_tmp_path}" ]] + [[ -d "${container_tmp_path}"/docs ]] + [[ -d "${container_tmp_path}"/instance ]] + [[ -e "${container_tmp_path}"/che.env ]] + [[ -e "${container_tmp_path}"/cli.log ]] #WHEN - docker run --rm -v $SCRIPTS_DIR:/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v $tmp_path:/data $CLI_IMAGE destroy --skip:nightly --quiet --cli 1>/dev/null + docker run --rm -v "${SCRIPTS_DIR}":/scripts/base -v /var/run/docker.sock:/var/run/docker.sock -v "${tmp_path}":/data $CLI_IMAGE destroy --skip:nightly --quiet --cli 1>/dev/null #THEN - [[ ! -d ${container_tmp_path}/docs ]] - [[ ! -d ${container_tmp_path}/instance ]] - [[ ! -e ${container_tmp_path}/che.env ]] - [[ ! -e ${container_tmp_path}/cli.log ]] - rm -rf ${container_tmp_path} + [[ ! -d "${container_tmp_path}"/docs ]] + [[ ! -d "${container_tmp_path}"/instance ]] + [[ ! -e "${container_tmp_path}"/che.env ]] + [[ ! -e "${container_tmp_path}"/cli.log ]] + rm -rf "${container_tmp_path}" } diff --git a/dockerfiles/cli/tests/cmd_start_tests.bats b/dockerfiles/cli/tests/cmd_start_tests.bats index 0f89e526c03..a73ea0e8834 100644 --- a/dockerfiles/cli/tests/cmd_start_tests.bats +++ b/dockerfiles/cli/tests/cmd_start_tests.bats @@ -12,8 +12,8 @@ source /dockerfiles/cli/tests/test_base.sh # Kill running che server instance if there is any to be able to run tests setup() { - kill_running_named_container che - remove_named_container che + kill_running_named_container chetest + remove_named_container chetest } teardown() { diff --git a/docs/README.md b/docs/README.md index ae9a7ca213b..f966cfa0c93 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1 +1 @@ -Docs are located in seperate repository [https://github.com/codenvy/che-docs](https://github.com/codenvy/che-docs). +Docs are located at [https://github.com/codenvy/che-docs](https://github.com/codenvy/che-docs). \ No newline at end of file