aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/fake.sh12
-rw-r--r--tests/test-all.yml1
-rw-r--r--tests/test-configure-app.yml4
-rw-r--r--tests/test-noop-deploy.yml35
-rw-r--r--tests/test-restart-app.yml6
-rw-r--r--tests/test-scalability.yml4
6 files changed, 51 insertions, 11 deletions
diff --git a/tests/fake.sh b/tests/fake.sh
index bbb4380..65ff819 100755
--- a/tests/fake.sh
+++ b/tests/fake.sh
@@ -1,15 +1,19 @@
1#!/usr/bin/env bash 1#!/usr/bin/env bash
2 2
3binary="${0/*\/}" 3binary="${0/*\/}"
4fakeCommit="aaa000aaa000aaa000aaa000aaa000aaa000aaa0" 4localCommit="${PRETEND_LOCAL_COMMIT:-aaa000aaa000aaa000aaa000aaa000aaa000aaa0}"
5remoteCommit="${PRETEND_REMOTE_COMMIT:-bbb000bbb000bbb000bbb000bbb000bbb000bbb0}"
5 6
6if [ "${binary}" = "clever" ] && [ "${1}" = "--version" ]; then 7if [ "${binary}" = "clever" ] && [ "${1}" = "--version" ]; then
7 echo "2.6.1" 8 echo "2.6.1"
8elif [ "${binary}" = "clever" ] && [ "${1}" = "activity" ]; then 9elif [ "${binary}" = "clever" ] && [ "${1}" = "activity" ]; then
9 echo "2020-02-02T20:20:02+02:00 OK DEPLOY ${fakeCommit} Git" 10 echo "2020-02-02T20:20:02+02:00 OK DEPLOY ${remoteCommit} Git"
11elif [ "${binary}" = "clever" ] && [ "${1}" = "status" ]; then
12 echo "test-app: running (1*pico, Commit: ${remoteCommit})"
10elif [ "${binary}" = "git" ]; then 13elif [ "${binary}" = "git" ]; then
11 echo "${fakeCommit}" 14 echo "${localCommit}"
12else 15else
13 echo "${1}" >> "${binary}-commands"
14 echo "${binary} called with arguments: ${*}" 16 echo "${binary} called with arguments: ${*}"
15fi 17fi
18
19echo "${1}" >> "${binary}-commands"
diff --git a/tests/test-all.yml b/tests/test-all.yml
index 64eb239..145b16d 100644
--- a/tests/test-all.yml
+++ b/tests/test-all.yml
@@ -2,5 +2,6 @@
2- import_playbook: ./test-simple-app.yml 2- import_playbook: ./test-simple-app.yml
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-scalability.yml 6- import_playbook: ./test-scalability.yml
6- import_playbook: ./test-restart-app.yml 7- import_playbook: ./test-restart-app.yml
diff --git a/tests/test-configure-app.yml b/tests/test-configure-app.yml
index 15987fd..e9861a2 100644
--- a/tests/test-configure-app.yml
+++ b/tests/test-configure-app.yml
@@ -21,7 +21,7 @@
21 msg: "CC_RUN_COMMAND env variable should not be present in the environment dict" 21 msg: "CC_RUN_COMMAND env variable should not be present in the environment dict"
22 when: clever_env.CC_RUN_COMMAND is defined 22 when: clever_env.CC_RUN_COMMAND is defined
23 - name: Check stubbed commands 23 - name: Check stubbed commands
24 command: "{{ item.cmd }}" 24 shell: "{{ item.cmd }}"
25 ignore_errors: true 25 ignore_errors: true
26 vars: 26 vars:
27 display: "{{ item.display }}" 27 display: "{{ item.display }}"
@@ -34,7 +34,7 @@
34 display: "Expected 'clever domain' command to be called" 34 display: "Expected 'clever domain' command to be called"
35 - cmd: "grep drain ../clever-commands" 35 - cmd: "grep drain ../clever-commands"
36 display: "Expected 'clever drain' command to be called" 36 display: "Expected 'clever drain' command to be called"
37 - cmd: "grep -v restart ../clever-commands" 37 - cmd: "! grep restart ../clever-commands"
38 display: "Expected 'clever restart' command to NOT be called" 38 display: "Expected 'clever restart' command to NOT be called"
39 register: tests_results 39 register: tests_results
40 - name: show results 40 - name: show results
diff --git a/tests/test-noop-deploy.yml b/tests/test-noop-deploy.yml
new file mode 100644
index 0000000..13eed20
--- /dev/null
+++ b/tests/test-noop-deploy.yml
@@ -0,0 +1,35 @@
1---
2- name: Do nothing if the app is 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 PRETEND_REMOTE_COMMIT: aaa000aaa000aaa000aaa000aaa000aaa000aaa0
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 NOT be called"
24 vars:
25 display: "{{ item.display }}"
26 register: tests_results
27 - name: show results
28 debug:
29 msg:
30 - "failed_results: {{ failed_results }}"
31 - "success_results: {{ success_results }}"
32 failed_when: tests_results is failed
33 vars:
34 failed_results: "{{ tests_results.results | selectattr('failed') | map(attribute='item.display') | list }}"
35 success_results: "{{ tests_results.results | rejectattr('failed') | map(attribute='item.display') | list }}"
diff --git a/tests/test-restart-app.yml b/tests/test-restart-app.yml
index 4c13a14..bc880a8 100644
--- a/tests/test-restart-app.yml
+++ b/tests/test-restart-app.yml
@@ -15,16 +15,16 @@
15 clever_restart_only: true 15 clever_restart_only: true
16 post_tasks: 16 post_tasks:
17 - name: Check stubbed commands 17 - name: Check stubbed commands
18 command: "{{ item.cmd }}" 18 shell: "{{ item.cmd }}"
19 ignore_errors: true 19 ignore_errors: true
20 vars: 20 vars:
21 display: "{{ item.display }}" 21 display: "{{ item.display }}"
22 with_list: 22 with_list:
23 - cmd: "grep restart ../clever-commands" 23 - cmd: "grep restart ../clever-commands"
24 display: "Expected 'clever restart' command to be called" 24 display: "Expected 'clever restart' command to be called"
25 - cmd: "grep -v deploy ../clever-commands" 25 - cmd: "! grep deploy ../clever-commands"
26 display: "Expected 'clever deploy' command to NOT be called" 26 display: "Expected 'clever deploy' command to NOT be called"
27 - cmd: "grep -v scale ../clever-commands" 27 - cmd: "! grep scale ../clever-commands"
28 display: "Expected 'clever scale' command to NOT be called" 28 display: "Expected 'clever scale' command to NOT be called"
29 register: tests_results 29 register: tests_results
30 - name: show results 30 - name: show results
diff --git a/tests/test-scalability.yml b/tests/test-scalability.yml
index 6bb90d2..258beaf 100644
--- a/tests/test-scalability.yml
+++ b/tests/test-scalability.yml
@@ -29,7 +29,7 @@
29 flavors: { min: "nano", max: "XS" } 29 flavors: { min: "nano", max: "XS" }
30 post_tasks: 30 post_tasks:
31 - name: Check stubbed commands 31 - name: Check stubbed commands
32 command: "{{ item.cmd }}" 32 shell: "{{ item.cmd }}"
33 ignore_errors: true 33 ignore_errors: true
34 vars: 34 vars:
35 display: "{{ item.display }}" 35 display: "{{ item.display }}"
@@ -38,7 +38,7 @@
38 display: "Expected 'clever deploy' command to be called" 38 display: "Expected 'clever deploy' command to be called"
39 - cmd: "grep scale ../clever-commands" 39 - cmd: "grep scale ../clever-commands"
40 display: "Expected 'clever scale' command to be called" 40 display: "Expected 'clever scale' command to be called"
41 - cmd: "grep -v restart ../clever-commands" 41 - cmd: "! grep restart ../clever-commands"
42 display: "Expected 'clever restart' command to NOT be called" 42 display: "Expected 'clever restart' command to NOT be called"
43 register: tests_results 43 register: tests_results
44 - name: show results 44 - name: show results