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

Backport: fix upgrade script for 1.17 #3825

Merged
merged 2 commits into from
Nov 19, 2024
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
6 changes: 5 additions & 1 deletion boefjes/tests/integration/test_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from pathlib import Path

import pytest
from tools.upgrade_v1_16_0 import upgrade
from tools.upgrade_v1_17_0 import upgrade

from boefjes.clients.bytes_client import BytesAPIClient
from boefjes.config import BASE_DIR
from boefjes.models import Organisation
from boefjes.sql.organisation_storage import SQLOrganisationStorage
from octopoes.connector.octopoes import OctopoesAPIConnector
from octopoes.models import Reference
Expand All @@ -25,6 +26,9 @@ def test_migration(
octopoes_api_connector.session._timeout.connect = 60
octopoes_api_connector.session._timeout.read = 60

# Create an organisation that does not exist in Octopoes
organisation_repository.create(Organisation(id="test2", name="Test 2"))

iterations = 30
cache_path = Path(BASE_DIR.parent / ".ci" / f".cache_{iterations}.json")
hostname_range = range(0, iterations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ def migrate_organisation(
and set the source_method to the boefje id. Then update the origin, i.e. save it and delete the old one.
"""

try:
connector.health()
except HTTPStatusError as e:
if e.response.status_code == 404:
logger.warning(
"Organisation found that does not exist in Octopoes [organisation_id=%s]. Make sure to remove this "
"organisation from the Katalogus database if it is no longer in use.",
organisation_id,
)
raise

failed = 0
processed = 0

Expand Down