Skip to content

Commit

Permalink
Shuffle virtual IPs for VMs in runtest.py
Browse files Browse the repository at this point in the history
This somewhat reduces risk of two simultaneously booted HA VMs
trying to get the same virtual IP as well as reducing the impact
of an AD test run failing to properly clean up after itself.
  • Loading branch information
anodos325 committed Aug 5, 2024
1 parent 760679e commit 10e9239
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/runtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from sys import argv, exit
import os
import getopt
import random
import socket
import sys
import secrets
Expand Down Expand Up @@ -206,7 +207,12 @@ def get_ipinfo(ip_to_use):
elif os.environ.get('virtual_ip'):
vip = os.environ['virtual_ip']
else:
for i in ip_interface(f'{ip}/{netmask}').network:
# reduce risk of trying to assign same VIP to two VMs
# starting at roughly the same time
vip_pool = list(ip_interface(f'{ip}/{netmask}').network)
random.shuffle(vip_pool)

for i in vip_pool:
last_octet = int(i.compressed.split('.')[-1])
if last_octet < 15 or last_octet >= 250:
# addresses like *.255, *.0 and any of them that
Expand Down

0 comments on commit 10e9239

Please sign in to comment.