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

@@ -24,7 +24,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
/** /**
* Tests for creating urls to download artifacts. * Tests for creating urls to download artifacts.
* <p/> * <p/>
* Feature: Unit Tests - Artifact URL Handler<br/> * Feature: Unit Tests - Artifact URL Handler<br/>
* Story: Test to generate the artifact download URL * Story: Test to generate the artifact download URL
*/ */

View File

@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serialization of DDI api model 'DdiActionFeedback' * Test serialization of DDI api model 'DdiActionFeedback'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serialization of DDI api Models * Story: Serialization of DDI api Models
*/ */

View File

@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiActionHistory' * Test serializability of DDI api model 'DdiActionHistory'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models * Story: Serializability of DDI api Models
*/ */

View File

@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiArtifactHash' * Test serializability of DDI api model 'DdiArtifactHash'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models * Story: Serializability of DDI api Models
*/ */

View File

@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiArtifact' * Test serializability of DDI api model 'DdiArtifact'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models * Story: Serializability of DDI api Models
*/ */

View File

@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiCancelActionToStop' * Test serializability of DDI api model 'DdiCancelActionToStop'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models * Story: Serializability of DDI api Models
*/ */

View File

@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiArtifact' * Test serializability of DDI api model 'DdiArtifact'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models * Story: Serializability of DDI api Models
*/ */

View File

@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiChunk' * Test serializability of DDI api model 'DdiChunk'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models * Story: Serializability of DDI api Models
*/ */

View File

@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiConfigData' * Test serializability of DDI api model 'DdiConfigData'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models * Story: Serializability of DDI api Models
*/ */

View File

@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiConfig' * Test serializability of DDI api model 'DdiConfig'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models * Story: Serializability of DDI api Models
*/ */

View File

@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiConfirmationBase' * Test serializability of DDI api model 'DdiConfirmationBase'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: CHeck JSON serialization of DDI api confirmation models * Story: CHeck JSON serialization of DDI api confirmation models
*/ */

View File

@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiControllerBase' * Test serializability of DDI api model 'DdiControllerBase'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models * Story: Serializability of DDI api Models
*/ */

View File

@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiDeploymentBase' * Test serializability of DDI api model 'DdiDeploymentBase'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models * Story: Serializability of DDI api Models
*/ */

View File

@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiDeployment' * Test serializability of DDI api model 'DdiDeployment'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models * Story: Serializability of DDI api Models
*/ */

View File

@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiMetadata' * Test serializability of DDI api model 'DdiMetadata'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models * Story: Serializability of DDI api Models
*/ */

View File

@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiPolling' * Test serializability of DDI api model 'DdiPolling'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models * Story: Serializability of DDI api Models
*/ */

View File

@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiProgress' * Test serializability of DDI api model 'DdiProgress'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models * Story: Serializability of DDI api Models
*/ */

View File

@@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiResult' * Test serializability of DDI api model 'DdiResult'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models * Story: Serializability of DDI api Models
*/ */

View File

@@ -28,7 +28,7 @@ import org.junit.jupiter.params.provider.MethodSource;
/** /**
* Test serializability of DDI api model 'DdiStatus' * Test serializability of DDI api model 'DdiStatus'
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models * Story: Serializability of DDI api Models
*/ */

View File

@@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Check DDI api model classes for '@JsonIgnoreProperties' annotation * Check DDI api model classes for '@JsonIgnoreProperties' annotation
* <p/> * <p/>
* Feature: Unit Tests - Direct Device Integration API<br/> * Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serialization of DDI api Models * Story: Serialization of DDI api Models
*/ */

View File

@@ -50,7 +50,7 @@ import org.springframework.test.web.servlet.MvcResult;
/** /**
* Test artifact downloads from the controller. * Test artifact downloads from the controller.
* <p/> * <p/>
* Feature: Component Tests - Direct Device Integration API<br/> * Feature: Component Tests - Direct Device Integration API<br/>
* Story: Artifact Download Resource * Story: Artifact Download Resource
*/ */

View File

@@ -43,7 +43,7 @@ import org.springframework.integration.json.JsonPathUtils;
/** /**
* Test cancel action from the controller. * Test cancel action from the controller.
* <p/> * <p/>
* Feature: Component Tests - Direct Device Integration API<br/> * Feature: Component Tests - Direct Device Integration API<br/>
* Story: Cancel Action Resource * Story: Cancel Action Resource
*/ */

View File

@@ -59,7 +59,7 @@ import org.springframework.test.web.servlet.ResultActions;
/** /**
* Test confirmation base from the controller. * Test confirmation base from the controller.
* <p/> * <p/>
* Feature: Component Tests - Direct Device Integration API<br/> * Feature: Component Tests - Direct Device Integration API<br/>
* Story: Confirmation Action Resource * Story: Confirmation Action Resource
*/ */

View File

@@ -67,7 +67,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
/** /**
* Test deployment base from the controller. * Test deployment base from the controller.
* <p/> * <p/>
* Feature: Component Tests - Direct Device Integration API<br/> * Feature: Component Tests - Direct Device Integration API<br/>
* Story: Deployment Action Resource * Story: Deployment Action Resource
*/ */

View File

@@ -63,7 +63,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
/** /**
* Test installed base from the controller. * Test installed base from the controller.
* <p/> * <p/>
* Feature: Component Tests - Direct Device Integration API<br/> * Feature: Component Tests - Direct Device Integration API<br/>
* Story: Installed Base Resource * Story: Installed Base Resource
*/ */

View File

@@ -69,7 +69,7 @@ import org.springframework.test.web.servlet.ResultActions;
/** /**
* Test the root controller resources. * Test the root controller resources.
* <p/> * <p/>
* Feature: Component Tests - Direct Device Integration API<br/> * Feature: Component Tests - Direct Device Integration API<br/>
* Story: Root Poll Resource * Story: Root Poll Resource
*/ */

View File

@@ -93,10 +93,7 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
} }
protected <T> T waitUntilIsPresent(final Callable<Optional<T>> callable) { protected <T> T waitUntilIsPresent(final Callable<Optional<T>> callable) {
await().until(() -> SecurityContextSwitch.runAsPrivileged(() -> callable.call().isPresent()));
createConditionFactory()
.until(() -> SecurityContextSwitch.runAsPrivileged(() -> callable.call().isPresent()));
try { try {
return SecurityContextSwitch.runAsPrivileged(() -> callable.call().get()); return SecurityContextSwitch.runAsPrivileged(() -> callable.call().get());
} catch (final Exception e) { } catch (final Exception e) {
@@ -105,8 +102,8 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
} }
protected void waitUntilEventMessagesAreDispatchedToTarget(final EventTopic... eventTopics) { protected void waitUntilEventMessagesAreDispatchedToTarget(final EventTopic... eventTopics) {
createConditionFactory().untilAsserted(() -> assertThat(replyToListener.getLatestEventMessageTopics()) await().untilAsserted(() ->
.containsExactlyInAnyOrderElementsOf(Arrays.asList(eventTopics))); assertThat(replyToListener.getLatestEventMessageTopics()).containsExactlyInAnyOrderElementsOf(Arrays.asList(eventTopics)));
replyToListener.resetLatestEventMessageTopics(); replyToListener.resetLatestEventMessageTopics();
} }
@@ -188,8 +185,8 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
} }
protected void assertDmfDownloadAndUpdateRequest(final DmfDownloadAndUpdateRequest request, protected void assertDmfDownloadAndUpdateRequest(
final Set<SoftwareModule> softwareModules, final String controllerId) { final DmfDownloadAndUpdateRequest request, final Set<SoftwareModule> softwareModules, final String controllerId) {
assertSoftwareModules(softwareModules, request.getSoftwareModules()); assertSoftwareModules(softwareModules, request.getSoftwareModules());
final Target updatedTarget = waitUntilIsPresent(() -> targetManagement.getByControllerID(controllerId)); final Target updatedTarget = waitUntilIsPresent(() -> targetManagement.getByControllerID(controllerId));
assertThat(updatedTarget).isNotNull(); assertThat(updatedTarget).isNotNull();
@@ -217,8 +214,7 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
} }
protected void verifyReplyToListener() { protected void verifyReplyToListener() {
createConditionFactory() await().untilAsserted(() -> Mockito.verify(replyToListener, Mockito.atLeast(1)).handleMessage(Mockito.any()));
.untilAsserted(() -> Mockito.verify(replyToListener, Mockito.atLeast(1)).handleMessage(Mockito.any()));
} }
protected Long cancelAction(final Long actionId, final String controllerId) { protected Long cancelAction(final Long actionId, final String controllerId) {
@@ -369,8 +365,7 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
protected void assertUpdateAttributes(final String controllerId, final Map<String, String> attributes) { protected void assertUpdateAttributes(final String controllerId, final Map<String, String> attributes) {
waitUntilIsPresent(() -> controllerManagement.getByControllerId(controllerId)); waitUntilIsPresent(() -> controllerManagement.getByControllerId(controllerId));
await().untilAsserted(() -> {
createConditionFactory().untilAsserted(() -> {
try { try {
final Map<String, String> controllerAttributes = SecurityContextSwitch.runAsPrivileged( final Map<String, String> controllerAttributes = SecurityContextSwitch.runAsPrivileged(
() -> targetManagement.getControllerAttributes(controllerId)); () -> targetManagement.getControllerAttributes(controllerId));
@@ -416,16 +411,14 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
assertConfirmRequest(confirmRequest, dsModules, controllerId); assertConfirmRequest(confirmRequest, dsModules, controllerId);
} }
protected void assertConfirmRequest(final DmfConfirmRequest request, final Set<SoftwareModule> softwareModules, protected void assertConfirmRequest(final DmfConfirmRequest request, final Set<SoftwareModule> softwareModules, final String controllerId) {
final String controllerId) {
assertSoftwareModules(softwareModules, request.getSoftwareModules()); assertSoftwareModules(softwareModules, request.getSoftwareModules());
final Target updatedTarget = waitUntilIsPresent(() -> targetManagement.getByControllerID(controllerId)); final Target updatedTarget = waitUntilIsPresent(() -> targetManagement.getByControllerID(controllerId));
assertThat(updatedTarget).isNotNull(); assertThat(updatedTarget).isNotNull();
assertThat(updatedTarget.getSecurityToken()).isEqualTo(request.getTargetSecurityToken()); assertThat(updatedTarget.getSecurityToken()).isEqualTo(request.getTargetSecurityToken());
} }
private void assertAssignmentMessage(final Set<SoftwareModule> dsModules, final String controllerId, private void assertAssignmentMessage(final Set<SoftwareModule> dsModules, final String controllerId, final EventTopic topic) {
final EventTopic topic) {
final Message replyMessage = assertReplyMessageHeader(topic, controllerId); final Message replyMessage = assertReplyMessageHeader(topic, controllerId);
assertAllTargetsCount(1); assertAllTargetsCount(1);
@@ -435,7 +428,8 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
assertDmfDownloadAndUpdateRequest(downloadAndUpdateRequest, dsModules, controllerId); assertDmfDownloadAndUpdateRequest(downloadAndUpdateRequest, dsModules, controllerId);
} }
private void registerAndAssertTargetWithExistingTenant(final String controllerId, final String name, private void registerAndAssertTargetWithExistingTenant(
final String controllerId, final String name,
final int existingTargetsAfterCreation, final TargetUpdateStatus expectedTargetStatus, final int existingTargetsAfterCreation, final TargetUpdateStatus expectedTargetStatus,
final String createdBy, final Map<String, String> attributes, final String createdBy, final Map<String, String> attributes,
final Callable<Optional<Target>> fetchTarget) { final Callable<Optional<Target>> fetchTarget) {
@@ -443,8 +437,9 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
final Target registeredTarget = waitUntilIsPresent(fetchTarget::call); final Target registeredTarget = waitUntilIsPresent(fetchTarget::call);
assertAllTargetsCount(existingTargetsAfterCreation); assertAllTargetsCount(existingTargetsAfterCreation);
assertThat(registeredTarget).isNotNull(); assertThat(registeredTarget).isNotNull();
assertTarget(registeredTarget, name != null ? name : controllerId, expectedTargetStatus, createdBy, assertTarget(
attributes != null ? attributes : Collections.emptyMap()); registeredTarget, name != null ? name : controllerId, expectedTargetStatus,
createdBy, attributes != null ? attributes : Collections.emptyMap());
} }
private Optional<Target> findTargetBasedOnNewVersion(final String controllerId, final int version) { private Optional<Target> findTargetBasedOnNewVersion(final String controllerId, final int version) {
@@ -455,7 +450,8 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
return Optional.empty(); return Optional.empty();
} }
private void assertTarget(final Target target, final String name, final TargetUpdateStatus updateStatus, private void assertTarget(
final Target target, final String name, final TargetUpdateStatus updateStatus,
final String createdBy, final Map<String, String> attributes) { final String createdBy, final Map<String, String> attributes) {
assertThat(target.getTenant()).isEqualTo(TENANT_EXIST); assertThat(target.getTenant()).isEqualTo(TENANT_EXIST);
assertThat(target.getName()).isEqualTo(name); assertThat(target.getName()).isEqualTo(name);
@@ -463,9 +459,7 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
assertThat(target.getDescription()).contains(target.getControllerId()); assertThat(target.getDescription()).contains(target.getControllerId());
assertThat(target.getCreatedBy()).isEqualTo(createdBy); assertThat(target.getCreatedBy()).isEqualTo(createdBy);
assertThat(target.getUpdateStatus()).isEqualTo(updateStatus); assertThat(target.getUpdateStatus()).isEqualTo(updateStatus);
assertThat(target.getAddress()) assertThat(target.getAddress()).isEqualTo(IpUtil.createAmqpUri(getVirtualHost(), DmfTestConfiguration.REPLY_TO_EXCHANGE));
.isEqualTo(IpUtil.createAmqpUri(getVirtualHost(), DmfTestConfiguration.REPLY_TO_EXCHANGE));
assertThat(targetManagement.getControllerAttributes(target.getControllerId())).isEqualTo(attributes); assertThat(targetManagement.getControllerAttributes(target.getControllerId())).isEqualTo(attributes);
} }
}
}

View File

@@ -794,7 +794,7 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
} }
private void waitUntil(final Callable<Boolean> callable) { private void waitUntil(final Callable<Boolean> callable) {
createConditionFactory().until(() -> SecurityContextSwitch.runAsPrivileged(callable)); await().until(() -> SecurityContextSwitch.runAsPrivileged(callable));
} }
private void assertLatestMultiActionMessageContainsInstallMessages(final String controllerId, private void assertLatestMultiActionMessageContainsInstallMessages(final String controllerId,

View File

@@ -1229,26 +1229,22 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
} }
private void assertAction(final Long actionId, final int messages, final Status... expectedActionStates) { private void assertAction(final Long actionId, final int messages, final Status... expectedActionStates) {
createConditionFactory().await().untilAsserted(() -> { await().untilAsserted(() -> {
try { try {
SecurityContextSwitch.runAsPrivileged(() -> { SecurityContextSwitch.runAsPrivileged(() -> {
final List<ActionStatus> actionStatusList = deploymentManagement final List<ActionStatus> actionStatusList = deploymentManagement.findActionStatusByAction(actionId, PAGE).getContent();
.findActionStatusByAction(actionId, PAGE).getContent();
// Check correlation ID // Check correlation ID
final List<String> messagesFromServer = actionStatusList.stream() final List<String> messagesFromServer = actionStatusList.stream()
.flatMap(actionStatus -> deploymentManagement .flatMap(actionStatus -> deploymentManagement
.findMessagesByActionStatusId(actionStatus.getId(), PAGE).getContent().stream()) .findMessagesByActionStatusId(actionStatus.getId(), PAGE).getContent().stream())
.filter(Objects::nonNull) .filter(Objects::nonNull)
.filter(message -> message .filter(message -> message.startsWith(RepositoryConstants.SERVER_MESSAGE_PREFIX + "DMF message"))
.startsWith(RepositoryConstants.SERVER_MESSAGE_PREFIX + "DMF message"))
.toList(); .toList();
assertThat(messagesFromServer).hasSize(messages) assertThat(messagesFromServer).hasSize(messages).allMatch(message -> message.endsWith(CORRELATION_ID));
.allMatch(message -> message.endsWith(CORRELATION_ID));
final List<Status> status = actionStatusList.stream().map(ActionStatus::getStatus) final List<Status> status = actionStatusList.stream().map(ActionStatus::getStatus).toList();
.toList();
assertThat(status).containsOnly(expectedActionStates); assertThat(status).containsOnly(expectedActionStates);
return null; return null;
@@ -1267,7 +1263,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
private void assertActionStatusList(final Long actionId, final int statusListCount, private void assertActionStatusList(final Long actionId, final int statusListCount,
final Status... expectedActionStates) { final Status... expectedActionStates) {
createConditionFactory().await().untilAsserted(() -> { await().untilAsserted(() -> {
try { try {
SecurityContextSwitch.runAsPrivileged(() -> { SecurityContextSwitch.runAsPrivileged(() -> {
final List<ActionStatus> actionStatusList = deploymentManagement final List<ActionStatus> actionStatusList = deploymentManagement
@@ -1302,8 +1298,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
private void verifyNumberOfDeadLetterMessages(final int numberOfInvocations) { private void verifyNumberOfDeadLetterMessages(final int numberOfInvocations) {
assertEmptyReceiverQueueCount(); assertEmptyReceiverQueueCount();
createConditionFactory().untilAsserted(() -> Mockito await().untilAsserted(
.verify(getDeadletterListener(), Mockito.times(numberOfInvocations)).handleMessage(Mockito.any())); () -> Mockito.verify(getDeadletterListener(), Mockito.times(numberOfInvocations)).handleMessage(Mockito.any()));
Mockito.reset(getDeadletterListener()); Mockito.reset(getDeadletterListener());
} }
} }

View File

@@ -40,8 +40,6 @@ import org.springframework.test.context.ContextConfiguration;
@SuppressWarnings("java:S6813") // constructor injects are not possible for test classes @SuppressWarnings("java:S6813") // constructor injects are not possible for test classes
public abstract class AbstractAmqpIntegrationTest extends AbstractIntegrationTest { public abstract class AbstractAmqpIntegrationTest extends AbstractIntegrationTest {
private static final Duration TIMEOUT = Duration.ofSeconds(5);
@Autowired @Autowired
private ConnectionFactory connectionFactory; private ConnectionFactory connectionFactory;
@Autowired @Autowired
@@ -60,8 +58,11 @@ public abstract class AbstractAmqpIntegrationTest extends AbstractIntegrationTes
return dmfClient; return dmfClient;
} }
protected ConditionFactory createConditionFactory() { private static final Duration AT_LEAST = Duration.ofMillis(Integer.getInteger("hawkbit.it.amqp.await.atLeastMs", 100));
return Awaitility.await().atMost(TIMEOUT.toMillis(), TimeUnit.MILLISECONDS); private static final Duration POLL_INTERVAL = Duration.ofMillis(Integer.getInteger("hawkbit.it.amqp.await.pollIntervalMs", 200));
private static final Duration TIMEOUT = Duration.ofMillis(Integer.getInteger("hawkbit.it.amqp.await.timeoutMs", 5000));
protected ConditionFactory await() {
return Awaitility.await().atLeast(AT_LEAST).pollInterval(POLL_INTERVAL).atMost(TIMEOUT);
} }
protected Message createMessage(final Object payload, final MessageProperties messageProperties) { protected Message createMessage(final Object payload, final MessageProperties messageProperties) {

View File

@@ -19,14 +19,11 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.time.Duration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import org.awaitility.Awaitility;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtActionRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtActionRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
@@ -42,7 +39,7 @@ import org.springframework.test.web.servlet.ResultActions;
/** /**
* Integration test for the {@link MgmtActionRestApi}. * Integration test for the {@link MgmtActionRestApi}.
* <p/> * <p/>
* Feature: Component Tests - Management API<br/> * Feature: Component Tests - Management API<br/>
* Story: Action Resource * Story: Action Resource
*/ */
@@ -65,7 +62,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
* Handles the GET request of retrieving a specific action. * Handles the GET request of retrieving a specific action.
*/ */
@Test @Test
void getAction() throws Exception { void getAction() throws Exception {
getAction(false); getAction(false);
} }
@@ -73,7 +70,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
* Handles the GET request of retrieving a specific action with external reference. * Handles the GET request of retrieving a specific action with external reference.
*/ */
@Test @Test
void getActionExtRef() throws Exception { void getActionExtRef() throws Exception {
getAction(true); getAction(true);
} }
@@ -82,7 +79,6 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
*/ */
@Test @Test
void filterActionsByStatus() throws Exception { void filterActionsByStatus() throws Exception {
// prepare test // prepare test
final DistributionSet dsA = testdataFactory.createDistributionSet(""); final DistributionSet dsA = testdataFactory.createDistributionSet("");
assignDistributionSet(dsA, Collections.singletonList(testdataFactory.createTarget("knownTargetId"))); assignDistributionSet(dsA, Collections.singletonList(testdataFactory.createTarget("knownTargetId")));
@@ -217,8 +213,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(action.getId()).code(200) controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(action.getId()).code(200)
.message("Update succeeded").status(Status.FINISHED)); .message("Update succeeded").status(Status.FINISHED));
// verify that one result is returned if the actions are filtered for // verify that one result is returned if the actions are filtered for status code 200
// status code 200
final String rsqlStatusCode = "lastStatusCode==200"; final String rsqlStatusCode = "lastStatusCode==200";
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlStatusCode)) mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlStatusCode))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
@@ -227,8 +222,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("size", equalTo(1))) .andExpect(jsonPath("size", equalTo(1)))
.andExpect(jsonPath("content[0].status", equalTo("finished"))); .andExpect(jsonPath("content[0].status", equalTo("finished")));
// verify no result is returned if we filter for a non-existing status // verify no result is returned if we filter for a non-existing status code
// code
final String rsqlWrongStatusCode = "lastStatusCode==999"; final String rsqlWrongStatusCode = "lastStatusCode==999";
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlWrongStatusCode)) mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlWrongStatusCode))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
@@ -298,8 +292,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
// rollout // rollout
final Target target1 = testdataFactory.createTarget("t1"); final Target target1 = testdataFactory.createTarget("t1");
final Rollout rollout = testdataFactory.createRolloutByVariables("TestRollout", "TestDesc", 1, final Rollout rollout = testdataFactory.createRolloutByVariables(
"name==" + target1.getName(), ds, "50", "5"); "TestRollout", "TestDesc", 1, "name==" + target1.getName(), ds, "50", "5");
rolloutManagement.start(rollout.getId()); rolloutManagement.start(rollout.getId());
rolloutHandler.handleAll(); rolloutHandler.handleAll();
@@ -517,8 +511,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
} }
private static String generateActionLink(final String targetId, final Long actionId) { private static String generateActionLink(final String targetId, final Long actionId) {
return "http://localhost" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + targetId + "/" + return "http://localhost" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING +
MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId; "/" + targetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId;
} }
private static String generateTargetLink(final String targetId) { private static String generateTargetLink(final String targetId) {
@@ -526,8 +520,7 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
} }
private static String generateDistributionSetLink(final Action action) { private static String generateDistributionSetLink(final Action action) {
return "http://localhost" + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" return "http://localhost" + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + action.getDistributionSet().getId();
+ action.getDistributionSet().getId();
} }
private void verifyResultsByTargetPropertyFilter(final Target target, final DistributionSet ds, final String rsqlTargetFilter) private void verifyResultsByTargetPropertyFilter(final Target target, final DistributionSet ds, final String rsqlTargetFilter)
@@ -598,13 +591,12 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
final DistributionSet ds = testdataFactory.createDistributionSet(); final DistributionSet ds = testdataFactory.createDistributionSet();
// rollout // rollout
final Target target = testdataFactory.createTarget(knownTargetId); final Target target = testdataFactory.createTarget(knownTargetId);
final Rollout rollout = testdataFactory.createRolloutByVariables("TestRollout", "TestDesc", 1, final Rollout rollout = testdataFactory.createRolloutByVariables(
"name==" + target.getName(), ds, "50", "5"); "TestRollout", "TestDesc", 1, "name==" + target.getName(), ds, "50", "5");
rolloutManagement.start(rollout.getId()); rolloutManagement.start(rollout.getId());
rolloutHandler.handleAll(); rolloutHandler.handleAll();
final List<Action> actions = deploymentManagement.findActionsByTarget(target.getControllerId(), PAGE) final List<Action> actions = deploymentManagement.findActionsByTarget(target.getControllerId(), PAGE).getContent();
.getContent();
assertThat(actions).hasSize(1); assertThat(actions).hasSize(1);
final String externalRef = "externalRef#123"; final String externalRef = "externalRef#123";
if (withExternalRef) { if (withExternalRef) {
@@ -625,8 +617,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
return generateTargetWithTwoUpdatesWithOneOverrideWithMaintenanceWindow(knownTargetId, null, null, null); return generateTargetWithTwoUpdatesWithOneOverrideWithMaintenanceWindow(knownTargetId, null, null, null);
} }
private List<Action> generateTargetWithTwoUpdatesWithOneOverrideWithMaintenanceWindow(final String knownTargetId, private List<Action> generateTargetWithTwoUpdatesWithOneOverrideWithMaintenanceWindow(
final String schedule, final String duration, final String timezone) { final String knownTargetId, final String schedule, final String duration, final String timezone) {
final Target target = testdataFactory.createTarget(knownTargetId); final Target target = testdataFactory.createTarget(knownTargetId);
final Iterator<DistributionSet> sets = testdataFactory.createDistributionSets(2).iterator(); final Iterator<DistributionSet> sets = testdataFactory.createDistributionSets(2).iterator();
@@ -639,26 +631,22 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.getAssignedEntity().stream().map(Action::getTarget).toList(); .getAssignedEntity().stream().map(Action::getTarget).toList();
// 2nd update // 2nd update
// sleep 10ms to ensure that we can sort by reportedAt // sleep 10ms to ensure that we can sort by reportedAt
Awaitility.await().atMost(Duration.ofMillis(100)).atLeast(5, TimeUnit.MILLISECONDS) await().until(() -> updatedTargets.stream().allMatch(t -> t.getLastModifiedAt() > 0L));
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> updatedTargets.stream().allMatch(t -> t.getLastModifiedAt() > 0L));
assignDistributionSet(two, updatedTargets); assignDistributionSet(two, updatedTargets);
} else { } else {
final List<Target> updatedTargets = assignDistributionSetWithMaintenanceWindow(one.getId(), final List<Target> updatedTargets =
target.getControllerId(), schedule, duration, timezone).getAssignedEntity().stream() assignDistributionSetWithMaintenanceWindow(one.getId(), target.getControllerId(), schedule, duration, timezone)
.map(Action::getTarget).toList(); .getAssignedEntity().stream()
.map(Action::getTarget)
.toList();
// 2nd update // 2nd update
// sleep 10ms to ensure that we can sort by reportedAt // sleep 10ms to ensure that we can sort by reportedAt
Awaitility.await().atMost(Duration.ofMillis(100)).atLeast(5, TimeUnit.MILLISECONDS) await().until(() -> updatedTargets.stream().allMatch(t -> t.getLastModifiedAt() > 0L));
.pollInterval(10, TimeUnit.MILLISECONDS) assignDistributionSetWithMaintenanceWindow(two.getId(), updatedTargets.get(0).getControllerId(), schedule, duration, timezone);
.until(() -> updatedTargets.stream().allMatch(t -> t.getLastModifiedAt() > 0L));
assignDistributionSetWithMaintenanceWindow(two.getId(), updatedTargets.get(0).getControllerId(), schedule,
duration, timezone);
} }
// two updates, one cancellation // two updates, one cancellation
final List<Action> actions = deploymentManagement.findActionsByTarget(target.getControllerId(), PAGE) final List<Action> actions = deploymentManagement.findActionsByTarget(target.getControllerId(), PAGE).getContent();
.getContent();
assertThat(actions).hasSize(2); assertThat(actions).hasSize(2);
return actions; return actions;

View File

@@ -46,7 +46,7 @@ import org.springframework.test.web.servlet.MvcResult;
/** /**
* Test for {@link MgmtDistributionSetTypeResource}. * Test for {@link MgmtDistributionSetTypeResource}.
* <p/> * <p/>
* Feature: Component Tests - Management API<br/> * Feature: Component Tests - Management API<br/>
* Story: Distribution Set Type Resource * Story: Distribution Set Type Resource
*/ */

View File

@@ -34,8 +34,8 @@ import java.util.Optional;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.awaitility.Awaitility; import org.awaitility.Awaitility;
import org.awaitility.core.ConditionFactory;
import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.im.authentication.SpPermission;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtRestModelMapper; import org.eclipse.hawkbit.mgmt.rest.resource.mapper.MgmtRestModelMapper;
import org.eclipse.hawkbit.repository.RolloutGroupManagement; import org.eclipse.hawkbit.repository.RolloutGroupManagement;
@@ -74,7 +74,7 @@ import org.springframework.test.web.servlet.ResultMatcher;
/** /**
* Tests for covering the {@link MgmtRolloutResource}. * Tests for covering the {@link MgmtRolloutResource}.
* <p/> * <p/>
* Feature: Component Tests - Management API<br/> * Feature: Component Tests - Management API<br/>
* Story: Rollout Resource * Story: Rollout Resource
*/ */
@@ -95,7 +95,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
* Handles the GET request of retrieving a single rollout. * Handles the GET request of retrieving a single rollout.
*/ */
@Test @Test
void getRollout() throws Exception { void getRollout() throws Exception {
enableMultiAssignments(); enableMultiAssignments();
approvalStrategy.setApprovalNeeded(true); approvalStrategy.setApprovalNeeded(true);
try { try {
@@ -132,7 +132,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
* Handles the GET request of retrieving a all targets of a specific deploy group of a rollout. * Handles the GET request of retrieving a all targets of a specific deploy group of a rollout.
*/ */
@Test @Test
void getRolloutDeployGroupTargetsWithParameters() throws Exception { void getRolloutDeployGroupTargetsWithParameters() throws Exception {
testdataFactory.createTargets(4, "rollout", "description"); testdataFactory.createTargets(4, "rollout", "description");
final DistributionSet dsA = testdataFactory.createDistributionSet(""); final DistributionSet dsA = testdataFactory.createDistributionSet("");
final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*"); final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*");
@@ -152,7 +152,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
* Handles the POST request of approving a rollout. * Handles the POST request of approving a rollout.
*/ */
@Test @Test
void approveRollout() throws Exception { void approveRollout() throws Exception {
approvalStrategy.setApprovalNeeded(true); approvalStrategy.setApprovalNeeded(true);
try { try {
testdataFactory.createTargets(4, "rollout", "description"); testdataFactory.createTargets(4, "rollout", "description");
@@ -190,7 +190,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
* Check if approvalDecidedBy and approvalRemark are present when rollout is approved * Check if approvalDecidedBy and approvalRemark are present when rollout is approved
*/ */
@Test @Test
void validateIfApprovalFieldsArePresentAfterApproval() throws Exception { void validateIfApprovalFieldsArePresentAfterApproval() throws Exception {
approvalStrategy.setApprovalNeeded(true); approvalStrategy.setApprovalNeeded(true);
approvalStrategy.setApproveDecidedBy("testUser"); approvalStrategy.setApproveDecidedBy("testUser");
final int amountTargets = 2; final int amountTargets = 2;
@@ -223,7 +223,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
* Retry rollout test scenario * Retry rollout test scenario
*/ */
@Test @Test
void retryRolloutTest() throws Exception { void retryRolloutTest() throws Exception {
final DistributionSet dsA = testdataFactory.createDistributionSet(""); final DistributionSet dsA = testdataFactory.createDistributionSet("");
final List<Target> successTargets = testdataFactory.createTargets("retryRolloutTargetSuccess-", 6); final List<Target> successTargets = testdataFactory.createTargets("retryRolloutTargetSuccess-", 6);
@@ -294,7 +294,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
* Retrying a running rollout should not be allowed. * Retrying a running rollout should not be allowed.
*/ */
@Test @Test
void retryNotFinishedRolloutShouldNotBeAllowed() throws Exception { void retryNotFinishedRolloutShouldNotBeAllowed() throws Exception {
final DistributionSet dsA = testdataFactory.createDistributionSet(""); final DistributionSet dsA = testdataFactory.createDistributionSet("");
testdataFactory.createTargets("retryRolloutTarget-", 10); testdataFactory.createTargets("retryRolloutTarget-", 10);
postRollout("rolloutToBeRetried", 1, dsA.getId(), "id==retryRolloutTarget*", 10, Action.ActionType.FORCED); postRollout("rolloutToBeRetried", 1, dsA.getId(), "id==retryRolloutTarget*", 10, Action.ActionType.FORCED);
@@ -314,7 +314,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
* Retrying a non-existing rollout should lead to NOT FOUND. * Retrying a non-existing rollout should lead to NOT FOUND.
*/ */
@Test @Test
void retryNonExistingRolloutShouldLeadToNotFound() throws Exception { void retryNonExistingRolloutShouldLeadToNotFound() throws Exception {
mvc.perform(post("/rest/v1/rollouts/{rolloutId}/retry", 6782623)) mvc.perform(post("/rest/v1/rollouts/{rolloutId}/retry", 6782623))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound()); .andExpect(status().isNotFound());
@@ -1911,19 +1911,22 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
} }
private void awaitRunningState(final Long rolloutId) { private void awaitRunningState(final Long rolloutId) {
Awaitility.await().atMost(Duration.ofMinutes(1)).pollInterval(Duration.ofMillis(100)).with() awaitRollout().until(() -> SecurityContextSwitch
.until(() -> SecurityContextSwitch .runAsPrivileged(() -> rolloutManagement.get(rolloutId).orElseThrow(NoSuchElementException::new))
.runAsPrivileged( .getStatus().equals(RolloutStatus.RUNNING));
() -> rolloutManagement.get(rolloutId).orElseThrow(NoSuchElementException::new))
.getStatus().equals(RolloutStatus.RUNNING));
} }
private void awaitActionStatus(final Long actionId, final Status status) { private void awaitActionStatus(final Long actionId, final Status status) {
Awaitility.await().atMost(Duration.ofMinutes(1)).pollInterval(Duration.ofMillis(100)).with() awaitRollout().until(() -> SecurityContextSwitch
.until(() -> SecurityContextSwitch .runAsPrivileged(() -> deploymentManagement.findAction(actionId).orElseThrow(NoSuchElementException::new))
.runAsPrivileged( .getStatus().equals(status));
() -> deploymentManagement.findAction(actionId).orElseThrow(NoSuchElementException::new)) }
.getStatus().equals(status));
private static final Duration ROLLOUT_AT_LEAST = Duration.ofMillis(Integer.getInteger("hawkbit.it.rest.await.rolloutAtLeastMs", 50));
private static final Duration ROLLOUT_POLL_INTERVAL = Duration.ofMillis(Integer.getInteger("hawkbit.it.rest.await.rolloutPollIntervalMs", 100));
private static final Duration ROLLOUT_TIMEOUT = Duration.ofMillis(Integer.getInteger("hawkbit.it.rest.await.rolloutTimeoutMs", 60_000));
private ConditionFactory awaitRollout() {
return Awaitility.await().atLeast(ROLLOUT_AT_LEAST).pollInterval(ROLLOUT_POLL_INTERVAL).atMost(ROLLOUT_TIMEOUT);
} }
private void assertStatusIs(final Rollout rollout, final RolloutStatus expected) { private void assertStatusIs(final Rollout rollout, final RolloutStatus expected) {

View File

@@ -32,16 +32,13 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.time.Duration;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.TimeUnit;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.awaitility.Awaitility;
import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact; import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode;
@@ -83,7 +80,7 @@ import org.springframework.web.bind.annotation.RestController;
/** /**
* Tests for {@link MgmtSoftwareModuleResource} {@link RestController}. * Tests for {@link MgmtSoftwareModuleResource} {@link RestController}.
* <p/> * <p/>
* Feature: Component Tests - Management API<br/> * Feature: Component Tests - Management API<br/>
* Story: Software Module Resource * Story: Software Module Resource
*/ */
@@ -249,10 +246,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
.toString(); .toString();
// ensures that we are not to fast so that last modified is not set correctly // ensures that we are not to fast so that last modified is not set correctly
Awaitility.await() await().until(() -> sm.getLastModifiedAt() > 0L && sm.getLastModifiedBy() != null);
.atMost(Duration.ofMillis(100))
.pollInterval(10L, TimeUnit.MILLISECONDS)
.until(() -> sm.getLastModifiedAt() > 0L && sm.getLastModifiedBy() != null);
mvc.perform(put("/rest/v1/softwaremodules/{smId}", sm.getId()).content(body) mvc.perform(put("/rest/v1/softwaremodules/{smId}", sm.getId()).content(body)
.contentType(MediaType.APPLICATION_JSON)) .contentType(MediaType.APPLICATION_JSON))
@@ -292,10 +286,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
final String body = new JSONObject().put("deleted", true).toString(); final String body = new JSONObject().put("deleted", true).toString();
// ensures that we are not to fast so that last modified is not set correctly // ensures that we are not to fast so that last modified is not set correctly
Awaitility.await() await().until(() -> sm.getLastModifiedAt() > 0L && sm.getLastModifiedBy() != null);
.atMost(Duration.ofMillis(100))
.pollInterval(10L, TimeUnit.MILLISECONDS)
.until(() -> sm.getLastModifiedAt() > 0L && sm.getLastModifiedBy() != null);
mvc.perform(put("/rest/v1/softwaremodules/{smId}", sm.getId()).content(body) mvc.perform(put("/rest/v1/softwaremodules/{smId}", sm.getId()).content(body)
.contentType(MediaType.APPLICATION_JSON)) .contentType(MediaType.APPLICATION_JSON))
@@ -323,10 +314,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
entityFactory.softwareModule().create().type(osType).name("name1").version("version1")); entityFactory.softwareModule().create().type(osType).name("name1").version("version1"));
assertThat(sm.isLocked()).as("Created software module should not be locked").isFalse(); assertThat(sm.isLocked()).as("Created software module should not be locked").isFalse();
// ensures that we are not to fast so that last modified is not set correctly // ensures that we are not to fast so that last modified is not set correctly
Awaitility.await() await().until(() -> sm.getLastModifiedAt() > 0L && sm.getLastModifiedBy() != null);
.atMost(Duration.ofMillis(100))
.pollInterval(10L, TimeUnit.MILLISECONDS)
.until(() -> sm.getLastModifiedAt() > 0L && sm.getLastModifiedBy() != null);
// lock // lock
final String body = new JSONObject().put("locked", true).toString(); final String body = new JSONObject().put("locked", true).toString();
@@ -361,10 +349,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes
.as("Software module is locked") .as("Software module is locked")
.isTrue(); .isTrue();
// ensures that we are not to fast so that last modified is not set correctly // ensures that we are not to fast so that last modified is not set correctly
Awaitility.await() await().until(() -> sm.getLastModifiedAt() > 0L && sm.getLastModifiedBy() != null);
.atMost(Duration.ofMillis(100))
.pollInterval(10L, TimeUnit.MILLISECONDS)
.until(() -> sm.getLastModifiedAt() > 0L && sm.getLastModifiedBy() != null);
// unlock // unlock
final String body = new JSONObject().put("locked", false).toString(); final String body = new JSONObject().put("locked", false).toString();

View File

@@ -41,7 +41,7 @@ import org.springframework.test.web.servlet.MvcResult;
/** /**
* Test for {@link MgmtSoftwareModuleTypeResource}. * Test for {@link MgmtSoftwareModuleTypeResource}.
* <p/> * <p/>
* Feature: Component Tests - Management API<br/> * Feature: Component Tests - Management API<br/>
* Story: Software Module Type Resource * Story: Software Module Type Resource
*/ */

View File

@@ -55,7 +55,7 @@ import org.springframework.web.util.UriUtils;
/** /**
* Spring MVC Tests against the MgmtTargetResource. * Spring MVC Tests against the MgmtTargetResource.
* <p/> * <p/>
* Feature: Component Tests - Management API<br/> * Feature: Component Tests - Management API<br/>
* Story: Target Filter Query Resource * Story: Target Filter Query Resource
*/ */

View File

@@ -30,7 +30,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.time.Duration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
@@ -40,14 +39,12 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream; import java.util.stream.Stream;
import jakarta.validation.ConstraintViolationException; import jakarta.validation.ConstraintViolationException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import org.awaitility.Awaitility;
import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.im.authentication.SpPermission;
import org.eclipse.hawkbit.mgmt.json.model.action.MgmtActionConfirmationRequestBodyPut; import org.eclipse.hawkbit.mgmt.json.model.action.MgmtActionConfirmationRequestBodyPut;
@@ -102,7 +99,7 @@ import org.springframework.test.web.servlet.ResultActions;
/** /**
* Spring MVC Tests against the MgmtTargetResource. * Spring MVC Tests against the MgmtTargetResource.
* <p/> * <p/>
* Feature: Component Tests - Management API<br/> * Feature: Component Tests - Management API<br/>
* Story: Target Resource * Story: Target Resource
*/ */
@@ -2971,9 +2968,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
.getAssignedEntity().stream().map(Action::getTarget).toList(); .getAssignedEntity().stream().map(Action::getTarget).toList();
// 2nd update // 2nd update
// sleep 10ms to ensure that we can sort by reportedAt // sleep 10ms to ensure that we can sort by reportedAt
Awaitility.await().atMost(Duration.ofMillis(100)).atLeast(5, TimeUnit.MILLISECONDS) await().until(() -> updatedTargets.stream().allMatch(t -> t.getLastModifiedAt() > 0L));
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> updatedTargets.stream().allMatch(t -> t.getLastModifiedAt() > 0L));
assignDistributionSet(two, updatedTargets); assignDistributionSet(two, updatedTargets);
} else { } else {
final List<Target> updatedTargets = assignDistributionSetWithMaintenanceWindow(one.getId(), final List<Target> updatedTargets = assignDistributionSetWithMaintenanceWindow(one.getId(),
@@ -2981,9 +2976,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
.map(Action::getTarget).toList(); .map(Action::getTarget).toList();
// 2nd update // 2nd update
// sleep 10ms to ensure that we can sort by reportedAt // sleep 10ms to ensure that we can sort by reportedAt
Awaitility.await().atMost(Duration.ofMillis(100)).atLeast(5, TimeUnit.MILLISECONDS) await().until(() -> updatedTargets.stream().allMatch(t -> t.getLastModifiedAt() > 0L));
.pollInterval(10, TimeUnit.MILLISECONDS)
.until(() -> updatedTargets.stream().allMatch(t -> t.getLastModifiedAt() > 0L));
assignDistributionSetWithMaintenanceWindow(two.getId(), updatedTargets.get(0).getControllerId(), schedule, assignDistributionSetWithMaintenanceWindow(two.getId(), updatedTargets.get(0).getControllerId(), schedule,
duration, timezone); duration, timezone);
} }

View File

@@ -50,7 +50,7 @@ import org.springframework.test.web.servlet.ResultActions;
/** /**
* Spring MVC Tests against the MgmtTargetTagResource. * Spring MVC Tests against the MgmtTargetTagResource.
* <p/> * <p/>
* Feature: Component Tests - Management API<br/> * Feature: Component Tests - Management API<br/>
* Story: Target Tag Resource * Story: Target Tag Resource
*/ */

View File

@@ -49,7 +49,7 @@ import org.springframework.test.web.servlet.ResultActions;
/** /**
* Spring MVC Tests against the MgmtTargetTypeResource. * Spring MVC Tests against the MgmtTargetTypeResource.
* <p/> * <p/>
* Feature: Component Tests - Management API<br/> * Feature: Component Tests - Management API<br/>
* Story: Target Type Resource * Story: Target Type Resource
*/ */

View File

@@ -32,7 +32,7 @@ import org.springframework.test.web.servlet.ResultMatcher;
/** /**
* Spring MVC Tests against the MgmtTenantManagementResource. * Spring MVC Tests against the MgmtTenantManagementResource.
* <p/> * <p/>
* Feature: Component Tests - Management API<br/> * Feature: Component Tests - Management API<br/>
* Story: Tenant Management Resource * Story: Tenant Management Resource
*/ */

View File

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

View File

@@ -24,7 +24,7 @@ import org.springframework.dao.UncategorizedDataAccessException;
/** /**
* Mapping tests for {@link HawkbitEclipseLinkJpaDialect}. * Mapping tests for {@link HawkbitEclipseLinkJpaDialect}.
* <p/> * <p/>
* Feature: Unit Tests - Repository<br/> * Feature: Unit Tests - Repository<br/>
* Story: Exception handling * 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. * Counts all actions referring to a given rollout, rollout group and status.
* <p/> * <p/>
* No access control applied * No access control applied
* *
* @param rolloutId the ID of rollout the actions belong to * @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} * Returns {@code true} if actions for the given rollout exists, otherwise {@code false}
* <p/> * <p/>
* No access control applied * No access control applied
* *
* @param rolloutId the ID of the rollout the actions belong to * @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. * 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. * Finding all actions of a specific rollout group parent relation.
* <p/> * <p/>
* No access control applied * No access control applied
* *
* @param pageable page parameters * @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. * Retrieving all actions referring to the first group of a rollout.
* <p/> * <p/>
* No access control applied * No access control applied
* *
* @param pageable page parameters * @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. * Retrieves all actions for a specific rollout and in a specific status.
* <p/> * <p/>
* No access control applied * No access control applied
* *
* @param pageable page parameters * @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. * 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 * No access control applied
* *
* @param rolloutId id of {@link Rollout} * @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. * 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 * No access control applied
* *
* @param rolloutId id of {@link Rollout} * @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. * 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 * No access control applied
* *
* @param rolloutGroupId id of {@link RolloutGroup} * @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. * 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 * No access control applied
* *
* @param rolloutGroupId list of id of {@link RolloutGroup} * @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. * Test the remote entity events.
* <p/> * <p/>
* Feature: Component Tests - Repository<br/> * Feature: Component Tests - Repository<br/>
* Story: Entity Id Events * Story: Entity Id Events
*/ */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -48,7 +48,10 @@ class ActionTest extends AbstractJpaIntegrationTest {
assertThat(timeforcedAction.isForcedOrTimeForced()).isFalse(); assertThat(timeforcedAction.isForcedOrTimeForced()).isFalse();
// wait until timeforce time is hit // 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}. * Test class for {@link ArtifactManagement}.
* <p/> * <p/>
* Feature: Component Tests - Repository<br/> * Feature: Component Tests - Repository<br/>
* Story: Artifact Management * 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 * Test class testing the functionality of triggering a deployment of
* {@link DistributionSet}s to {@link Target}s with AutoConfirmation active. * {@link DistributionSet}s to {@link Target}s with AutoConfirmation active.
* <p/> * <p/>
* Feature: Component Tests - Repository<br/> * Feature: Component Tests - Repository<br/>
* Story: Confirmation Management * 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. * Test class testing the functionality of triggering a deployment of {@link DistributionSet}s to {@link Target}s.
* <p/> * <p/>
* Feature: Component Tests - Repository<br/> * Feature: Component Tests - Repository<br/>
* Story: Deployment Management * Story: Deployment Management
*/ */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
/** /**
* Test the entity listener interceptor. * Test the entity listener interceptor.
* <p/> * <p/>
* Feature: Component Tests - Repository<br/> * Feature: Component Tests - Repository<br/>
* Story: Entity Listener Interceptor * 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 * Multi-Tenancy tests which testing the CRUD operations of entities that all
* CRUD-Operations are tenant aware and cannot access or delete entities not * CRUD-Operations are tenant aware and cannot access or delete entities not
* belonging to the current tenant. * belonging to the current tenant.
* <p/> * <p/>
* Feature: Component Tests - Repository<br/> * Feature: Component Tests - Repository<br/>
* Story: Multi Tenancy * Story: Multi Tenancy
*/ */

View File

@@ -17,6 +17,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.nio.file.Files; import java.nio.file.Files;
import java.time.Duration;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
@@ -25,9 +26,10 @@ import java.util.NoSuchElementException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils; 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.ArtifactRepository;
import org.eclipse.hawkbit.artifact.repository.ArtifactStoreException; import org.eclipse.hawkbit.artifact.repository.ArtifactStoreException;
import org.eclipse.hawkbit.cache.TenantAwareCacheManager;
import org.eclipse.hawkbit.repository.ArtifactManagement; import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.ConfirmationManagement; import org.eclipse.hawkbit.repository.ConfirmationManagement;
import org.eclipse.hawkbit.repository.ControllerManagement; 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.boot.test.context.SpringBootTest;
import org.springframework.cloud.bus.ServiceMatcher; import org.springframework.cloud.bus.ServiceMatcher;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.data.auditing.AuditingHandler;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
@@ -263,6 +264,14 @@ public abstract class AbstractIntegrationTest {
return currentTime.getOffset().getId().replace("Z", "+00:00"); 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( protected static Action getFirstAssignedAction(
final DistributionSetAssignmentResult distributionSetAssignmentResult) { final DistributionSetAssignmentResult distributionSetAssignmentResult) {
return distributionSetAssignmentResult.getAssignedEntity().stream().findFirst() return distributionSetAssignmentResult.getAssignedEntity().stream().findFirst()

View File

@@ -9,6 +9,8 @@
*/ */
package org.eclipse.hawkbit.rest; package org.eclipse.hawkbit.rest;
import java.time.Duration;
import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration; import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration;
import org.eclipse.hawkbit.repository.test.TestConfiguration; import org.eclipse.hawkbit.repository.test.TestConfiguration;
import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest; import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest;

View File

@@ -30,7 +30,7 @@ public interface SecurityContextSerializer {
SecurityContextSerializer NOP = new Nop(); SecurityContextSerializer NOP = new Nop();
/** /**
* Serializer the uses Java serialization of {@link java.io.Serializable} objects. * Serializer the uses Java serialization of {@link java.io.Serializable} objects.
* <p/> * <p/>
* Note that serialized via java serialization context might become unreadable if incompatible * Note that serialized via java serialization context might become unreadable if incompatible
* changes are made to the object classes. * changes are made to the object classes.
*/ */

View File

@@ -20,7 +20,7 @@ import org.springframework.util.ReflectionUtils;
/** /**
* Test {@link SpPermission}. * Test {@link SpPermission}.
* <p/> * <p/>
* Feature: Unit Tests - Security<br/> * Feature: Unit Tests - Security<br/>
* Story: Permission Test * Story: Permission Test
*/ */

View File

@@ -44,7 +44,6 @@ import com.vaadin.flow.data.renderer.ComponentRenderer;
import com.vaadin.flow.router.PageTitle; import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route; import com.vaadin.flow.router.Route;
import com.vaadin.flow.server.streams.UploadEvent; import com.vaadin.flow.server.streams.UploadEvent;
import com.vaadin.flow.server.streams.UploadHandler;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.eclipse.hawkbit.mgmt.json.model.PagedList; import org.eclipse.hawkbit.mgmt.json.model.PagedList;
import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact; import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact;