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 missing tests #52

Merged
merged 1 commit into from
Oct 2, 2017
Merged
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
2 changes: 1 addition & 1 deletion alignak_backend_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

# Application version and manifest
VERSION = (1, 0, 0)
VERSION = (1, 0, 1)

__application__ = u"Alignak Backend client"
__short_version__ = '.'.join((str(each) for each in VERSION[:2]))
Expand Down
24 changes: 24 additions & 0 deletions test/alignak-backend-cli-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,30 @@ def test_start_02_create(self):
))
assert exit_code == 0

def test_start_02_create_nrpe(self):
# pylint: disable=no-self-use
""" CLI to create backend objects - several services with the same name"""

work_dir = os.path.abspath(os.path.dirname(__file__))
work_dir = os.path.join(work_dir, 'json/nrpe')

print("Creating backend elements...")
# Create commands
exit_code = subprocess.call(shlex.split(
'python ../alignak_backend_client/backend_client.py -f "%s" -t command -d commands.json add' % work_dir
))
assert exit_code == 0

# Create templates
exit_code = subprocess.call(shlex.split(
'python ../alignak_backend_client/backend_client.py -f "%s" -t host -d hosts-templates.json add' % work_dir
))
assert exit_code == 0
exit_code = subprocess.call(shlex.split(
'python ../alignak_backend_client/backend_client.py -f "%s" -t service -d services-templates.json add' % work_dir
))
assert exit_code == 0

def test_start_03_get_elements(self):
# pylint: disable=no-self-use
""" CLI to get default backend objects"""
Expand Down
46 changes: 46 additions & 0 deletions test/json/nrpe/commands.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"_realm": "All",
"_sub_realm": true,
"alias": "Check NRPE version",
"command_line": "$NRPE_PLUGINS_DIR$/check_nrpe -H $HOSTADDRESS$ -t $_HOSTNRPE_TIMEOUT$ -u $_HOSTNRPE_SSL$",
"enable_environment_macros": false,
"imported_from": "alignak-checks-nrpe",
"name": "check_nrpe_version",
"poller_tag": "",
"timeout": -1
},
{
"_realm": "All",
"_sub_realm": true,
"alias": "Check alive",
"command_line": "$NRPE_PLUGINS_DIR$/check_nrpe -H $HOSTADDRESS$ -t $_HOSTNRPE_TIMEOUT$ -u $_HOSTNRPE_SSL$",
"enable_environment_macros": false,
"imported_from": "alignak-checks-nrpe",
"name": "check_nrpe_alive",
"poller_tag": "",
"timeout": -1
},
{
"_realm": "All",
"_sub_realm": true,
"alias": "NRPE check",
"command_line": "$NRPE_PLUGINS_DIR$/check_nrpe -H $HOSTADDRESS$ -t $_HOSTNRPE_TIMEOUT$ -u $_HOSTNRPE_SSL$ -c $ARG1$",
"enable_environment_macros": false,
"imported_from": "alignak-checks-nrpe",
"name": "check_nrpe",
"poller_tag": "",
"timeout": -1
},
{
"_realm": "All",
"_sub_realm": true,
"alias": "NRPE check with arguments",
"command_line": "$NRPE_PLUGINS_DIR$/check_nrpe -H $HOSTADDRESS$ -t $_HOSTNRPE_TIMEOUT$ -u $_HOSTNRPE_SSL$ -c $ARG1$ -a $ARG2$ $ARG3$ $ARG4$ $ARG5$ $ARG6$ $ARG7$ $ARG8$ $ARG9$",
"enable_environment_macros": false,
"imported_from": "alignak-checks-nrpe",
"name": "check_nrpe_args",
"poller_tag": "",
"timeout": -1
}
]
71 changes: 71 additions & 0 deletions test/json/nrpe/hosts-templates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[
{
"_is_template": true,
"_realm": "All",
"_sub_realm": true,
"_templates_with_services": true,
"active_checks_enabled": true,
"alias": "",
"check_command": "check_nrpe_alive",
"check_command_args": "",
"check_period": "24x7",
"customs": {
"_NRPE_TIMEOUT": 10,
"_NRPE_SSL": "-n"
},
"imported_from": "alignak-checks-nrpe",
"initial_state": "x",
"name": "freebsd-nrpe",
"notes": "",
"notes_url": "",
"tags": [
"nrpe-host", "freebsd"
]
},
{
"_is_template": true,
"_realm": "All",
"_sub_realm": true,
"_templates_with_services": true,
"active_checks_enabled": true,
"alias": "",
"check_command": "check_nrpe_alive",
"check_command_args": "",
"check_period": "24x7",
"customs": {
"_NRPE_TIMEOUT": 10,
"_NRPE_SSL": "-n"
},
"imported_from": "alignak-checks-nrpe",
"initial_state": "x",
"name": "linux-nrpe",
"notes": "",
"notes_url": "",
"tags": [
"nrpe-host", "linux"
]
},
{
"_is_template": true,
"_realm": "All",
"_sub_realm": true,
"_templates_with_services": true,
"active_checks_enabled": true,
"alias": "",
"check_command": "check_nrpe_alive",
"check_command_args": "",
"check_period": "24x7",
"customs": {
"_NRPE_TIMEOUT": 10,
"_NRPE_SSL": "-n"
},
"imported_from": "alignak-checks-nrpe",
"initial_state": "x",
"name": "windows-nrpe",
"notes": "",
"notes_url": "",
"tags": [
"nrpe-host", "windows"
]
}
]
68 changes: 68 additions & 0 deletions test/json/nrpe/services-templates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
[
{
"_is_template": true,
"_realm": "All",
"_sub_realm": true,
"aggregation": "",
"active_checks_enabled": true,
"alias": "",
"check_period": "24x7",
"host": "_dummy",
"imported_from": "alignak-checks-nrpe",
"initial_state": "x",
"name": "freebsd-nrpe-service",
"notes": "",
"notes_url": "",
"tags": [
"nrpe-service"
]
},
{
"_is_template": true,
"_realm": "All",
"_sub_realm": true,
"aggregation": "",
"active_checks_enabled": true,
"alias": "",
"check_period": "24x7",
"host": "_dummy",
"imported_from": "alignak-checks-nrpe",
"initial_state": "x",
"name": "linux-nrpe-service",
"notes": "",
"notes_url": "",
"tags": [
"nrpe-service"
]
},
{
"_is_template": true,
"_realm": "All",
"_sub_realm": true,
"_templates": [
"linux-nrpe-service"
],
"aggregation": "system",
"alias": "NRPE status",
"check_command": "check_nrpe_version",
"check_command_args": "",
"host": "linux-nrpe",
"max_check_attempts": 2,
"name": "Nrpe-status"
},
{
"_is_template": true,
"_realm": "All",
"_sub_realm": true,
"_templates": [
"linux-nrpe-service"
],
"aggregation": "system",
"alias": "NRPE status",
"check_command": "check_nrpe_version",
"check_command_args": "",
"host": "freebsd-nrpe",
"max_check_attempts": 2,
"name": "Nrpe-status"
}
]