diff --git a/src/fc/qemu/agent.py b/src/fc/qemu/agent.py index d269e49..6d8f40e 100644 --- a/src/fc/qemu/agent.py +++ b/src/fc/qemu/agent.py @@ -3,11 +3,10 @@ import datetime import distutils.spawn import fcntl -import glob +import importlib.resources import json import math import os -import os.path as p import shutil import socket import subprocess @@ -21,7 +20,6 @@ import colorama import consulate import consulate.models.agent -import pkg_resources import requests import yaml @@ -272,9 +270,9 @@ class Agent(object): timeout_graceful = 10 system_config_template = Path("etc/qemu/qemu.vm.cfg.in") - builtin_config_template = Path( - pkg_resources.resource_filename(__name__, "qemu.vm.cfg.in") - ) + # XXX the importlib schema requiring a context manager + # is not helpful here. + builtin_config_template = Path(__file__).parent / "qemu.vm.cfg.in" consul_token = None consul_generation = -1 diff --git a/tests/conftest.py b/tests/conftest.py index 1e52219..59e8efb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,7 +6,6 @@ import traceback from pathlib import Path -import pkg_resources import pytest import structlog @@ -224,8 +223,8 @@ def vm(clean_environment, monkeypatch, tmpdir): import fc.qemu.hazmat.qemu monkeypatch.setattr(fc.qemu.hazmat.qemu.Qemu, "guestagent_timeout", 0.1) - fixtures = pkg_resources.resource_filename(__name__, "fixtures") - shutil.copy(fixtures + "/simplevm.yaml", "/etc/qemu/vm/simplevm.cfg") + simplevm_cfg = Path(__file__).parent / "fixtures" / "simplevm.yaml" + shutil.copy(simplevm_cfg, "/etc/qemu/vm/simplevm.cfg") Path("/etc/qemu/vm/.simplevm.cfg.staging").unlink(missing_ok=True) vm = Agent("simplevm") diff --git a/tests/hazmat/test_ceph.py b/tests/hazmat/test_ceph.py index fb8f1cf..f6ce3b2 100644 --- a/tests/hazmat/test_ceph.py +++ b/tests/hazmat/test_ceph.py @@ -54,7 +54,7 @@ def test_multiple_images_raises_error(ceph_inst): @pytest.mark.timeout(60) @pytest.mark.live() def test_rbd_pool_migration(ceph_inst, patterns) -> None: - ceph_inst.cfg["tmp_size"] = 50 * 1024 * 1024 + ceph_inst.cfg["tmp_size"] = 500 * 1024 * 1024 ceph_inst.cfg["swap_size"] = 50 * 1024 * 1024 ceph_inst.cfg["root_size"] = 50 * 1024 * 1024 rbd.RBD().create( @@ -83,6 +83,8 @@ def test_rbd_pool_migration(ceph_inst, patterns) -> None: first_start.optional( """ waiting interval=0 machine=simplevm remaining=4 subsystem=ceph volume=rbd.hdd/simplevm.tmp +sgdisk> Setting name! +sgdisk> partNum is 0 """ ) first_start.in_order( @@ -138,8 +140,6 @@ def test_rbd_pool_migration(ceph_inst, patterns) -> None: sgdisk> The operation has completed successfully. sgdisk machine=simplevm returncode=0 subsystem=ceph volume=rbd.hdd/simplevm.tmp sgdisk args=-a 8192 -n 1:8192:0 -c "1:tmp" -t 1:8300 "/dev/rbd/rbd.hdd/simplevm.tmp" machine=simplevm subsystem=ceph volume=rbd.hdd/simplevm.tmp -sgdisk> Setting name! -sgdisk> partNum is 0 sgdisk> The operation has completed successfully. sgdisk machine=simplevm returncode=0 subsystem=ceph volume=rbd.hdd/simplevm.tmp partprobe args=/dev/rbd/rbd.hdd/simplevm.tmp machine=simplevm subsystem=ceph volume=rbd.hdd/simplevm.tmp diff --git a/tests/hazmat/test_volume.py b/tests/hazmat/test_volume.py index 87857e5..7205180 100644 --- a/tests/hazmat/test_volume.py +++ b/tests/hazmat/test_volume.py @@ -159,7 +159,7 @@ def test_volume_mkswap(ceph_inst): @pytest.mark.timeout(60) def test_volume_tmp_mkfs(tmp_spec): - tmp_spec.desired_size = 100 * 1024 * 1024 + tmp_spec.desired_size = 400 * 1024 * 1024 tmp_spec.ensure_presence() with tmp_spec.volume.mapped(): tmp_spec.mkfs() diff --git a/tests/test_agent.py b/tests/test_agent.py index d4ed2f7..efb268d 100644 --- a/tests/test_agent.py +++ b/tests/test_agent.py @@ -1,9 +1,7 @@ -import os import shutil from pathlib import Path import mock -import pkg_resources import psutil import pytest @@ -14,7 +12,7 @@ @pytest.fixture def simplevm_cfg(monkeypatch): - fixtures = Path(pkg_resources.resource_filename(__name__, "fixtures")) + fixtures = Path(__file__).parent / "fixtures" source = fixtures / "simplevm.yaml" # The Qemu prefix gets adjusted automatically in the synhetic_root # auto-use fixture that checks whether this is a live test or not. diff --git a/tests/test_binenv.py b/tests/test_binenv.py index 5222908..934eae4 100644 --- a/tests/test_binenv.py +++ b/tests/test_binenv.py @@ -38,3 +38,4 @@ def test_no_unexpected_binaries(): @pytest.mark.unit def test_ensure_critical_module_imports(): import rados # noqa + import structlog # noqa