From 68523cd8de366bfec93f17812b4680467c4577f2 Mon Sep 17 00:00:00 2001 From: Jonathan Knoblauch Date: Tue, 19 Sep 2017 17:49:19 +0200 Subject: [PATCH] Flag parameter for management simulator to wait till scenario ends (#572) * Add waitTillRolloutComplete parameter and setter for scenarios Signed-off-by: Jonathan Philip Knoblauch * Change to stream form parallel stream because of auth problems and fix delete rollout call Signed-off-by: Jonathan Philip Knoblauch * Changed back to parallelStream Signed-off-by: Jonathan Philip Knoblauch * Removed catch feign exception and added decode404 to feign client Signed-off-by: Jonathan Philip Knoblauch --- .../eclipse/hawkbit/mgmt/client/Application.java | 2 +- .../mgmt/client/ClientConfigurationProperties.java | 13 +++++++++++++ .../mgmt/client/scenarios/ConfigurableScenario.java | 5 ++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/examples/hawkbit-example-mgmt-simulator/src/main/java/org/eclipse/hawkbit/mgmt/client/Application.java b/examples/hawkbit-example-mgmt-simulator/src/main/java/org/eclipse/hawkbit/mgmt/client/Application.java index e94d959a5..97538f72c 100644 --- a/examples/hawkbit-example-mgmt-simulator/src/main/java/org/eclipse/hawkbit/mgmt/client/Application.java +++ b/examples/hawkbit-example-mgmt-simulator/src/main/java/org/eclipse/hawkbit/mgmt/client/Application.java @@ -96,7 +96,7 @@ public class Application implements CommandLineRunner { final ObjectMapper mapper = new ObjectMapper() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .registerModule(new Jackson2HalModule()); - return Feign.builder().contract(new IgnoreMultipleConsumersProducersSpringMvcContract()) + return Feign.builder().contract(new IgnoreMultipleConsumersProducersSpringMvcContract()).decode404() .requestInterceptor( new BasicAuthRequestInterceptor(configuration.getUsername(), configuration.getPassword())) .logger(new Slf4jLogger()).encoder(new FeignMultipartEncoder()) diff --git a/examples/hawkbit-example-mgmt-simulator/src/main/java/org/eclipse/hawkbit/mgmt/client/ClientConfigurationProperties.java b/examples/hawkbit-example-mgmt-simulator/src/main/java/org/eclipse/hawkbit/mgmt/client/ClientConfigurationProperties.java index 6fc70eeaf..aff70ba85 100644 --- a/examples/hawkbit-example-mgmt-simulator/src/main/java/org/eclipse/hawkbit/mgmt/client/ClientConfigurationProperties.java +++ b/examples/hawkbit-example-mgmt-simulator/src/main/java/org/eclipse/hawkbit/mgmt/client/ClientConfigurationProperties.java @@ -46,6 +46,7 @@ public class ClientConfigurationProperties { */ public static class Scenario { private boolean cleanRepository; + private boolean waitTillRolloutComplete = true; private int targets = 100; private int distributionSets = 10; private int appModulesPerDistributionSet = 2; @@ -101,6 +102,14 @@ public class ClientConfigurationProperties { this.cleanRepository = cleanRepository; } + public boolean isWaitTillRolloutComplete() { + return waitTillRolloutComplete; + } + + public void setWaitTillRolloutComplete(final boolean waitTillRolloutComplete) { + this.waitTillRolloutComplete = waitTillRolloutComplete; + } + public int getRolloutDeploymentGroups() { return rolloutDeploymentGroups; } @@ -227,6 +236,10 @@ public class ClientConfigurationProperties { return scenarios; } + public void addScenarios(final Scenario scenario) { + scenarios.add(scenario); + } + public String getUrl() { return url; } diff --git a/examples/hawkbit-example-mgmt-simulator/src/main/java/org/eclipse/hawkbit/mgmt/client/scenarios/ConfigurableScenario.java b/examples/hawkbit-example-mgmt-simulator/src/main/java/org/eclipse/hawkbit/mgmt/client/scenarios/ConfigurableScenario.java index 7f3c1d2ce..c4fafb228 100644 --- a/examples/hawkbit-example-mgmt-simulator/src/main/java/org/eclipse/hawkbit/mgmt/client/scenarios/ConfigurableScenario.java +++ b/examples/hawkbit-example-mgmt-simulator/src/main/java/org/eclipse/hawkbit/mgmt/client/scenarios/ConfigurableScenario.java @@ -278,11 +278,14 @@ public class ConfigurableScenario { // start the created Rollout rolloutResource.start(rolloutResponseBody.getRolloutId()); - waitUntilRolloutIsComplete(rolloutResponseBody.getRolloutId()); + if (scenario.isWaitTillRolloutComplete()) { + waitUntilRolloutIsComplete(rolloutResponseBody.getRolloutId()); + } LOGGER.info("Run rollout for set {} -> Done", set.getDsId()); } private void waitUntilRolloutNoLongerExists(final Long id) { + do { try { TimeUnit.SECONDS.sleep(5);