Skip to content

Commit

Permalink
Fix Pylint, rely on official container for tests
Browse files Browse the repository at this point in the history
also don't skip the tests when a `docker` binary is present only (e.g.
macOS Docker Desktop, possibly Podman with Docker shim [?])
  • Loading branch information
lkubb committed Sep 26, 2024
1 parent 186e748 commit 7661c58
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ requires-python = ">= 3.8"
dynamic = ["version"]
dependencies = [
"salt>=3006",
"kazoo",
]

[project.readme]
Expand Down
28 changes: 26 additions & 2 deletions src/saltext/zookeeper/modules/zk_concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(
try:
for child in self.client.get_children(self.path):
try:
data, stat = self.client.get(self.path + "/" + child)
data, _ = self.client.get(self.path + "/" + child)
if identifier == data.decode("utf-8"):
self.create_path = self.path + "/" + child
self.is_acquired = True
Expand Down Expand Up @@ -150,7 +150,7 @@ def lock_holders(
zk_hosts=None,
identifier=None,
max_concurrency=1,
timeout=None,
timeout=None, # pylint: disable=unused-argument
ephemeral_lease=False,
profile=None,
scheme=None,
Expand All @@ -161,6 +161,12 @@ def lock_holders(
"""
Return an un-ordered list of lock holders
CLI Example:
.. code-block:: bash
salt '*' zk_concurrency.lock_holders some/path
path
The path in zookeeper where the lock is
Expand Down Expand Up @@ -221,6 +227,12 @@ def lock(
"""
Get lock (with optional timeout)
CLI Example:
.. code-block:: bash
salt '*' zk_concurrency.lock some/path
path
The path in zookeeper where the lock is
Expand Down Expand Up @@ -296,6 +308,12 @@ def unlock(
"""
Remove lease from semaphore
CLI Example:
.. code-block:: bash
salt '*' zk_concurrency.unlock some/path
path
The path in zookeeper where the lock is
Expand Down Expand Up @@ -363,6 +381,12 @@ def party_members(
Get the List of identifiers in a particular party, optionally waiting for the
specified minimum number of nodes (min_nodes) to appear
CLI Example:
.. code-block:: bash
salt '*' zk_concurrency.party_members some/path
path
The path in zookeeper where the lock is
Expand Down
4 changes: 3 additions & 1 deletion src/saltext/zookeeper/states/zk_concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ def min_party(
name, zk_hosts, min_nodes, blocking=blocking, **conn_kwargs
)
if not isinstance(nodes, list):
raise Exception(f"Error from zk_concurrency.party_members, return was not a list: {nodes}")
ret["result"] = False
ret["comment"] = f"Error from zk_concurrency.party_members, return was not a list: {nodes}"
return ret

num_nodes = len(nodes)

Expand Down
7 changes: 2 additions & 5 deletions tests/functional/states/test_zookeeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@
import pytest
from saltfactories.utils import random_string

pytest.importorskip("kazoo")
pytest.importorskip("docker")

log = logging.getLogger(__name__)

pytestmark = [
pytest.mark.slow_test,
pytest.mark.skip_if_binaries_missing("dockerd"),
pytest.mark.slow_test,
pytest.mark.skip_if_binaries_missing("docker", "dockerd", check_all=False),
]


Expand Down Expand Up @@ -60,7 +57,7 @@ def minion_config_overrides(zookeeper_port):
def zookeeper_container(salt_factories):
container = salt_factories.get_container(
random_string("zookeeper-"),
"ghcr.io/saltstack/salt-ci-containers/zookeeper",
"docker.io/library/zookeeper",
container_run_kwargs={
"ports": {
"2181/tcp": None,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/states/test_zk_concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest

import saltext.zookeeper.states.zk_concurrency as zk_concurrency
from saltext.zookeeper.states import zk_concurrency


@pytest.fixture
Expand Down

0 comments on commit 7661c58

Please sign in to comment.