Skip to content

Commit

Permalink
Podman: make current utility class explicit async
Browse files Browse the repository at this point in the history
There's no clear indication that the current Podman utility class is
an async implementation.  With some use cases that can benefit from a
non-async behavior, let's make this current implementation explicitly
an async one (with the renaming), so that a sync implementation can
have the standard name.

Signed-off-by: Cleber Rosa <[email protected]>
  • Loading branch information
clebergnu committed Feb 22, 2024
1 parent 191c66e commit ca88839
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions avocado/plugins/runners/podman_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from avocado.core.nrunner.app import BaseRunnerApp
from avocado.core.nrunner.runner import RUNNER_RUN_STATUS_INTERVAL, BaseRunner
from avocado.core.utils import messages
from avocado.utils.podman import Podman, PodmanException
from avocado.utils.podman import AsyncPodman, PodmanException


class PodmanImageRunner(BaseRunner):
Expand All @@ -34,7 +34,7 @@ def _run_podman_pull(self, uri, queue):
# information for debugging in case of errors.
logging.getLogger("avocado.utils.podman").addHandler(logging.NullHandler())
try:
podman = Podman()
podman = AsyncPodman()
loop = asyncio.get_event_loop()
loop.run_until_complete(podman.execute("pull", uri))
queue.put({"result": "pass"})
Expand Down
4 changes: 2 additions & 2 deletions avocado/plugins/spawners/podman.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from avocado.core.version import VERSION
from avocado.utils import distro
from avocado.utils.asset import Asset
from avocado.utils.podman import Podman, PodmanException
from avocado.utils.podman import AsyncPodman, PodmanException

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -163,7 +163,7 @@ def podman(self):
if self._podman is None:
podman_bin = self.config.get("spawner.podman.bin")
try:
self._podman = Podman(podman_bin)
self._podman = AsyncPodman(podman_bin)
except PodmanException as ex:
LOG.error(ex)
return self._podman
Expand Down
2 changes: 1 addition & 1 deletion avocado/utils/podman.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PodmanException(Exception):
pass


class Podman:
class AsyncPodman:
def __init__(self, podman_bin=None):
path = which(podman_bin or "podman")
if not path:
Expand Down
4 changes: 2 additions & 2 deletions selftests/functional/plugin/podman_image.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from avocado import Test
from avocado.utils.podman import Podman
from avocado.utils.podman import AsyncPodman


class PodmanImageTest(Test):
Expand All @@ -8,7 +8,7 @@ async def test(self):
:avocado: dependency={"type": "package", "name": "podman", "action": "check"}
:avocado: dependency={"type": "podman-image", "uri": "registry.fedoraproject.org/fedora:38"}
"""
podman = Podman()
podman = AsyncPodman()
_, stdout, _ = await podman.execute(
"images",
"--filter",
Expand Down
8 changes: 4 additions & 4 deletions selftests/functional/utils/podman.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from avocado import Test
from avocado.utils.podman import Podman
from avocado.utils.podman import AsyncPodman


class PodmanTest(Test):
class AsyncPodmanTest(Test):
async def test_python_version(self):
"""
:avocado: dependency={"type": "package", "name": "podman", "action": "check"}
:avocado: dependency={"type": "podman-image", "uri": "fedora:38"}
:avocado: tags=slow
"""
podman = Podman()
podman = AsyncPodman()
result = await podman.get_python_version("fedora:38")
self.assertEqual(result, (3, 11, "/usr/bin/python3"))

Expand All @@ -19,7 +19,7 @@ async def test_container_info(self):
:avocado: dependency={"type": "podman-image", "uri": "fedora:38"}
:avocado: tags=slow
"""
podman = Podman()
podman = AsyncPodman()
_, stdout, _ = await podman.execute("create", "fedora:38", "/bin/bash")
container_id = stdout.decode().strip()
result = await podman.get_container_info(container_id)
Expand Down

0 comments on commit ca88839

Please sign in to comment.