summaryrefslogtreecommitdiff
path: root/tests/integration_tests/__init__.py
diff options
context:
space:
mode:
authorDaniel Watkins <oddbloke@ubuntu.com>2021-02-18 11:17:26 -0500
committerGitHub <noreply@github.com>2021-02-18 11:17:26 -0500
commit5a9008e53d7cf987b5cfb78964d2bd987d180993 (patch)
tree91227d5a71d103500b2b8bc4f4bba12739ba5fdb /tests/integration_tests/__init__.py
parent6056ccd4d4a8a1a314ab8cd6d2bebdf8ae39b35c (diff)
downloadvyos-cloud-init-5a9008e53d7cf987b5cfb78964d2bd987d180993.tar.gz
vyos-cloud-init-5a9008e53d7cf987b5cfb78964d2bd987d180993.zip
integration_tests: use unique MAC addresses for tests (#813)
Using the same MAC address results in strange test behaviour if more than one such instance is up: traffic gets routed to an arbitrary interface with the given MAC address. This can happen if running tests in parallel, or on a system which retains test instances from previous runs. The introduction of tests/integration_tests/__init__.py means that pylint now checks the integration tests: this commit also addresses those failures.
Diffstat (limited to 'tests/integration_tests/__init__.py')
-rw-r--r--tests/integration_tests/__init__.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/integration_tests/__init__.py b/tests/integration_tests/__init__.py
new file mode 100644
index 00000000..e1d4cd28
--- /dev/null
+++ b/tests/integration_tests/__init__.py
@@ -0,0 +1,12 @@
+import random
+
+
+def random_mac_address() -> str:
+ """Generate a random MAC address.
+
+ The MAC address will have a 1 in its least significant bit, indicating it
+ to be a locally administered address.
+ """
+ return "02:00:00:%02x:%02x:%02x" % (random.randint(0, 255),
+ random.randint(0, 255),
+ random.randint(0, 255))