2.6. framework module¶
- class framework.BoolEnvironmentVariable(env_var_name, default='n', true_values=None)¶
Bases:
object
- class framework.CPUInterface¶
Bases:
abc.ABC- classmethod assign_cpus(cpus)¶
- cpus = []¶
- abstract classmethod get_cpus_required()¶
- skipped_due_to_cpu_lack = False¶
- class framework.KeepAliveReporter¶
Bases:
objectSingleton object which reports test start to parent process
- property pipe¶
- send_keep_alive(test, desc=None)¶
Write current test tmpdir & desc to keep-alive pipe to signal liveness
- class framework.TestCaseInfo(logger, tempdir, vpp_pid, vpp_bin_path)¶
Bases:
object
- class framework.TestCaseTag(value)¶
Bases:
enum.EnumAn enumeration.
- FIXME_VPP_WORKERS = 2¶
- RUN_SOLO = 1¶
- exception framework.VppDiedError(rv=None, testcase=None, method_name=None)¶
Bases:
Exceptionexception for reporting that the subprocess has died.
- signals_by_value = {Signals.SIGHUP: 'SIGHUP', Signals.SIGINT: 'SIGINT', Signals.SIGQUIT: 'SIGQUIT', Signals.SIGILL: 'SIGILL', Signals.SIGTRAP: 'SIGTRAP', Signals.SIGABRT: 'SIGABRT', Signals.SIGBUS: 'SIGBUS', Signals.SIGFPE: 'SIGFPE', Signals.SIGKILL: 'SIGKILL', Signals.SIGUSR1: 'SIGUSR1', Signals.SIGSEGV: 'SIGSEGV', Signals.SIGUSR2: 'SIGUSR2', Signals.SIGPIPE: 'SIGPIPE', Signals.SIGALRM: 'SIGALRM', Signals.SIGTERM: 'SIGTERM', Signals.SIGCHLD: 'SIGCHLD', Signals.SIGCONT: 'SIGCONT', Signals.SIGSTOP: 'SIGSTOP', Signals.SIGTSTP: 'SIGTSTP', Signals.SIGTTIN: 'SIGTTIN', Signals.SIGTTOU: 'SIGTTOU', Signals.SIGURG: 'SIGURG', Signals.SIGXCPU: 'SIGXCPU', Signals.SIGXFSZ: 'SIGXFSZ', Signals.SIGVTALRM: 'SIGVTALRM', Signals.SIGPROF: 'SIGPROF', Signals.SIGWINCH: 'SIGWINCH', Signals.SIGIO: 'SIGPOLL', Signals.SIGPWR: 'SIGPWR', Signals.SIGSYS: 'SIGSYS', Signals.SIGRTMIN: 'SIGRTMIN', Signals.SIGRTMAX: 'SIGRTMAX'}¶
- class framework.VppTestCase(methodName='runTest')¶
Bases:
framework.CPUInterface,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_checksum_valid(received_packet, layer, field_name='chksum', ignore_zero_checksum=False)¶
Check checksum of received packet on given layer
- assert_embedded_icmp_checksum_valid(received_packet)¶
- assert_equal(real_value, expected_value, name_or_class=None)¶
- assert_error_counter_equal(counter, expected_value)¶
- assert_icmp_checksum_valid(received_packet)¶
- assert_icmpv6_checksum_valid(pkt)¶
- assert_in_range(real_value, expected_min, expected_max, name=None)¶
- assert_ip_checksum_valid(received_packet, ignore_zero_checksum=False)¶
- assert_packet_checksums_valid(packet, ignore_zero_udp_checksums=True)¶
- assert_packet_counter_equal(counter, expected_value)¶
- assert_tcp_checksum_valid(received_packet, ignore_zero_checksum=False)¶
- assert_udp_checksum_valid(received_packet, ignore_zero_checksum=True)¶
- classmethod attach_vpp()¶
- classmethod create_bvi_interfaces(count)¶
Create BVI interfaces.
- Parameters
count – number of interfaces created.
- Returns
List of created interfaces.
- classmethod create_loopback_interfaces(count)¶
Create loopback interfaces.
- Parameters
count – number of interfaces created.
- 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_ethernet_interfaces(interfaces, gso=0, gso_size=0)¶
- classmethod create_pg_interfaces(interfaces, gso=0, gso_size=0)¶
- classmethod create_pg_interfaces_internal(interfaces, gso=0, gso_size=0, mode=None)¶
Create packet-generator interfaces.
- Parameters
interfaces – iterable indexes of the interfaces.
- Returns
List of created interfaces.
- classmethod create_pg_ip4_interfaces(interfaces, gso=0, gso_size=0)¶
- classmethod create_pg_ip6_interfaces(interfaces, gso=0, gso_size=0)¶
- static extend_packet(packet, size, padding=' ')¶
Extend packet to given size by padding with spaces or custom padding NOTE: Currently works only when Raw layer is present.
- Parameters
packet – packet
size – target size
padding – padding used to extend the payload
- extra_vpp_plugin_config = []¶
- extra_vpp_punt_config = []¶
- extra_vpp_statseg_config = ''¶
- classmethod get_api_segment_prefix()¶
- classmethod get_api_sock_path()¶
- classmethod get_cpus_required()¶
- 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
- get_packet_counter(counter)¶
- classmethod get_stats_sock_path()¶
- classmethod get_tempdir()¶
- classmethod get_vpp_time()¶
- classmethod get_vpp_worker_count()¶
- classmethod has_tag(tag)¶
if the test case has a given tag - return true
- 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
- classmethod is_tagged_run_solo()¶
if the test case class is timing-sensitive - return true
- logger = <Logger VppTestCase (WARNING)>¶
- property packet_infos¶
List of packet infos
- static payload_to_info(payload, payload_field='load')¶
Convert packet payload to _PacketInfo object
- Parameters
payload (<class 'scapy.packet.Raw'>) – packet payload
payload_field (str) – packet fieldname of payload “load” for <class ‘scapy.packet.Raw’>
- Returns
_PacketInfo object containing de-serialized data from payload
- classmethod pg_enable_capture(interfaces=None)¶
Enable capture on packet-generator interfaces
- Parameters
interfaces – iterable interface indexes (if None, use self.pg_interfaces)
- pg_send(intf, pkts, worker=None, trace=True)¶
- classmethod pg_start(trace=True)¶
Enable the PG, wait till it is done, then clean up
- classmethod quit()¶
Disconnect vpp-api, kill vpp and cleanup shared memory files
- classmethod register_pcap(intf, worker)¶
Register a pcap 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='', timeout=None)¶
- send_and_expect(intf, pkts, output, n_rx=None, worker=None, trace=True)¶
- send_and_expect_only(intf, pkts, output, timeout=None)¶
- 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)¶
- show_commands_at_teardown()¶
Allow subclass specific teardown logging additions.
- classmethod sleep(timeout, remark=None)¶
- classmethod sleep_on_vpp_time(sec)¶
Sleep according to time in VPP world
- tearDown()¶
Show various debug prints after each test
- classmethod tearDownClass()¶
Perform final cleanup after running all tests in this test-case
- vapi_response_timeout = 5¶
- classmethod wait_for_coredump()¶
- classmethod wait_for_enter()¶
- class framework.VppTestResult(stream=None, descriptions=None, verbosity=None, runner=None)¶
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 –
- add_error(test, err, unittest_fn, error_type)¶
- core_crash_test_cases_info = {}¶
- current_test_case_info = None¶
- failed_test_cases_info = {}¶
- getDescription(test)¶
Get test description
- Parameters
test –
- Returns
test description
- log_error(test, err, fn_name)¶
- 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_result_through_pipe(test, result)¶
- startTest(test)¶
Start a test
- Parameters
test –
- stopTest(test)¶
Called when the given test has been run
- Parameters
test –
- symlink_failed()¶
- class framework.VppTestRunner(keep_alive_pipe=None, descriptions=True, verbosity=1, result_pipe=None, failfast=False, buffer=False, resultclass=None, print_summary=True, **kwargs)¶
Bases:
unittest.runner.TextTestRunnerA basic test runner implementation which prints results to standard error.
- property resultclass¶
Class maintaining the results of the tests
- run(test)¶
Run the tests
- Parameters
test –
- class framework.Worker(executable_args, logger, env=None, *args, **kwargs)¶
Bases:
threading.Thread- run()¶
Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
- wait_for_enter()¶
- framework.create_tag_decorator(e)¶
- framework.get_environ_vpp_worker_count()¶
- framework.get_test_description(descriptions, test)¶
- framework.get_testcase_doc_name(test)¶
- framework.pump_output(testclass)¶
pump output from vpp stdout/stderr to proper queues
- framework.tag_fixme_vpp_workers(cls)¶
- framework.tag_run_solo(cls)¶