Feature - TargetType compatibility check (#1180)

* added targettype compatibility check in deployment

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* added targettype compatibility for autssignment

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* added / fixed tests for auto assignment compatibility check

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* adapted rollout creation to use JPA specifications for compatibility checks

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* fix unit tests and javadoc

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* fix copyright header

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* fixed review findings

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* fixed review findings

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* replaced validated-DS management calls

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* improved compatibility check in DeploymentManagementTest

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>

* fixed review findings

Signed-off-by: Robert Sing <robert.sing@bosch-si.com>
This commit is contained in:
Robert Sing
2021-10-15 15:39:21 +02:00
committed by GitHub
parent 39ccf65f2e
commit 76be812cf1
16 changed files with 857 additions and 502 deletions

View File

@@ -124,8 +124,8 @@ public class TestdataFactory {
public static final String SM_TYPE_RT = "runtime";
/**
* Key of test "application" {@link SoftwareModuleType} : optional software
* in {@link #DS_TYPE_DEFAULT}.
* Key of test "application" {@link SoftwareModuleType} : optional software in
* {@link #DS_TYPE_DEFAULT}.
*/
public static final String SM_TYPE_APP = "application";
@@ -175,8 +175,8 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link DistributionSet#isRequiredMigrationStep()} <code>false</code>.
*
* @param prefix
@@ -191,8 +191,8 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link DistributionSet#isRequiredMigrationStep()} <code>false</code>.
*
* @return {@link DistributionSet} entity.
@@ -203,8 +203,8 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link DistributionSet#isRequiredMigrationStep()} <code>false</code>.
*
* @param modules
@@ -218,8 +218,8 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link DistributionSet#isRequiredMigrationStep()} <code>false</code>.
*
* @param modules
@@ -236,8 +236,8 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION}.
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION}.
*
* @param prefix
* for {@link SoftwareModule}s and {@link DistributionSet}s name,
@@ -253,8 +253,8 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} and
* {@link DistributionSet#isRequiredMigrationStep()} <code>false</code>.
*
* @param prefix
@@ -271,16 +271,15 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP}.
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP}.
*
* @param prefix
* for {@link SoftwareModule}s and {@link DistributionSet}s name,
* vendor and description.
* @param version
* {@link DistributionSet#getVersion()} and
* {@link SoftwareModule#getVersion()} extended by a random
* number.
* {@link SoftwareModule#getVersion()} extended by a random number.
* @param isRequiredMigrationStep
* for {@link DistributionSet#isRequiredMigrationStep()}
*
@@ -341,8 +340,7 @@ public class TestdataFactory {
* vendor and description.
* @param version
* {@link DistributionSet#getVersion()} and
* {@link SoftwareModule#getVersion()} extended by a random
* number.
* {@link SoftwareModule#getVersion()} extended by a random number.
* @param isRequiredMigrationStep
* for {@link DistributionSet#isRequiredMigrationStep()}
* @param modules
@@ -362,8 +360,8 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP}.
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP}.
*
* @param prefix
* for {@link SoftwareModule}s and {@link DistributionSet}s name,
@@ -390,9 +388,9 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet}s in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} followed by an
* iterative number and {@link DistributionSet#isRequiredMigrationStep()}
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} followed by an iterative
* number and {@link DistributionSet#isRequiredMigrationStep()}
* <code>false</code>.
*
* @param number
@@ -406,8 +404,7 @@ public class TestdataFactory {
}
/**
* Create a list of {@link DistributionSet}s without modules, i.e.
* incomplete.
* Create a list of {@link DistributionSet}s without modules, i.e. incomplete.
*
* @param number
* of {@link DistributionSet}s to create
@@ -427,9 +424,9 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet}s in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} followed by an
* iterative number and {@link DistributionSet#isRequiredMigrationStep()}
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} followed by an iterative
* number and {@link DistributionSet#isRequiredMigrationStep()}
* <code>false</code>.
*
* @param prefix
@@ -469,8 +466,8 @@ public class TestdataFactory {
}
/**
* Creates {@link Artifact}s for given {@link SoftwareModule} with a small
* text payload.
* Creates {@link Artifact}s for given {@link SoftwareModule} with a small text
* payload.
*
* @param moduleId
* the {@link Artifact}s belong to.
@@ -488,8 +485,8 @@ public class TestdataFactory {
}
/**
* Create an {@link Artifact} for given {@link SoftwareModule} with a small
* text payload.
* Create an {@link Artifact} for given {@link SoftwareModule} with a small text
* payload.
*
* @param artifactData
* the {@link Artifact} Inputstream
@@ -509,8 +506,8 @@ public class TestdataFactory {
}
/**
* Create an {@link Artifact} for given {@link SoftwareModule} with a small
* text payload.
* Create an {@link Artifact} for given {@link SoftwareModule} with a small text
* payload.
*
* @param artifactData
* the {@link Artifact} Inputstream
@@ -534,8 +531,8 @@ public class TestdataFactory {
/**
* Creates {@link SoftwareModule} with {@link #DEFAULT_VENDOR} and
* {@link #DEFAULT_VERSION} and random generated
* {@link Target#getDescription()} in the repository.
* {@link #DEFAULT_VERSION} and random generated {@link Target#getDescription()}
* in the repository.
*
* @param typeKey
* of the {@link SoftwareModuleType}
@@ -547,10 +544,9 @@ public class TestdataFactory {
}
/**
* Creates {@link SoftwareModule} of type
* {@value Constants#SMT_DEFAULT_APP_KEY} with {@link #DEFAULT_VENDOR} and
* {@link #DEFAULT_VERSION} and random generated
* {@link Target#getDescription()} in the repository.
* Creates {@link SoftwareModule} of type {@value Constants#SMT_DEFAULT_APP_KEY}
* with {@link #DEFAULT_VENDOR} and {@link #DEFAULT_VERSION} and random
* generated {@link Target#getDescription()} in the repository.
*
*
* @return persisted {@link SoftwareModule}.
@@ -560,10 +556,9 @@ public class TestdataFactory {
}
/**
* Creates {@link SoftwareModule} of type
* {@value Constants#SMT_DEFAULT_APP_KEY} with {@link #DEFAULT_VENDOR} and
* {@link #DEFAULT_VERSION} and random generated
* {@link Target#getDescription()} in the repository.
* Creates {@link SoftwareModule} of type {@value Constants#SMT_DEFAULT_APP_KEY}
* with {@link #DEFAULT_VENDOR} and {@link #DEFAULT_VERSION} and random
* generated {@link Target#getDescription()} in the repository.
*
* @param prefix
* added to name and version
@@ -576,10 +571,9 @@ public class TestdataFactory {
}
/**
* Creates {@link SoftwareModule} of type
* {@value Constants#SMT_DEFAULT_OS_KEY} with {@link #DEFAULT_VENDOR} and
* {@link #DEFAULT_VERSION} and random generated
* {@link Target#getDescription()} in the repository.
* Creates {@link SoftwareModule} of type {@value Constants#SMT_DEFAULT_OS_KEY}
* with {@link #DEFAULT_VENDOR} and {@link #DEFAULT_VERSION} and random
* generated {@link Target#getDescription()} in the repository.
*
*
* @return persisted {@link SoftwareModule}.
@@ -589,10 +583,9 @@ public class TestdataFactory {
}
/**
* Creates {@link SoftwareModule} of type
* {@value Constants#SMT_DEFAULT_OS_KEY} with {@link #DEFAULT_VENDOR} and
* {@link #DEFAULT_VERSION} and random generated
* {@link Target#getDescription()} in the repository.
* Creates {@link SoftwareModule} of type {@value Constants#SMT_DEFAULT_OS_KEY}
* with {@link #DEFAULT_VENDOR} and {@link #DEFAULT_VERSION} and random
* generated {@link Target#getDescription()} in the repository.
*
* @param prefix
* added to name and version
@@ -606,8 +599,8 @@ public class TestdataFactory {
/**
* Creates {@link SoftwareModule} with {@link #DEFAULT_VENDOR} and
* {@link #DEFAULT_VERSION} and random generated
* {@link Target#getDescription()} in the repository.
* {@link #DEFAULT_VERSION} and random generated {@link Target#getDescription()}
* in the repository.
*
* @param typeKey
* of the {@link SoftwareModuleType}
@@ -679,15 +672,14 @@ public class TestdataFactory {
/**
* Creates {@link DistributionSet}s in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} followed by an
* iterative number and {@link DistributionSet#isRequiredMigrationStep()}
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT} ,
* {@link #SM_TYPE_APP} with {@link #DEFAULT_VERSION} followed by an iterative
* number and {@link DistributionSet#isRequiredMigrationStep()}
* <code>false</code>.
*
* In addition it updates the created {@link DistributionSet}s and
* {@link SoftwareModule}s to ensure that
* {@link BaseEntity#getLastModifiedAt()} and
* {@link BaseEntity#getLastModifiedBy()} is filled.
* {@link SoftwareModule}s to ensure that {@link BaseEntity#getLastModifiedAt()}
* and {@link BaseEntity#getLastModifiedBy()} is filled.
*
* @return persisted {@link DistributionSet}.
*/
@@ -705,8 +697,8 @@ public class TestdataFactory {
/**
* @return {@link DistributionSetType} with key {@link #DS_TYPE_DEFAULT} and
* {@link SoftwareModuleType}s {@link #SM_TYPE_OS},
* {@link #SM_TYPE_RT} , {@link #SM_TYPE_APP}.
* {@link SoftwareModuleType}s {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
* , {@link #SM_TYPE_APP}.
*/
public DistributionSetType findOrCreateDefaultTestDsType() {
final List<SoftwareModuleType> mand = new ArrayList<>();
@@ -762,8 +754,8 @@ public class TestdataFactory {
/**
* Finds {@link SoftwareModuleType} in repository with given
* {@link SoftwareModuleType#getKey()} or creates if it does not exist yet
* with {@link SoftwareModuleType#getMaxAssignments()} = 1.
* {@link SoftwareModuleType#getKey()} or creates if it does not exist yet with
* {@link SoftwareModuleType#getMaxAssignments()} = 1.
*
* @param key
* {@link SoftwareModuleType#getKey()}
@@ -869,9 +861,8 @@ public class TestdataFactory {
}
/**
* Creates {@link Target}s in repository and with
* {@link #DEFAULT_CONTROLLER_ID} as prefix for
* {@link Target#getControllerId()}.
* Creates {@link Target}s in repository and with {@link #DEFAULT_CONTROLLER_ID}
* as prefix for {@link Target#getControllerId()}.
*
* @param number
* of {@link Target}s to create
@@ -888,6 +879,30 @@ public class TestdataFactory {
return targetManagement.create(targets);
}
/**
* Creates {@link Target}s in repository and with {@link TargetType}.
*
* @param number
* of {@link Target}s to create
* @param controllerIdPrefix
* prefix for the controller id
* @param targetType
* targetType of targets to create
*
* @return {@link List} of {@link Target} entities
*/
public List<Target> createTargetsWithType(final int number, final String controllerIdPrefix,
final TargetType targetType) {
final List<TargetCreate> targets = Lists.newArrayListWithExpectedSize(number);
for (int i = 0; i < number; i++) {
targets.add(entityFactory.target().create().controllerId(controllerIdPrefix + i)
.targetType(targetType.getId()));
}
return targetManagement.create(targets);
}
/**
* Creates {@link Target}s in repository and with given targetIds.
*
@@ -929,8 +944,7 @@ public class TestdataFactory {
/**
* Builds {@link Target} objects with given prefix for
* {@link Target#getControllerId()} followed by a number suffix starting
* with 0.
* {@link Target#getControllerId()} followed by a number suffix starting with 0.
*
* @param numberOfTargets
* of {@link Target}s to generate
@@ -1046,8 +1060,7 @@ public class TestdataFactory {
}
/**
* Append {@link ActionStatus} to all {@link Action}s of given
* {@link Target}s.
* Append {@link ActionStatus} to all {@link Action}s of given {@link Target}s.
*
* @param targets
* to add {@link ActionStatus}
@@ -1064,8 +1077,7 @@ public class TestdataFactory {
}
/**
* Append {@link ActionStatus} to all {@link Action}s of given
* {@link Target}s.
* Append {@link ActionStatus} to all {@link Action}s of given {@link Target}s.
*
* @param targets
* to add {@link ActionStatus}
@@ -1163,8 +1175,8 @@ public class TestdataFactory {
* {@link Target}s.
*
* @param prefix
* for rollouts name, description,
* {@link Target#getControllerId()} filter
* for rollouts name, description, {@link Target#getControllerId()}
* filter
* @return created {@link Rollout}
*/
public Rollout createRollout(final String prefix) {
@@ -1174,12 +1186,12 @@ public class TestdataFactory {
}
/**
* Create the soft deleted {@link Rollout} with a new
* {@link DistributionSet} and {@link Target}s.
* Create the soft deleted {@link Rollout} with a new {@link DistributionSet}
* and {@link Target}s.
*
* @param prefix
* for rollouts name, description,
* {@link Target#getControllerId()} filter
* for rollouts name, description, {@link Target#getControllerId()}
* filter
* @return created {@link Rollout}
*/
public Rollout createSoftDeletedRollout(final String prefix) {
@@ -1194,7 +1206,8 @@ public class TestdataFactory {
/**
* Finds {@link TargetType} in repository with given
* {@link TargetType#getName()} or creates if it does not exist yet. No ds
* types are assigned on creation.
* types
* are assigned on creation.
*
* @param targetTypeName
* {@link TargetType#getName()}
@@ -1210,7 +1223,8 @@ public class TestdataFactory {
/**
* Creates {@link TargetType} in repository with given
* {@link TargetType#getName()}. Compatible distribution set types are
* assigned on creation
* assigned
* on creation
*
* @param targetTypeName
* {@link TargetType#getName()}