|
14 | 14 | ProgramMessage, |
15 | 15 | StoreMessage, |
16 | 16 | ) |
17 | | -from aleph_message.models.execution.environment import MachineResources |
| 17 | +from aleph_message.models.execution.environment import HypervisorType, MachineResources |
18 | 18 | from aleph_message.status import MessageStatus |
19 | 19 |
|
20 | 20 | from aleph.sdk.exceptions import InsufficientFundsError |
@@ -116,6 +116,7 @@ async def test_create_instance(mock_session_with_post_success): |
116 | 116 | receiver="0x4145f182EF2F06b45E50468519C1B92C60FBd4A0", |
117 | 117 | type=PaymentType.superfluid, |
118 | 118 | ), |
| 119 | + hypervisor=HypervisorType.qemu, |
119 | 120 | ) |
120 | 121 |
|
121 | 122 | assert mock_session_with_post_success.http_session.post.called_once |
@@ -144,6 +145,27 @@ async def test_create_instance_no_payment(mock_session_with_post_success): |
144 | 145 | assert isinstance(instance_message, InstanceMessage) |
145 | 146 |
|
146 | 147 |
|
| 148 | +@pytest.mark.asyncio |
| 149 | +async def test_create_instance_no_hypervisor(mock_session_with_post_success): |
| 150 | + """Test that an instance can be created with no hypervisor specified. |
| 151 | + It should in this case default to "firecracker". |
| 152 | + """ |
| 153 | + async with mock_session_with_post_success as session: |
| 154 | + instance_message, message_status = await session.create_instance( |
| 155 | + rootfs="cafecafecafecafecafecafecafecafecafecafecafecafecafecafecafecafe", |
| 156 | + rootfs_size=1, |
| 157 | + rootfs_name="rootfs", |
| 158 | + channel="TEST", |
| 159 | + metadata={"tags": ["test"]}, |
| 160 | + hypervisor=None, |
| 161 | + ) |
| 162 | + |
| 163 | + assert instance_message.content.environment.hypervisor == HypervisorType.firecracker |
| 164 | + |
| 165 | + assert mock_session_with_post_success.http_session.post.called_once |
| 166 | + assert isinstance(instance_message, InstanceMessage) |
| 167 | + |
| 168 | + |
147 | 169 | @pytest.mark.asyncio |
148 | 170 | async def test_forget(mock_session_with_post_success): |
149 | 171 | async with mock_session_with_post_success as session: |
|
0 commit comments