From 668e712d6c27c080ba1fb115568749bf073b075f Mon Sep 17 00:00:00 2001 From: Christian McHugh Date: Mon, 8 Apr 2019 17:41:00 +0100 Subject: [PATCH 1/2] Add initial saltcheck tests --- salt/saltcheck-tests/api.tst | 26 ++++++++++++++++ salt/saltcheck-tests/master.tst | 47 ++++++++++++++++++++++++++++ salt/saltcheck-tests/minion.tst | 55 +++++++++++++++++++++++++++++++++ salt/saltcheck-tests/ssh.tst | 21 +++++++++++++ 4 files changed, 149 insertions(+) create mode 100644 salt/saltcheck-tests/api.tst create mode 100644 salt/saltcheck-tests/master.tst create mode 100644 salt/saltcheck-tests/minion.tst create mode 100644 salt/saltcheck-tests/ssh.tst diff --git a/salt/saltcheck-tests/api.tst b/salt/saltcheck-tests/api.tst new file mode 100644 index 000000000..57035bfdf --- /dev/null +++ b/salt/saltcheck-tests/api.tst @@ -0,0 +1,26 @@ +{% from "salt/map.jinja" import salt_settings with context %} + +{% if salt_settings.install_packages %} +api_installed: + module_and_function: pkg.version + args: + - {{ salt_settings.salt_api }} + {%- if salt_settings.version is defined %} + assertion: assertEqual + expected-return: {{ salt_settings.version }} + {% else %} + assertion: assertNotEmpty + {%- endif %} +{% endif %} + +api_running: + module_and_function: service.status + args: + - {{ salt_settings.api_service }} + assertion: assertTrue + +api_enabled: + module_and_function: service.enabled + args: + - {{ salt_settings.api_service }} + assertion: assertTrue diff --git a/salt/saltcheck-tests/master.tst b/salt/saltcheck-tests/master.tst new file mode 100644 index 000000000..73c917b9f --- /dev/null +++ b/salt/saltcheck-tests/master.tst @@ -0,0 +1,47 @@ +{% from "salt/map.jinja" import salt_settings with context %} + +{% if salt_settings.install_packages %} +master_installed: + module_and_function: pkg.version + args: + - {{ salt_settings.salt_master }} + {%- if salt_settings.version is defined %} + assertion: assertEqual + expected-return: {{ salt_settings.version }} + {% else %} + assertion: assertNotEmpty + {%- endif %} +{% endif %} + +master_running: + module_and_function: service.status + args: + - {{ salt_settings.master_service }} + assertion: assertTrue + +master_enabled: + module_and_function: service.enabled + args: + - {{ salt_settings.master_service }} + assertion: assertTrue + +master_conf_deployed: + module_and_function: file.search + args: + - {{ salt_settings.config_path }}/master.d/f_defaults.conf + - This file managed by Salt, do not edit by hand + assertion: assertTrue + +{% if salt_settings.master_remove_config %} +default-master-conf-removed: + module_and_function: file.file_exists + args: + - {{ salt_settings.config_path }}/master + assertion: assertFalse +{% endif %} + +old-master-conf-removed: + module_and_function: file.file_exists + args: + - {{ salt_settings.config_path }}/master.d/_defaults.conf + assertion: assertFalse diff --git a/salt/saltcheck-tests/minion.tst b/salt/saltcheck-tests/minion.tst new file mode 100644 index 000000000..45962f822 --- /dev/null +++ b/salt/saltcheck-tests/minion.tst @@ -0,0 +1,55 @@ +{% from "salt/map.jinja" import salt_settings with context %} + +{% if salt_settings.install_packages %} +minion_installed: + module_and_function: pkg.version + args: + - {{ salt_settings.salt_minion }} + {%- if salt_settings.version is defined %} + assertion: assertEqual + expected-return: {{ salt_settings.version }} + {% else %} + assertion: assertNotEmpty + {%- endif %} +{% endif %} + +minion_running: + module_and_function: service.status + args: + - {{ salt_settings.minion_service }} + assertion: assertTrue + +minion_enabled: + module_and_function: service.enabled + args: + - {{ salt_settings.minion_service }} + assertion: assertTrue + +minion_conf_deployed: + module_and_function: file.search + args: + - {{ salt_settings.config_path }}/master.d/f_defaults.conf + - This file managed by Salt, do not edit by hand!! + assertion: assertTrue + +{% if salt_settings.minion_remove_config %} +default-minion-conf-removed: + module_and_function: file.file_exists + args: + - {{ salt_settings.config_path }}/minion + assertion: assertFalse +{% endif %} + +old-minion-conf-removed: + module_and_function: file.file_exists + args: + - {{ salt_settings.config_path }}/minion + assertion: assertFalse + +{% if 'inotify' in salt_settings.get('minion', {}).get('beacons', {}) and salt_settings.get('pyinotify', False) %} +inotify_installed: + module_and_function: pkg.version + args: + - {{ salt_settings.pyinotify }} + assertion: assertNotEmpty +{% endif %} diff --git a/salt/saltcheck-tests/ssh.tst b/salt/saltcheck-tests/ssh.tst new file mode 100644 index 000000000..7db83a944 --- /dev/null +++ b/salt/saltcheck-tests/ssh.tst @@ -0,0 +1,21 @@ +{% from "salt/map.jinja" import salt_settings with context %} + +{% if salt_settings.install_packages %} +master_installed: + module_and_function: pkg.version + args: + - {{ salt_settings.salt_ssh }} + {%- if salt_settings.version is defined %} + assertion: assertEqual + expected-return: {{ salt_settings.version }} + {% else %} + assertion: assertNotEmpty + {%- endif %} +{% endif %} + +roster_deployed: + module_and_function: file.search + args: + - {{ salt_settings.config_path }}/roster + - This file is managed by Salt! Do not edit by hand! + assertion: assertTrue From 3753fc96d00c2a85e05cb90b0640fa22cfe8dbf7 Mon Sep 17 00:00:00 2001 From: Christian McHugh Date: Mon, 8 Apr 2019 18:35:06 +0100 Subject: [PATCH 2/2] Update ssh.tst --- salt/saltcheck-tests/ssh.tst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/saltcheck-tests/ssh.tst b/salt/saltcheck-tests/ssh.tst index 7db83a944..c09eec2ad 100644 --- a/salt/saltcheck-tests/ssh.tst +++ b/salt/saltcheck-tests/ssh.tst @@ -1,7 +1,7 @@ {% from "salt/map.jinja" import salt_settings with context %} {% if salt_settings.install_packages %} -master_installed: +salt_ssh_installed: module_and_function: pkg.version args: - {{ salt_settings.salt_ssh }}