Make some test timeouts (await) configurable (#2525)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-07-02 12:45:26 +03:00
committed by GitHub
parent bdbc658ea9
commit 8c6d56f177
77 changed files with 188 additions and 211 deletions

View File

@@ -18,7 +18,7 @@ import org.junit.jupiter.api.Test;
/**
* Test class to verify that no {@link ArtifactEncryptionService} required beans
* are loaded and therefore the encryption support is not given.
* <p/>
* <p/>
* Feature: Unit Tests - Repository<br/>
* Story: Artifact Encryption Service
*/

View File

@@ -24,7 +24,7 @@ import org.springframework.dao.UncategorizedDataAccessException;
/**
* Mapping tests for {@link HawkbitEclipseLinkJpaDialect}.
* <p/>
* <p/>
* Feature: Unit Tests - Repository<br/>
* Story: Exception handling
*/

View File

@@ -161,7 +161,7 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction> {
/**
* Counts all actions referring to a given rollout, rollout group and status.
* <p/>
* <p/>
* No access control applied
*
* @param rolloutId the ID of rollout the actions belong to
@@ -196,7 +196,7 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction> {
/**
* Returns {@code true} if actions for the given rollout exists, otherwise {@code false}
* <p/>
* <p/>
* No access control applied
*
* @param rolloutId the ID of the rollout the actions belong to
@@ -208,9 +208,9 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction> {
/**
* Retrieving all actions referring to a given rollout with a specific action as parent reference and a specific status.
* <p/>
* <p/>
* Finding all actions of a specific rollout group parent relation.
* <p/>
* <p/>
* No access control applied
*
* @param pageable page parameters
@@ -224,7 +224,7 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction> {
/**
* Retrieving all actions referring to the first group of a rollout.
* <p/>
* <p/>
* No access control applied
*
* @param pageable page parameters
@@ -237,7 +237,7 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction> {
/**
* Retrieves all actions for a specific rollout and in a specific status.
* <p/>
* <p/>
* No access control applied
*
* @param pageable page parameters
@@ -249,7 +249,7 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction> {
/**
* Get list of objects which has details of status and count of targets in each status in specified rollout.
* <p/>
* <p/>
* No access control applied
*
* @param rolloutId id of {@link Rollout}
@@ -260,7 +260,7 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction> {
/**
* Get list of objects which has details of status and count of targets in each status in specified rollout.
* <p/>
* <p/>
* No access control applied
*
* @param rolloutId id of {@link Rollout}
@@ -271,7 +271,7 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction> {
/**
* Get list of objects which has details of status and count of targets in each status in specified rollout group.
* <p/>
* <p/>
* No access control applied
*
* @param rolloutGroupId id of {@link RolloutGroup}
@@ -282,7 +282,7 @@ public interface ActionRepository extends BaseEntityRepository<JpaAction> {
/**
* Get list of objects which has details of status and count of targets in each status in specified rollout group.
* <p/>
* <p/>
* No access control applied
*
* @param rolloutGroupId list of id of {@link RolloutGroup}

View File

@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
/**
* Test the remote entity events.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Entity Id Events
*/

View File

@@ -19,7 +19,7 @@ import org.eclipse.hawkbit.repository.event.remote.AbstractRemoteEventTest;
/**
* Test the remote entity events.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Entity Events
*/

View File

@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
/**
* Test the remote entity events.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Test ActionCreatedEvent and ActionUpdatedEvent
*/

View File

@@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test;
/**
* Test the remote entity events.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Test DistributionSetCreatedEvent
*/

View File

@@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test;
/**
* Test the remote entity events.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Test DistributionSetTagCreatedEvent and DistributionSetTagUpdateEvent
*/

View File

@@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test;
/**
* Test the remote entity events.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Test DistributionSetUpdateEvent
*/

View File

@@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test;
/**
* Test the remote entity events.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Test RolloutUpdatedEvent
*/

View File

@@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
/**
* Test the remote entity events.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Test RolloutGroupCreatedEvent and RolloutGroupUpdatedEvent
*/

View File

@@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test;
/**
* Test the remote entity events.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Test SoftwareModuleCreatedEvent, SoftwareModuleUpdatedEvent
*/

View File

@@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test;
/**
* Test the remote entity events.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Test TargetCreatedEvent, TargetUpdatedEvent and CancelTargetAssignmentEvent
*/

View File

@@ -14,7 +14,7 @@ import org.junit.jupiter.api.Test;
/**
* Test the remote entity events.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Test TargetTagCreatedEvent and TargetTagUpdateEvent
*/

View File

@@ -43,7 +43,7 @@ import org.springframework.test.context.TestPropertySource;
/**
* Test class testing the invalidation of a {@link DistributionSet} while the
* handle rollouts is ongoing.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Concurrent Distribution Set invalidation
*/
@@ -67,12 +67,14 @@ class ConcurrentDistributionSetInvalidationTest extends AbstractJpaIntegrationTe
return 0;
}, tenant)).start();
// wait until at least one RolloutGroup is created, as this means that
// the thread has started and has acquired the lock
Awaitility.await().atMost(Duration.ofSeconds(5))
// wait until at least one RolloutGroup is created, as this means that the thread has started and has acquired the lock
Awaitility.await()
.pollInterval(Duration.ofMillis(100))
.until(() -> tenantAware.runAsTenant(tenant, () -> systemSecurityContext
.runAsSystem(() -> rolloutGroupManagement.findByRollout(rollout.getId(), PAGE).getSize() > 0)));
.atMost(Duration.ofSeconds(5))
.until(() -> tenantAware.runAsTenant(
tenant,
() -> systemSecurityContext.runAsSystem(
() -> rolloutGroupManagement.findByRollout(rollout.getId(), PAGE).getSize() > 0)));
final DistributionSetInvalidation distributionSetInvalidation = new DistributionSetInvalidation(
Collections.singletonList(distributionSet.getId()), CancelationType.SOFT, true);

View File

@@ -45,7 +45,7 @@ import org.springframework.data.domain.Slice;
/**
* Test class for {@link AutoAssignChecker}.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Auto assign checker
*/

View File

@@ -27,7 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
/**
* Test class for {@link AutoActionCleanup}.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Action cleanup handler
*/

View File

@@ -22,7 +22,7 @@ import org.springframework.integration.support.locks.LockRegistry;
/**
* Test class for {@link AutoCleanupScheduler}.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Auto cleanup scheduler
*/

View File

@@ -48,7 +48,10 @@ class ActionTest extends AbstractJpaIntegrationTest {
assertThat(timeforcedAction.isForcedOrTimeForced()).isFalse();
// wait until timeforce time is hit
Awaitility.await().atMost(Duration.ofSeconds(2)).pollInterval(Duration.ofMillis(100)).until(timeforcedAction::isForcedOrTimeForced);
Awaitility.await()
.pollInterval(Duration.ofMillis(100))
.atMost(Duration.ofSeconds(2))
.until(timeforcedAction::isForcedOrTimeForced);
}
/**

View File

@@ -54,7 +54,7 @@ import org.junit.jupiter.api.Test;
/**
* Test class for {@link ArtifactManagement}.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Artifact Management
*/

View File

@@ -35,7 +35,7 @@ import org.junit.jupiter.params.provider.MethodSource;
/**
* Test class testing the functionality of triggering a deployment of
* {@link DistributionSet}s to {@link Target}s with AutoConfirmation active.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Confirmation Management
*/

View File

@@ -93,7 +93,7 @@ import org.springframework.data.domain.Sort.Direction;
/**
* Test class testing the functionality of triggering a deployment of {@link DistributionSet}s to {@link Target}s.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Deployment Management
*/

View File

@@ -38,7 +38,7 @@ import org.springframework.data.repository.query.Param;
/**
* Test class testing the functionality of invalidating a
* {@link DistributionSet}
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Distribution set invalidation management
*/

View File

@@ -69,7 +69,7 @@ import org.springframework.beans.factory.annotation.Autowired;
/**
* {@link DistributionSetManagement} tests.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: DistributionSet Management
*/

View File

@@ -41,7 +41,7 @@ import org.springframework.data.domain.Pageable;
/**
* {@link DistributionSetTagManagement} tests.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: DistributionSet Tag Management
*/

View File

@@ -44,7 +44,7 @@ import org.junit.jupiter.api.Test;
/**
* {@link DistributionSetManagement} tests.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: DistributionSet Management
*/

View File

@@ -32,7 +32,7 @@ import org.springframework.test.context.TestPropertySource;
/**
* Junit tests for RolloutManagement.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Rollout Management (Flow)
*/

View File

@@ -99,7 +99,7 @@ import org.springframework.data.domain.Sort.Direction;
/**
* Junit tests for RolloutManagement.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Rollout Management
*/
@@ -2497,7 +2497,9 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
}
private void awaitRunningState(final Long myRolloutId) {
Awaitility.await().atMost(Duration.ofSeconds(10)).pollInterval(Duration.ofMillis(500)).with()
Awaitility.await()
.pollInterval(Duration.ofMillis(500))
.atMost(Duration.ofSeconds(10))
.until(() -> SecurityContextSwitch
.runAsPrivileged(
() -> rolloutManagement.get(myRolloutId).orElseThrow(NoSuchElementException::new))

View File

@@ -56,7 +56,7 @@ import org.springframework.data.domain.Slice;
/**
* Test class for {@link TargetFilterQueryManagement}.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Target Filter Query Management
*/

View File

@@ -43,7 +43,7 @@ import org.springframework.data.domain.Pageable;
/**
* Test class for {@link TargetTagManagement}.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Target Tag Management
*/

View File

@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
/**
* Test the entity listener interceptor.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Entity Listener Interceptor
*/

View File

@@ -31,7 +31,7 @@ import org.springframework.data.domain.Slice;
* Multi-Tenancy tests which testing the CRUD operations of entities that all
* CRUD-Operations are tenant aware and cannot access or delete entities not
* belonging to the current tenant.
* <p/>
* <p/>
* Feature: Component Tests - Repository<br/>
* Story: Multi Tenancy
*/

View File

@@ -17,6 +17,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.time.Duration;
import java.time.ZonedDateTime;
import java.util.Collections;
import java.util.Comparator;
@@ -25,9 +26,10 @@ import java.util.NoSuchElementException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.awaitility.Awaitility;
import org.awaitility.core.ConditionFactory;
import org.eclipse.hawkbit.artifact.repository.ArtifactRepository;
import org.eclipse.hawkbit.artifact.repository.ArtifactStoreException;
import org.eclipse.hawkbit.cache.TenantAwareCacheManager;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.ConfirmationManagement;
import org.eclipse.hawkbit.repository.ControllerManagement;
@@ -74,7 +76,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.bus.ServiceMatcher;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.data.auditing.AuditingHandler;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
@@ -263,6 +264,14 @@ public abstract class AbstractIntegrationTest {
return currentTime.getOffset().getId().replace("Z", "+00:00");
}
private static final Duration AT_LEAST = Duration.ofMillis(Integer.getInteger("hawkbit.it.rest.await.atLeastMs", 5));
private static final Duration POLL_INTERVAL = Duration.ofMillis(Integer.getInteger("hawkbit.it.rest.await.pollIntervalMs", 10));
private static final Duration TIMEOUT = Duration.ofMillis(Integer.getInteger("hawkbit.it.rest.await.timeoutMs", 200));
// default wait condition factory
protected ConditionFactory await() {
return Awaitility.await().atLeast(AT_LEAST).pollInterval(POLL_INTERVAL).atMost(TIMEOUT);
}
protected static Action getFirstAssignedAction(
final DistributionSetAssignmentResult distributionSetAssignmentResult) {
return distributionSetAssignmentResult.getAssignedEntity().stream().findFirst()