-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add scenario with mixed livestatus / http sources
- Loading branch information
Showing
10 changed files
with
219 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
600-scenarios.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include ../_common/Makefile.common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
site: | ||
build: omd/ | ||
ports: | ||
- "127.0.0.3:60080:80" | ||
- "127.0.0.3:60443:443" | ||
- "127.0.0.3:60557:6557" | ||
volumes: | ||
- ../../../:/thruk:ro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM consol/omd-labs-centos:latest | ||
|
||
COPY playbook.yml /root/ansible_dropin/ | ||
ENV ANSIBLE_ROLES_PATH /thruk/t/scenarios/_common/ansible/roles | ||
COPY test.cfg /root/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
- hosts: all | ||
roles: | ||
- role: common | ||
- role: thruk_developer | ||
- role: test-config-generator | ||
tasks: | ||
- shell: omd config demo set APACHE_MODE own | ||
- shell: omd config demo set CORE naemon | ||
- shell: omd config demo set LIVESTATUS_TCP on | ||
- copy: | ||
src: /omd/sites/demo/share/doc/naemon/example.cfg | ||
dest: /omd/sites/demo/etc/naemon/conf.d/example.cfg | ||
owner: demo | ||
group: demo | ||
- shell: echo "testkey" > /omd/sites/demo/var/thruk/secret.key | ||
- file: | ||
path: /omd/sites/demo/var/thruk/secret.key | ||
mode: 0600 | ||
owner: demo | ||
group: demo | ||
- copy: | ||
src: /root/test.cfg | ||
dest: /omd/sites/demo/etc/naemon/conf.d/test.cfg | ||
owner: demo | ||
group: demo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
define servicegroup { | ||
servicegroup_name Http Check | ||
alias Http Checks | ||
members localhost,Http | ||
} | ||
|
||
define hostgroup { | ||
hostgroup_name Everything | ||
alias Just all hosts | ||
members * | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
use warnings; | ||
use strict; | ||
use Cpanel::JSON::XS qw/decode_json/; | ||
use Test::More; | ||
|
||
BEGIN { | ||
plan tests => 246; | ||
|
||
use lib('t'); | ||
require TestUtils; | ||
import TestUtils; | ||
} | ||
|
||
use_ok 'Thruk::Controller::rest_v1'; | ||
TestUtils::set_test_user_token(); | ||
my($host,$service) = ('localhost', 'Users'); | ||
my($hostgroup,$servicegroup) = ('Everything', 'Http Check'); | ||
|
||
my $pages = [{ | ||
# force reschedule so we get some performance data | ||
url => 'POST /hosts/<name>/cmd/schedule_forced_host_check', | ||
post => { start_time => 'now' }, | ||
like => ['Command successfully submitted'], | ||
}, { | ||
url => 'GET /hosts/<name>', | ||
waitfor => 'rta_unit', | ||
}, { | ||
url => 'GET /hosts/<name>', | ||
like => ['"rta_unit" : "ms",', '"rta" : "\d+\.\d+', ''], | ||
}, { | ||
# verify configuration from config tool | ||
url => 'GET /hosts/<name>/config', | ||
like => ['"alias" : "localhost",', '"address" : "127.0.0.1",', '/omd/sites/demo/etc/naemon/conf.d/example.cfg:1'], | ||
}, { | ||
url => 'GET /hostgroups/'.$hostgroup.'/config', | ||
like => ['Just all hosts'], | ||
}, { | ||
url => 'GET /servicegroups/'.$servicegroup.'/config', | ||
like => ['Http Checks'], | ||
}, { | ||
# change a few things | ||
url => 'PATCH /hosts/<name>/config', | ||
post => {address => '127.0.0.2', max_check_attempts => 5, icon_image => undef }, | ||
like => ['changed 1 objects successfully.'], | ||
}, { | ||
url => 'GET /hosts/<name>/config', | ||
like => ['"alias" : "localhost",', '"address" : "127.0.0.2",', '/omd/sites/demo/etc/naemon/conf.d/example.cfg:1'], | ||
unlike => ['icon_image'], | ||
}, { | ||
url => 'GET /config/diff', | ||
like => ['/omd/sites/demo/etc/naemon/conf.d/example.cfg', 'max_check_attempts'], | ||
}, { | ||
url => 'POST /config/check', | ||
post => {}, | ||
like => ['"failed" : false,', 'Running configuration check'], | ||
}, { | ||
url => 'POST /config/save', | ||
post => {}, | ||
like => ['successfully saved changes for 1 site.'], | ||
}, { | ||
url => 'POST /config/reload', | ||
post => {}, | ||
like => ['"failed" : false'], | ||
}, { | ||
url => 'GET /hosts/<name>/config', | ||
like => ['"alias" : "localhost",', '"address" : "127.0.0.2",', '/omd/sites/demo/etc/naemon/conf.d/example.cfg:1'], | ||
unlike => ['icon_image'], | ||
}, { | ||
url => 'GET /hosts/<name>', | ||
like => ['"alias" : "localhost",', '"address" : "127.0.0.2",'], | ||
}, { | ||
# try reverting changes | ||
url => 'PATCH /hosts/<name>/config', | ||
post => {address => '127.0.0.1', max_check_attempts => undef, icon_image => "linux40.png" }, | ||
like => ['changed 1 objects successfully.'], | ||
}, { | ||
url => 'GET /config/diff', | ||
like => ['/omd/sites/demo/etc/naemon/conf.d/example.cfg', 'linux40.png'], | ||
}, { | ||
url => 'POST /config/revert', | ||
post => {}, | ||
like => ['successfully reverted stashed changes for 1 site.'], | ||
}, { | ||
# try deleting things | ||
url => 'DELETE /hosts/<name>/config', | ||
post => {}, | ||
like => ['removed 1 objects successfully.'], | ||
}, { | ||
url => 'GET /config/diff', | ||
like => ['/omd/sites/demo/etc/naemon/conf.d/example.cfg', '-\s*alias'], | ||
}, { | ||
url => 'POST /config/revert', | ||
post => {}, | ||
like => ['successfully reverted stashed changes for 1 site.'], | ||
}, { | ||
# finally revert host back to start | ||
url => 'PATCH /hosts/<name>/config', | ||
post => {address => '127.0.0.1', max_check_attempts => undef, icon_image => "linux40.png" }, | ||
like => ['changed 1 objects successfully.'], | ||
}, { | ||
url => 'POST /config/save', | ||
post => {}, | ||
like => ['successfully saved changes for 1 site.'], | ||
}, { | ||
url => 'POST /config/reload', | ||
post => {}, | ||
like => ['"failed" : false'], | ||
}, { | ||
url => 'GET /hosts/<name>/config', | ||
like => ['"alias" : "localhost",', '"address" : "127.0.0.1",', '/omd/sites/demo/etc/naemon/conf.d/example.cfg:1', 'linux40.png'], | ||
}, { | ||
url => 'GET /config/files', | ||
like => ['/etc/naemon/conf.d/example.cfg', '/etc/naemon/conf.d/test.cfg'], | ||
}, { | ||
url => 'GET /config/objects', | ||
like => ['/etc/naemon/conf.d/example.cfg', '/etc/naemon/conf.d/test.cfg'], | ||
}, { | ||
url => 'GET /config/fullobjects', | ||
like => ['/etc/naemon/conf.d/example.cfg', '/etc/naemon/conf.d/test.cfg', ':TEMPLATES'], | ||
}, { | ||
# create new host | ||
url => 'POST /config/objects', | ||
post => {':TYPE' => 'host', ':FILE' => '301-test.cfg', 'name' => '301-test'}, | ||
like => ['created 1 objects successfully.', '301-test.cfg'], | ||
}, { | ||
url => 'POST /config/revert', | ||
post => {}, | ||
like => ['successfully reverted stashed changes for 1 site.'], | ||
}, | ||
]; | ||
|
||
for my $test (@{$pages}) { | ||
my($method, $url) = split(/\s+/mx, $test->{'url'}, 2); | ||
$url =~ s%/hosts?/<name>%/hosts/$host%gmx; | ||
$test->{'url'} = '/thruk/r'.$url; | ||
$test->{'method'} = $method; | ||
$test->{'content_type'} = 'application/json; charset=utf-8'; | ||
my $page = TestUtils::test_page(%{$test}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../thruk.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Component Thruk::Backend> | ||
<peer> | ||
name = naemon | ||
id = abcd | ||
type = livestatus | ||
<options> | ||
peer = 127.0.0.3:60557 | ||
peer = http://127.0.0.3:60080/demo | ||
auth = testkey | ||
</options> | ||
</peer> | ||
</Component> | ||
|
||
#use_lmd_core=1 | ||
#lmd_core_bin=lmd | ||
#lmd_core_config=t/scenarios/backend_mixed_source/lmd.ini |