Skip to content

Commit e35cdf4

Browse files
dirkmuellerdcermak
authored andcommitted
Add valkey testing
1 parent 4b98de6 commit e35cdf4

File tree

5 files changed

+48
-3
lines changed

5 files changed

+48
-3
lines changed

bci_tester/data.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,14 +1029,22 @@ def create_BCI(
10291029
custom_entry_point="/bin/bash",
10301030
)
10311031

1032-
10331032
STUNNEL_CONTAINER = create_BCI(
10341033
build_tag=f"{APP_CONTAINER_PREFIX}/stunnel:5",
10351034
bci_type=ImageType.APPLICATION,
10361035
custom_entry_point="/bin/sh",
10371036
available_versions=["15.6", "15.7", "tumbleweed"],
10381037
)
10391038

1039+
VALKEY_CONTAINERS = [
1040+
create_BCI(
1041+
build_tag=f"{APP_CONTAINER_PREFIX}/valkey:{tag}",
1042+
bci_type=ImageType.APPLICATION,
1043+
available_versions=versions,
1044+
forwarded_ports=[PortForwarding(container_port=6379)],
1045+
)
1046+
for versions, tag in ((("tumbleweed", "15.6", "15.7"), "8.0"),)
1047+
]
10401048

10411049
CONTAINERS_WITH_ZYPPER = (
10421050
[
@@ -1111,6 +1119,7 @@ def create_BCI(
11111119
*MARIADB_CONTAINERS,
11121120
STUNNEL_CONTAINER,
11131121
*KUBECTL_CONTAINERS,
1122+
*VALKEY_CONTAINERS,
11141123
]
11151124

11161125

@@ -1171,7 +1180,7 @@ def create_BCI(
11711180

11721181
ACC_CONTAINERS = POSTGRESQL_CONTAINERS
11731182

1174-
#: Containers that are directly pulled from registry.suse.de
1183+
#: Containers pulled from registry.suse.de
11751184
ALL_CONTAINERS = CONTAINERS_WITH_ZYPPER + CONTAINERS_WITHOUT_ZYPPER
11761185

11771186

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ markers = [
154154
'bci-sle16-kernel-module-devel_16.0',
155155
'spack_0.23',
156156
'stunnel_5',
157+
'valkey_8.0',
157158
]
158159

159160
[tool.ruff]

tests/test_metadata.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
from bci_tester.data import SPACK_CONTAINERS
9090
from bci_tester.data import STUNNEL_CONTAINER
9191
from bci_tester.data import TOMCAT_CONTAINERS
92+
from bci_tester.data import VALKEY_CONTAINERS
9293
from bci_tester.data import ImageType
9394
from bci_tester.runtime_choice import PODMAN_SELECTED
9495

@@ -286,6 +287,10 @@ def _get_container_label_prefix(
286287
(kea_container, "kea", ImageType.APPLICATION)
287288
for kea_container in KEA_CONTAINERS
288289
]
290+
+ [
291+
(valkey_container, "valkey", ImageType.APPLICATION)
292+
for valkey_container in VALKEY_CONTAINERS
293+
]
289294
]
290295

291296

tests/test_valkey.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""This module contains the tests for the valkey container."""
2+
3+
import socket
4+
5+
from pytest_container.container import ContainerData
6+
from tenacity import retry
7+
from tenacity import stop_after_attempt
8+
from tenacity import wait_exponential
9+
10+
from bci_tester.data import VALKEY_CONTAINERS
11+
12+
CONTAINER_IMAGES = VALKEY_CONTAINERS
13+
14+
15+
def test_valkey_ping(auto_container: ContainerData):
16+
"""Test that we can reach valkey port successfully."""
17+
host_port = auto_container.forwarded_ports[0].host_port
18+
19+
# Retry 5 times with exponential backoff delay
20+
@retry(
21+
wait=wait_exponential(multiplier=1, min=4, max=10),
22+
stop=stop_after_attempt(5),
23+
)
24+
def check_valkey_response():
25+
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
26+
sock.connect(("0.0.0.0", host_port))
27+
sock.sendall(b"PING\n")
28+
assert sock.recv(5) == b"+PONG"
29+
30+
check_valkey_response()

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = {py36,py39,py310,py311,py312,py313}-unit, all, base, cosign, fips, init, dotnet, python, ruby, node, go, openjdk, openjdk_devel, rust, php, busybox, 389ds, metadata, minimal, multistage, repository, doc, lint, check_marks, pcp, distribution, postgres, git, helm, nginx, kernel_module, mariadb, tomcat, spack, gcc, prometheus, grafana, kiwi, postfix, ai, stunnel, kubectl, kea
2+
envlist = {py36,py39,py310,py311,py312,py313}-unit, all, base, cosign, fips, init, dotnet, python, ruby, node, go, openjdk, openjdk_devel, rust, php, busybox, 389ds, metadata, minimal, multistage, repository, doc, lint, check_marks, pcp, distribution, postgres, git, helm, nginx, kernel_module, mariadb, tomcat, spack, gcc, prometheus, grafana, kiwi, postfix, ai, stunnel, kubectl, kea, valkey
33
skip_missing_interpreters = True
44

55
[common]

0 commit comments

Comments
 (0)