diff --git a/plugins/modules/monitor.py b/plugins/modules/monitor.py index a7b29c5..489a6c5 100644 --- a/plugins/modules/monitor.py +++ b/plugins/modules/monitor.py @@ -222,7 +222,7 @@ api_password: secret123 type: keyword name: Monitor 1 - url: http://192.168.20.135 + url: http://127.0.0.1 keyword: healthy state: present @@ -233,7 +233,7 @@ api_password: secret123 type: http name: Monitor 1 - url: http://192.168.20.135 + url: http://127.0.0.1 state: present - name: Remove a monitor diff --git a/run_tests.sh b/run_tests.sh index 40814b0..2c093a3 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,8 +1,19 @@ #!/bin/sh +# usage: +# +# run all tests: +# ./run_tests.sh +# +# run all tests against specific uptime kuma version: +# ./run_tests.sh 1.19.4 +# +# run all tests against specific uptime kuma version and specific modules: +# ./run_tests.sh 1.19.4 maintenance maintenance_info + collection_path="$HOME/.ansible/collections/ansible_collections/lucasheld/uptime_kuma" version="$1" -files="${@:2}" +modules="${@:2}" if [ ! -d "$collection_path" ] then @@ -15,14 +26,17 @@ if [ $version ] && [ "$version" != "all" ] then versions=("$version") else - versions=(1.19.3 1.18.5 1.17.1) + versions=(1.19.4 1.18.5 1.17.1) fi -targets="" -for file in ${files[*]} +unit_targets="" +integration_targets="" +for module in ${modules[*]} do - filepath="tests/unit/plugins/module_utils/${file}" - targets+="$filepath " + unit_filepath="tests/unit/plugins/module_utils/test_${module}.py" + unit_targets+="${unit_filepath} " + + integration_targets+="${module} " done for version in ${versions[*]} @@ -37,11 +51,15 @@ do sleep 0.5 done - echo "Running tests..." - ansible-test units -v --target-python default --num-workers 1 $targets + echo "Running unit tests..." + ansible-test units -v --target-python default --num-workers 1 $unit_targets + + echo "" + echo "Running integration tests..." + ansible-test integration -v $integration_targets echo "Stopping uptime kuma..." docker stop uptimekuma > /dev/null - echo '' + echo "" done diff --git a/tests/integration/targets/docker_host/tasks/main.yml b/tests/integration/targets/docker_host/tasks/main.yml new file mode 100644 index 0000000..b177f5a --- /dev/null +++ b/tests/integration/targets/docker_host/tasks/main.yml @@ -0,0 +1,8 @@ +- name: Add docker host + lucasheld.uptime_kuma.docker_host: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 + name: Docker host 1 + dockerType: socket + dockerDaemon: /var/run/docker.sock diff --git a/tests/integration/targets/docker_host_info/tasks/main.yml b/tests/integration/targets/docker_host_info/tasks/main.yml new file mode 100644 index 0000000..9fa7c93 --- /dev/null +++ b/tests/integration/targets/docker_host_info/tasks/main.yml @@ -0,0 +1,5 @@ +- name: get all docker hosts + lucasheld.uptime_kuma.docker_host_info: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 diff --git a/tests/integration/targets/login/tasks/main.yml b/tests/integration/targets/login/tasks/main.yml new file mode 100644 index 0000000..6498cce --- /dev/null +++ b/tests/integration/targets/login/tasks/main.yml @@ -0,0 +1,5 @@ +- name: login + lucasheld.uptime_kuma.login: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 diff --git a/tests/integration/targets/maintenance/tasks/main.yml b/tests/integration/targets/maintenance/tasks/main.yml new file mode 100644 index 0000000..c7e9604 --- /dev/null +++ b/tests/integration/targets/maintenance/tasks/main.yml @@ -0,0 +1,8 @@ +- name: Add a maintenance + lucasheld.uptime_kuma.maintenance: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 + title: maintenance 1 + strategy: single + state: present diff --git a/tests/integration/targets/maintenance_info/tasks/main.yml b/tests/integration/targets/maintenance_info/tasks/main.yml new file mode 100644 index 0000000..403fdb2 --- /dev/null +++ b/tests/integration/targets/maintenance_info/tasks/main.yml @@ -0,0 +1,5 @@ +- name: get all maintenances + lucasheld.uptime_kuma.maintenance_info: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 diff --git a/tests/integration/targets/monitor/tasks/main.yml b/tests/integration/targets/monitor/tasks/main.yml new file mode 100644 index 0000000..8e7a33a --- /dev/null +++ b/tests/integration/targets/monitor/tasks/main.yml @@ -0,0 +1,10 @@ +- name: Add a monitor + lucasheld.uptime_kuma.monitor: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 + type: keyword + name: Monitor 1 + url: http://127.0.0.1 + keyword: healthy + state: present diff --git a/tests/integration/targets/monitor_info/tasks/main.yml b/tests/integration/targets/monitor_info/tasks/main.yml new file mode 100644 index 0000000..994456c --- /dev/null +++ b/tests/integration/targets/monitor_info/tasks/main.yml @@ -0,0 +1,5 @@ +- name: get all monitors + lucasheld.uptime_kuma.monitor_info: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 diff --git a/tests/integration/targets/notification/tasks/main.yml b/tests/integration/targets/notification/tasks/main.yml new file mode 100644 index 0000000..ddf15fa --- /dev/null +++ b/tests/integration/targets/notification/tasks/main.yml @@ -0,0 +1,12 @@ +- name: Add notification + lucasheld.uptime_kuma.notification: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 + name: Notification 1 + type: telegram + isDefault: false + applyExisting: false + telegramBotToken: 1111 + telegramChatID: 2222 + state: present diff --git a/tests/integration/targets/notification_info/tasks/main.yml b/tests/integration/targets/notification_info/tasks/main.yml new file mode 100644 index 0000000..1dc4c25 --- /dev/null +++ b/tests/integration/targets/notification_info/tasks/main.yml @@ -0,0 +1,5 @@ +- name: get all notifications + lucasheld.uptime_kuma.notification_info: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 diff --git a/tests/integration/targets/proxy/tasks/main.yml b/tests/integration/targets/proxy/tasks/main.yml new file mode 100644 index 0000000..08f0c3e --- /dev/null +++ b/tests/integration/targets/proxy/tasks/main.yml @@ -0,0 +1,9 @@ +- name: Add proxy + lucasheld.uptime_kuma.proxy: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 + protocol: http + host: 127.0.0.1 + port: 8080 + state: present diff --git a/tests/integration/targets/proxy_info/tasks/main.yml b/tests/integration/targets/proxy_info/tasks/main.yml new file mode 100644 index 0000000..727cae1 --- /dev/null +++ b/tests/integration/targets/proxy_info/tasks/main.yml @@ -0,0 +1,5 @@ +- name: get all proxies + lucasheld.uptime_kuma.proxy_info: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 diff --git a/tests/integration/targets/settings/tasks/main.yml b/tests/integration/targets/settings/tasks/main.yml new file mode 100644 index 0000000..39ecf49 --- /dev/null +++ b/tests/integration/targets/settings/tasks/main.yml @@ -0,0 +1,6 @@ +- name: Enable beta version update check + lucasheld.uptime_kuma.settings: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 + checkBeta: true diff --git a/tests/integration/targets/settings_info/tasks/main.yml b/tests/integration/targets/settings_info/tasks/main.yml new file mode 100644 index 0000000..7bc9a16 --- /dev/null +++ b/tests/integration/targets/settings_info/tasks/main.yml @@ -0,0 +1,5 @@ +- name: get settings + lucasheld.uptime_kuma.settings_info: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 diff --git a/tests/integration/targets/setup/tasks/main.yml b/tests/integration/targets/setup/tasks/main.yml new file mode 100644 index 0000000..4bdc4ed --- /dev/null +++ b/tests/integration/targets/setup/tasks/main.yml @@ -0,0 +1,5 @@ +- name: Setup + lucasheld.uptime_kuma.setup: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 diff --git a/tests/integration/targets/status_page/tasks/main.yml b/tests/integration/targets/status_page/tasks/main.yml new file mode 100644 index 0000000..ba096b6 --- /dev/null +++ b/tests/integration/targets/status_page/tasks/main.yml @@ -0,0 +1,8 @@ +- name: Add status page + lucasheld.uptime_kuma.status_page: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 + slug: testslug + title: testtitle + state: present diff --git a/tests/integration/targets/status_page_info/tasks/main.yml b/tests/integration/targets/status_page_info/tasks/main.yml new file mode 100644 index 0000000..1480950 --- /dev/null +++ b/tests/integration/targets/status_page_info/tasks/main.yml @@ -0,0 +1,5 @@ +- name: get all status_pages + lucasheld.uptime_kuma.status_page_info: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 diff --git a/tests/integration/targets/tag/tasks/main.yml b/tests/integration/targets/tag/tasks/main.yml new file mode 100644 index 0000000..c82d9c3 --- /dev/null +++ b/tests/integration/targets/tag/tasks/main.yml @@ -0,0 +1,8 @@ +- name: Add tag + lucasheld.uptime_kuma.tag: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123 + name: Tag 1 + color: "#ff0000" + state: present diff --git a/tests/integration/targets/tag_info/tasks/main.yml b/tests/integration/targets/tag_info/tasks/main.yml new file mode 100644 index 0000000..180a3ce --- /dev/null +++ b/tests/integration/targets/tag_info/tasks/main.yml @@ -0,0 +1,5 @@ +- name: get all tags + lucasheld.uptime_kuma.tag_info: + api_url: http://127.0.0.1:3001 + api_username: admin + api_password: secret123