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.
* <p/>
* <p/>
* Feature: Unit Tests - Artifact URL Handler<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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'
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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
* <p/>
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* 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.
* <p/>
* <p/>
* Feature: Component Tests - Direct Device Integration API<br/>
* Story: Artifact Download Resource
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -794,7 +794,7 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
}
private void waitUntil(final Callable<Boolean> callable) {
createConditionFactory().until(() -> SecurityContextSwitch.runAsPrivileged(callable));
await().until(() -> SecurityContextSwitch.runAsPrivileged(callable));
}
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) {
createConditionFactory().await().untilAsserted(() -> {
await().untilAsserted(() -> {
try {
SecurityContextSwitch.runAsPrivileged(() -> {
final List<ActionStatus> actionStatusList = deploymentManagement
.findActionStatusByAction(actionId, PAGE).getContent();
final List<ActionStatus> actionStatusList = deploymentManagement.findActionStatusByAction(actionId, PAGE).getContent();
// Check correlation ID
final List<String> messagesFromServer = actionStatusList.stream()
.flatMap(actionStatus -> deploymentManagement
.findMessagesByActionStatusId(actionStatus.getId(), PAGE).getContent().stream())
.filter(Objects::nonNull)
.filter(message -> message
.startsWith(RepositoryConstants.SERVER_MESSAGE_PREFIX + "DMF message"))
.filter(message -> message.startsWith(RepositoryConstants.SERVER_MESSAGE_PREFIX + "DMF message"))
.toList();
assertThat(messagesFromServer).hasSize(messages)
.allMatch(message -> message.endsWith(CORRELATION_ID));
assertThat(messagesFromServer).hasSize(messages).allMatch(message -> message.endsWith(CORRELATION_ID));
final List<Status> status = actionStatusList.stream().map(ActionStatus::getStatus)
.toList();
final List<Status> status = actionStatusList.stream().map(ActionStatus::getStatus).toList();
assertThat(status).containsOnly(expectedActionStates);
return null;
@@ -1267,7 +1263,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
private void assertActionStatusList(final Long actionId, final int statusListCount,
final Status... expectedActionStates) {
createConditionFactory().await().untilAsserted(() -> {
await().untilAsserted(() -> {
try {
SecurityContextSwitch.runAsPrivileged(() -> {
final List<ActionStatus> actionStatusList = deploymentManagement
@@ -1302,8 +1298,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
private void verifyNumberOfDeadLetterMessages(final int numberOfInvocations) {
assertEmptyReceiverQueueCount();
createConditionFactory().untilAsserted(() -> Mockito
.verify(getDeadletterListener(), Mockito.times(numberOfInvocations)).handleMessage(Mockito.any()));
await().untilAsserted(
() -> Mockito.verify(getDeadletterListener(), Mockito.times(numberOfInvocations)).handleMessage(Mockito.any()));
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
public abstract class AbstractAmqpIntegrationTest extends AbstractIntegrationTest {
private static final Duration TIMEOUT = Duration.ofSeconds(5);
@Autowired
private ConnectionFactory connectionFactory;
@Autowired
@@ -60,8 +58,11 @@ public abstract class AbstractAmqpIntegrationTest extends AbstractIntegrationTes
return dmfClient;
}
protected ConditionFactory createConditionFactory() {
return Awaitility.await().atMost(TIMEOUT.toMillis(), TimeUnit.MILLISECONDS);
private static final Duration AT_LEAST = Duration.ofMillis(Integer.getInteger("hawkbit.it.amqp.await.atLeastMs", 100));
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) {

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

View File

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

View File

@@ -34,8 +34,8 @@ import java.util.Optional;
import java.util.stream.Stream;
import org.awaitility.Awaitility;
import org.awaitility.core.ConditionFactory;
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.resource.mapper.MgmtRestModelMapper;
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
@@ -74,7 +74,7 @@ import org.springframework.test.web.servlet.ResultMatcher;
/**
* Tests for covering the {@link MgmtRolloutResource}.
* <p/>
* <p/>
* Feature: Component Tests - Management API<br/>
* Story: Rollout Resource
*/
@@ -95,7 +95,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
* Handles the GET request of retrieving a single rollout.
*/
@Test
void getRollout() throws Exception {
void getRollout() throws Exception {
enableMultiAssignments();
approvalStrategy.setApprovalNeeded(true);
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.
*/
@Test
void getRolloutDeployGroupTargetsWithParameters() throws Exception {
void getRolloutDeployGroupTargetsWithParameters() throws Exception {
testdataFactory.createTargets(4, "rollout", "description");
final DistributionSet dsA = testdataFactory.createDistributionSet("");
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.
*/
@Test
void approveRollout() throws Exception {
void approveRollout() throws Exception {
approvalStrategy.setApprovalNeeded(true);
try {
testdataFactory.createTargets(4, "rollout", "description");
@@ -190,7 +190,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
* Check if approvalDecidedBy and approvalRemark are present when rollout is approved
*/
@Test
void validateIfApprovalFieldsArePresentAfterApproval() throws Exception {
void validateIfApprovalFieldsArePresentAfterApproval() throws Exception {
approvalStrategy.setApprovalNeeded(true);
approvalStrategy.setApproveDecidedBy("testUser");
final int amountTargets = 2;
@@ -223,7 +223,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
* Retry rollout test scenario
*/
@Test
void retryRolloutTest() throws Exception {
void retryRolloutTest() throws Exception {
final DistributionSet dsA = testdataFactory.createDistributionSet("");
final List<Target> successTargets = testdataFactory.createTargets("retryRolloutTargetSuccess-", 6);
@@ -294,7 +294,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
* Retrying a running rollout should not be allowed.
*/
@Test
void retryNotFinishedRolloutShouldNotBeAllowed() throws Exception {
void retryNotFinishedRolloutShouldNotBeAllowed() throws Exception {
final DistributionSet dsA = testdataFactory.createDistributionSet("");
testdataFactory.createTargets("retryRolloutTarget-", 10);
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.
*/
@Test
void retryNonExistingRolloutShouldLeadToNotFound() throws Exception {
void retryNonExistingRolloutShouldLeadToNotFound() throws Exception {
mvc.perform(post("/rest/v1/rollouts/{rolloutId}/retry", 6782623))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound());
@@ -1911,19 +1911,22 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
}
private void awaitRunningState(final Long rolloutId) {
Awaitility.await().atMost(Duration.ofMinutes(1)).pollInterval(Duration.ofMillis(100)).with()
.until(() -> SecurityContextSwitch
.runAsPrivileged(
() -> rolloutManagement.get(rolloutId).orElseThrow(NoSuchElementException::new))
.getStatus().equals(RolloutStatus.RUNNING));
awaitRollout().until(() -> SecurityContextSwitch
.runAsPrivileged(() -> rolloutManagement.get(rolloutId).orElseThrow(NoSuchElementException::new))
.getStatus().equals(RolloutStatus.RUNNING));
}
private void awaitActionStatus(final Long actionId, final Status status) {
Awaitility.await().atMost(Duration.ofMinutes(1)).pollInterval(Duration.ofMillis(100)).with()
.until(() -> SecurityContextSwitch
.runAsPrivileged(
() -> deploymentManagement.findAction(actionId).orElseThrow(NoSuchElementException::new))
.getStatus().equals(status));
awaitRollout().until(() -> SecurityContextSwitch
.runAsPrivileged(() -> 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) {

View File

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

View File

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

View File

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

View File

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

View File

@@ -32,7 +32,7 @@ import org.springframework.test.web.servlet.ResultMatcher;
/**
* Spring MVC Tests against the MgmtTenantManagementResource.
* <p/>
* <p/>
* Feature: Component Tests - Management API<br/>
* 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
* 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()

View File

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

View File

@@ -30,7 +30,7 @@ public interface SecurityContextSerializer {
SecurityContextSerializer NOP = new Nop();
/**
* 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
* changes are made to the object classes.
*/

View File

@@ -20,7 +20,7 @@ import org.springframework.util.ReflectionUtils;
/**
* Test {@link SpPermission}.
* <p/>
* <p/>
* Feature: Unit Tests - Security<br/>
* 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.Route;
import com.vaadin.flow.server.streams.UploadEvent;
import com.vaadin.flow.server.streams.UploadHandler;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact;