Skip to content

mrc-6404 Fix for latest packit #51

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

Merged
merged 12 commits into from
Apr 23, 2025
14 changes: 5 additions & 9 deletions .github/workflows/test.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
name: Run Tests
on:
schedule:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this was running on a schedule, doesn't feel like we need it now!

- cron: '0 2 * * *' # run at 2 AM UTC
push:
branches:
- main
- master
- "main"
- "master"
pull_request:
branches:
- main
- master

name: Tests

- "main"
- "master"
jobs:
test:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions config/packit/orderly-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ packit:
name: packit-api
tag: main
app:
name: packit
tag: mrc-4261
name: montagu-packit
tag: mrc-5140-trusted-headers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you want to handle the merge order here? Keep this for now as mrc-ide/packit#187 is in draft?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, for the moment. Looks like that's what we did before!

db:
name: packit-db
tag: main
41 changes: 18 additions & 23 deletions orderly_web/constellation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import tempfile
import docker
import time

from PIL import Image

Expand Down Expand Up @@ -71,37 +72,28 @@ def packit_db_container(cfg):

def packit_db_configure(container, cfg):
docker_util.exec_safely(container, ["wait-for-db"])
docker_util.exec_safely(container,
["psql", "-U", "packituser", "-d",
"packit", "-a", "-f",
"/packit-schema/schema.sql"])


def packit_api_container(cfg):
name = cfg.containers["packit-api"]
packit_db = cfg.containers["packit-db"]
outpack = cfg.containers["outpack-server"]
db_url = (f"jdbc:postgresql://{cfg.container_prefix}-{packit_db}:5432/"
"packit?stringtype=unspecified")
outpack_url = f"http://{cfg.container_prefix}-{outpack}:8000"
env = {
"PACKIT_DB_URL": db_url,
"PACKIT_DB_USER": "packituser",
"PACKIT_DB_PASSWORD": "changeme",
"PACKIT_OUTPACK_SERVER_URL": outpack_url,
# We assume no auth is required in Packit alongside OW!
"PACKIT_AUTH_ENABLED": "false",
}
packit_api = constellation.ConstellationContainer(
name, cfg.packit_api_ref, configure=packit_api_configure)
name, cfg.packit_api_ref, environment=env)
return packit_api


def packit_api_configure(container, cfg):
print("[web] Configuring Packit API container")
outpack_container = cfg.containers["outpack-server"]
packit_db_container = cfg.containers["packit-db"]
url = "jdbc:postgresql://{}-{}:5432/packit?stringtype=unspecified"
opts = {
"db.url": url.format(cfg.container_prefix,
packit_db_container),
"db.user": "packituser",
"db.password": "changeme",
"outpack.server.url": "http://{}-{}:8000".format(cfg.container_prefix,
outpack_container)
}
txt = "".join(["{}={}\n".format(k, v) for k, v in opts.items()])
docker_util.string_into_container(
txt, container, "/etc/packit/config.properties")


def packit_container(cfg):
name = cfg.containers["packit"]
packit = constellation.ConstellationContainer(
Expand Down Expand Up @@ -151,6 +143,9 @@ def orderly_configure(container, cfg):
orderly_initial_data(cfg, container)
orderly_check_schema(container)
orderly_start(container)
# This is gross but wait a little for orderly to backup db before
# starting outpack server
time.sleep(5)


def orderly_initial_data(cfg, container):
Expand Down
14 changes: 9 additions & 5 deletions test/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def test_vault_github_login_with_prompt():
del os.environ["VAULT_AUTH_GITHUB_TOKEN"]
with mock.patch('builtins.input',
return_value=os.environ["VAULT_TEST_GITHUB_PAT"]):
with vault_dev.server() as s:
with vault_dev.Server() as s:
cl = s.client()
enable_github_login(cl)
cl.write("secret/db/password", value="s3cret")
Expand All @@ -336,15 +336,18 @@ def test_vault_github_login_with_prompt():
# This environment variable is configured on github actions
def test_vault_github_login_from_env():
os.environ["VAULT_AUTH_GITHUB_TOKEN"] = os.environ["VAULT_TEST_GITHUB_PAT"]
with vault_dev.server() as s:
with vault_dev.Server() as s:
cl = s.client()
enable_github_login(cl)
cl.write("secret/db/password", value="s3cret")

path = "config/vault"
vault_addr = "http://localhost:{}".format(s.port)
options = {"vault": {"addr": vault_addr}}

options = {
"vault": {
"addr": vault_addr
}
}
orderly_web.start(path, options=options)

cfg = fetch_config(path)
Expand All @@ -362,7 +365,7 @@ def test_vault_github_login_from_env():
# This environment variable is configured on github actions
def test_vault_github_login_with_mount_path():
os.environ["VAULT_AUTH_GITHUB_TOKEN"] = os.environ["VAULT_TEST_GITHUB_PAT"]
with vault_dev.server() as s:
with vault_dev.Server() as s:
cl = s.client()
enable_github_login(cl, path="github-custom")
cl.write("secret/db/password", value="s3cret")
Expand Down Expand Up @@ -498,6 +501,7 @@ def test_start_and_stop_multiple_workers():
try:
res = orderly_web.start(path, options=options)
assert res

assert docker_util.container_exists("orderly-web-web")
assert docker_util.container_exists("orderly-web-orderly")
assert docker_util.container_exists("orderly-web-proxy")
Expand Down