-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_carthage_windows.py
68 lines (55 loc) · 2.02 KB
/
test_carthage_windows.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Copyright (C) 2024, Hadron Industries.
# Carthage is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation. It is distributed
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
# LICENSE for details.
import carthage.pytest_plugin
import pytest
from pathlib import Path
from carthage import *
from carthage.modeling import *
from carthage_windows import *
import carthage_windows.layout
from carthage.pytest import *
pytest_plugins = ('carthage.pytest_plugin', )
@pytest.fixture()
def ainjector(ainjector):
base_injector(
carthage.plugins.load_plugin, 'carthage_windows')
return ainjector
class layout(carthage_windows.layout.layout):
@provides("windows_net")
class net(NetworkModel):
bridge_name = 'blaptop'
v4_config = V4Config(dhcp=True)
class net_config(NetworkConfigModel):
add('eth0', mac=persistent_random_mac, net=injector_access('windows_net'))
@provides(carthage.vm.vm_image_key)
class image(LibvirtWindowsBaseImage):
pass
class vm_1(MachineModel):
add_provider(machine_implementation_key, dependency_quote(carthage.vm.Vm))
ssh_login_user = 'admin'
@async_test
async def test_image_build(ainjector):
l = await ainjector(layout)
ainjector = l.ainjector
await l.image.delete()
#wait_for_shutdown gives 30 minutes, but we want extra time so we can actually clean up.
with TestTiming(32*60):
await l.image.async_become_ready()
@async_test
async def test_use_image(ainjector):
l = await ainjector(layout)
ainjector = l.ainjector
with TestTiming(32*60):
await l.image.async_become_ready()
with TestTiming(10*60):
vm =l.vm_1.machine
try:
async with vm.machine_running():
await vm.ssh('powershell ls')
finally:
await vm.delete()