mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-04-08 17:06:05 +02:00
Wip
This commit is contained in:
parent
5ede7cc984
commit
58ee810541
@ -160,7 +160,8 @@ sub get_session_id {
|
||||
(defined($md5_secret_cache) && $md5_secret_cache ne $md5_secret)
|
||||
) {
|
||||
my $json_request = { username => $self->{api_username}, password => $self->{api_password} };
|
||||
my $encoded = centreon::plugins::misc::json_encode($json_request) or {
|
||||
my $encoded = centreon::plugins::misc::json_encode($json_request);
|
||||
unless($encoded) {
|
||||
$self->{output}->add_option_msg(short_msg => 'cannot encode json request');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
@ -66,7 +66,8 @@ sub manage_selection {
|
||||
'direction' => 'ASCENDING'
|
||||
}
|
||||
};
|
||||
$payload = centreon::plugins::misc::json_encode($payload) or {
|
||||
$payload = centreon::plugins::misc::json_encode($payload);
|
||||
unless($payload) {
|
||||
$self->{output}->add_option_msg(short_msg => 'cannot encode json request');
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
|
@ -109,10 +109,9 @@ sub plan_long_output {
|
||||
sub prefix_plan_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return sprintf(
|
||||
"plan '%s' ",
|
||||
$options{instance_value}->{name}
|
||||
);
|
||||
my $plan_name = defined $options{instance_value}->{name} ? $options{instance_value}->{name} : 'unknown';
|
||||
|
||||
return sprintf("plan '%s' ", $plan_name);
|
||||
}
|
||||
|
||||
sub prefix_global_output {
|
||||
@ -331,7 +330,7 @@ sub manage_selection {
|
||||
$self->{plans} = {};
|
||||
foreach my $plan (@{$plans->{data}}) {
|
||||
# skip plans created by keyword single execution
|
||||
next if ($plan->{visible} =~ /false|0/);
|
||||
next if (defined $plan->{visible} && $plan->{visible} =~ /false|0/);
|
||||
next if (defined($self->{option_results}->{filter_plan_id}) && $self->{option_results}->{filter_plan_id} ne '' &&
|
||||
$plan->{id} !~ /$self->{option_results}->{filter_plan_id}/);
|
||||
next if (defined($self->{option_results}->{filter_plan_name}) && $self->{option_results}->{filter_plan_name} ne '' &&
|
||||
|
1
tests/apps/exense/step/restapi/list-plan.json
Normal file
1
tests/apps/exense/step/restapi/list-plan.json
Normal file
File diff suppressed because one or more lines are too long
163
tests/apps/exense/step/restapi/list-plans.json
Normal file
163
tests/apps/exense/step/restapi/list-plans.json
Normal file
File diff suppressed because one or more lines are too long
36
tests/apps/exense/step/restapi/list-plans.robot
Normal file
36
tests/apps/exense/step/restapi/list-plans.robot
Normal file
@ -0,0 +1,36 @@
|
||||
*** Settings ***
|
||||
|
||||
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
|
||||
|
||||
Suite Setup Start Mockoon ${MOCKOON_JSON}
|
||||
Suite Teardown Stop Mockoon
|
||||
Test Timeout 120s
|
||||
|
||||
|
||||
*** Variables ***
|
||||
${MOCKOON_JSON} ${CURDIR}${/}list-plans.json
|
||||
${HOSTNAME} host.docker.internal
|
||||
${APIPORT} 3001
|
||||
|
||||
${cmd} ${CENTREON_PLUGINS}
|
||||
... --plugin=apps::exense::step::restapi::plugin
|
||||
... --hostname=${HOSTNAME}
|
||||
... --port=${APIPORT}
|
||||
... --proto=http
|
||||
... --timeout=15
|
||||
... --token=token
|
||||
|
||||
|
||||
*** Test Cases ***
|
||||
list-plans ${tc}
|
||||
[Tags] apps
|
||||
${command} Catenate
|
||||
... ${cmd}
|
||||
... --mode=list-plans
|
||||
... ${extraoptions}
|
||||
|
||||
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
|
||||
|
||||
Examples: tc extraoptions expected_result --
|
||||
... 1 ${EMPTY} List plans: [id: 66d1904664e24c6ef10f74d2][name: plop2-test] [id: 669fc855498c2a0322a6a9c5][name: test-plan] [id: 66d180a764e24c6ef10e0155][name: test-plan_Copy]
|
||||
... 2 --tenant-name='[All]' List plans: [id: 66d1904664e24c6ef10f74d2][name: plop2-test] [id: 669fc855498c2a0322a6a9c5][name: test-plan] [id: 66d180a764e24c6ef10e0155][name: test-plan_Copy]
|
1
tests/apps/exense/step/restapi/list-tenants.json
Normal file
1
tests/apps/exense/step/restapi/list-tenants.json
Normal file
@ -0,0 +1 @@
|
||||
{"openapi":"3.0.0","info":{"title":"List tenats","version":"1.0.0"},"servers":[{"url":"http://localhost:3002/"}],"paths":{"/rest/tenants":{"get":{"description":"","responses":{"200":{"description":"","content":{"application/json":{"example":"[\r\n {\r\n \"name\": \"[All]\",\r\n \"global\": true,\r\n \"projectId\": null\r\n },\r\n {\r\n \"name\": \"Common\",\r\n \"global\": false,\r\n \"projectId\": \"669fc509498c2a0322a6a5ad\"\r\n },\r\n {\r\n \"name\": \"test-project\",\r\n \"global\": false,\r\n \"projectId\": \"66d18fc464e24c6ef10f6f02\"\r\n }\r\n]\r\n"}},"headers":{"Access-Control-Allow-Origin":{"schema":{"type":"string"},"example":"*"},"Access-Control-Allow-Methods":{"schema":{"type":"string"},"example":"GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS"},"Access-Control-Allow-Headers":{"schema":{"type":"string"},"example":"Content-Type, Origin, Accept, Authorization, Content-Length, X-Requested-With"},"Authorization":{"schema":{"type":"string"},"example":""}}}}}}}}
|
35
tests/apps/exense/step/restapi/list-tenants.robot
Normal file
35
tests/apps/exense/step/restapi/list-tenants.robot
Normal file
@ -0,0 +1,35 @@
|
||||
*** Settings ***
|
||||
|
||||
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
|
||||
|
||||
Suite Setup Start Mockoon ${MOCKOON_JSON}
|
||||
Suite Teardown Stop Mockoon
|
||||
Test Timeout 120s
|
||||
|
||||
|
||||
*** Variables ***
|
||||
${MOCKOON_JSON} ${CURDIR}${/}list-tenants.json
|
||||
${HOSTNAME} host.docker.internal
|
||||
${APIPORT} 3002
|
||||
|
||||
${cmd} ${CENTREON_PLUGINS}
|
||||
... --plugin=apps::exense::step::restapi::plugin
|
||||
... --hostname=${HOSTNAME}
|
||||
... --port=${APIPORT}
|
||||
... --proto=http
|
||||
... --timeout=15
|
||||
... --token=token
|
||||
|
||||
|
||||
*** Test Cases ***
|
||||
list-tenants ${tc}
|
||||
[Tags] apps
|
||||
${command} Catenate
|
||||
... ${cmd}
|
||||
... --mode=list-tenants
|
||||
... ${extraoptions}
|
||||
|
||||
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
|
||||
|
||||
Examples: tc extraoptions expected_result --
|
||||
... 1 ${EMPTY} List tenants: [name: [All]][projectId: ][global: 1] [name: Common][projectId: 669fc509498c2a0322a6a5ad][global: 0] [name: test-project][projectId: 66d18fc464e24c6ef10f6f02][global: 0]
|
1
tests/apps/exense/step/restapi/plans.json
Normal file
1
tests/apps/exense/step/restapi/plans.json
Normal file
File diff suppressed because one or more lines are too long
43
tests/apps/exense/step/restapi/plans.robot
Normal file
43
tests/apps/exense/step/restapi/plans.robot
Normal file
@ -0,0 +1,43 @@
|
||||
*** Settings ***
|
||||
|
||||
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
|
||||
|
||||
Suite Setup Start Mockoon ${MOCKOON_JSON}
|
||||
Suite Teardown Stop Mockoon
|
||||
Test Timeout 120s
|
||||
|
||||
|
||||
*** Variables ***
|
||||
${MOCKOON_JSON} ${CURDIR}${/}plans.json
|
||||
${HOSTNAME} host.docker.internal
|
||||
${APIPORT} 3000
|
||||
|
||||
${cmd} ${CENTREON_PLUGINS}
|
||||
... --plugin=apps::exense::step::restapi::plugin
|
||||
... --hostname=${HOSTNAME}
|
||||
... --port=${APIPORT}
|
||||
... --proto=http
|
||||
... --timeout=15
|
||||
... --token=token
|
||||
|
||||
|
||||
*** Test Cases ***
|
||||
plans ${tc}
|
||||
[Tags] apps
|
||||
${command} Catenate
|
||||
... ${cmd}
|
||||
... --mode=plans
|
||||
... ${extraoptions}
|
||||
#Log ${cmd}
|
||||
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
|
||||
|
||||
Examples: tc extraoptions expected_result --
|
||||
... 1 ${EMPTY} OK: All plans are ok | 'plans.detected.count'=3;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 'plop2-test#plan.executions.detected.count'=0;;;0; 'plop2-test#plan.executions.failed.percentage'=0.00%;;;0;100
|
||||
... 2 --tenant-name='[All]' OK: All plans are ok | 'plans.detected.count'=3;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 'plop2-test#plan.executions.detected.count'=0;;;0; 'plop2-test#plan.executions.failed.percentage'=0.00%;;;0;100
|
||||
... 3 --critical-plan-execution-status='\\\%{planName} eq NORUN' OK: All plans are ok | 'plans.detected.count'=3;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 'plop2-test#plan.executions.detected.count'=0;;;0; 'plop2-test#plan.executions.failed.percentage'=0.00%;;;0;100
|
||||
... 4 --unknown-plan-execution-status='\\\%{planName} eq plop2-test' OK: All plans are ok | 'plans.detected.count'=3;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 'plop2-test#plan.executions.detected.count'=0;;;0; 'plop2-test#plan.executions.failed.percentage'=0.00%;;;0;100
|
||||
... 5 --warning-plan-execution-status='\\\%{planName} eq test-plan_Copy' OK: All plans are ok | 'plans.detected.count'=3;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 'plop2-test#plan.executions.detected.count'=0;;;0; 'plop2-test#plan.executions.failed.percentage'=0.00%;;;0;100
|
||||
... 6 --status-failed='\\\%{result} =~ /technical_error|failed|interrupted/i' OK: All plans are ok | 'plans.detected.count'=3;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 'plop2-test#plan.executions.detected.count'=0;;;0; 'plop2-test#plan.executions.failed.percentage'=0.00%;;;0;100
|
||||
... 7 --only-last-execution OK: All plans are ok | 'plans.detected.count'=3;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 'plop2-test#plan.executions.detected.count'=0;;;0; 'plop2-test#plan.executions.failed.percentage'=0.00%;;;0;100
|
||||
... 8 --since-timeperiod OK: All plans are ok | 'plans.detected.count'=3;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100 'plop2-test#plan.executions.detected.count'=0;;;0; 'plop2-test#plan.executions.failed.percentage'=0.00%;;;0;100
|
||||
... 9 --filter-plan-name='test-plan' OK: All plans are ok | 'plans.detected.count'=2;;;0; 'test-plan#plan.executions.detected.count'=0;;;0; 'test-plan#plan.executions.failed.percentage'=0.00%;;;0;100 'test-plan_Copy#plan.executions.detected.count'=0;;;0; 'test-plan_Copy#plan.executions.failed.percentage'=0.00%;;;0;100
|
Loading…
x
Reference in New Issue
Block a user