diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/fake.sh | 14 | ||||
-rw-r--r-- | tests/test-all.yml | 1 | ||||
-rw-r--r-- | tests/test-restart-deploy.yml | 37 |
3 files changed, 50 insertions, 2 deletions
diff --git a/tests/fake.sh b/tests/fake.sh index 65ff819..776907b 100755 --- a/tests/fake.sh +++ b/tests/fake.sh | |||
@@ -3,6 +3,9 @@ | |||
3 | binary="${0/*\/}" | 3 | binary="${0/*\/}" |
4 | localCommit="${PRETEND_LOCAL_COMMIT:-aaa000aaa000aaa000aaa000aaa000aaa000aaa0}" | 4 | localCommit="${PRETEND_LOCAL_COMMIT:-aaa000aaa000aaa000aaa000aaa000aaa000aaa0}" |
5 | remoteCommit="${PRETEND_REMOTE_COMMIT:-bbb000bbb000bbb000bbb000bbb000bbb000bbb0}" | 5 | remoteCommit="${PRETEND_REMOTE_COMMIT:-bbb000bbb000bbb000bbb000bbb000bbb000bbb0}" |
6 | uptodateDeployment="${DEPLOY_UP_TO_DATE_APP:-}" | ||
7 | |||
8 | echo "${1}" >> "${binary}-commands" | ||
6 | 9 | ||
7 | if [ "${binary}" = "clever" ] && [ "${1}" = "--version" ]; then | 10 | if [ "${binary}" = "clever" ] && [ "${1}" = "--version" ]; then |
8 | echo "2.6.1" | 11 | echo "2.6.1" |
@@ -10,10 +13,17 @@ elif [ "${binary}" = "clever" ] && [ "${1}" = "activity" ]; then | |||
10 | echo "2020-02-02T20:20:02+02:00 OK DEPLOY ${remoteCommit} Git" | 13 | echo "2020-02-02T20:20:02+02:00 OK DEPLOY ${remoteCommit} Git" |
11 | elif [ "${binary}" = "clever" ] && [ "${1}" = "status" ]; then | 14 | elif [ "${binary}" = "clever" ] && [ "${1}" = "status" ]; then |
12 | echo "test-app: running (1*pico, Commit: ${remoteCommit})" | 15 | echo "test-app: running (1*pico, Commit: ${remoteCommit})" |
16 | elif [ "${binary}" = "clever" ] && [ "${1}" = "deploy" ]; then | ||
17 | if [ -z "${uptodateDeployment}" ]; then | ||
18 | echo "Clever deploy done." | ||
19 | else | ||
20 | # Mimic the current behavior until https://github.com/CleverCloud/clever-tools/issues/422 is solved | ||
21 | >&2 echo "The clever-cloud application is up-to-date. Try this command to restart the application:" | ||
22 | >&2 echo " clever restart" | ||
23 | exit 1 | ||
24 | fi | ||
13 | elif [ "${binary}" = "git" ]; then | 25 | elif [ "${binary}" = "git" ]; then |
14 | echo "${localCommit}" | 26 | echo "${localCommit}" |
15 | else | 27 | else |
16 | echo "${binary} called with arguments: ${*}" | 28 | echo "${binary} called with arguments: ${*}" |
17 | fi | 29 | fi |
18 | |||
19 | echo "${1}" >> "${binary}-commands" | ||
diff --git a/tests/test-all.yml b/tests/test-all.yml index 8a6c0ba..b9c5dea 100644 --- a/tests/test-all.yml +++ b/tests/test-all.yml | |||
@@ -3,6 +3,7 @@ | |||
3 | - import_playbook: ./test-configure-app.yml | 3 | - import_playbook: ./test-configure-app.yml |
4 | - import_playbook: ./test-haskell-app.yml | 4 | - import_playbook: ./test-haskell-app.yml |
5 | - import_playbook: ./test-noop-deploy.yml | 5 | - import_playbook: ./test-noop-deploy.yml |
6 | - import_playbook: ./test-restart-deploy.yml | ||
6 | - import_playbook: ./test-scalability.yml | 7 | - import_playbook: ./test-scalability.yml |
7 | - import_playbook: ./test-service-deps.yml | 8 | - import_playbook: ./test-service-deps.yml |
8 | - import_playbook: ./test-restart-app.yml | 9 | - import_playbook: ./test-restart-app.yml |
diff --git a/tests/test-restart-deploy.yml b/tests/test-restart-deploy.yml new file mode 100644 index 0000000..cbd6cdd --- /dev/null +++ b/tests/test-restart-deploy.yml | |||
@@ -0,0 +1,37 @@ | |||
1 | --- | ||
2 | - name: Launch a restart when commit is already up-to-date on clever | ||
3 | hosts: localhost | ||
4 | remote_user: root | ||
5 | pre_tasks: | ||
6 | - file: | ||
7 | state: absent | ||
8 | path: ../clever-commands | ||
9 | roles: | ||
10 | - role: clever | ||
11 | vars: | ||
12 | clever_token: 123abc | ||
13 | clever_secret: cba321 | ||
14 | clever_app: app_00000000-0000-0000-0000-000000000000 | ||
15 | environment: | ||
16 | DEPLOY_UP_TO_DATE_APP: true | ||
17 | post_tasks: | ||
18 | - name: Check stubbed commands | ||
19 | shell: "{{ item.cmd }}" | ||
20 | ignore_errors: true | ||
21 | with_list: | ||
22 | - cmd: "grep deploy ../clever-commands" | ||
23 | display: "Expected 'clever deploy' command to be called" | ||
24 | - cmd: "grep restart ../clever-commands" | ||
25 | display: "Expected 'clever restart' command to be called" | ||
26 | vars: | ||
27 | display: "{{ item.display }}" | ||
28 | register: tests_results | ||
29 | - name: show results | ||
30 | debug: | ||
31 | msg: | ||
32 | - "failed_results: {{ failed_results }}" | ||
33 | - "success_results: {{ success_results }}" | ||
34 | failed_when: tests_results is failed | ||
35 | vars: | ||
36 | failed_results: "{{ tests_results.results | selectattr('failed') | map(attribute='item.display') | list }}" | ||
37 | success_results: "{{ tests_results.results | rejectattr('failed') | map(attribute='item.display') | list }}" | ||