External ref for actions and status-update events (#830)
* Add feature to listen to rollout status update * With this feature, extensions can update back the status of a given rollout using an event(containing distributionSetId and targetId). * In future, AmqpMessageHandlerService can make use of this feature and de-couple its own implementation from performing status update of an action. * Implement ActionStatusUpdateHandlerService using actionId * Extend actions to support externalRef * Update the action status using externalRef. * Update securityContext to support running a callable under specific authorities. * Fixing the review comments * Increase length of externalRef to 128 chars * Remove actionStatusUpdateEvent and the handler service * Use 256 chars for externalRef * Increment the version for migration script * Another feature had use v1_12_12 in a recent PR. So incrementing the version. * Create length limit for externalRef and add it to index * Externalref will be much longer than 256 chars if controllerId is as long as 256 chars * Adding tests for verifying externalRef in controllerManagement * Improve test to consider multiple externalRefs * Fix issue in migration script for mssql server * Fix documentation Signed-off-by: Ravindranath Sandeep (INST-IOT/ESW-Imb) <Sandeep.Ravindranath@bosch-si.com>
This commit is contained in:
committed by
Stefan Behl
parent
e80399bc79
commit
fba6cf9787
@@ -22,6 +22,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -54,6 +55,7 @@ import org.eclipse.hawkbit.repository.exception.InvalidTargetAttributeException;
|
||||
import org.eclipse.hawkbit.repository.exception.QuotaExceededException;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||
@@ -1315,6 +1317,44 @@ public class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify that the attaching externalRef to an action is propery stored")
|
||||
public void updatedExternalRefOnActionIsReallyUpdated() {
|
||||
final List<String> allExternalRef = new ArrayList<>();
|
||||
final List<Long> allActionId = new ArrayList<>();
|
||||
final int numberOfActions = 3;
|
||||
final DistributionSet knownDistributionSet = testdataFactory.createDistributionSet();
|
||||
for (int i = 0; i < numberOfActions; i++) {
|
||||
final String knownControllerId = "controllerId" + i;
|
||||
final String knownExternalref = "externalRefId" + i;
|
||||
|
||||
testdataFactory.createTarget(knownControllerId);
|
||||
final DistributionSetAssignmentResult assignmentResult = deploymentManagement.assignDistributionSet(
|
||||
knownDistributionSet.getId(), ActionType.FORCED, 0, Collections.singleton(knownControllerId));
|
||||
final Long actionId = assignmentResult.getActionIds().get(0);
|
||||
controllerManagement.updateActionExternalRef(actionId, knownExternalref);
|
||||
|
||||
allExternalRef.add(knownExternalref);
|
||||
allActionId.add(actionId);
|
||||
}
|
||||
|
||||
final List<Action> foundAction = controllerManagement.getActiveActionsByExternalRef(allExternalRef);
|
||||
assertThat(foundAction).isNotNull();
|
||||
for (int i = 0; i < numberOfActions; i++) {
|
||||
assertThat(foundAction.get(i).getId()).isEqualTo(allActionId.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify that a null externalRef cannot be assigned to an action")
|
||||
public void externalRefCannotBeNull() {
|
||||
try {
|
||||
controllerManagement.updateActionExternalRef(1L, null);
|
||||
fail("No ConstraintViolationException thrown when a null externalRef was set on an action");
|
||||
} catch (final ConstraintViolationException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that a target can report FINISHED/ERROR updates for DOWNLOAD_ONLY assignments regardless of "
|
||||
+ "repositoryProperties.rejectActionStatusForClosedAction value.")
|
||||
|
||||
Reference in New Issue
Block a user