View-scoped event listeners (#1134)

* added UI EntityNotFound error details extractor

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* changed Target count label to not rely on grid data change events but rather on EntityModified UI events to decide how to react dependand on the event type

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* added current view check on entity modified events

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* unsubscribe/resubscribe event listeners on view leave/enter, reselect grid entities on view enter

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* fixed target grid count reset on initial load and after view change

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* re-evaluate filters on Deployment View enter

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* added on view enter logic for rest of the views

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* introduced event listener aware layout and view, adapted code accordingly

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* fixed bulk upload

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* added missing docs

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* adapted software module deselection upon master entity change

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* fixed npe in case master support is not present (Artifact View)

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* restructured amqp assignDistributionSetMultipleTimes test

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>

* added waiting for the messages to be dispached by test

Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch.io>
This commit is contained in:
Bondar Bogdan
2021-07-22 11:00:05 +02:00
committed by GitHub
parent 1a285849e6
commit ace2f00742
75 changed files with 1603 additions and 600 deletions

View File

@@ -8,9 +8,23 @@
*/
package org.eclipse.hawkbit.integration;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.hawkbit.dmf.amqp.api.EventTopic.DOWNLOAD;
import static org.eclipse.hawkbit.dmf.amqp.api.MessageType.EVENT;
import static org.eclipse.hawkbit.repository.model.Action.ActionType.DOWNLOAD_ONLY;
import java.util.AbstractMap.SimpleEntry;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import org.eclipse.hawkbit.dmf.amqp.api.EventTopic;
import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey;
import org.eclipse.hawkbit.dmf.json.model.DmfActionRequest;
@@ -55,22 +69,9 @@ import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.amqp.core.Message;
import java.util.AbstractMap.SimpleEntry;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.hawkbit.dmf.amqp.api.EventTopic.DOWNLOAD;
import static org.eclipse.hawkbit.dmf.amqp.api.MessageType.EVENT;
import static org.eclipse.hawkbit.repository.model.Action.ActionType.DOWNLOAD_ONLY;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
@Feature("Component Tests - Device Management Federation API")
@Story("Amqp Message Dispatcher Service")
@@ -147,33 +148,37 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
@Expect(type = SoftwareModuleUpdatedEvent.class, count = 12),
@Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 2) })
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 3) })
public void assignDistributionSetMultipleTimes() {
final String controllerId = TARGET_PREFIX + "assignDistributionSetMultipleTimes";
final DistributionSetAssignmentResult assignmentResult = registerTargetAndAssignDistributionSet(controllerId);
waitUntilEventMessagesAreDispatchedToTarget(EventTopic.DOWNLOAD_AND_INSTALL);
final DistributionSet distributionSet2 = testdataFactory.createDistributionSet();
testdataFactory.addSoftwareModuleMetadata(distributionSet2);
// first assignment will be canceled -> Open cancellations -> No message through the DMF
// first assignment will be canceled -> Open cancellations
assignDistributionSet(distributionSet2.getId(), controllerId);
// should not get the message of the second assignment
assertDownloadAndInstallMessage(assignmentResult.getDistributionSet().getModules(), controllerId);
waitUntilEventMessagesAreDispatchedToTarget(EventTopic.CANCEL_DOWNLOAD);
assertCancelActionMessage(getFirstAssignedActionId(assignmentResult), controllerId);
// cancelation message is returned upon polling
createAndSendThingCreated(controllerId, TENANT_EXIST);
waitUntilTargetHasStatus(controllerId, TargetUpdateStatus.PENDING);
waitUntilEventMessagesAreDispatchedToTarget(EventTopic.CANCEL_DOWNLOAD);
assertCancelActionMessage(getFirstAssignedActionId(assignmentResult), controllerId);
// confirm the cancel of the first action should lead to expose the latest action
// confirm the cancel of the first action should lead to expose the
// latest action
createAndSendActionStatusUpdateMessage(controllerId, getFirstAssignedActionId(assignmentResult),
DmfActionStatus.CANCELED);
waitUntilEventMessagesAreDispatchedToTarget(EventTopic.DOWNLOAD_AND_INSTALL);
// verify latest action is exposed
assertDownloadAndInstallMessage(distributionSet2.getModules(), controllerId);
// latest action is returned upon polling
createAndSendThingCreated(controllerId, TENANT_EXIST);
waitUntilEventMessagesAreDispatchedToTarget(EventTopic.DOWNLOAD_AND_INSTALL);
assertDownloadAndInstallMessage(distributionSet2.getModules(), controllerId);
}
@Test
@@ -401,8 +406,8 @@ public class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpSer
@Test
@Description("If multi assignment is enabled finishing one rollout does not affect other rollouts of the target.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 3), @Expect(type = ActionCreatedEvent.class, count = 3),
@Expect(type = ActionUpdatedEvent.class, count = 5),
@Expect(type = MultiActionAssignEvent.class, count = 3),
@Expect(type = ActionCreatedEvent.class, count = 3), @Expect(type = ActionUpdatedEvent.class, count = 5),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 6),
@Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = TargetUpdatedEvent.class, count = 5), @Expect(type = TargetPollEvent.class, count = 1),