Skip to content

Commit 7862f97

Browse files
committed
tests: Add automated tests to install packages for fedora,ubuntu
Signed-off-by: Abhijat Malviya <[email protected]>
1 parent 4f5bb07 commit 7862f97

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

tests/dragonfly/conftest.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,11 @@ def pytest_runtest_makereport(item, call):
433433
if report.when == "teardown":
434434
call_outcome = getattr(item, "call_outcome", None)
435435
log_dir = item.funcargs.get("df_log_dir")
436-
if report.failed:
437-
copy_failed_logs(log_dir, report)
438-
if call_outcome and call_outcome.failed:
439-
copy_failed_logs(log_dir, call_outcome)
436+
if log_dir:
437+
if report.failed:
438+
copy_failed_logs(log_dir, report)
439+
if call_outcome and call_outcome.failed:
440+
copy_failed_logs(log_dir, call_outcome)
440441

441442

442443
@pytest.fixture(scope="function")
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from testcontainers.core.container import DockerContainer
2+
3+
4+
def check(container: DockerContainer, cmd: str):
5+
result = container.exec(cmd)
6+
assert result.exit_code == 0, f"command {cmd} failed with result {result}"
7+
8+
9+
async def test_install_package_on_fedora():
10+
with DockerContainer(image="fedora:latest", tty=True) as fedora:
11+
check(
12+
fedora,
13+
"dnf config-manager addrepo --from-repofile=https://packages.dragonflydb.io/dragonfly.repo",
14+
)
15+
check(fedora, "dnf -y install dragonfly")
16+
check(fedora, "dragonfly --version")
17+
18+
19+
async def test_install_package_on_ubuntu():
20+
with DockerContainer(image="ubuntu:latest", tty=True) as ubuntu:
21+
check(ubuntu, "apt update")
22+
check(ubuntu, "apt install -y curl")
23+
check(
24+
ubuntu,
25+
"curl -Lo /usr/share/keyrings/dragonfly-keyring.public https://packages.dragonflydb.io/pgp-key.public",
26+
)
27+
check(
28+
ubuntu,
29+
"curl -Lo /etc/apt/sources.list.d/dragonfly.sources https://packages.dragonflydb.io/dragonfly.sources",
30+
)
31+
check(ubuntu, "apt update")
32+
check(ubuntu, "apt install -y dragonfly")
33+
check(ubuntu, "dragonfly --version")

0 commit comments

Comments
 (0)