Skip to content

Commit

Permalink
Refresh branch hash in cache for local worker on create
Browse files Browse the repository at this point in the history
Fixes #5130
  • Loading branch information
ogenstad committed Dec 3, 2024
1 parent 7603f76 commit b3ebac7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
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
6 changes: 4 additions & 2 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 @@ -178,8 +179,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

0 comments on commit b3ebac7

Please sign in to comment.