Table of Contents |
---|
...
Example of how to create a unit test:
Run the command from the parent directory of directory which the ind files are located: indeni-knowledge/parsers/src/checkpoint/firewall/interface-fake-tx-hang (separated to different lines for clarity of reading)):
Code Block |
---|
/indeni-knowledge/parsers/src/checkpoint/firewall $ command-runner test create indeni-knowledge/parsers/src/checkpoint/firewall/cphaprob-state-vsx/cphaprob-state-vsx../interface-fake-tx-hang/interface-fake-tx-hang.ind.yaml just_a_meaningful_test_name indeni-knowledge/parsers/test/checkpoint/firewall/cphaprob-state-vsx/2_VS-one-with-3-digits-in-each-ip-quad/input_0_0 2018-12-28 09:36:05,031 INFO0 input.txt 2020-04-21 15:32:00,689 INFO -- Starting command runner 20182020-1204-2821 0915:3632:0601,007134 INFO -- Preparing test case 'just_a_meaningful_test_name0' for command 'cphaprob-state-vsx.ind' 2018-12-28 09:36:08,740 INFO../interface-fake-tx-hang/interface-fake-tx-hang.ind.yaml' 2020-04-21 15:32:03,170 INFO -- Successfully prepared test case 20182020-1204-2821 0915:3632:0803,741171 INFO -- Exiting |
Parameters:
...
-- Exiting |
Parameters:
File name | Description |
---|---|
indeni-knowledge/parsers/src/checkpoint/firewall/cphaprobinterface-fake-statetx-vsx/2_VS-one-with-3-digits-in-each-ip-quad/input_0_0hang/interface-fake-tx-hang.ind.yaml | The script we're creating the test for |
0 | The name of the test |
input.txt | The path to an input file which contains input test data for the test |
...
- Test name can be anything - choose descriptive name
- Input file: a file that is being created manually and contains the output data from a command on a device that your script would execute.
e.g, the cphaprobinterface-fake-statetx-vsxhang.ind script runs the cphaprob-state .yaml script runs some grep command command against Check Point Clustered Virtual firewalls, so the input file for the test would contain the output from running cphaprob state on running the same grep command on a Check Point Clustered virtual firewalldevice.
The command above will create a new test in /indeni-knowledge/parsers/test/checkpoint/firewall/cphaprob-state-vsx/.
e.g. it creates the test in a directory with the same path as the .ind script, only under /test instead of /src, AND under a directory 'named after' the script - see thisall the files under the corresponding test folder. See here for example. - You need to run the command including the 2 dots before the forward slash (../), otherwise the command may fail.
- The device from which you got you test input has an OS or model version. Add that version number to the end of your test case name. E.g., if the test input data was gathered from a Check Point gateway running GAIA OS version R80.20, your test name would be "my_test_which_tests_this_thing_R8020". Use all capitals. No dots, hyphens, or underscores, etc.
This is not mandatory, if you do not have too many cases to test, use the name 0. - Your tests should cover every possible path through the code.
- Each test should test a different path in the code.
- After your script has been running in production, if someone finds a bug in it, before you fix the bug, it is good practice to first create a test case which reproduces the bug: then, when the test passes, you know for sure that the bug is fixed.
...
2. If you run into this error message "No such variable 'api-key' in '/api?type=op&cmd=<show><ntp></ntp></show>&key=${api-key}' " in the logs, replace {api-key} with {credentials.api-key}