|
1 | 1 | """igvm - Shared functions |
2 | 2 |
|
3 | | -Copyright (c) 2020 InnoGames GmbH |
| 3 | +Copyright (c) 2025 InnoGames GmbH |
4 | 4 | """ |
5 | 5 |
|
6 | 6 | from datetime import datetime, timezone |
7 | | -from math import ceil, log |
8 | 7 | from re import match |
9 | | -from time import sleep |
10 | 8 | from shlex import quote |
| 9 | +from time import sleep |
11 | 10 | from typing import Optional |
12 | 11 |
|
13 | 12 | import boto3 |
14 | 13 | from adminapi.dataset import Query |
15 | 14 | from adminapi.exceptions import DatasetError |
16 | | -from adminapi.filters import Any, Not, Regexp |
| 15 | +from adminapi.filters import Any, Regexp |
17 | 16 | from botocore.exceptions import ClientError |
18 | 17 | from libvirt import VIR_DOMAIN_RUNNING |
19 | 18 |
|
20 | | -from igvm.exceptions import IGVMTestError |
21 | 19 | from igvm.hypervisor import Hypervisor |
22 | 20 | from igvm.settings import HYPERVISOR_ATTRIBUTES, AWS_RETURN_CODES |
23 | 21 | from tests import ( |
24 | 22 | IGVM_LOCKED_TIMEOUT, |
25 | 23 | JENKINS_EXECUTOR, |
26 | | - PYTEST_XDIST_WORKER, |
27 | | - PYTEST_XDIST_WORKER_COUNT, |
28 | 24 | VM_HOSTNAME_PATTERN, |
29 | | - VM_NET, |
30 | 25 | ) |
31 | 26 |
|
32 | 27 |
|
@@ -70,14 +65,6 @@ def clean_all(route_network, datacenter_type, vm_hostname=None): |
70 | 65 | # Remove all connected Serveradmin objects. |
71 | 66 | clean_serveradmin({'hostname': Regexp(pattern)}) |
72 | 67 |
|
73 | | - # Try to remove VMs with the same IP in any case because we use custom |
74 | | - # logic to assign them and we want to avoid IP address conflicts. |
75 | | - # Index 1 is usually used for the test's subject VM, |
76 | | - # 2 might be used for testing IP change. |
77 | | - for ip_attr in ('ipv4', 'ipv6'): |
78 | | - ips = [get_next_address(VM_NET, i, ip_attr) for i in [1, 2]] |
79 | | - clean_serveradmin({ip_attr: Any(*ips)}) |
80 | | - |
81 | 68 |
|
82 | 69 | def clean_hv(hv, pattern): |
83 | 70 | # We never know what happened on the HV, so always refresh |
@@ -207,30 +194,3 @@ def _wait_for_state_reached(ec2_client, instance_id: str, state: str, |
207 | 194 | if not any(error in str(e) for error in |
208 | 195 | ['InvalidInstanceID', 'IncorrectInstanceState']): |
209 | 196 | raise |
210 | | - |
211 | | - |
212 | | -def get_next_address(vm_net, index, ip_attr): |
213 | | - non_vm_hosts = list(Query({ |
214 | | - 'project_network': vm_net, |
215 | | - 'servertype': Not('vm'), |
216 | | - }, [ip_attr])) |
217 | | - offset = 1 if len(non_vm_hosts) > 0 else 0 |
218 | | - subnet_levels = ceil(log(PYTEST_XDIST_WORKER_COUNT + offset, 2)) |
219 | | - project_network = Query({'hostname': vm_net}, [ip_attr]).get() |
220 | | - try: |
221 | | - subnets = list(project_network[ip_attr].subnets(subnet_levels)) |
222 | | - except ValueError: |
223 | | - raise IGVMTestError( |
224 | | - 'Can\'t split {} into enough subnets ' |
225 | | - 'for {} parallel tests'.format( |
226 | | - vm_net, PYTEST_XDIST_WORKER_COUNT, |
227 | | - ) |
228 | | - ) |
229 | | - if len(non_vm_hosts) > subnets[0].num_addresses: |
230 | | - raise IGVMTestError( |
231 | | - 'Can\'t split {} into enough subnets ' |
232 | | - 'for {} parallel tests'.format( |
233 | | - vm_net, PYTEST_XDIST_WORKER_COUNT, |
234 | | - ) |
235 | | - ) |
236 | | - return subnets[PYTEST_XDIST_WORKER + 1][index] |
0 commit comments