Skip to content

Commit

Permalink
Fix: Execution creation was not tested
Browse files Browse the repository at this point in the history
Solution: Add a test that creates a new VM execution and checks that it starts properly.
  • Loading branch information
hoh committed Mar 6, 2024
1 parent c7a2bf9 commit 60bc93c
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/supervisor/test_execution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import asyncio

import pytest
from aleph_message.models import ItemHash

from aleph.vm.conf import settings
from aleph.vm.models import VmExecution
from aleph.vm.storage import get_message


@pytest.mark.asyncio
async def test_create_execution():
"""
Create a new VM execution and check that it starts properly.
"""

settings.FAKE_DATA_PROGRAM = settings.BENCHMARK_FAKE_DATA_PROGRAM
settings.ALLOW_VM_NETWORKING = False
vm_hash = ItemHash("fake-hash-fake-hash-fake-hash-fake-hash-fake-hash-fake-hash-hash")
message = await get_message(ref=vm_hash)

execution = VmExecution(
vm_hash=vm_hash,
message=message.content,
original=message.content,
snapshot_manager=None,
systemd_manager=None,
persistent=False,
)

# Downloading the resources required may take some time, limit it to 10 seconds
async with asyncio.timeout(30):
await execution.prepare()

execution.create(vm_id=3, tap_interface=None)
# async with asyncio.timeout(30):
# await execution.start()

0 comments on commit 60bc93c

Please sign in to comment.