Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/ibx-6507-retry-load-user-group' …
Browse files Browse the repository at this point in the history
  • Loading branch information
micszo committed Feb 28, 2024
2 parents 5281359 + fa5cf6f commit 7d6c578
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/browser-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
admin-ui:
name: "Admin UI tests"
uses: ibexa/gh-workflows/.github/workflows/browser-tests.yml@main
uses: ibexa/gh-workflows/.github/workflows/browser-tests.yml@ibx-6507
with:
project-edition: 'oss'
test-suite: '--profile=browser --suite=admin-ui-full'
Expand All @@ -22,7 +22,7 @@ jobs:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
examples:
name: "BehatBundle examples"
uses: ibexa/gh-workflows/.github/workflows/browser-tests.yml@main
uses: ibexa/gh-workflows/.github/workflows/browser-tests.yml@ibx-6507
with:
project-edition: 'oss'
test-suite: '--mode=standard --profile=service --suite=examples'
Expand Down
17 changes: 17 additions & 0 deletions features/setup/multirepository/multirepository_elastic.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Feature: Multirepository setup for testing with Elastic

@multirepository @IbexaContent @IbexaExperience @IbexaCommerce
Scenario: Set up new connection and make the default one unaccessible
Given I append configuration to "parameters" in "config/packages/ibexa_elasticsearch.yaml"
"""
elasticsearch_dsn_invalid: "INVALID"
"""
And I set configuration to "ibexa_elasticsearch.connections" in "config/packages/ibexa_elasticsearch.yaml"
"""
default:
hosts:
- "%elasticsearch_dsn_invalid%"
second_connection:
hosts:
- "%elasticsearch_dsn%"
"""
30 changes: 30 additions & 0 deletions features/setup/multirepository/multirepository_solr.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Feature: Multirepository setup for testing with Solr

@multirepository
Scenario: Set up new connection and make the default one unaccessible
Given I append configuration to "parameters" in "config/packages/ibexa_solr.yaml"
"""
solr_dsn_invalid: 'INVALID'
solr_core_invalid: 'INVALID'
"""
And I set configuration to "ibexa_solr" in "config/packages/ibexa_solr.yaml"
"""
endpoints:
endpoint0:
dsn: '%solr_dsn%'
core: '%solr_core%'
endpoint1_invalid:
dsn: '%solr_dsn_invalid%'
core: '%solr_core_invalid%'
connections:
default:
entry_endpoints:
- endpoint1_invalid
mapping:
default: endpoint1_invalid
second_connection:
entry_endpoints:
- endpoint0
mapping:
default: endpoint0
"""
18 changes: 12 additions & 6 deletions src/lib/API/Facade/UserFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,21 @@ private function loadLegacyUserGroupByName(string $userGroupName): UserGroup
new Criterion\ContentTypeIdentifier(self::USERGROUP_CONTENT_IDENTIFIER),
]);

$result = $this->searchService->findContent($query);
$iteration_count = 5;

while ($iteration_count > 0) {
$result = $this->searchService->findContent($query);

foreach ($result->searchHits as $searchHit) {
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Content $content */
$content = $searchHit->valueObject;
foreach ($result->searchHits as $searchHit) {
/** @var \Ibexa\Contracts\Core\Repository\Values\Content\Content $content */
$content = $searchHit->valueObject;

if ($content->contentInfo->name === $userGroupName) {
return $this->userService->loadUserGroup($content->contentInfo->id);
if ($content->contentInfo->name === $userGroupName) {
return $this->userService->loadUserGroup($content->contentInfo->id);
}
}
usleep(500000);
--$iteration_count;
}

throw new NotFoundException('User Group', $userGroupName);
Expand Down

0 comments on commit 7d6c578

Please sign in to comment.