Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor fixups of podman-compose #510

Merged
merged 2 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion asu/asu.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def store_path(path="index.html"):

from . import metrics

redis_client = get_redis_client(app.config["REDIS_URL"])
redis_client = get_redis_client(app.config)

app.config["REGISTRY"].register(metrics.BuildCollector(redis_client))

Expand Down
6 changes: 3 additions & 3 deletions asu/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
import json
import logging
import struct
from os import getenv
from pathlib import Path
from re import match
from shutil import unpack_archive
from tempfile import NamedTemporaryFile

import nacl.signing
import redis
import requests
from podman import PodmanClient

import redis


def get_redis_client(config):
return redis.from_url(config["REDIS_URL"])
return redis.from_url(getenv("REDIS_URL") or config["REDIS_URL"])


def is_modified(config, url: str) -> bool:
Expand Down
24 changes: 13 additions & 11 deletions podman-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,47 @@ volumes:
redis:
services:
server:
image: "aparcar/asu:latest"
image: "localhost/aparcar/asu:latest"
build:
context: ./
dockerfile: Containerfile
environment:
- REDIS_HOST=redis
- REDIS_URL=redis://redis/
volumes:
- "./asu-service/public/:/app/public/"
- "./asu-service/public/:/app/public/:rw"
ports:
- "127.0.0.1:8000:8000"
depends_on:
- redis

worker:
image: "aparcar/asu:latest"
image: "localhost/aparcar/asu:latest"
build:
context: ./
dockerfile: Containerfile
command: rqworker --url "redis://redis"
environment:
- CONTAINER_HOST=unix:///tmp/socket/podman.sock
- REDIS_URL=redis://redis/
volumes:
- ./asu-service/public/:/app/public/
- podman-sock:/tmp/socket/
- ./asu-service/public/:/app/public/:rw
- podman-sock:/tmp/socket/:rw
depends_on:
- redis
- podman

worker2:
image: "aparcar/asu:latest"
image: "localhost/aparcar/asu:latest"
build:
context: ./
dockerfile: Containerfile
command: rqworker --url "redis://redis"
environment:
- CONTAINER_HOST=unix:///tmp/socket/podman.sock
- REDIS_URL=redis://redis/
volumes:
- ./asu-service/public/:/app/public/
- podman-sock:/tmp/socket/
- ./asu-service/public/:/app/public/:rw
- podman-sock:/tmp/socket/:rw
depends_on:
- redis
- podman
Expand All @@ -55,9 +57,9 @@ services:
command: sh -c "mkdir -p /tmp/socket && podman system service --time=0 unix:///tmp/socket/podman.sock"

redis:
image: "redis:alpine"
image: "docker.io/redis:alpine"
volumes:
- redis:/data/
- redis:/data/:rw

# Podman may not allow ports 1024, consider using an external web server
# webserver:
Expand Down
11 changes: 6 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ def redis_load_mock_data(redis):
redis.sadd("packages:SNAPSHOT:SNAPSHOT:ath79/generic", "vim", "tmux")
redis.sadd("packages:SNAPSHOT:SNAPSHOT:x86/64", "vim", "tmux")

redis.sadd("profiles:21.02:21.02.7:ath79/generic", "tplink_tl-wdr4300-v1")
redis.sadd("packages:21.02:21.02.7:ath79/generic", "vim", "tmux")
redis.sadd("packages:21.02:21.02.7:x86/64", "vim", "tmux")

redis.hset(
"mapping:1.2:1.2.3:testtarget/testsubtarget",
mapping={"testvendor,testprofile": "testprofile"},
)
redis.sadd("targets:1.2", "testtarget/testsubtarget")
redis.sadd("targets:SNAPSHOT", "ath79/generic", "x86/64")
redis.sadd("targets:21.02", "testtarget/testsubtarget")
redis.sadd("targets:21.02", "testtarget/testsubtarget", "ath79/generic", "x86/64")
redis.hset("mapping-abi", mapping={"test1-1": "test1"})


Expand Down Expand Up @@ -81,7 +85,6 @@ def test_path():

@pytest.fixture
def app(mocked_redis, test_path):

registry = prometheus_client.CollectorRegistry(auto_describe=True)

mock_app = create_app(
Expand Down Expand Up @@ -134,7 +137,7 @@ def app(mocked_redis, test_path):
"name": "21.02",
"enabled": True,
"snapshot": True,
"versions": ["21.02.0", "21.02.0-rc4", "21.02-SNAPSHOT"],
"versions": ["21.02.7", "21.02.0", "21.02.0-rc4", "21.02-SNAPSHOT"],
"git_branch": "openwrt-21.02",
"path": "releases/{version}",
"path_packages": "releases/packages-{branch}",
Expand Down Expand Up @@ -164,7 +167,6 @@ def app(mocked_redis, test_path):

@pytest.fixture
def app_using_branches_yml(mocked_redis, test_path):

registry = prometheus_client.CollectorRegistry(auto_describe=True)

mock_app = create_app(
Expand All @@ -185,7 +187,6 @@ def app_using_branches_yml(mocked_redis, test_path):

@pytest.fixture
def app_using_default_branches(mocked_redis, test_path):

registry = prometheus_client.CollectorRegistry(auto_describe=True)

mock_app = create_app(
Expand Down
10 changes: 5 additions & 5 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def test_api_build_prerelease_rc(client):
response = client.post(
"/api/v1/build",
json=dict(
version="21.02.0",
version="21.02.7",
target="testtarget/testsubtarget",
profile="testprofile",
packages=["test1", "test2"],
Expand Down Expand Up @@ -284,7 +284,7 @@ def test_api_build_real_x86(app):
"/api/v1/build",
json=dict(
target="x86/64",
version="SNAPSHOT",
version="21.02.7",
packages=["tmux", "vim"],
profile="some_random_cpu_which_doesnt_exists_as_profile",
),
Expand All @@ -297,7 +297,7 @@ def test_api_build_real_x86(app):
"/api/v1/build",
json=dict(
target="x86/64",
version="SNAPSHOT",
version="21.02.7",
packages=["tmux", "vim"],
profile="some_random_cpu_which_doesnt_exists_as_profile",
filesystem="ext4",
Expand All @@ -316,7 +316,7 @@ def test_api_build_real_ath79(app):
"/api/v1/build",
json=dict(
target="ath79/generic",
version="SNAPSHOT",
version="21.02.7",
packages=["tmux", "vim"],
profile="tplink_tl-wdr4300-v1",
),
Expand All @@ -329,7 +329,7 @@ def test_api_build_real_ath79(app):
"/api/v1/build",
json=dict(
target="ath79/generic",
version="SNAPSHOT",
version="21.02.7",
packages=["tmux", "vim"],
profile="tplink_tl-wdr4300-v1",
filesystem="squashfs",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_janitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_update_meta_latest_json(app):
update_meta_json(app.config)
latest_json = json.loads((app.config["JSON_PATH"] / "latest.json").read_text())
assert "19.07.7" in latest_json["latest"]
assert "21.02.0" in latest_json["latest"]
assert "21.02.7" in latest_json["latest"]
assert "SNAPSHOT" in latest_json["latest"]


Expand Down