Complete repo exception tests (#452)

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2017-03-23 18:24:58 +01:00
committed by GitHub
parent c4d3ff5166
commit 081c3cccbf
26 changed files with 740 additions and 300 deletions

View File

@@ -43,12 +43,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorAction;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorCondition;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetWithActionType;
@@ -273,24 +267,6 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware {
entityFactory.actionStatus().create(savedAction.getId()).status(Action.Status.FINISHED));
}
protected Rollout createRolloutByVariables(final String rolloutName, final String rolloutDescription,
final int groupSize, final String filterQuery, final DistributionSet distributionSet,
final String successCondition, final String errorCondition) {
final RolloutGroupConditions conditions = new RolloutGroupConditionBuilder().withDefaults()
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, successCondition)
.errorCondition(RolloutGroupErrorCondition.THRESHOLD, errorCondition)
.errorAction(RolloutGroupErrorAction.PAUSE, null).build();
final Rollout rollout = rolloutManagement.createRollout(entityFactory.rollout().create().name(rolloutName)
.description(rolloutDescription).targetFilterQuery(filterQuery).set(distributionSet), groupSize,
conditions);
// Run here, because Scheduler is disabled during tests
rolloutManagement.handleRollouts();
return rolloutManagement.findRolloutById(rollout.getId()).get();
}
@Before
public void before() throws Exception {
mvc = createMvcWebAppContext().build();

View File

@@ -28,6 +28,7 @@ import org.eclipse.hawkbit.repository.ControllerManagement;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.DistributionSetManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.TagManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
@@ -42,6 +43,12 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorAction;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorCondition;
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.model.Target;
@@ -127,6 +134,9 @@ public class TestdataFactory {
@Autowired
private ArtifactManagement artifactManagement;
@Autowired
private RolloutManagement rolloutManagement;
/**
* Creates {@link DistributionSet} in repository including three
* {@link SoftwareModule}s of types {@link #SM_TYPE_OS}, {@link #SM_TYPE_RT}
@@ -902,4 +912,56 @@ public class TestdataFactory {
}
return result;
}
/**
* Creates rollout based on given parameters.
*
* @param rolloutName
* of the {@link Rollout}
* @param rolloutDescription
* of the {@link Rollout}
* @param groupSize
* of the {@link Rollout}
* @param filterQuery
* to identify the {@link Target}s
* @param distributionSet
* to assign
* @param successCondition
* to switch to next group
* @param errorCondition
* to switch to next group
* @return created {@link Rollout}
*/
public Rollout createRolloutByVariables(final String rolloutName, final String rolloutDescription,
final int groupSize, final String filterQuery, final DistributionSet distributionSet,
final String successCondition, final String errorCondition) {
final RolloutGroupConditions conditions = new RolloutGroupConditionBuilder().withDefaults()
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, successCondition)
.errorCondition(RolloutGroupErrorCondition.THRESHOLD, errorCondition)
.errorAction(RolloutGroupErrorAction.PAUSE, null).build();
final Rollout rollout = rolloutManagement.createRollout(entityFactory.rollout().create().name(rolloutName)
.description(rolloutDescription).targetFilterQuery(filterQuery).set(distributionSet), groupSize,
conditions);
// Run here, because Scheduler is disabled during tests
rolloutManagement.handleRollouts();
return rolloutManagement.findRolloutById(rollout.getId()).get();
}
/**
* Create {@link Rollout} with a new {@link DistributionSet} and
* {@link Target}s.
*
* @param prefix
* for rollouts name, description,
* {@link Target#getControllerId()} filter
* @return created {@link Rollout}
*/
public Rollout createRollout(final String prefix) {
createTargets(10, prefix);
return createRolloutByVariables(prefix, prefix + " description", 10, "controllerId==" + prefix + "*",
createDistributionSet(prefix), "50", "5");
}
}