Skip to content

Commit 37a60f7

Browse files
committed
tests: Add automated tests to install packages for fedora,ubuntu
Signed-off-by: Abhijat Malviya <[email protected]>
1 parent 55f874d commit 37a60f7

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-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: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
return result.output
8+
9+
10+
async def test_install_package_on_fedora():
11+
with DockerContainer(image="fedora:latest", tty=True) as fedora:
12+
check(
13+
fedora,
14+
"dnf config-manager addrepo --from-repofile=https://packages.dragonflydb.io/dragonfly.repo",
15+
)
16+
check(fedora, "dnf -y install dragonfly")
17+
check(fedora, "dragonfly --version")
18+
19+
20+
async def test_install_package_on_ubuntu():
21+
with DockerContainer(image="ubuntu:latest", tty=True) as ubuntu:
22+
check(ubuntu, "apt update")
23+
check(ubuntu, "apt install -y curl")
24+
check(
25+
ubuntu,
26+
"curl -Lo /usr/share/keyrings/dragonfly-keyring.public https://packages.dragonflydb.io/pgp-key.public",
27+
)
28+
check(
29+
ubuntu,
30+
"curl -Lo /etc/apt/sources.list.d/dragonfly.sources https://packages.dragonflydb.io/dragonfly.sources",
31+
)
32+
check(ubuntu, "apt update")
33+
check(ubuntu, "apt install -y dragonfly")
34+
check(ubuntu, "dragonfly --version")

0 commit comments

Comments
 (0)