forked from aparnachaudhary/nagios-plugin-jbossas7
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_check_wildfly_status.py
57 lines (41 loc) · 1.3 KB
/
test_check_wildfly_status.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python
import check_wildfly as wf
import requests_mock
import pytest
BASE_URL = 'http://localhost:9990/management'
def before():
wf.CONFIG['mode'] = 'standalone'
@pytest.fixture()
def requests():
mocker = requests_mock.Mocker()
mocker.start()
yield mocker
mocker.stop()
def test_check_status_ok(requests):
requests.get(BASE_URL,
text='"running"')
result = wf.check_server_status()
assert result == 0
def test_check_status_warning_on_restart(requests):
requests.get(BASE_URL,
text='"restart-required"')
result = wf.check_server_status()
assert result == 1
def test_check_status_warning_on_reload_required(requests):
requests.get(BASE_URL,
text='"reload-required"')
result = wf.check_server_status()
assert result == 1
def test_check_status_critical(requests):
requests.get(BASE_URL,
text='"stopped"')
result = wf.check_server_status()
assert result == 2
def test_check_status_with_domain(requests):
wf.CONFIG['mode'] = 'domain'
wf.CONFIG['node'] = 'master'
wf.CONFIG['instance'] = 'server-one'
requests.get(BASE_URL + '/host/master/server/server-one',
text='"running"')
result = wf.check_server_status()
assert result == 0