Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial saltcheck tests #408

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions salt/saltcheck-tests/api.tst
Original file line number Diff line number Diff line change
@@ -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
47 changes: 47 additions & 0 deletions salt/saltcheck-tests/master.tst
Original file line number Diff line number Diff line change
@@ -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
55 changes: 55 additions & 0 deletions salt/saltcheck-tests/minion.tst
Original file line number Diff line number Diff line change
@@ -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 %}
21 changes: 21 additions & 0 deletions salt/saltcheck-tests/ssh.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% from "salt/map.jinja" import salt_settings with context %}

{% if salt_settings.install_packages %}
salt_ssh_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