Skip to content

Commit af37556

Browse files
committed
linstor tests: use the small marvin-alpine guest template when registered
Add get_guest_template() to linstor_test_utils and use it in the volume, encrypted-snapshot and incremental-snapshot tests. It picks the purpose-built ~512 MiB "marvin-alpine" USER template registered by `cs-linstor.py setup-test-template` and falls back to the builtin template when it is absent, so no extra setup is required. The builtin CentOS template is an 8 GiB volume that takes ~55s to reach sshd, and creating an encrypted volume from it forces a full block-level re-encrypt copy of the whole virtual size (~500s per VM). A small template makes that negligible.
1 parent 9f97aee commit af37556

4 files changed

Lines changed: 38 additions & 9 deletions

File tree

‎test/integration/plugins/linstor/linstor_test_utils.py‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,35 @@
2020
import socket
2121
import time
2222

23+
from marvin.codes import FAILED
24+
from marvin.lib.common import get_template
25+
26+
# Registered by `cs-linstor.py setup-test-template`. Optional: clusters without it fall
27+
# back to the builtin template, so nothing here requires the extra setup step.
28+
TEST_TEMPLATE_NAME = "marvin-alpine"
29+
30+
31+
def get_guest_template(api_client, zone_id, hypervisor="KVM", name=TEST_TEMPLATE_NAME):
32+
"""The small purpose-built guest template if it is registered, else the builtin one.
33+
34+
The builtin CentOS 5.5 template is an 8 GiB volume that takes ~55s to reach sshd.
35+
Worse, creating an *encrypted* volume from a template cannot share blocks with the
36+
source - a new passphrase means different ciphertext - so LINSTOR does a full
37+
block-level re-encrypt copy of the whole virtual size, measured at ~500s per VM.
38+
A ~512 MiB template makes that negligible.
39+
40+
Note marvin's get_template() only returns FAILED when the list call itself comes back
41+
empty; otherwise it falls through to the first result even if nothing matched the
42+
requested type. So detection has to key off FAILED, and the type has to be USER
43+
because our template is registered rather than built in.
44+
"""
45+
template = get_template(api_client, zone_id, template_filter="all",
46+
template_type="USER", template_name=name,
47+
hypervisor=hypervisor)
48+
if template != FAILED and getattr(template, "isready", False):
49+
return template
50+
return get_template(api_client, zone_id, hypervisor=hypervisor)
51+
2352

2453
class ServiceReady:
2554
@classmethod

‎test/integration/plugins/linstor/test_linstor_encrypted_snapshots.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
from marvin.cloudstackException import CloudstackAPIException
2929
from marvin.lib.base import Account, Configurations, Host, ServiceOffering, \
3030
Snapshot, StoragePool, User, VirtualMachine, Volume
31-
from marvin.lib.common import get_domain, get_template, get_zone, list_hosts, list_virtual_machines, list_volumes
31+
from marvin.lib.common import get_domain, get_zone, list_hosts, list_virtual_machines, list_volumes
3232
from marvin.lib.utils import cleanup_resources
3333
from marvin.sshClient import SshClient
3434
from nose.plugins.attrib import attr
3535

36-
from linstor_test_utils import ServiceReady
36+
from linstor_test_utils import ServiceReady, get_guest_template
3737

3838
# Prerequisites:
3939
# Only one zone / pod / cluster
@@ -141,7 +141,7 @@ def setUpClass(cls):
141141

142142
cls.zone = get_zone(cls.apiClient, zone_id=cls.testdata[TestData.zoneId])
143143
cls.domain = get_domain(cls.apiClient, cls.testdata[TestData.domainId])
144-
cls.template = get_template(cls.apiClient, cls.zone.id, hypervisor="KVM")
144+
cls.template = get_guest_template(cls.apiClient, cls.zone.id, hypervisor="KVM")
145145

146146
# Host SSH credentials, only needed by test_03 to inspect the backed-up qcow2 on secondary
147147
# storage. A full marvin config carries these under zones->pods->clusters->hosts, but a

‎test/integration/plugins/linstor/test_linstor_incremental_snapshots.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
# Import Integration Libraries
2727
from marvin.lib.base import Account, Configurations, ServiceOffering, \
2828
Snapshot, StoragePool, Template, User, VirtualMachine, Volume
29-
from marvin.lib.common import get_domain, get_template, get_zone, list_hosts, list_virtual_machines, list_volumes
29+
from marvin.lib.common import get_domain, get_zone, list_hosts, list_virtual_machines, list_volumes
3030
from marvin.lib.utils import cleanup_resources
3131
from marvin.sshClient import SshClient
3232
from nose.plugins.attrib import attr
3333

34-
from linstor_test_utils import ServiceReady
34+
from linstor_test_utils import ServiceReady, get_guest_template
3535

3636
# Prerequisites:
3737
# Only one zone / pod / cluster
@@ -140,7 +140,7 @@ def setUpClass(cls):
140140

141141
cls.zone = get_zone(cls.apiClient, zone_id=cls.testdata[TestData.zoneId])
142142
cls.domain = get_domain(cls.apiClient, cls.testdata[TestData.domainId])
143-
cls.template = get_template(cls.apiClient, cls.zone.id, hypervisor="KVM")
143+
cls.template = get_guest_template(cls.apiClient, cls.zone.id, hypervisor="KVM")
144144

145145
# Host SSH credentials, needed by the tests that inspect or manipulate the backed-up qcow2
146146
# files on secondary storage. A full marvin config carries these under

‎test/integration/plugins/linstor/test_linstor_volumes.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
from marvin.lib.base import VirtualMachine, Volume, VmSnapshot
3030

3131
# common - commonly used methods for all tests are listed here
32-
from marvin.lib.common import get_domain, get_template, get_zone, list_clusters, list_hosts, list_virtual_machines, \
32+
from marvin.lib.common import get_domain, get_zone, list_clusters, list_hosts, list_virtual_machines, \
3333
list_volumes
3434

3535
# utils - utility classes for common cleanup, external library wrappers, etc.
3636
from marvin.lib.utils import cleanup_resources, validateList
3737
from marvin.codes import PASS
3838
from nose.plugins.attrib import attr
3939

40-
from linstor_test_utils import ServiceReady
40+
from linstor_test_utils import ServiceReady, get_guest_template
4141

4242
# Prerequisites:
4343
# Only one zone
@@ -260,7 +260,7 @@ def setUpClass(cls):
260260
# Get Resources from Cloud Infrastructure
261261
cls.zone = get_zone(cls.apiClient, zone_id=cls.testdata[TestData.zoneId])
262262
cls.cluster = list_clusters(cls.apiClient)[0]
263-
cls.template = get_template(cls.apiClient, cls.zone.id, hypervisor=TestData.hypervisor_type)
263+
cls.template = get_guest_template(cls.apiClient, cls.zone.id, hypervisor=TestData.hypervisor_type)
264264
cls.domain = get_domain(cls.apiClient, cls.testdata[TestData.domainId])
265265

266266
# Create test account

0 commit comments

Comments
 (0)