2.4. framework module¶
-
class
framework.Filter_by_test_option(filter_file_name, filter_class_name, filter_func_name)¶
-
class
framework.KeepAliveReporter¶ Bases:
objectSingleton object which reports test start to parent process
-
pipe¶
-
send_keep_alive(test)¶ Write current test tmpdir & desc to keep-alive pipe to signal liveness
-
-
class
framework.VppTestCase(methodName='runTest')¶ Bases:
unittest.case.TestCaseThis subclass is a base class for VPP test cases that are implemented as classes. It provides methods to create and run test case.
-
assert_equal(real_value, expected_value, name_or_class=None)¶
-
assert_in_range(real_value, expected_min, expected_max, name=None)¶
-
classmethod
create_loopback_interfaces(interfaces)¶ Create loopback interfaces.
Parameters: interfaces – iterable indexes of the interfaces. Returns: List of created interfaces.
-
classmethod
create_packet_info(src_if, dst_if)¶ Create packet info object containing the source and destination indexes and add it to the testcase’s packet info list
Parameters: - src_if (VppInterface) – source interface
- dst_if (VppInterface) – destination interface
Returns: _PacketInfo object
-
classmethod
create_pg_interfaces(interfaces)¶ Create packet-generator interfaces.
Parameters: interfaces – iterable indexes of the interfaces. Returns: List of created interfaces.
-
static
extend_packet(packet, size)¶ Extend packet to given size by padding with spaces NOTE: Currently works only when Raw layer is present.
Parameters: - packet – packet
- size – target size
-
get_next_packet_info(info)¶ Iterate over the packet info list stored in the testcase Start iteration with first element if info is None Continue based on index in info if info is specified
Parameters: info – info or None Returns: next info in list or None if no more infos
-
get_next_packet_info_for_interface(src_index, info)¶ Search the packet info list for the next packet info with same source interface index
Parameters: - src_index – source interface index to search for
- info – packet info - where to start the search
Returns: packet info or None
-
get_next_packet_info_for_interface2(src_index, dst_index, info)¶ Search the packet info list for the next packet info with same source and destination interface indexes
Parameters: - src_index – source interface index to search for
- dst_index – destination interface index to search for
- info – packet info - where to start the search
Returns: packet info or None
-
classmethod
get_packet_count_for_if_idx(dst_if_index)¶ Get the number of packet info for specified destination if index
-
static
info_to_payload(info)¶ Convert _PacketInfo object to packet payload
Parameters: info – _PacketInfo object Returns: string containing serialized data from packet info
-
classmethod
instance()¶ Return the instance of this testcase
-
packet_infos¶ List of packet infos
-
static
payload_to_info(payload)¶ Convert packet payload to _PacketInfo object
Parameters: payload – packet payload Returns: _PacketInfo object containing de-serialized data from payload
-
classmethod
pg_enable_capture(interfaces)¶ Enable capture on packet-generator interfaces
Parameters: interfaces – iterable interface indexes
-
classmethod
pg_start()¶ Remove any zombie captures and enable the packet generator
-
classmethod
quit()¶ Disconnect vpp-api, kill vpp and cleanup shared memory files
-
classmethod
register_capture(cap_name)¶ Register a capture in the testclass
-
classmethod
reset_packet_infos()¶ Reset the list of packet info objects and packet counts to zero
-
classmethod
run_vpp()¶
-
send_and_assert_no_replies(intf, pkts, remark='')¶
-
send_and_expect(input, pkts, output)¶
-
setUp()¶ Clear trace before running each test
-
classmethod
setUpClass()¶ Perform class setup before running the testcase Remove shared memory files, start vpp and connect the vpp-api
-
classmethod
setUpConstants()¶ Set-up the test case class based on environment variables
-
classmethod
set_debug_flags(d)¶
-
classmethod
sleep(timeout, remark=None)¶
-
tearDown()¶ Show various debug prints after each test
-
classmethod
tearDownClass()¶ Perform final cleanup after running all tests in this test-case
-
classmethod
wait_for_enter()¶
-
-
class
framework.VppTestResult(stream, descriptions, verbosity)¶ Bases:
unittest.result.TestResult- @property result_string
- String variable to store the test case result string.
- @property errors
- List variable containing 2-tuples of TestCase instances and strings holding formatted tracebacks. Each tuple represents a test which raised an unexpected exception.
- @property failures
- List variable containing 2-tuples of TestCase instances and strings holding formatted tracebacks. Each tuple represents a test where a failure was explicitly signalled using the TestCase.assert*() methods.
-
addError(test, err)¶ Record a test error result
Parameters: - test –
- err – error message
-
addFailure(test, err)¶ Record a test failed result
Parameters: - test –
- err – error message
-
addSkip(test, reason)¶ Record a test skipped.
Parameters: - test –
- reason –
-
addSuccess(test)¶ Record a test succeeded result
Parameters: test –
-
getDescription(test)¶ Get test description
Parameters: test – Returns: test description
-
printErrorList(flavour, errors)¶ Print error list to the output stream together with error type and test case description.
Parameters: - flavour – error type
- errors – iterable errors
-
printErrors()¶ Print errors from running the test case
-
send_failure_through_pipe(test)¶
-
startTest(test)¶ Start a test
Parameters: test –
-
stopTest(test)¶ Stop a test
Parameters: test –
-
symlink_failed(test)¶
-
class
framework.VppTestRunner(keep_alive_pipe=None, failed_pipe=None, stream=<open file '<stderr>', mode 'w'>, descriptions=True, verbosity=1, failfast=False, buffer=False, resultclass=None)¶ Bases:
unittest.runner.TextTestRunnerA basic test runner implementation which prints results to standard error.
-
static
filter_tests(tests, filter_cb)¶
-
parse_test_option()¶
-
resultclass¶ Class maintaining the results of the tests
-
run(test)¶ Run the tests
Parameters: test –
-
test_option= 'TEST'¶
-
static
-
framework.pump_output(testclass)¶ pump output from vpp stdout/stderr to proper queues
-
framework.running_extended_tests()¶
-
framework.running_on_centos()¶