Skip to content

enh(tools): enhance robot tests generator#6216

Open
omercier wants to merge 3 commits into
developfrom
CTOR-2336-Proposer-un-script-de-g-n-ration-automatique-des-tests-robots
Open

enh(tools): enhance robot tests generator#6216
omercier wants to merge 3 commits into
developfrom
CTOR-2336-Proposer-un-script-de-g-n-ration-automatique-des-tests-robots

Conversation

@omercier

@omercier omercier commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Description

Refs: CTOR-2336

Type of change

  • Patch fixing an issue (non-breaking change)
  • New functionality (non-breaking change)
  • Functionality enhancement or optimization (non-breaking change)
  • Breaking change (patch or feature) that might cause side effects breaking part of the Software

How this pull request can be tested ?

Please describe the procedure to verify that the goal of the PR is matched.
Provide clear instructions so that it can be correctly tested.
Mention the automated tests included in this FOR (what they test like mode/option combinations).

Checklist

  • I have followed the coding style guidelines provided by Centreon
  • I have commented my code, especially hard-to-understand areas of the PR.
  • I have rebased my development branch on the base branch (develop).
  • In case of a new plugin, I have created the new packaging directory accordingly.
  • I have implemented automated tests related to my commits.
    • Data used for automated tests are anonymized.
  • I have reviewed all the help messages in all the .pm files I have modified.
    • All sentences begin with a capital letter.
    • All sentences end with a period.
    • I am able to understand all the help messages, if not, exchange with the PO or TW to rewrite them.
  • After having created the PR, I will make sure that all the tests provided in this PR have run and passed.

@omercier omercier marked this pull request as ready for review June 9, 2026 09:35
@omercier omercier requested review from a team as code owners June 9, 2026 09:35
@omercier omercier requested review from Evan-Adam, paloth, sdepassio, smau-centreon and tom-rt and removed request for a team June 9, 2026 09:35
Comment on lines +196 to +197
# Import constants for counter types and kinds
use centreon::plugins::constants qw(:counter_types :counter_kinds);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Import constants for counter types and kinds
use centreon::plugins::constants qw(:counter_types :counter_kinds);
# Import constants for counter types, kinds and skipped values
use centreon::plugins::constants qw(:counters :values);

Comment on lines 198 to 199
# We will have to process some JSON, no need to reinvent the wheel, load the lib you installed in a previous section
use JSON::XS;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# We will have to process some JSON, no need to reinvent the wheel, load the lib you installed in a previous section
use JSON::XS;
# We need to process some JSON. No need to reinvent the wheel:
# use the available functions provided by misc.pm, such as
# json_encode() and json_decode().
use centreon::plugins::misc qw/json_encode json_decode/;

# Needed libraries
use strict;
use warnings;
use centreon::plugins::constants qw(:counter_types);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use centreon::plugins::constants qw(:counter_types);
use centreon::plugins::constants qw(:counters);

```perl
use centreon::plugins::constants qw(:counter_types);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use centreon::plugins::constants qw(:counter_types);
use centreon::plugins::constants qw(:counters);


use strict;
use warnings;
use centreon::plugins::constants qw(:counter_types);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use centreon::plugins::constants qw(:counter_types);
use centreon::plugins::constants qw(:counters);


use strict;
use warnings;
use centreon::plugins::constants qw(:counter_types);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use centreon::plugins::constants qw(:counter_types);
use centreon::plugins::constants qw(:counters);


use strict;
use warnings;
use centreon::plugins::constants qw(:counter_types);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use centreon::plugins::constants qw(:counter_types);
use centreon::plugins::constants qw(:counters);

```skipped_code => { -2 => 1, -10 => 1 }```
This is much more understandable this way:
```skipped_code => { NOT_PROCESSED() => 1, NO_VALUE() => 1 }```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Use the short_msg parameter of option_exit
When you need to display an error message and exit the plugin, it is simpler to use a single `option_exit` call rather than calling `add_opton_msg` followed by `option_exit`.
For example:
$self->{output}->option_exit(short_msg => "Cannot encode JSON result");
Instead of:
$self->{output}->add_option_msg(short_msg => "Cannot encode JSON result");
$self->{output}->option_exit();
### Use the functions provided by Misc.pm
In general, before implementing something from scratch, check whether an existing function in [centreon/plugins/misc.pm](../../../src/centreon/plugins/misc.pm) already provides the required functionality.
Please refer to the [misc.pm](../../../src/centreon/plugins/misc.pm) documentation for the list of available functions and examples of their usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants