Live tests code documentation¶
-
class
pierky.arouteserver.tests.live_tests.instances.
BGPSpeakerInstance
(name, ip, mount=[], **kwargs)¶ This class abstracts a BGP speaker instance.
Currently, the
start
,stop
,is_running
andrun_cmd
methods inherited from BaseInstance are implemented by theDockerInstance
andKVMInstance
derived classes, while therestart
,reload_config
,get_bgp_session
,get_routes
andlog_contains
methods by the [Docker|KVM]Instance-derivedBIRDInstance
andOpenBGPDInstance
classes.-
bgp_session_is_up
(other_inst, force_update=False)¶ Check if a BGP session with
other_inst
is up.Parameters: - other_inst – the
BGPSpeakerInstance
instance that the current instance is expected to have a running BGP session with. - force_update (bool) – if True, the instance must bypass any caching mechanism used to keep the BGP sessions status.
Returns: True if the current instance has a running BGP session with
other_inst
; False otherwise.- other_inst – the
-
clear_cached_routes
()¶ Clear any internal cache where routes may be stored.
-
get_bgp_session
(other_inst, force_update=False)¶ Get information about the BGP session with
other_inst
.Parameters: - other_inst – the
BGPSpeakerInstance
instance that the current instance is expected to have a running BGP session with. - force_update (bool) – if True, the instance must bypass any caching mechanism used to keep the BGP sessions status.
Returns: None if the BGP session is not found, otherwise a dictionary containing information about the BGP session:
- ”ip”: “neighbor IP address”,
- ”is_up”: [True|False]
- other_inst – the
-
get_routes
(prefix, include_filtered=False, only_best=False)¶ Get a list of all the known routes for
prefix
.Parameters: - prefix (str) – the IP prefix that returned routes must match. If None, all the routes are returned.
- include_filtered (bool) – include filtered routes / rejected prefixes in the result.
- only_best (bool) – include only the best route toward
prefix
.
Returns: list of
Route
objects.
-
log_contains
(s)¶ Verifies if the BGP speaker’s logs contain the expected message.
Parameters: s (str) – the message that is expected to be found in the BGP speaker’s logs. Returns: True or False if the message is found or not.
-
log_contains_errors
(allowed_errors=[], list_errors=False)¶ Returns True if the BGP speaker’s log contains warning/errors.
Parameters: - allowed_errors (list) – list of strings representing errors that are allowed to be found within the BGP speaker’s log.
- list_errors (bool) – when set to True, the functions returns a touple (errors_found, list_of_errors).
Returns: True of False if error messages or warnings are found within the BGP speaker’s logs. When
list_errors
is True, a touple (bool, str).Return type: When
list_errors
is False
-
-
exception
pierky.arouteserver.tests.live_tests.instances.
InstanceError
¶
-
exception
pierky.arouteserver.tests.live_tests.instances.
InstanceNotRunning
(name, *args, **kwargs)¶
-
class
pierky.arouteserver.tests.live_tests.instances.
Route
(prefix, **kwargs)¶ Details about a route.
-
prefix
¶ the IPv4/IPv6 prefix.
Type: str
-
via
¶ the IP address of the peer from which the route has been received.
Type: str
-
as_path
¶ the AS_PATH attribute of the route, in the “<asn> <asn> <asn>…” format (example: “1 2 345”).
Type: str
-
next_hop
¶ the NEXT_HOP attribute of the route.
Type: str
-
filtered
¶ True if the route has been rejected/filtered.
Type: bool
-
std_comms
¶ list of standard BGP communities (strings in the “x:y” format).
Type: list
-
lrg_comms
¶ list of large BGP communities (strings in the “x:y:z” format).
Type: list
-
ext_comms
¶ list of extended BGP communities (strings in the “[rt|ro]:x:y” format).
Type: list
-
localpref
¶ local-pref.
Type: int
-
otc
¶ the OTC (Only To Customer) attribute, if present.
Type: int
-
reject_reasons
¶ list of integers that identify the reasons for which the route is considered to be rejected.
Type: list
-
-
class
pierky.arouteserver.tests.live_tests.bird.
BIRD2Instance
(*args, **kwargs)¶
-
class
pierky.arouteserver.tests.live_tests.bird.
BIRD3Instance
(*args, **kwargs)¶
-
class
pierky.arouteserver.tests.live_tests.bird.
BIRDInstance
(*args, **kwargs)¶ This class implements BIRD-specific methods.
This class is derived from
DockerInstance
, that implements some Docker-specific methods to start/stop the instance and to run commands on it.-
clear_cached_routes
()¶ Clear any internal cache where routes may be stored.
-
get_bgp_session
(other_inst_or_ip, force_update=False)¶ Get information about the BGP session with
other_inst
.Parameters: - other_inst – the
BGPSpeakerInstance
instance that the current instance is expected to have a running BGP session with. - force_update (bool) – if True, the instance must bypass any caching mechanism used to keep the BGP sessions status.
Returns: None if the BGP session is not found, otherwise a dictionary containing information about the BGP session:
- ”ip”: “neighbor IP address”,
- ”is_up”: [True|False]
- other_inst – the
-
get_routes
(prefix, include_filtered=False, only_best=False)¶ Get a list of all the known routes for
prefix
.Parameters: - prefix (str) – the IP prefix that returned routes must match. If None, all the routes are returned.
- include_filtered (bool) – include filtered routes / rejected prefixes in the result.
- only_best (bool) – include only the best route toward
prefix
.
Returns: list of
Route
objects.
-
log_contains
(s)¶ Verifies if the BGP speaker’s logs contain the expected message.
Parameters: s (str) – the message that is expected to be found in the BGP speaker’s logs. Returns: True or False if the message is found or not.
-
log_contains_errors
(allowed_errors=[], list_errors=False)¶ Returns True if the BGP speaker’s log contains warning/errors.
Parameters: - allowed_errors (list) – list of strings representing errors that are allowed to be found within the BGP speaker’s log.
- list_errors (bool) – when set to True, the functions returns a touple (errors_found, list_of_errors).
Returns: True of False if error messages or warnings are found within the BGP speaker’s logs. When
list_errors
is True, a touple (bool, str).Return type: When
list_errors
is False
-
reload_config
()¶ Reload BIRD configuration.
It runs the “[birdcl/birdcl6] configure” command to reload BIRD’s configuration.
-
restart
()¶ Restart BIRD.
It runs the “[birdcl/birdcl6] configure” and “restart all” commands.
-
-
class
pierky.arouteserver.tests.live_tests.bird.
BIRDInstanceIPv4
(*args, **kwargs)¶
-
class
pierky.arouteserver.tests.live_tests.bird.
BIRDInstanceIPv6
(*args, **kwargs)¶