Skip to content

Commit 0da0bd4

Browse files
authored
Merge pull request #76 from cloudscale-ch/denis/update-nested-url
Fix and unifiy all access to custom images
2 parents 6231d20 + 7845f79 commit 0da0bd4

4 files changed

Lines changed: 39 additions & 30 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ These tests are run regularly against our public infrastructure as well as our i
4343
| | [test_frontend_allowed_cidr](./test_load_balancer.py#L737) | default |
4444
| | [test_proxy_protocol](./test_load_balancer.py#L812) | default |
4545
| | [test_ping](./test_load_balancer.py#L855) | default |
46-
| **Nested Virtualization** | [test_virtualization_support](./test_nested_virtualization.py#L13) | default |
47-
| | [test_run_nested_vm](./test_nested_virtualization.py#L39) | default |
46+
| **Nested Virtualization** | [test_virtualization_support](./test_nested_virtualization.py#L14) | default |
47+
| | [test_run_nested_vm](./test_nested_virtualization.py#L40) | default |
4848
| **Private Network** | [test_private_ip_address_on_all_images](./test_private_network.py#L14) | all |
4949
| | [test_private_network_connectivity_on_all_images](./test_private_network.py#L35) | all |
5050
| | [test_multiple_private_network_interfaces](./test_private_network.py#L88) | default |

conftest.py

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from constants import API_URL
1010
from constants import LOCKS_PATH
1111
from constants import RUNNER_ID
12+
from constants import CUSTOM_IMAGE_ALPINE_URL
13+
from constants import CUSTOM_IMAGE_DEBIAN_URL
1214
from datetime import datetime
1315
from datetime import timedelta
1416
from events import trigger
@@ -22,7 +24,6 @@
2224
from resources import Server
2325
from resources import ServerGroup
2426
from resources import Volume
25-
from urllib.parse import urlparse
2627
from util import extract_short_error
2728
from util import global_run_id
2829
from util import in_parallel
@@ -626,47 +627,25 @@ def private_network(create_private_network):
626627
return create_private_network()
627628

628629

629-
@pytest.fixture(scope='session')
630-
def custom_image_prefix():
631-
""" The prefix to use for custom images stored in S3. """
632-
633-
host = urlparse(API_URL).netloc
634-
635-
if host == 'api.cloudscale.ch':
636-
return 'prod'
637-
638-
return host.split('.', 1)[0].split('-')[0]
639-
640-
641630
@pytest.fixture(scope='session', params=['raw', 'qcow2', 'iso'])
642-
def custom_alpine_image(request, upload_custom_image, custom_image_prefix):
631+
def custom_alpine_image(request, upload_custom_image):
643632
""" A session scoped custom Alpine image. """
644633

645-
host = 'https://at-images.objects.lpg.cloudscale.ch'
646-
path = f'{custom_image_prefix}/alpine'
647-
648634
return upload_custom_image(
649635
img_name='Alpine',
650-
img=f'{host}/{path}',
636+
img=CUSTOM_IMAGE_ALPINE_URL,
651637
firmware_type='bios',
652638
fmt=request.param
653639
)
654640

655641

656642
@pytest.fixture(scope='session', params=['raw', 'qcow2'])
657-
def custom_debian_uefi_image(
658-
request,
659-
upload_custom_image,
660-
custom_image_prefix,
661-
):
643+
def custom_debian_uefi_image(request, upload_custom_image):
662644
""" A session scoped custom Debian UEFI image. """
663645

664-
host = 'https://at-images.objects.lpg.cloudscale.ch'
665-
path = f'{custom_image_prefix}/debian'
666-
667646
return upload_custom_image(
668647
img_name='Debian UEFI',
669-
img=f'{host}/{path}',
648+
img=CUSTOM_IMAGE_DEBIAN_URL,
670649
firmware_type='uefi',
671650
fmt=request.param
672651
)

constants.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,35 @@
3030
6: '2001:4860:4860::8888'
3131
}
3232

33+
# Custom images for tests. Each image comes in the following formats (appended
34+
# to the CUSTOM_IMAGE_<IMAGE>_URL variable as extension:
35+
#
36+
# - qcow2
37+
# - raw
38+
# - iso
39+
#
40+
# For example:
41+
#
42+
# https://at-images.objects.lpg.cloudscale.ch/prod/alpine.qcow2
43+
#
44+
# Each format further has the following hash sums, each of which refers to the
45+
# hash that OpenStack sees after import (in the case of qcow2, this is the same
46+
# hash as the raw image, as qcow2 is first converted to raw):
47+
#
48+
# - md5
49+
# - sha256
50+
#
51+
# For exmple:
52+
#
53+
# https://at-images.objects.lpg.cloudscale.ch/prod/alpine.sha256
54+
#
55+
# Note: These images are built for testing and not meant for anything else.
56+
#
57+
CUSTOM_IMAGE_PREFIX = re.search('/(|[a-z]+)-?api', API_URL).group(1) or 'prod'
58+
CUSTOM_IMAGE_BASE = f'https://at-images.objects.lpg.cloudscale.ch'
59+
CUSTOM_IMAGE_ALPINE_URL = f'{CUSTOM_IMAGE_BASE}/{CUSTOM_IMAGE_PREFIX}/alpine'
60+
CUSTOM_IMAGE_DEBIAN_URL = f'{CUSTOM_IMAGE_BASE}/{CUSTOM_IMAGE_PREFIX}/debian'
61+
3362
# Unique id that distinguishes acceptance tests generated resources.
3463
RUNNER_ID_HASH = blake2b(API_TOKEN.encode("utf-8"), digest_size=8).hexdigest()
3564
RUNNER_ID = f'at-{RUNNER_ID_HASH}'

test_nested_virtualization.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
"""
99

10+
from constants import CUSTOM_IMAGE_ALPINE_URL
1011
from util import oneliner
1112

1213

@@ -40,7 +41,7 @@ def test_run_nested_vm(server):
4041
""" Nested virtualization is supported. """
4142

4243
vm_os = 'alpine' # Needs to match one virt os-variant
43-
vm_iso_url = 'https://at-images.objects.lpg.cloudscale.ch/alpine.qcow2'
44+
vm_iso_url = f"{CUSTOM_IMAGE_ALPINE_URL}.qcow2"
4445

4546
# Install the required package
4647
server.run('sudo apt update')

0 commit comments

Comments
 (0)