enable and fix existing and add some more tests CLI tests. (#5304)
* enable, fix and add more CLI tests.6.19.x
parent
a50cf745b5
commit
57106827fb
|
|
@ -1 +1,2 @@
|
|||
version/nightly/images
|
||||
tests/testrun/*
|
||||
|
|
|
|||
|
|
@ -37,11 +37,18 @@ run_test_in_docker_container() {
|
|||
$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
|
||||
run_test_in_docker_container cli_prompts_usage_tests.bats
|
||||
echo "Running functionals bats tests for config command"
|
||||
run_test_in_docker_container cmd_config_tests.bats
|
||||
echo "Running functionals bats tests for info command"
|
||||
run_test_in_docker_container cmd_info_tests.bats
|
||||
echo "Running functional bats tests for init and destroy commands"
|
||||
#run_test_in_docker_container cmd_init_destroy_tests.bats
|
||||
echo "Running functionals bats tests for start command"
|
||||
run_test_in_docker_container cmd_start_tests.bats --net=host
|
||||
run_test_in_docker_container cmd_init_destroy_tests.bats
|
||||
echo "Running functionals bats tests for start, stop, restart command"
|
||||
run_test_in_docker_container cmd_start_stop_restart_tests.bats --net=host
|
||||
echo "Running functionals bats tests for backup / restore commands"
|
||||
run_test_in_docker_container cmd_backup_restore_tests.bats
|
||||
echo "Running functionals bats tests for offline command"
|
||||
run_test_in_docker_container cmd_offline_tests.bats
|
||||
|
|
|
|||
|
|
@ -17,12 +17,11 @@ source /dockerfiles/cli/tests/test_base.sh
|
|||
prompt_substring="-v /var/run/docker.sock:/var/run/docker.sock"
|
||||
|
||||
#WHEN
|
||||
run docker run --rm $CLI_IMAGE start
|
||||
run execute_cli_command --che-cli-mount-scripts=false --che-cli-use-docker-sock=false --che-cli-command=start
|
||||
|
||||
#THEN
|
||||
assert_failure
|
||||
assert_output --partial ${prompt_substring}
|
||||
|
||||
}
|
||||
|
||||
@test "test CLI prompt to provide directory for user data" {
|
||||
|
|
@ -30,7 +29,7 @@ source /dockerfiles/cli/tests/test_base.sh
|
|||
prompt_substring="-v <YOUR_LOCAL_PATH>:/data"
|
||||
|
||||
#WHEN
|
||||
run docker run --rm -v "${SCRIPTS_DIR}":/scripts/base -v /var/run/docker.sock:/var/run/docker.sock $CLI_IMAGE start
|
||||
run execute_cli_command --che-cli-command=start
|
||||
|
||||
#THEN
|
||||
assert_failure
|
||||
|
|
@ -42,10 +41,8 @@ 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=$(execute_cli_command || true)
|
||||
|
||||
#THEN
|
||||
[[ $result == *${expected_output}* ]]
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,127 @@
|
|||
#!/usr/bin/env bats
|
||||
# Copyright (c) 2017 Codenvy, S.A.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# Roman Iuvshyn
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
teardown() {
|
||||
kill_running_named_container che
|
||||
remove_named_container che
|
||||
}
|
||||
|
||||
@test "test cli 'backup' command: backup fail if che is running" {
|
||||
#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}"/cli_cmd_backup_fail_if_che_is_running
|
||||
mkdir -p "${tmp_path}"
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
check_che_state
|
||||
#WHEN
|
||||
result=$(execute_cli_command --che-data-path=${tmp_path} --che-cli-command=backup --che-cli-extra-options="--skip:nightly --skip:pull" || true)
|
||||
|
||||
#THEN
|
||||
[[ $result == *"che is running. Stop before performing a backup."* ]]
|
||||
}
|
||||
|
||||
@test "test cli 'restore' command: restore fail if che is running" {
|
||||
#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}"/cli_cmd_restore_fail_if_che_is_running
|
||||
mkdir -p "${tmp_path}"
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
check_che_state
|
||||
#WHEN
|
||||
result=$(execute_cli_command --che-data-path=${tmp_path} --che-cli-command=restore --che-cli-extra-options="--quiet --skip:nightly --skip:pull")
|
||||
|
||||
#THEN
|
||||
[[ $result == *"Eclipse Che is running. Stop before performing a restore."* ]]
|
||||
}
|
||||
|
||||
@test "test cli 'restore' command: restore fail if no backup found" {
|
||||
#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}"/cli_cmd_restore_fail_if_no_backup_found
|
||||
mkdir -p "${tmp_path}"
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
check_che_state
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=stop --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
|
||||
#WHEN
|
||||
result=$(execute_cli_command --che-data-path=${tmp_path} --che-cli-command=restore --che-cli-extra-options="--quiet --skip:nightly --skip:pull")
|
||||
|
||||
#THEN
|
||||
[[ $result == *"Backup files not found. To do restore please do backup first."* ]]
|
||||
}
|
||||
|
||||
@test "test cli 'backup / restore' commands" {
|
||||
# TEST BACKUP
|
||||
#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}"/cli_cmd_backup_do_backup_restore
|
||||
container_tmp_path="${CONTAINER_TESTRUN_DIR}"/cli_cmd_backup_do_backup_restore
|
||||
workspace_name="backup-restore"
|
||||
mkdir -p "${tmp_path}"
|
||||
#start che
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
check_che_state
|
||||
#create a workspace
|
||||
|
||||
ws_create=$(curl 'http://'${ip_address}':8080/api/workspace?namespace=che&attribute=stackId:java-default' -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept: application/json, text/plain, */*' --data-binary '{"defaultEnv":"wksp-1p0b","environments":{"wksp-1p0b":{"recipe":{"location":"eclipse/ubuntu_jdk8","type":"dockerimage"},"machines":{"dev-machine":{"servers":{},"agents":["org.eclipse.che.exec","org.eclipse.che.terminal","org.eclipse.che.ws-agent","org.eclipse.che.ssh"],"attributes":{"memoryLimitBytes":"2147483648"}}}}},"projects":[],"commands":[{"commandLine":"mvn clean install -f ${current.project.path}","name":"build","type":"mvn","attributes":{"goal":"Build","previewUrl":""}}],"name":"backup-restore","links":[]}' --compressed)
|
||||
[[ "$ws_create" == *"created"* ]]
|
||||
[[ "$ws_create" == *"STOPPED"* ]]
|
||||
#stop che
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=stop --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
|
||||
#WHEN
|
||||
backup=$(execute_cli_command --che-data-path=${tmp_path} --che-cli-command=backup --che-cli-extra-options="--skip:nightly --skip:pull")
|
||||
|
||||
#THEN
|
||||
[[ "$backup" == *"Saving codenvy data..."* ]]
|
||||
[[ "$backup" == *"che data saved in ${tmp_path}/backup/che_backup.tar.gz"* ]]
|
||||
[[ -f "${container_tmp_path}"/backup/che_backup.tar.gz ]]
|
||||
|
||||
# TEST RESTORE
|
||||
#GIVEN
|
||||
#destroy to wipe data
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=destroy --che-cli-extra-options="--quiet --skip:nightly --skip:pull"
|
||||
[[ ! -d "${container_tmp_path}"/instance ]]
|
||||
#WHEN
|
||||
#perform restore from backup
|
||||
restore=$(execute_cli_command --che-data-path=${tmp_path} --che-cli-command=restore --che-cli-extra-options="--quiet --skip:nightly --skip:pull")
|
||||
|
||||
#THEN
|
||||
[[ "$restore" == *"Recovering Eclipse Che data..."* ]]
|
||||
[[ -d "${container_tmp_path}"/instance ]]
|
||||
[[ -d "${container_tmp_path}"/instance/data ]]
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
check_che_state
|
||||
|
||||
#THEN
|
||||
[[ "$(curl -fsS http://${ip_address}:8080/api/workspace)" == *"$workspace_name"* ]]
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env bats
|
||||
# Copyright (c) 2017 Codenvy, S.A.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# Roman Iuvshyn
|
||||
|
||||
load '/bats-support/load.bash'
|
||||
load '/bats-assert/load.bash'
|
||||
source /dockerfiles/cli/tests/test_base.sh
|
||||
|
||||
@test "test CLI 'config' command" {
|
||||
#GIVEN
|
||||
tmp_path="${TESTRUN_DIR}"/cli_cmd_config
|
||||
container_tmp_path="${CONTAINER_TESTRUN_DIR}"/cli_cmd_config
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=config --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
|
||||
#THEN
|
||||
[[ -d "${container_tmp_path}"/docs ]]
|
||||
[[ -e "${container_tmp_path}"/che.env ]]
|
||||
[[ -e "${container_tmp_path}"/cli.log ]]
|
||||
[[ -d "${container_tmp_path}"/instance ]]
|
||||
[[ -d "${container_tmp_path}"/instance/config ]]
|
||||
[[ -f "${container_tmp_path}"/instance/config/che.env ]]
|
||||
[[ -d "${container_tmp_path}"/instance/data ]]
|
||||
[[ -d "${container_tmp_path}"/instance/logs ]]
|
||||
[[ -d "${container_tmp_path}"/instance/stacks ]]
|
||||
[[ -d "${container_tmp_path}"/instance/templates ]]
|
||||
[[ -f "${container_tmp_path}"/instance/docker-compose-container.yml ]]
|
||||
[[ -f "${container_tmp_path}"/instance/che.ver.do_not_modify ]]
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env bats
|
||||
# Copyright (c) 2017 Codenvy, S.A.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# Roman Iuvshyn
|
||||
|
||||
load '/bats-support/load.bash'
|
||||
load '/bats-assert/load.bash'
|
||||
source /dockerfiles/cli/tests/test_base.sh
|
||||
|
||||
@test "test CLI 'info' command" {
|
||||
#GIVEN
|
||||
tmp_path="${TESTRUN_DIR}"/cli_cmd_info
|
||||
expected_output_1="CLI:"
|
||||
expected_output_2="Mounts:"
|
||||
expected_output_3="System:"
|
||||
expected_output_4="Internal:"
|
||||
expected_output_5="Image Registry:"
|
||||
|
||||
#WHEN
|
||||
result=$(execute_cli_command --che-data-path=${tmp_path} --che-cli-command=info --che-cli-extra-options="--skip:nightly --skip:pull")
|
||||
|
||||
#THEN
|
||||
[[ $result == *${expected_output_1}* ]]
|
||||
[[ $result == *${expected_output_2}* ]]
|
||||
[[ $result == *${expected_output_3}* ]]
|
||||
[[ $result == *${expected_output_4}* ]]
|
||||
[[ $result == *${expected_output_5}* ]]
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ source /dockerfiles/cli/tests/test_base.sh
|
|||
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 --skip:pull
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=init --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
|
||||
#THEN
|
||||
[[ -d "${container_tmp_path}"/docs ]]
|
||||
|
|
@ -27,8 +27,8 @@ source /dockerfiles/cli/tests/test_base.sh
|
|||
[[ -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 --skip:pull
|
||||
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=destroy --che-cli-extra-options="--quiet --skip:nightly --skip:pull"
|
||||
|
||||
#THEN
|
||||
[[ ! -d "${container_tmp_path}"/docs ]]
|
||||
[[ ! -d "${container_tmp_path}"/instance ]]
|
||||
|
|
@ -43,8 +43,8 @@ source /dockerfiles/cli/tests/test_base.sh
|
|||
tmp_path="${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 --skip:pull 1>/dev/null
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=init --che-cli-extra-options="--skip:nightly --skip:pull 1>/dev/null"
|
||||
|
||||
#THEN
|
||||
[[ -e "${container_tmp_path}" ]]
|
||||
|
|
@ -54,7 +54,7 @@ source /dockerfiles/cli/tests/test_base.sh
|
|||
[[ -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 --skip:pull --quiet 1>/dev/null
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=destroy --che-cli-extra-options="--quiet --skip:nightly --skip:pull 1>/dev/null"
|
||||
|
||||
#THEN
|
||||
[[ ! -d "${container_tmp_path}"/docs ]]
|
||||
|
|
@ -73,7 +73,7 @@ source /dockerfiles/cli/tests/test_base.sh
|
|||
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 --skip:pull 1>/dev/null
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=init --che-cli-extra-options="--skip:nightly --skip:pull 1>/dev/null"
|
||||
remove_named_container $CLI_CONTAINER
|
||||
|
||||
#THEN
|
||||
|
|
@ -83,7 +83,7 @@ source /dockerfiles/cli/tests/test_base.sh
|
|||
[[ -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 --skip:pull --quiet --cli 1>/dev/null
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=destroy --che-cli-extra-options="--quiet --skip:nightly --skip:pull --cli 1>/dev/null"
|
||||
|
||||
#THEN
|
||||
[[ ! -d "${container_tmp_path}"/docs ]]
|
||||
|
|
@ -101,7 +101,7 @@ source /dockerfiles/cli/tests/test_base.sh
|
|||
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 --skip:pull 1>/dev/null
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=init --che-cli-extra-options="--skip:nightly --skip:pull 1>/dev/null"
|
||||
|
||||
#THEN
|
||||
[[ -d "${container_tmp_path}" ]]
|
||||
|
|
@ -111,14 +111,12 @@ source /dockerfiles/cli/tests/test_base.sh
|
|||
[[ -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 --skip:pull --quiet --cli 1>/dev/null
|
||||
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-cli-command=destroy --che-cli-extra-options="--skip:nightly --skip:pull --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}"
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
#!/usr/bin/env bats
|
||||
# Copyright (c) 2017 Codenvy, S.A.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# Roman Iuvshyn
|
||||
|
||||
source /dockerfiles/cli/tests/test_base.sh
|
||||
|
||||
@test "test cli 'offline' command: with default parameters" {
|
||||
#GIVEN
|
||||
tmp_path="${TESTRUN_DIR}"/cli_cmd_offline_with_default_parameters
|
||||
container_tmp_path="${CONTAINER_TESTRUN_DIR}"/cli_cmd_offline_with_default_parameters
|
||||
mkdir -p "${tmp_path}"
|
||||
|
||||
#WHEN
|
||||
result=$(execute_cli_command --che-data-path=${tmp_path} --che-cli-command=offline --che-cli-extra-options="--skip:nightly --skip:pull")
|
||||
|
||||
#THEN
|
||||
[[ $result == *"Saving che cli image..."* ]]
|
||||
[[ $result == *"Saving che bootstrap images..."* ]]
|
||||
[[ $result == *"Saving che system images..."* ]]
|
||||
[[ $result == *"Saving utility images..."* ]]
|
||||
[[ $result == *"Saving che stack images..."* ]]
|
||||
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/alpine*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/docker_compose*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-action*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-cli*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-dir*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-init*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-ip*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-mount*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-server*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-test*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/traefik*.tar) ]]
|
||||
}
|
||||
|
||||
@test "test cli 'offline' command: include custom stack images" {
|
||||
#GIVEN
|
||||
tmp_path="${TESTRUN_DIR}"/cli_cmd_offline_with_custom_stack_images
|
||||
container_tmp_path="${CONTAINER_TESTRUN_DIR}"/cli_cmd_offline_with_custom_stack_images
|
||||
mkdir -p "${tmp_path}"
|
||||
|
||||
#WHEN
|
||||
result=$(execute_cli_command --che-data-path=${tmp_path} --che-cli-command=offline --che-cli-extra-options="--image:eclipse/alpine_jdk8 --image:eclipse/debian_jre --skip:nightly --skip:pull")
|
||||
|
||||
#THEN
|
||||
[[ $result == *"Saving che cli image..."* ]]
|
||||
[[ $result == *"Saving che bootstrap images..."* ]]
|
||||
[[ $result == *"Saving che system images..."* ]]
|
||||
[[ $result == *"Saving utility images..."* ]]
|
||||
[[ $result == *"Saving che stack images..."* ]]
|
||||
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/alpine*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/docker_compose*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-action*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-cli*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-dir*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-init*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-ip*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-mount*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-server*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/eclipse_che-test*.tar) ]]
|
||||
[[ -f $(ls "${container_tmp_path}"/backup/traefik*.tar) ]]
|
||||
[[ -f "${container_tmp_path}"/backup/eclipse_alpine_jdk8.tar ]]
|
||||
[[ -f "${container_tmp_path}"/backup/eclipse_debian_jre.tar ]]
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
#!/usr/bin/env bats
|
||||
# Copyright (c) 2012-2017 Red Hat, Inc
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# Marian Labuda - Initial Implementation
|
||||
# Roman Iuvshyn
|
||||
|
||||
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 chetest
|
||||
remove_named_container chetest
|
||||
}
|
||||
|
||||
teardown() {
|
||||
kill_running_named_container chetest
|
||||
remove_named_container chetest
|
||||
}
|
||||
|
||||
@test "test cli 'start' command 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}"/cli_cmd_start_with_default_params
|
||||
mkdir -p "${tmp_path}"
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-container-name=chetest --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
|
||||
#THEN
|
||||
check_che_state --che-container-name="chetest"
|
||||
}
|
||||
|
||||
@test "test cli 'stop' command 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}"/cli_cmd_stop_with_default_settings
|
||||
mkdir -p "${tmp_path}"
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-container-name=chetest --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
check_che_state --che-container-name="chetest"
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-container-name=chetest --che-cli-command=stop --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
|
||||
#THEN
|
||||
#check that container is stopped and removed
|
||||
[[ "$(docker ps -a)" != *"chetest"* ]]
|
||||
}
|
||||
|
||||
@test "test cli 'restart' command 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}"/cli_cmd_restart_with_default_settings
|
||||
mkdir -p "${tmp_path}"
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-container-name=chetest --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
check_che_state --che-container-name="chetest"
|
||||
che_container_id=$(docker inspect --format="{{.Id}}" chetest)
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-container-name=chetest --che-cli-command=restart --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
|
||||
#THEN
|
||||
[[ "$(docker inspect --format="{{.Id}}" chetest)" != "$che_container_id" ]]
|
||||
check_che_state --che-container-name="chetest"
|
||||
}
|
||||
|
||||
@test "test cli 'start' with custom port" {
|
||||
#GIVEN
|
||||
tmp_path=${TESTRUN_DIR}/cli_cmd_start_with_custom_port
|
||||
free_port=$(get_free_port)
|
||||
|
||||
#WHEN
|
||||
execute_cli_command --che-data-path=${tmp_path} --che-port=$free_port --che-container-name=chetest --che-cli-command=start --che-cli-extra-options="--skip:nightly --skip:pull"
|
||||
#THEN
|
||||
check_che_state --che-container-name="chetest" --che-port="$free_port"
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
#!/usr/bin/env bats
|
||||
# Copyright (c) 2012-2017 Red Hat, Inc
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# Marian Labuda - Initial Implementation
|
||||
|
||||
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 chetest
|
||||
remove_named_container chetest
|
||||
}
|
||||
|
||||
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 --skip:pull
|
||||
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 --skip:pull
|
||||
}
|
||||
|
||||
@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
|
||||
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 -e CHE_CONTAINER=chetest $CLI_IMAGE start --skip:nightly --skip:pull
|
||||
|
||||
#THEN
|
||||
[[ $(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
|
||||
}
|
||||
|
||||
@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 -e CHE_CONTAINER=chetest $CLI_IMAGE start --skip:nightly --skip:pull
|
||||
|
||||
#THEN
|
||||
[[ $(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
|
||||
}
|
||||
|
|
@ -14,8 +14,9 @@ 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 "${CONTAINER_TESTRUN_DIR}" ]; then
|
||||
rm -rf "${CONTAINER_TESTRUN_DIR}"
|
||||
fi
|
||||
mkdir "${TESTRUN_DIR}" -p
|
||||
|
||||
|
|
@ -56,3 +57,99 @@ get_free_port() {
|
|||
echo $port
|
||||
}
|
||||
|
||||
check_che_state() {
|
||||
local CHE_CONTAINER_NAME="che"
|
||||
local CHE_PORT="8080"
|
||||
local IS_RUNNING="true"
|
||||
for i in "${@}"
|
||||
do
|
||||
case $i in
|
||||
--che-container-name=*)
|
||||
CHE_CONTAINER_NAME="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--che-port=*)
|
||||
CHE_PORT="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--is-running=*)
|
||||
IS_RUNNING="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "You've passed unknown option"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
[[ "$(docker inspect --format='{{.State.Running}}' $CHE_CONTAINER_NAME)" == "$IS_RUNNING" ]]
|
||||
ip_address=$(docker inspect -f {{.NetworkSettings.Networks.bridge.IPAddress}} $CHE_CONTAINER_NAME)
|
||||
curl -fsS http://${ip_address}:$CHE_PORT > /dev/null
|
||||
}
|
||||
|
||||
execute_cli_command() {
|
||||
local CHE_CONTAINER_NAME="che"
|
||||
local CHE_DATA_PATH=""
|
||||
local CHE_CLI_COMMAND=""
|
||||
local CHE_CLI_EXTRA_OPTIONS=""
|
||||
local CHE_PORT="8080"
|
||||
local DATA_VOLUME=""
|
||||
local USE_DOCKER_SOCK="true"
|
||||
local MOUNT_SCRIPTS="true"
|
||||
|
||||
for i in "${@}"
|
||||
do
|
||||
case $i in
|
||||
--che-container-name=*)
|
||||
CHE_CONTAINER_NAME="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--che-port=*)
|
||||
CHE_PORT="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--che-data-path=*)
|
||||
CHE_DATA_PATH="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--che-cli-command=*)
|
||||
CHE_CLI_COMMAND="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--che-cli-extra-options=*)
|
||||
CHE_CLI_EXTRA_OPTIONS="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--che-cli-use-docker-sock=*)
|
||||
USE_DOCKER_SOCK="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
--che-cli-mount-scripts=*)
|
||||
MOUNT_SCRIPTS="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "You've passed unknown option"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ! -z $CHE_DATA_PATH ]; then
|
||||
DATA_VOLUME="-v ${CHE_DATA_PATH}:/data"
|
||||
fi
|
||||
if [ $USE_DOCKER_SOCK == "true" ]; then
|
||||
DOCKER_SOCK_VOLUME="-v /var/run/docker.sock:/var/run/docker.sock"
|
||||
fi
|
||||
if [ $MOUNT_SCRIPTS == "true" ]; then
|
||||
SCRIPTS_VOLUME="-v ${SCRIPTS_DIR}:/scripts/base"
|
||||
fi
|
||||
if [ $CHE_PORT -ne 8080 ]; then
|
||||
CLI_CUSTOM_PORT="-e CHE_PORT=${CHE_PORT}"
|
||||
fi
|
||||
if [ $CHE_CONTAINER_NAME != "che" ]; then
|
||||
CLI_CUSTOM_CHE_CONTAINER_NAME="-e CHE_CONTAINER=${CHE_CONTAINER_NAME}"
|
||||
fi
|
||||
|
||||
docker run --rm ${CLI_CUSTOM_PORT} ${SCRIPTS_VOLUME} ${DOCKER_SOCK_VOLUME} ${DATA_VOLUME} ${CLI_CUSTOM_CHE_CONTAINER_NAME} $CLI_IMAGE ${CHE_CLI_COMMAND} ${CHE_CLI_EXTRA_OPTIONS}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue