Hide getRolloutWithStatusDetails from API (#2442)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.rest.resource;
|
||||
|
||||
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE;
|
||||
import static org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
|
||||
|
||||
@@ -32,7 +34,6 @@ import org.eclipse.hawkbit.mgmt.json.model.rolloutgroup.MgmtDynamicRolloutGroupT
|
||||
import org.eclipse.hawkbit.mgmt.json.model.rolloutgroup.MgmtRolloutGroup;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.rolloutgroup.MgmtRolloutGroupResponseBody;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRolloutRestApi;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.builder.DynamicRolloutGroupTemplate;
|
||||
@@ -95,8 +96,8 @@ final class MgmtRolloutMapper {
|
||||
|
||||
if (withDetails) {
|
||||
for (final TotalTargetCountStatus.Status status : TotalTargetCountStatus.Status.values()) {
|
||||
body.addTotalTargetsPerStatus(status.name().toLowerCase(),
|
||||
rollout.getTotalTargetCountStatus().getTotalTargetCountByStatus(status));
|
||||
body.addTotalTargetsPerStatus(
|
||||
status.name().toLowerCase(), rollout.getTotalTargetCountStatus().getTotalTargetCountByStatus(status));
|
||||
}
|
||||
body.setTotalGroups(rollout.getRolloutGroupsCreated());
|
||||
body.setStartAt(rollout.getStartAt());
|
||||
@@ -107,20 +108,17 @@ final class MgmtRolloutMapper {
|
||||
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).start(rollout.getId())).withRel("start").expand());
|
||||
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).pause(rollout.getId())).withRel("pause").expand());
|
||||
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).resume(rollout.getId())).withRel("resume").expand());
|
||||
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).triggerNextGroup(rollout.getId()))
|
||||
.withRel("triggerNextGroup").expand());
|
||||
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).approve(rollout.getId(), null)).withRel("approve")
|
||||
.expand());
|
||||
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).triggerNextGroup(rollout.getId())).withRel("triggerNextGroup").expand());
|
||||
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).approve(rollout.getId(), null)).withRel("approve").expand());
|
||||
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).deny(rollout.getId(), null)).withRel("deny").expand());
|
||||
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).getRolloutGroups(rollout.getId(),
|
||||
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE,
|
||||
MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null, null, null)).withRel("groups")
|
||||
.expand());
|
||||
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).getRolloutGroups(
|
||||
rollout.getId(),
|
||||
REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE, REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null, null, null))
|
||||
.withRel("groups").expand());
|
||||
|
||||
final DistributionSet distributionSet = rollout.getDistributionSet();
|
||||
body.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getDistributionSet(distributionSet.getId()))
|
||||
.withRel("distributionset").withName(distributionSet.getName() + ":" + distributionSet.getVersion())
|
||||
.expand());
|
||||
.withRel("distributionset").withName(distributionSet.getName() + ":" + distributionSet.getVersion()).expand());
|
||||
}
|
||||
|
||||
body.add(linkTo(methodOn(MgmtRolloutRestApi.class).getRollout(rollout.getId())).withSelfRel().expand());
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRolloutRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
|
||||
import org.eclipse.hawkbit.repository.RolloutManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
|
||||
@@ -48,7 +47,6 @@ import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.eclipse.hawkbit.utils.TenantConfigHelper;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -85,30 +83,23 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
||||
public ResponseEntity<PagedList<MgmtRolloutResponseBody>> getRollouts(
|
||||
final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam,
|
||||
final String representationModeParam) {
|
||||
final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
|
||||
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
|
||||
final Sort sorting = PagingUtility.sanitizeRolloutSortParam(sortParam);
|
||||
|
||||
final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sortParam);
|
||||
final boolean isFullMode = parseRepresentationMode(representationModeParam) == MgmtRepresentationMode.FULL;
|
||||
|
||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||
final Page<Rollout> rollouts;
|
||||
if (rsqlParam != null) {
|
||||
rollouts = rolloutManagement.findByRsql(pageable, rsqlParam, false);
|
||||
} else {
|
||||
rollouts = rolloutManagement.findAll(pageable, false);
|
||||
}
|
||||
|
||||
final long totalElements = rollouts.getTotalElements();
|
||||
|
||||
final List<MgmtRolloutResponseBody> rest;
|
||||
if (isFullMode) {
|
||||
rest = MgmtRolloutMapper.toResponseRolloutWithDetails(rolloutManagement.getRolloutWithStatusDetails(rollouts).getContent());
|
||||
rollouts = rsqlParam == null
|
||||
? rolloutManagement.findAllWithDetailedStatus(pageable, false)
|
||||
: rolloutManagement.findByRsqlWithDetailedStatus(pageable, rsqlParam, false);
|
||||
rest = MgmtRolloutMapper.toResponseRolloutWithDetails(rollouts.getContent());
|
||||
} else {
|
||||
rollouts = rsqlParam == null
|
||||
? rolloutManagement.findAll(pageable, false)
|
||||
: rolloutManagement.findByRsql(pageable, rsqlParam, false);
|
||||
rest = MgmtRolloutMapper.toResponseRollout(rollouts.getContent());
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(new PagedList<>(rest, totalElements));
|
||||
return ResponseEntity.ok(new PagedList<>(rest, rollouts.getTotalElements()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -214,28 +205,22 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
||||
final Long rolloutId,
|
||||
final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam,
|
||||
final String representationModeParam) {
|
||||
final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
|
||||
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
|
||||
final Sort sorting = PagingUtility.sanitizeRolloutGroupSortParam(sortParam);
|
||||
|
||||
final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sortParam);
|
||||
final boolean isFullMode = parseRepresentationMode(representationModeParam) == MgmtRepresentationMode.FULL;
|
||||
|
||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||
|
||||
final Page<RolloutGroup> rolloutGroups;
|
||||
if (rsqlParam != null) {
|
||||
if (isFullMode) {
|
||||
rolloutGroups = this.rolloutGroupManagement.findByRolloutAndRsqlWithDetailedStatus(rolloutId, rsqlParam, pageable
|
||||
);
|
||||
} else {
|
||||
rolloutGroups = this.rolloutGroupManagement.findByRolloutAndRsql(rolloutId, rsqlParam, pageable);
|
||||
}
|
||||
} else {
|
||||
if (rsqlParam == null) {
|
||||
if (isFullMode) {
|
||||
rolloutGroups = this.rolloutGroupManagement.findByRolloutWithDetailedStatus(rolloutId, pageable);
|
||||
} else {
|
||||
rolloutGroups = this.rolloutGroupManagement.findByRollout(rolloutId, pageable);
|
||||
}
|
||||
} else {
|
||||
if (isFullMode) {
|
||||
rolloutGroups = this.rolloutGroupManagement.findByRolloutAndRsqlWithDetailedStatus(rolloutId, rsqlParam, pageable);
|
||||
} else {
|
||||
rolloutGroups = this.rolloutGroupManagement.findByRolloutAndRsql(rolloutId, rsqlParam, pageable);
|
||||
}
|
||||
}
|
||||
|
||||
final List<MgmtRolloutGroupResponseBody> rest = MgmtRolloutMapper.toResponseRolloutGroup(
|
||||
@@ -249,7 +234,6 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
||||
|
||||
final RolloutGroup rolloutGroup = rolloutGroupManagement.getWithDetailedStatus(groupId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(RolloutGroup.class, rolloutId));
|
||||
|
||||
if (!Objects.equals(rolloutId, rolloutGroup.getRollout().getId())) {
|
||||
throw new EntityNotFoundException(RolloutGroup.class, groupId);
|
||||
}
|
||||
@@ -263,19 +247,13 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
||||
final Long rolloutId, final Long groupId,
|
||||
final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam) {
|
||||
findRolloutOrThrowException(rolloutId);
|
||||
final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
|
||||
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
|
||||
final Sort sorting = PagingUtility.sanitizeTargetSortParam(sortParam);
|
||||
|
||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||
final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sortParam);
|
||||
|
||||
final Page<Target> rolloutGroupTargets;
|
||||
if (rsqlParam != null) {
|
||||
rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(pageable, groupId,
|
||||
rsqlParam);
|
||||
if (rsqlParam == null) {
|
||||
rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroup(groupId, pageable);
|
||||
} else {
|
||||
final Page<Target> pageTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroup(groupId, pageable);
|
||||
rolloutGroupTargets = pageTargets;
|
||||
rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(pageable, groupId, rsqlParam);
|
||||
}
|
||||
final List<MgmtTarget> rest = MgmtTargetMapper.toResponse(rolloutGroupTargets.getContent(), tenantConfigHelper);
|
||||
return ResponseEntity.ok(new PagedList<>(rest, rolloutGroupTargets.getTotalElements()));
|
||||
@@ -284,15 +262,14 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
||||
@Override
|
||||
@AuditLog(entity = "Rollout", type = AuditLog.Type.UPDATE, description = "Trigger Next Rollout Group")
|
||||
public ResponseEntity<Void> triggerNextGroup(final Long rolloutId) {
|
||||
this.rolloutManagement.triggerNextGroup(rolloutId);
|
||||
rolloutManagement.triggerNextGroup(rolloutId);
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<MgmtRolloutResponseBody> retryRollout(final Long rolloutId) {
|
||||
final Rollout rolloutForRetry = this.rolloutManagement.get(rolloutId)
|
||||
final Rollout rolloutForRetry = rolloutManagement.get(rolloutId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId));
|
||||
|
||||
if (rolloutForRetry.isDeleted()) {
|
||||
throw new EntityNotFoundException(Rollout.class, rolloutId);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.eclipse.hawkbit.repository.ActionFields;
|
||||
import org.eclipse.hawkbit.repository.ActionStatusFields;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetFields;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeFields;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.RolloutFields;
|
||||
import org.eclipse.hawkbit.repository.RolloutGroupFields;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleFields;
|
||||
@@ -24,6 +25,7 @@ import org.eclipse.hawkbit.repository.TagFields;
|
||||
import org.eclipse.hawkbit.repository.TargetFields;
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryFields;
|
||||
import org.eclipse.hawkbit.repository.TargetTypeFields;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
|
||||
@@ -146,4 +148,11 @@ public final class PagingUtility {
|
||||
}
|
||||
return Sort.by(SortUtility.parse(RolloutGroupFields.class, sortParam));
|
||||
}
|
||||
|
||||
public static Pageable toPageable(final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) {
|
||||
final int sanitizedOffsetParam = sanitizeOffsetParam(pagingOffsetParam);
|
||||
final int sanitizedLimitParam = sanitizePageLimitParam(pagingLimitParam);
|
||||
final Sort sorting = sanitizeRolloutSortParam(sortParam);
|
||||
return new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,6 @@ import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupsValidation;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
@@ -56,15 +55,6 @@ public interface RolloutManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
long count();
|
||||
|
||||
/**
|
||||
* Count rollouts by given text in name or description.
|
||||
*
|
||||
* @param searchText name or description
|
||||
* @return total count rollouts for specified filter text.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
long countByFilters(@NotEmpty String searchText);
|
||||
|
||||
/**
|
||||
* Counts all {@link Rollout}s for a specific {@link DistributionSet} that
|
||||
* are stoppable
|
||||
@@ -206,7 +196,7 @@ public interface RolloutManagement {
|
||||
* statuses
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Slice<Rollout> findAllWithDetailedStatus(@NotNull Pageable pageable, boolean deleted);
|
||||
Page<Rollout> findAllWithDetailedStatus(@NotNull Pageable pageable, boolean deleted);
|
||||
|
||||
/**
|
||||
* Retrieves all rollouts found by the given specification.
|
||||
@@ -232,7 +222,7 @@ public interface RolloutManagement {
|
||||
* not exists
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Slice<Rollout> findByFiltersWithDetailedStatus(@NotNull Pageable pageable, @NotEmpty String searchText,
|
||||
Page<Rollout> findByRsqlWithDetailedStatus(@NotNull Pageable pageable, @NotEmpty String searchText,
|
||||
boolean deleted);
|
||||
|
||||
/**
|
||||
@@ -406,12 +396,4 @@ public interface RolloutManagement {
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_UPDATE)
|
||||
void triggerNextGroup(long rolloutId);
|
||||
|
||||
/**
|
||||
* Enrich the rollouts Slice with additional details
|
||||
*
|
||||
* @param rollouts the rollouts to be enriched.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Slice<Rollout> getRolloutWithStatusDetails(final Slice<Rollout> rollouts);
|
||||
}
|
||||
@@ -36,14 +36,13 @@ import org.springframework.util.ObjectUtils;
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public final class JpaManagementHelper {
|
||||
|
||||
|
||||
public static <T, J extends T> Optional<J> findOneBySpec(
|
||||
final JpaSpecificationExecutor<J> repository, final List<Specification<J>> specList) {
|
||||
return repository.findOne(combineWithAnd(specList));
|
||||
}
|
||||
|
||||
public static <T, J extends T> Page<T> findAllWithCountBySpec(final JpaSpecificationExecutor<J> repository,
|
||||
final List<Specification<J>> specList, final Pageable pageable) {
|
||||
public static <T, J extends T> Page<T> findAllWithCountBySpec(
|
||||
final JpaSpecificationExecutor<J> repository, final List<Specification<J>> specList, final Pageable pageable) {
|
||||
if (CollectionUtils.isEmpty(specList)) {
|
||||
return convertPage(repository.findAll(Specification.where(null), pageable), pageable);
|
||||
}
|
||||
@@ -62,21 +61,20 @@ public final class JpaManagementHelper {
|
||||
return specList.size() == 1 ? specList.get(0) : SpecificationsBuilder.combineWithAnd(specList);
|
||||
}
|
||||
|
||||
public static <T, J extends T> Slice<T> findAllWithoutCountBySpec(final NoCountSliceRepository<J> repository,
|
||||
final Pageable pageable, final List<Specification<J>> specList) {
|
||||
public static <T, J extends T> Slice<T> findAllWithoutCountBySpec(
|
||||
final NoCountSliceRepository<J> repository, final List<Specification<J>> specList, final Pageable pageable) {
|
||||
if (CollectionUtils.isEmpty(specList)) {
|
||||
return convertPage(repository.findAllWithoutCount(pageable), pageable);
|
||||
return convertSlice(repository.findAllWithoutCount(pageable), pageable);
|
||||
}
|
||||
|
||||
return convertPage(repository.findAllWithoutCount(combineWithAnd(specList), pageable), pageable);
|
||||
return convertSlice(repository.findAllWithoutCount(combineWithAnd(specList), pageable), pageable);
|
||||
}
|
||||
|
||||
public static <T, J extends T> Slice<T> convertPage(final Slice<J> jpaAll, final Pageable pageable) {
|
||||
public static <T, J extends T> Slice<T> convertSlice(final Slice<J> jpaAll, final Pageable pageable) {
|
||||
return new PageImpl<>(Collections.unmodifiableList(jpaAll.getContent()), pageable, 0);
|
||||
}
|
||||
|
||||
public static <J> long countBySpec(final JpaSpecificationExecutor<J> repository,
|
||||
final List<Specification<J>> specList) {
|
||||
public static <J> long countBySpec(final JpaSpecificationExecutor<J> repository, final List<Specification<J>> specList) {
|
||||
if (CollectionUtils.isEmpty(specList)) {
|
||||
return repository.count(Specification.where(null));
|
||||
}
|
||||
@@ -101,11 +99,9 @@ public final class JpaManagementHelper {
|
||||
public static String[] getFilterNameAndVersionEntries(final String filterString) {
|
||||
final int semicolonIndex = filterString.indexOf(':');
|
||||
|
||||
final String filterName = semicolonIndex != -1 ? filterString.substring(0, semicolonIndex)
|
||||
: (filterString + "%");
|
||||
final String filterName = semicolonIndex != -1 ? filterString.substring(0, semicolonIndex) : (filterString + "%");
|
||||
final String filterVersion = semicolonIndex != -1 ? (filterString.substring(semicolonIndex + 1) + "%") : "%";
|
||||
|
||||
return new String[] { ObjectUtils.isEmpty(filterName) ? "%" : filterName, filterVersion };
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -308,14 +308,14 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
|
||||
|
||||
@Override
|
||||
public Slice<Action> findActionsAll(final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(actionRepository, pageable, null);
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(actionRepository, null, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Action> findActions(final String rsqlParam, final Pageable pageable) {
|
||||
final List<Specification<JpaAction>> specList = List.of(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, ActionFields.class, virtualPropertyReplacer, database));
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(actionRepository, pageable, specList);
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(actionRepository, specList, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -275,8 +275,8 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
@Override
|
||||
public Slice<DistributionSet> findAll(final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetRepository, pageable, List.of(
|
||||
DistributionSetSpecification.isNotDeleted()));
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetRepository, List.of(
|
||||
DistributionSetSpecification.isNotDeleted()), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -514,7 +514,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
public Slice<DistributionSet> findByCompleted(final Pageable pageReq, final Boolean complete) {
|
||||
final List<Specification<JpaDistributionSet>> specifications = buildSpecsByComplete(complete);
|
||||
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetRepository, pageReq, specifications);
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetRepository, specifications, pageReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -529,7 +529,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
final List<Specification<JpaDistributionSet>> specList = buildDistributionSetSpecifications(
|
||||
distributionSetFilter);
|
||||
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetRepository, pageable, specList);
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetRepository, specList, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -150,7 +150,7 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
|
||||
|
||||
@Override
|
||||
public Slice<DistributionSetTag> findAll(final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetTagRepository, pageable, null);
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetTagRepository, null, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -191,8 +191,8 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
|
||||
|
||||
@Override
|
||||
public Slice<DistributionSetType> findAll(final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetTypeRepository, pageable, List.of(
|
||||
DistributionSetTypeSpecification.isNotDeleted()));
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetTypeRepository, List.of(
|
||||
DistributionSetTypeSpecification.isNotDeleted()), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,6 @@ package org.eclipse.hawkbit.repository.jpa.management;
|
||||
import static org.eclipse.hawkbit.repository.jpa.builder.JpaRolloutGroupCreate.addSuccessAndErrorConditionsAndActions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@@ -84,7 +83,6 @@ import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
@@ -104,12 +102,12 @@ import org.springframework.validation.annotation.Validated;
|
||||
@Transactional(readOnly = true)
|
||||
public class JpaRolloutManagement implements RolloutManagement {
|
||||
|
||||
private static final List<RolloutStatus> ACTIVE_ROLLOUTS = Arrays.asList(RolloutStatus.CREATING,
|
||||
RolloutStatus.DELETING, RolloutStatus.STARTING, RolloutStatus.READY, RolloutStatus.RUNNING,
|
||||
RolloutStatus.STOPPING);
|
||||
private static final List<RolloutStatus> ROLLOUT_STATUS_STOPPABLE = Arrays.asList(RolloutStatus.RUNNING,
|
||||
RolloutStatus.CREATING, RolloutStatus.PAUSED, RolloutStatus.READY, RolloutStatus.STARTING,
|
||||
RolloutStatus.WAITING_FOR_APPROVAL, RolloutStatus.APPROVAL_DENIED);
|
||||
private static final List<RolloutStatus> ACTIVE_ROLLOUTS = List.of(
|
||||
RolloutStatus.CREATING, RolloutStatus.READY, RolloutStatus.STARTING, RolloutStatus.RUNNING,
|
||||
RolloutStatus.STOPPING, RolloutStatus.DELETING);
|
||||
private static final List<RolloutStatus> ROLLOUT_STATUS_STOPPABLE = List.of(
|
||||
RolloutStatus.CREATING, RolloutStatus.READY, RolloutStatus.WAITING_FOR_APPROVAL, RolloutStatus.STARTING, RolloutStatus.RUNNING,
|
||||
RolloutStatus.PAUSED, RolloutStatus.APPROVAL_DENIED);
|
||||
|
||||
private final RolloutRepository rolloutRepository;
|
||||
private final RolloutGroupRepository rolloutGroupRepository;
|
||||
@@ -178,11 +176,6 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
return rolloutRepository.count(RolloutSpecification.isDeleted(false, Sort.by(Direction.DESC, AbstractJpaBaseEntity_.ID)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countByFilters(final String searchText) {
|
||||
return rolloutRepository.count(RolloutSpecification.likeName(searchText, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countByDistributionSetIdAndRolloutIsStoppable(final long setId) {
|
||||
return rolloutRepository.countByDistributionSetIdAndStatusIn(setId, ROLLOUT_STATUS_STOPPABLE);
|
||||
@@ -273,28 +266,27 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Rollout> findAllWithDetailedStatus(final Pageable pageable, final boolean deleted) {
|
||||
final Slice<Rollout> rollouts = JpaManagementHelper.convertPage(
|
||||
public Page<Rollout> findAllWithDetailedStatus(final Pageable pageable, final boolean deleted) {
|
||||
return appendStatusDetails(JpaManagementHelper.convertPage(
|
||||
rolloutRepository.findAll(RolloutSpecification.isDeleted(deleted, pageable.getSort()), JpaRollout_.GRAPH_ROLLOUT_DS, pageable),
|
||||
pageable);
|
||||
return getRolloutWithStatusDetails(rollouts);
|
||||
pageable));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Rollout> findByRsql(final Pageable pageable, final String rsqlParam, final boolean deleted) {
|
||||
final List<Specification<JpaRollout>> specList = new ArrayList<>(2);
|
||||
specList.add(RSQLUtility.buildRsqlSpecification(rsqlParam, RolloutFields.class, virtualPropertyReplacer, database));
|
||||
specList.add(RolloutSpecification.isDeleted(deleted, pageable.getSort()));
|
||||
return JpaManagementHelper.convertPage(
|
||||
rolloutRepository.findAll(JpaManagementHelper.combineWithAnd(specList), JpaRollout_.GRAPH_ROLLOUT_DS, pageable), pageable);
|
||||
public Page<Rollout> findByRsql(final Pageable pageable, final String rsql, final boolean deleted) {
|
||||
final List<Specification<JpaRollout>> specList = List.of(
|
||||
RSQLUtility.buildRsqlSpecification(rsql, RolloutFields.class, virtualPropertyReplacer, database),
|
||||
RolloutSpecification.isDeleted(deleted, pageable.getSort()));
|
||||
return JpaManagementHelper.convertPage(rolloutRepository.findAll(JpaManagementHelper.combineWithAnd(specList), pageable), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Rollout> findByFiltersWithDetailedStatus(final Pageable pageable, final String searchText,
|
||||
final boolean deleted) {
|
||||
final Slice<Rollout> findAll = JpaManagementHelper.findAllWithoutCountBySpec(rolloutRepository, pageable,
|
||||
Collections.singletonList(RolloutSpecification.likeName(searchText, deleted)));
|
||||
return getRolloutWithStatusDetails(findAll);
|
||||
public Page<Rollout> findByRsqlWithDetailedStatus(final Pageable pageable, final String rsql, final boolean deleted) {
|
||||
final List<Specification<JpaRollout>> specList = List.of(
|
||||
RSQLUtility.buildRsqlSpecification(rsql, RolloutFields.class, virtualPropertyReplacer, database),
|
||||
RolloutSpecification.isDeleted(deleted, pageable.getSort()));
|
||||
return appendStatusDetails(JpaManagementHelper.convertPage(
|
||||
rolloutRepository.findAll(JpaManagementHelper.combineWithAnd(specList), JpaRollout_.GRAPH_ROLLOUT_DS, pageable), pageable));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -326,8 +318,8 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
rolloutStatusCache.putRolloutStatus(rolloutId, rolloutStatusCountItems);
|
||||
}
|
||||
|
||||
final TotalTargetCountStatus totalTargetCountStatus = new TotalTargetCountStatus(rolloutStatusCountItems,
|
||||
rollout.get().getTotalTargets(), rollout.get().getActionType());
|
||||
final TotalTargetCountStatus totalTargetCountStatus = new TotalTargetCountStatus(
|
||||
rolloutStatusCountItems, rollout.get().getTotalTargets(), rollout.get().getActionType());
|
||||
((JpaRollout) rollout.get()).setTotalTargetCountStatus(totalTargetCountStatus);
|
||||
return rollout;
|
||||
}
|
||||
@@ -445,14 +437,9 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
final JpaRollout jpaRollout = rolloutRepository.findById(rolloutId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Rollout.class, rolloutId));
|
||||
|
||||
if (jpaRollout == null) {
|
||||
throw new EntityNotFoundException(Rollout.class, rolloutId);
|
||||
}
|
||||
|
||||
if (RolloutStatus.DELETING == jpaRollout.getStatus()) {
|
||||
return;
|
||||
}
|
||||
|
||||
jpaRollout.setStatus(RolloutStatus.DELETING);
|
||||
rolloutRepository.save(jpaRollout);
|
||||
}
|
||||
@@ -496,8 +483,7 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
startNextRolloutGroupAction.exec(rollout, latestRunning);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slice<Rollout> getRolloutWithStatusDetails(final Slice<Rollout> rollouts) {
|
||||
private Page<Rollout> appendStatusDetails(final Page<Rollout> rollouts) {
|
||||
final List<Long> rolloutIds = rollouts.getContent().stream().map(Rollout::getId).toList();
|
||||
final Map<Long, List<TotalTargetCountActionStatus>> allStatesForRollout = getStatusCountItemForRollout(rolloutIds);
|
||||
|
||||
|
||||
@@ -253,9 +253,9 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
|
||||
@Override
|
||||
public Slice<SoftwareModule> findAll(final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(softwareModuleRepository, pageable, List.of(
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(softwareModuleRepository, List.of(
|
||||
SoftwareModuleSpecification.isNotDeleted(),
|
||||
SoftwareModuleSpecification.fetchType()));
|
||||
SoftwareModuleSpecification.fetchType()), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -412,7 +412,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
|
||||
specList.add(SoftwareModuleSpecification.fetchType());
|
||||
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(softwareModuleRepository, pageable, specList);
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(softwareModuleRepository, specList, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -436,10 +436,10 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
|
||||
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(
|
||||
softwareModuleRepository,
|
||||
pageable,
|
||||
List.of(
|
||||
SoftwareModuleSpecification.equalType(typeId),
|
||||
SoftwareModuleSpecification.isNotDeleted()));
|
||||
SoftwareModuleSpecification.isNotDeleted()), pageable
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -136,8 +136,9 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
|
||||
|
||||
@Override
|
||||
public Slice<SoftwareModuleType> findAll(final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(softwareModuleTypeRepository, pageable,
|
||||
List.of(SoftwareModuleTypeSpecification.isNotDeleted()));
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(softwareModuleTypeRepository,
|
||||
List.of(SoftwareModuleTypeSpecification.isNotDeleted()), pageable
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -158,7 +158,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
|
||||
@Override
|
||||
public Slice<TargetFilterQuery> findAll(final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetFilterQueryRepository, pageable, null);
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetFilterQueryRepository, null, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,8 +177,9 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
return findAll(pageable);
|
||||
}
|
||||
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetFilterQueryRepository, pageable,
|
||||
Collections.singletonList(TargetFilterQuerySpecification.likeName(name)));
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetFilterQueryRepository,
|
||||
Collections.singletonList(TargetFilterQuerySpecification.likeName(name)), pageable
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -207,7 +208,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
? Collections.singletonList(TargetFilterQuerySpecification.equalsQuery(query))
|
||||
: Collections.emptyList();
|
||||
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetFilterQueryRepository, pageable, specList);
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetFilterQueryRepository, specList, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -215,8 +216,9 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
final long setId) {
|
||||
final DistributionSet distributionSet = distributionSetManagement.getOrElseThrowException(setId);
|
||||
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetFilterQueryRepository, pageable,
|
||||
Collections.singletonList(TargetFilterQuerySpecification.byAutoAssignDS(distributionSet)));
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetFilterQueryRepository,
|
||||
Collections.singletonList(TargetFilterQuerySpecification.byAutoAssignDS(distributionSet)), pageable
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -236,8 +238,9 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
|
||||
@Override
|
||||
public Slice<TargetFilterQuery> findWithAutoAssignDS(final Pageable pageable) {
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetFilterQueryRepository, pageable,
|
||||
Collections.singletonList(TargetFilterQuerySpecification.withAutoAssignDS()));
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetFilterQueryRepository,
|
||||
Collections.singletonList(TargetFilterQuerySpecification.withAutoAssignDS()), pageable
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -343,7 +343,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
}
|
||||
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(
|
||||
targetRepository, pageRequest, List.of(TargetSpecifications.hasNoActionInRolloutGroup(group)));
|
||||
targetRepository, List.of(TargetSpecifications.hasNoActionInRolloutGroup(group)), pageRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -384,7 +384,7 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
@Override
|
||||
public Slice<Target> findByFilters(final Pageable pageable, final FilterParams filterParams) {
|
||||
final List<Specification<JpaTarget>> specList = buildSpecificationList(filterParams);
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetRepository, pageable, specList);
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetRepository, specList, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -420,8 +420,9 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
@Override
|
||||
public Slice<Target> findByRsql(final Pageable pageable, final String targetFilterQuery) {
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(
|
||||
targetRepository, pageable,
|
||||
List.of(RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database)));
|
||||
targetRepository,
|
||||
List.of(RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database)), pageable
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -430,9 +431,9 @@ public class JpaTargetManagement implements TargetManagement {
|
||||
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId));
|
||||
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(
|
||||
targetRepository, pageable,
|
||||
List.of(RSQLUtility.buildRsqlSpecification(
|
||||
targetFilterQuery.getQuery(), TargetFields.class, virtualPropertyReplacer, database)));
|
||||
targetRepository, List.of(RSQLUtility.buildRsqlSpecification(
|
||||
targetFilterQuery.getQuery(), TargetFields.class, virtualPropertyReplacer, database)), pageable
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -153,8 +153,8 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
|
||||
|
||||
@Override
|
||||
public Slice<TargetType> findByName(final Pageable pageable, final String name) {
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetTypeRepository, pageable,
|
||||
List.of(TargetTypeSpecification.likeName(name)));
|
||||
return JpaManagementHelper.findAllWithoutCountBySpec(targetTypeRepository, List.of(TargetTypeSpecification.likeName(name)), pageable
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,22 +40,4 @@ public final class RolloutSpecification {
|
||||
return predicate;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a {@link Specification} to search a rollout by name.
|
||||
*
|
||||
* @param searchText search string
|
||||
* @param isDeleted <code>true</code> if deleted rollouts should be included in
|
||||
* the search. Otherwise <code>false</code>
|
||||
* @return criteria specification with a query for name of a rollout
|
||||
*/
|
||||
public static Specification<JpaRollout> likeName(final String searchText, final boolean isDeleted) {
|
||||
return (rolloutRoot, query, criteriaBuilder) -> {
|
||||
final String searchTextToLower = searchText.toLowerCase();
|
||||
return criteriaBuilder.and(
|
||||
criteriaBuilder.like(criteriaBuilder.lower(rolloutRoot.get(AbstractJpaNamedEntity_.name)), searchTextToLower),
|
||||
criteriaBuilder.equal(rolloutRoot.get(JpaRollout_.deleted), isDeleted));
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -109,12 +109,6 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
assertPermissions(() -> rolloutManagement.countByDistributionSetIdAndRolloutIsStoppable(1L), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void countByFiltersPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.countByFilters("searchFilter"), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void createPermissionsCheck() {
|
||||
@@ -150,26 +144,9 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void findByFiltersWithDetailedStatusPermissionsCheck() {
|
||||
assertPermissions(() -> rolloutManagement.findByFiltersWithDetailedStatus(PAGE, "searchFilter", false),
|
||||
List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
|
||||
void getRolloutWithStatusDetailsPermissionsCheck() {
|
||||
final String rolloutName = "rollout-std";
|
||||
final int amountGroups = 5; // static only
|
||||
final String targetPrefix = "controller-rollout-std-";
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet("dsFor" + rolloutName);
|
||||
|
||||
testdataFactory.createTargets(targetPrefix, 0, amountGroups * 3);
|
||||
final Rollout rollout = testdataFactory.createRolloutByVariables(rolloutName, rolloutName, amountGroups,
|
||||
"controllerid==" + targetPrefix + "*", distributionSet, "60", "30", false, false);
|
||||
assertPermissions(() -> {
|
||||
rolloutManagement.getRolloutWithStatusDetails(new PageImpl<>(List.of(rollout)));
|
||||
return null;
|
||||
}, List.of(SpPermission.READ_ROLLOUT, SpPermission.READ_REPOSITORY));
|
||||
void findByRsqlWithDetailedStatusPermissionsCheck() {
|
||||
assertPermissions(() ->
|
||||
rolloutManagement.findByRsqlWithDetailedStatus(PAGE, "name==*", false), List.of(SpPermission.READ_ROLLOUT));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1096,32 +1096,9 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(count).isEqualTo(10L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify the count of filtered existing rollouts.")
|
||||
void countRolloutsAllByFilters() {
|
||||
|
||||
final int amountTargetsForRollout = 6;
|
||||
final int amountGroups = 2;
|
||||
final String successCondition = "50";
|
||||
final String errorCondition = "80";
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout, amountGroups, successCondition,
|
||||
errorCondition, "Rollout" + i, "Rollout" + i);
|
||||
}
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout, amountGroups, successCondition,
|
||||
errorCondition, "SomethingElse" + i, "SomethingElse" + i);
|
||||
}
|
||||
|
||||
final Long count = rolloutManagement.countByFilters("Rollout%");
|
||||
assertThat(count).isEqualTo(5L);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verify that the filtering and sorting ascending for rollout is working correctly.")
|
||||
void findRolloutByFilters() {
|
||||
|
||||
final int amountTargetsForRollout = 6;
|
||||
final int amountGroups = 2;
|
||||
final String successCondition = "50";
|
||||
@@ -1135,8 +1112,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
errorCondition, "SomethingElse" + i, "SomethingElse" + i);
|
||||
}
|
||||
|
||||
final Slice<Rollout> rollout = rolloutManagement.findByFiltersWithDetailedStatus(
|
||||
new OffsetBasedPageRequest(0, 100, Sort.by(Direction.ASC, "name")), "Rollout%", false);
|
||||
final Slice<Rollout> rollout = rolloutManagement.findByRsqlWithDetailedStatus(
|
||||
new OffsetBasedPageRequest(0, 100, Sort.by(Direction.ASC, "name")), "name==Rollout*", false);
|
||||
final List<Rollout> rolloutList = rollout.getContent();
|
||||
assertThat(rolloutList).hasSize(5);
|
||||
int i = 1;
|
||||
@@ -1905,8 +1882,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(rolloutManagement.findByRsql(PAGE, "name==*", true).getContent()).hasSize(1);
|
||||
assertThat(rolloutManagement.findByRsql(PAGE, "name==*", false).getContent()).isEmpty();
|
||||
assertThat(rolloutManagement.count()).isZero();
|
||||
assertThat(rolloutGroupManagement.findByRolloutWithDetailedStatus(createdRollout.getId(), PAGE).getContent())
|
||||
.hasSize(amountGroups);
|
||||
assertThat(rolloutGroupManagement.findByRolloutWithDetailedStatus(createdRollout.getId(), PAGE).getContent()).hasSize(amountGroups);
|
||||
|
||||
// verify that all scheduled actions are deleted
|
||||
assertThat(actionRepository.findByRolloutIdAndStatus(PAGE, deletedRollout.getId(), Status.SCHEDULED)
|
||||
|
||||
Reference in New Issue
Block a user