Completed configurable mgmt simulation scenario.
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -35,9 +35,10 @@ import feign.Feign;
|
||||
import feign.Logger;
|
||||
import feign.auth.BasicAuthRequestInterceptor;
|
||||
import feign.jackson.JacksonDecoder;
|
||||
import feign.slf4j.Slf4jLogger;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients
|
||||
@EnableFeignClients("org.eclipse.hawkbit.mgmt.client.resource")
|
||||
@EnableConfigurationProperties(ClientConfigurationProperties.class)
|
||||
@Configuration
|
||||
@AutoConfigureAfter(FeignClientConfiguration.class)
|
||||
@@ -83,6 +84,11 @@ public class Application implements CommandLineRunner {
|
||||
return new CreateStartedRolloutExample();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Logger.Level feignLoggerLevel() {
|
||||
return Logger.Level.FULL;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MgmtSoftwareModuleClientResource uploadSoftwareModule() {
|
||||
final ObjectMapper mapper = new ObjectMapper()
|
||||
@@ -92,13 +98,13 @@ public class Application implements CommandLineRunner {
|
||||
return Feign.builder().contract(new IgnoreMultipleConsumersProducersSpringMvcContract())
|
||||
.requestInterceptor(
|
||||
new BasicAuthRequestInterceptor(configuration.getUsername(), configuration.getPassword()))
|
||||
.logger(new Logger.ErrorLogger()).encoder(new FeignMultipartEncoder())
|
||||
.logger(new Slf4jLogger()).encoder(new FeignMultipartEncoder())
|
||||
.decoder(new ResponseEntityDecoder(new JacksonDecoder(mapper)))
|
||||
.target(MgmtSoftwareModuleClientResource.class,
|
||||
configuration.getUrl() + MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING);
|
||||
}
|
||||
|
||||
private boolean containsArg(final String containsArg, final String... args) {
|
||||
private static boolean containsArg(final String containsArg, final String... args) {
|
||||
for (final String arg : args) {
|
||||
if (arg.equalsIgnoreCase(containsArg)) {
|
||||
return true;
|
||||
|
||||
@@ -44,7 +44,6 @@ public class ClientConfigurationProperties {
|
||||
*
|
||||
*/
|
||||
public static class Scenario {
|
||||
private String tenant = "DEFAULT";
|
||||
private boolean cleanRepository;
|
||||
private int targets = 100;
|
||||
private int distributionSets = 10;
|
||||
@@ -96,14 +95,6 @@ public class ClientConfigurationProperties {
|
||||
this.targetAddress = targetAddress;
|
||||
}
|
||||
|
||||
public String getTenant() {
|
||||
return tenant;
|
||||
}
|
||||
|
||||
public void setTenant(final String tenant) {
|
||||
this.tenant = tenant;
|
||||
}
|
||||
|
||||
public int getArtifactsPerSM() {
|
||||
return artifactsPerSM;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
x * Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
@@ -159,10 +159,9 @@ public class ConfigurableScenario {
|
||||
LOGGER.info("Creating {} distribution sets", scenario.getDistributionSets());
|
||||
final byte[] artifact = generateArtifact(scenario);
|
||||
|
||||
distributionSetResource
|
||||
.createDistributionSets(new DistributionSetBuilder().name(scenario.getDsName()).type("os_app")
|
||||
.version("1.0.").buildAsList(scenario.getDistributionSets()))
|
||||
.getBody().parallelStream().forEach(dsSet -> {
|
||||
distributionSetResource.createDistributionSets(new DistributionSetBuilder().name(scenario.getDsName())
|
||||
.type("os_app").version("1.0.").buildAsList(scenario.getDistributionSets())).getBody()
|
||||
.forEach(dsSet -> {
|
||||
final List<MgmtSoftwareModule> modules = addModules(scenario, dsSet, artifact);
|
||||
|
||||
final SoftwareModuleAssigmentBuilder assign = new SoftwareModuleAssigmentBuilder();
|
||||
@@ -175,13 +174,13 @@ public class ConfigurableScenario {
|
||||
|
||||
private List<MgmtSoftwareModule> addModules(final Scenario scenario, final MgmtDistributionSet dsSet,
|
||||
final byte[] artifact) {
|
||||
final List<MgmtSoftwareModule> modules = softwareModuleResource.createSoftwareModules(
|
||||
new SoftwareModuleBuilder().name(scenario.getSmFwName()).version(dsSet.getVersion()).type("os").build())
|
||||
final List<MgmtSoftwareModule> modules = softwareModuleResource
|
||||
.createSoftwareModules(new SoftwareModuleBuilder().name(scenario.getSmFwName() + "-os")
|
||||
.version(dsSet.getVersion()).type("os").build())
|
||||
.getBody();
|
||||
modules.addAll(softwareModuleResource
|
||||
.createSoftwareModules(
|
||||
new SoftwareModuleBuilder().name(scenario.getSmSwName()).version(dsSet.getVersion() + ".")
|
||||
.type("application").buildAsList(scenario.getAppModulesPerDistributionSet()))
|
||||
modules.addAll(softwareModuleResource.createSoftwareModules(
|
||||
new SoftwareModuleBuilder().name(scenario.getSmSwName() + "-app").version(dsSet.getVersion() + ".")
|
||||
.type("application").buildAsList(scenario.getAppModulesPerDistributionSet()))
|
||||
.getBody());
|
||||
|
||||
for (int x = 0; x < scenario.getArtifactsPerSM(); x++) {
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) 2011-2015 Bosch Software Innovations GmbH, Germany. All rights reserved.
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.client.scenarios.upload;
|
||||
|
||||
@@ -100,16 +105,16 @@ public class FeignMultipartEncoder implements Encoder {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isMultipartFile(final Object object) {
|
||||
private static boolean isMultipartFile(final Object object) {
|
||||
return object instanceof MultipartFile;
|
||||
}
|
||||
|
||||
private class HttpOutputMessageImpl implements HttpOutputMessage {
|
||||
private static final class HttpOutputMessageImpl implements HttpOutputMessage {
|
||||
|
||||
private final OutputStream body;
|
||||
private final HttpHeaders headers;
|
||||
|
||||
public HttpOutputMessageImpl(final OutputStream body, final HttpHeaders headers) {
|
||||
private HttpOutputMessageImpl(final OutputStream body, final HttpHeaders headers) {
|
||||
this.body = body;
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,10 @@ hawkbit.password=admin
|
||||
|
||||
spring.main.show-banner=false
|
||||
|
||||
hawkbit.scenarios.[0].cleanRepository=true
|
||||
hawkbit.scenarios.[0].targets=0
|
||||
hawkbit.scenarios.[0].ds-name=gettingstarted-example
|
||||
hawkbit.scenarios.[0].distribution-sets=3
|
||||
hawkbit.scenarios.[0].sm-fw-name=gettingstarted-example
|
||||
hawkbit.scenarios.[0].sm-sw-name=gettingstarted-example
|
||||
hawkbit.scenarios.[0].sm-sw-name=gettingstarted-example
|
||||
hawkbit.scenarios.[0].runRollouts=false
|
||||
@@ -10,17 +10,11 @@
|
||||
|
||||
-->
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!-- Log message format -->
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
||||
|
||||
<logger name="org.eclipse.hawkbit" level="info" />
|
||||
<logger name="feign.Logger" level="debug" />
|
||||
|
||||
<root level="error">
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
|
||||
Reference in New Issue
Block a user