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

Refresh branch hash in cache for local worker on create #5138

Merged
merged 1 commit into from
Dec 3, 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
1 change: 1 addition & 0 deletions backend/infrahub/graphql/mutations/branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ async def mutate(

fields = await extract_fields(info.field_nodes[0].selection_set)
if context.service:
await context.service.component.refresh_schema_hash(branches=[obj.name])
message = messages.EventBranchCreate(
branch=obj.name,
branch_id=str(obj.id),
Expand Down
10 changes: 7 additions & 3 deletions backend/tests/unit/graphql/mutations/test_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from infrahub.graphql.initialization import prepare_graphql_params
from infrahub.message_bus import messages
from infrahub.services import InfrahubServices
from tests.adapters.cache import MemoryCache
from tests.adapters.message_bus import BusRecorder
from tests.helpers.graphql import graphql_mutation

Expand Down Expand Up @@ -71,7 +72,9 @@ async def test_branch_create(
}
"""
recorder = BusRecorder()
service = InfrahubServices(message_bus=recorder)
cache = MemoryCache()
service = InfrahubServices(message_bus=recorder, cache=cache, database=db)
await service.component.initialize(service=service)

result = await graphql_mutation(
query=query, db=db, service=service, branch=default_branch, account_session=session_admin
Expand Down Expand Up @@ -178,8 +181,9 @@ async def test_branch_delete(
query=delete_query, db=db, branch=default_branch, account_session=session_admin
)
recorder = BusRecorder()
service = InfrahubServices(message_bus=recorder)

cache = MemoryCache()
service = InfrahubServices(message_bus=recorder, cache=cache, database=db)
await service.component.initialize(service=service)
create = await graphql_mutation(
query=create_query, db=db, branch=default_branch, service=service, account_session=session_admin
)
Expand Down
1 change: 1 addition & 0 deletions changelog/5130.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Refresh branch hash on local worker during branch create
Loading