Skip to content

Commit 5ce53da

Browse files
authored
Merge pull request #58 from tiqi-group/podman-kube-play
Replace podman-compose dev environment with a podman kube play environment
2 parents 7d2ef79 + 8b4318d commit 5ce53da

File tree

10 files changed

+126
-109
lines changed

10 files changed

+126
-109
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,12 @@ Set up the development environment:
8888

8989
```bash
9090
uv sync --all-extras --dev
91-
````
91+
```
9292

9393
Start a development InfluxDB instance:
9494

95-
```bash
96-
cd docker
97-
uv run podman compose up
95+
```sh
96+
podman kube play k8s/dev.yml
9897
```
9998

10099
In a separate terminal, run the ICON server:

docker/docker-compose.yml

Lines changed: 0 additions & 66 deletions
This file was deleted.

docker/influxdb3-ui/config.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

docker/influxdb3/admin-token.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

k8s/dev.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: influxdb
6+
spec:
7+
replicas: 1
8+
selector:
9+
matchLabels:
10+
app: influxdb
11+
template:
12+
metadata:
13+
labels:
14+
app: influxdb
15+
spec:
16+
containers:
17+
- name: influxdb
18+
image: influxdb:1.11
19+
ports:
20+
- containerPort: 8087
21+
hostPort: 8087
22+
volumeMounts:
23+
- name: influxdb-storage
24+
mountPath: /var/lib/influxdb
25+
env:
26+
- name: INFLUXDB_DB
27+
value: testing
28+
- name: INFLUXDB_ADMIN_USER
29+
valueFrom:
30+
secretKeyRef:
31+
name: influxdb-credentials
32+
key: admin-user
33+
- name: INFLUXDB_ADMIN_PASSWORD
34+
valueFrom:
35+
secretKeyRef:
36+
name: influxdb-credentials
37+
key: admin-password
38+
- name: INFLUXDB_HTTP_BIND_ADDRESS
39+
value: ":8087"
40+
- name: INFLUXDB_HTTP_AUTH_ENABLED
41+
value: false
42+
volumes:
43+
- name: influxdb-storage
44+
persistentVolumeClaim:
45+
claimName: influxdb-storage
46+
---
47+
apiVersion: apps/v1
48+
kind: Deployment
49+
metadata:
50+
name: chronograf
51+
spec:
52+
replicas: 1
53+
selector:
54+
matchLabels:
55+
app: chronograf
56+
template:
57+
metadata:
58+
labels:
59+
app: chronograf
60+
spec:
61+
containers:
62+
- name: chronograf
63+
image: chronograf:latest
64+
ports:
65+
- containerPort: 8888
66+
hostPort: 8888
67+
volumeMounts:
68+
- name: chronograf-storage
69+
mountPath: /var/lib/chronograf
70+
env:
71+
- name: INFLUXDB_URL
72+
value: http://influxdb:8087
73+
- name: INFLUXDB_USERNAME
74+
valueFrom:
75+
secretKeyRef:
76+
name: influxdb-credentials
77+
key: admin-user
78+
- name: INFLUXDB_PASSWORD
79+
valueFrom:
80+
secretKeyRef:
81+
name: influxdb-credentials
82+
key: admin-password
83+
volumes:
84+
- name: chronograf-storage
85+
persistentVolumeClaim:
86+
claimName: chronograf-storage
87+
---
88+
kind: Secret
89+
apiVersion: v1
90+
metadata:
91+
name: influxdb-credentials
92+
data:
93+
admin-user: dGVzdGVy # <- tester
94+
admin-password: cGFzc3cwcmQ= # <- passw0rd

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,9 @@ allow-direct-references = true
4242
[dependency-groups]
4343
dev = [
4444
"mypy>=1.13.0",
45-
"podman-compose>=1.2.0",
4645
"pyright>=1.1.391",
4746
"pytest>=8.3.4",
4847
"pytest-asyncio>=0.25.0",
49-
"pytest-docker>=3.1.1",
5048
"pyyaml>=6.0.2",
5149
"requests>=2.32.3",
5250
"ruff>=0.8.4",

tests/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
import os
1+
from pathlib import Path
22

3-
os.environ["ENVIRONMENT"] = "testing"
3+
from icon.config.config_path import set_config_path
4+
5+
set_config_path(Path(__file__).parent / "config.yaml")

tests/config/test_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pathlib import Path
22

3-
from icon.config.config import get_config_source
3+
from icon.config.config import get_config_path
44

55

6-
def test_get_config_source() -> None:
7-
assert get_config_source() == Path(__file__).parent.parent / "config.yaml"
6+
def test_get_config_path() -> None:
7+
assert get_config_path() == Path(__file__).parent.parent / "config.yaml"

tests/conftest.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/server/data_access/db_context/test_influxdbv1.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import logging
2+
import os
3+
import socket
4+
import time
5+
from collections.abc import Iterable
6+
from pathlib import Path
27

38
import pytest
4-
import pytest_docker.plugin
59
import requests
610

711
from icon.config.config import get_config
@@ -26,21 +30,28 @@ def is_responsive(host: str, port: int) -> bool:
2630

2731

2832
@pytest.fixture(scope="session")
29-
def influxdbv1_service(
30-
docker_ip: str, docker_services: pytest_docker.plugin.Services
31-
) -> tuple[str, int]:
33+
def influxdbv1_service() -> Iterable[None]:
3234
"""Ensure that influxdbv1 service is up and responsive."""
3335

34-
port = 8087
35-
logger.debug("http://%s:%s", docker_ip, port)
36-
docker_services.wait_until_responsive(
37-
timeout=10.0, pause=0.1, check=lambda: is_responsive(docker_ip, port)
38-
)
36+
def check_port(port: int) -> bool:
37+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
38+
# Attempting to connect to localhost on the specified port
39+
return sock.connect_ex(("127.0.0.1", port)) == 0
3940

40-
return docker_ip, port
41+
port = 8087
42+
logger.debug("http://localhost:%s", port)
43+
if not check_port(port):
44+
yml = Path(__file__).parent.parent.parent.parent.parent / "k8s" / "dev.yml"
45+
os.system(f"podman kube play {yml}")
46+
while not check_port(port):
47+
time.sleep(0.5)
48+
yield
49+
os.system(f"podman kube play --down {yml}")
50+
else:
51+
yield
4152

4253

43-
def test_InfluxDBv1Session(influxdbv1_service: tuple[str, int]) -> None: # noqa: N802
54+
def test_InfluxDBv1Session(influxdbv1_service: None) -> None: # noqa: N802
4455
test_value = 1337
4556

4657
with InfluxDBv1Session() as session:

0 commit comments

Comments
 (0)