Rollouts can be deleted (#436)

* Management UI

Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>

* Repository

Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>

* Optimisations and scheduler deleting enabled

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Melanie Retter
2017-02-18 07:19:28 +01:00
committed by Kai Zimmermann
parent 804522f966
commit 5628d625e8
159 changed files with 3029 additions and 1737 deletions

View File

@@ -153,6 +153,7 @@ public class DeviceSimulatorUpdater {
if (device.getProgress() <= 0 && modules != null) {
device.setUpdateStatus(simulateDownloads(device.getTargetSecurityToken()));
if (isErrorResponse(device.getUpdateStatus())) {
device.setProgress(1.0);
callback.updateFinished(device, actionId);
eventbus.post(new ProgressUpdate(device));
return;
@@ -216,8 +217,11 @@ public class DeviceSimulatorUpdater {
private static UpdateStatus downloadUrl(final String url, final String targetToken, final String sha1Hash,
final long size) {
LOGGER.debug("Downloading {} with token {}, expected sha1 hash {} and size {}", url,
hideTokenDetails(targetToken), sha1Hash, size);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Downloading {} with token {}, expected sha1 hash {} and size {}", url,
hideTokenDetails(targetToken), sha1Hash, size);
}
try {
return readAndCheckDownloadUrl(url, targetToken, sha1Hash, size);

View File

@@ -232,7 +232,7 @@ public class SpSenderService extends SenderService {
headers.put(MessageHeaderKey.TENANT, tenant);
headers.put(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
headers.put(MessageHeaderKey.CONTENT_TYPE, MessageProperties.CONTENT_TYPE_JSON);
actionUpdateStatus.getMessage().addAll(updateResultMessages);
actionUpdateStatus.addMessage(updateResultMessages);
actionUpdateStatus.setActionId(actionId);
return convertMessage(actionUpdateStatus, messageProperties);

View File

@@ -17,16 +17,16 @@ spring.datasource.username=root
spring.datasource.password=
spring.datasource.driverClassName=org.mariadb.jdbc.Driver
spring.datasource.max-active=100
spring.datasource.max-idle=10
spring.datasource.min-idle=10
spring.datasource.initial-size=10
spring.datasource.validation-query=select 1 from dual
spring.datasource.validation-interval=30000
spring.datasource.test-on-borrow=true
spring.datasource.test-on-return=false
spring.datasource.test-while-idle=true
spring.datasource.time-between-eviction-runs-millis=30000
spring.datasource.min-evictable-idle-time-millis=60000
spring.datasource.max-wait=10000
spring.datasource.jmx-enabled=true
spring.datasource.tomcat.max-active=100
spring.datasource.tomcat.max-idle=10
spring.datasource.tomcat.min-idle=10
spring.datasource.tomcat.initial-size=10
spring.datasource.tomcat.validation-query=select 1 from dual
spring.datasource.tomcat.validation-interval=30000
spring.datasource.tomcat.test-on-borrow=true
spring.datasource.tomcat.test-on-return=false
spring.datasource.tomcat.test-while-idle=true
spring.datasource.tomcat.time-between-eviction-runs-millis=30000
spring.datasource.tomcat.min-evictable-idle-time-millis=60000
spring.datasource.tomcat.max-wait=10000
spring.datasource.tomcat.jmx-enabled=true

View File

@@ -41,6 +41,7 @@ import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag;
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import com.google.common.collect.Lists;
@@ -123,7 +124,6 @@ public class ConfigurableScenario {
.createTargetTags(new TagBuilder().name(group).description("Group " + group).build()).getBody()
.get(0).getTagId())
.collect(Collectors.toList());
}
private void cleanRepository() {
@@ -136,11 +136,20 @@ public class ConfigurableScenario {
}
private void deleteRollouts() {
// TODO: complete this as soon as rollouts can be deleted
LOGGER.info("Delete Rollouts");
PagedList<MgmtRolloutResponseBody> rollouts;
while ((rollouts = rolloutResource.getRollouts(0, PAGE_SIZE, null, null).getBody()).getTotal() > 0) {
rollouts.getContent().parallelStream().forEach(rollout -> {
rolloutResource.delete(rollout.getRolloutId());
waitUntilRolloutNoLongerExists(rollout.getRolloutId());
});
}
}
private void deleteSoftwareModules() {
LOGGER.info("Delete SoftwareModules");
PagedList<MgmtSoftwareModule> modules;
do {
modules = softwareModuleResource.getSoftwareModules(0, PAGE_SIZE, null, null).getBody();
@@ -150,6 +159,8 @@ public class ConfigurableScenario {
}
private void deleteDistributionSets() {
LOGGER.info("Delete DistributionSets");
PagedList<MgmtDistributionSet> distributionSets;
do {
distributionSets = distributionSetResource.getDistributionSets(0, PAGE_SIZE, null, null).getBody();
@@ -170,6 +181,8 @@ public class ConfigurableScenario {
}
private void deleteTargets() {
LOGGER.info("Delete Targets");
PagedList<MgmtTarget> targets;
do {
targets = targetResource.getTargets(0, PAGE_SIZE, null, null).getBody();
@@ -203,8 +216,9 @@ public class ConfigurableScenario {
LOGGER.info("Run semi automatic rollout for set {}", set.getDsId());
// create a Rollout
final MgmtRolloutResponseBody rolloutResponseBody = rolloutResource.create(new RolloutBuilder()
.name("Rollout" + set.getName() + set.getVersion()).semiAutomaticGroups(createRolloutGroups(scenario))
.targetFilterQuery("name==*").distributionSetId(set.getDsId())
.name("SemiAutomaticRollout" + set.getName() + set.getVersion())
.semiAutomaticGroups(createRolloutGroups(scenario)).targetFilterQuery("name==*")
.distributionSetId(set.getDsId())
.successThreshold(String.valueOf(scenario.getRolloutSuccessThreshold())).errorThreshold("5").build())
.getBody();
@@ -218,13 +232,15 @@ public class ConfigurableScenario {
}
private static List<MgmtRolloutGroup> createRolloutGroups(final Scenario scenario) {
final List<MgmtRolloutGroup> result = Lists.newArrayListWithCapacity(scenario.getDeviceGroups().size() * 2);
final List<MgmtRolloutGroup> result = Lists
.newArrayListWithExpectedSize((scenario.getDeviceGroups().size() * 3) + 1);
scenario.getDeviceGroups().forEach(groupname -> {
result.add(createGroup(1, groupname, 10F));
result.add(createGroup(2, groupname, 50F));
result.add(createGroup(3, groupname, 100F));
});
result.add(createFinalGroup());
return result;
}
@@ -238,6 +254,15 @@ public class ConfigurableScenario {
return one;
}
private static MgmtRolloutGroup createFinalGroup() {
final MgmtRolloutGroup one = new MgmtRolloutGroup();
one.setName("final");
one.setDescription("Group of non tagged devices");
one.setTargetFilterQuery("name==*");
one.setTargetPercentage(100F);
return one;
}
private void runRollout(final MgmtDistributionSet set, final Scenario scenario) {
LOGGER.info("Run rollout for set {}", set.getDsId());
// create a Rollout
@@ -256,6 +281,17 @@ public class ConfigurableScenario {
LOGGER.info("Run rollout for set {} -> Done", set.getDsId());
}
private void waitUntilRolloutNoLongerExists(final Long id) {
do {
try {
TimeUnit.SECONDS.sleep(5);
} catch (final InterruptedException e) {
LOGGER.warn("Interrupted!");
Thread.currentThread().interrupt();
}
} while (rolloutResource.getRollout(id).getStatusCode() != HttpStatus.NOT_FOUND);
}
private void waitUntilRolloutIsComplete(final Long id) {
do {
try {