Completed configurable mgmt simulation scenario.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
kaizimmerm
2016-06-19 20:43:47 +02:00
parent cc1dc09516
commit eac44899f2
21 changed files with 52 additions and 67 deletions

View File

@@ -15,7 +15,7 @@ import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the DistributionSet resource of the management API. * Client binding for the DistributionSet resource of the management API.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) @FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)
public interface MgmtDistributionSetClientResource extends MgmtDistributionSetRestApi { public interface MgmtDistributionSetClientResource extends MgmtDistributionSetRestApi {
} }

View File

@@ -15,6 +15,6 @@ import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the DistributionSetTag resource of the management API. * Client binding for the DistributionSetTag resource of the management API.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING) @FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING)
public interface MgmtDistributionSetTagClientResource extends MgmtDistributionSetTagRestApi { public interface MgmtDistributionSetTagClientResource extends MgmtDistributionSetTagRestApi {
} }

View File

@@ -16,7 +16,7 @@ import org.springframework.cloud.netflix.feign.FeignClient;
* Client binding for the DistributionSetType resource of the management API. * Client binding for the DistributionSetType resource of the management API.
* *
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING) @FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING)
public interface MgmtDistributionSetTypeClientResource extends MgmtDistributionSetTypeRestApi { public interface MgmtDistributionSetTypeClientResource extends MgmtDistributionSetTypeRestApi {
} }

View File

@@ -16,7 +16,7 @@ import org.springframework.cloud.netflix.feign.FeignClient;
* A feign-client interface declaration which allows to build a feign-client * A feign-client interface declaration which allows to build a feign-client
* stub. * stub.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING) @FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING)
public interface MgmtDownloadArtifactClientResource extends MgmtDownloadArtifactRestApi { public interface MgmtDownloadArtifactClientResource extends MgmtDownloadArtifactRestApi {
} }

View File

@@ -15,6 +15,6 @@ import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* *
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE) @FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.DOWNLOAD_ID_V1_REQUEST_MAPPING_BASE)
public interface MgmtDownloadClientResource extends MgmtDownloadRestApi { public interface MgmtDownloadClientResource extends MgmtDownloadRestApi {
} }

View File

@@ -15,6 +15,6 @@ import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the Rollout resource of the management API. * Client binding for the Rollout resource of the management API.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING) @FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING)
public interface MgmtRolloutClientResource extends MgmtRolloutRestApi { public interface MgmtRolloutClientResource extends MgmtRolloutRestApi {
} }

View File

@@ -24,9 +24,10 @@ import feign.Param;
/** /**
* Client binding for the SoftwareModule resource of the management API. * Client binding for the SoftwareModule resource of the management API.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING) @FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING)
public interface MgmtSoftwareModuleClientResource extends MgmtSoftwareModuleRestApi { public interface MgmtSoftwareModuleClientResource extends MgmtSoftwareModuleRestApi {
@Override
@RequestMapping(method = RequestMethod.POST, value = "/{softwareModuleId}/artifacts") @RequestMapping(method = RequestMethod.POST, value = "/{softwareModuleId}/artifacts")
ResponseEntity<MgmtArtifact> uploadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, ResponseEntity<MgmtArtifact> uploadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId,
@Param("file") final MultipartFile file, @Param("file") final MultipartFile file,

View File

@@ -15,6 +15,6 @@ import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the SoftwareModuleType resource of the management API. * Client binding for the SoftwareModuleType resource of the management API.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) @FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING)
public interface MgmtSoftwareModuleTypeClientResource extends MgmtSoftwareModuleTypeRestApi { public interface MgmtSoftwareModuleTypeClientResource extends MgmtSoftwareModuleTypeRestApi {
} }

View File

@@ -16,6 +16,6 @@ import org.springframework.cloud.netflix.feign.FeignClient;
* Client binding for the {@link MgmtSystemRestApi}. * Client binding for the {@link MgmtSystemRestApi}.
* *
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING) @FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING)
public interface MgmtSystemClientResource extends MgmtSystemRestApi { public interface MgmtSystemClientResource extends MgmtSystemRestApi {
} }

View File

@@ -16,7 +16,7 @@ import org.springframework.cloud.netflix.feign.FeignClient;
* Client binding for the {@link MgmtSystemManagementRestApi}. * Client binding for the {@link MgmtSystemManagementRestApi}.
* *
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.SYSTEM_ADMIN_MAPPING) @FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.SYSTEM_ADMIN_MAPPING)
public interface MgmtSystemManagementClientResource extends MgmtSystemManagementRestApi { public interface MgmtSystemManagementClientResource extends MgmtSystemManagementRestApi {
} }

View File

@@ -15,6 +15,6 @@ import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the Target resource of the management API. * Client binding for the Target resource of the management API.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING) @FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)
public interface MgmtTargetClientResource extends MgmtTargetRestApi { public interface MgmtTargetClientResource extends MgmtTargetRestApi {
} }

View File

@@ -15,6 +15,6 @@ import org.springframework.cloud.netflix.feign.FeignClient;
/** /**
* Client binding for the TargetTag resource of the management API. * Client binding for the TargetTag resource of the management API.
*/ */
@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING) @FeignClient(url = "${hawkbit.url:localhost:8080}" + MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING)
public interface MgmtTargetTagClientResource extends MgmtTargetTagRestApi { public interface MgmtTargetTagClientResource extends MgmtTargetTagRestApi {
} }

View File

@@ -90,7 +90,7 @@ public class SoftwareModuleBuilder {
* @return a single entry list of {@link MgmtSoftwareModuleRequestBodyPost} * @return a single entry list of {@link MgmtSoftwareModuleRequestBodyPost}
*/ */
public List<MgmtSoftwareModuleRequestBodyPost> build() { public List<MgmtSoftwareModuleRequestBodyPost> build() {
return Lists.newArrayList(doBuild(name)); return Lists.newArrayList(doBuild(""));
} }
/** /**

View File

@@ -35,9 +35,10 @@ import feign.Feign;
import feign.Logger; import feign.Logger;
import feign.auth.BasicAuthRequestInterceptor; import feign.auth.BasicAuthRequestInterceptor;
import feign.jackson.JacksonDecoder; import feign.jackson.JacksonDecoder;
import feign.slf4j.Slf4jLogger;
@SpringBootApplication @SpringBootApplication
@EnableFeignClients @EnableFeignClients("org.eclipse.hawkbit.mgmt.client.resource")
@EnableConfigurationProperties(ClientConfigurationProperties.class) @EnableConfigurationProperties(ClientConfigurationProperties.class)
@Configuration @Configuration
@AutoConfigureAfter(FeignClientConfiguration.class) @AutoConfigureAfter(FeignClientConfiguration.class)
@@ -83,6 +84,11 @@ public class Application implements CommandLineRunner {
return new CreateStartedRolloutExample(); return new CreateStartedRolloutExample();
} }
@Bean
public Logger.Level feignLoggerLevel() {
return Logger.Level.FULL;
}
@Bean @Bean
public MgmtSoftwareModuleClientResource uploadSoftwareModule() { public MgmtSoftwareModuleClientResource uploadSoftwareModule() {
final ObjectMapper mapper = new ObjectMapper() final ObjectMapper mapper = new ObjectMapper()
@@ -92,13 +98,13 @@ public class Application implements CommandLineRunner {
return Feign.builder().contract(new IgnoreMultipleConsumersProducersSpringMvcContract()) return Feign.builder().contract(new IgnoreMultipleConsumersProducersSpringMvcContract())
.requestInterceptor( .requestInterceptor(
new BasicAuthRequestInterceptor(configuration.getUsername(), configuration.getPassword())) 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))) .decoder(new ResponseEntityDecoder(new JacksonDecoder(mapper)))
.target(MgmtSoftwareModuleClientResource.class, .target(MgmtSoftwareModuleClientResource.class,
configuration.getUrl() + MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING); 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) { for (final String arg : args) {
if (arg.equalsIgnoreCase(containsArg)) { if (arg.equalsIgnoreCase(containsArg)) {
return true; return true;

View File

@@ -44,7 +44,6 @@ public class ClientConfigurationProperties {
* *
*/ */
public static class Scenario { public static class Scenario {
private String tenant = "DEFAULT";
private boolean cleanRepository; private boolean cleanRepository;
private int targets = 100; private int targets = 100;
private int distributionSets = 10; private int distributionSets = 10;
@@ -96,14 +95,6 @@ public class ClientConfigurationProperties {
this.targetAddress = targetAddress; this.targetAddress = targetAddress;
} }
public String getTenant() {
return tenant;
}
public void setTenant(final String tenant) {
this.tenant = tenant;
}
public int getArtifactsPerSM() { public int getArtifactsPerSM() {
return artifactsPerSM; return artifactsPerSM;
} }

View File

@@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * 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()); LOGGER.info("Creating {} distribution sets", scenario.getDistributionSets());
final byte[] artifact = generateArtifact(scenario); final byte[] artifact = generateArtifact(scenario);
distributionSetResource distributionSetResource.createDistributionSets(new DistributionSetBuilder().name(scenario.getDsName())
.createDistributionSets(new DistributionSetBuilder().name(scenario.getDsName()).type("os_app") .type("os_app").version("1.0.").buildAsList(scenario.getDistributionSets())).getBody()
.version("1.0.").buildAsList(scenario.getDistributionSets())) .forEach(dsSet -> {
.getBody().parallelStream().forEach(dsSet -> {
final List<MgmtSoftwareModule> modules = addModules(scenario, dsSet, artifact); final List<MgmtSoftwareModule> modules = addModules(scenario, dsSet, artifact);
final SoftwareModuleAssigmentBuilder assign = new SoftwareModuleAssigmentBuilder(); final SoftwareModuleAssigmentBuilder assign = new SoftwareModuleAssigmentBuilder();
@@ -175,13 +174,13 @@ public class ConfigurableScenario {
private List<MgmtSoftwareModule> addModules(final Scenario scenario, final MgmtDistributionSet dsSet, private List<MgmtSoftwareModule> addModules(final Scenario scenario, final MgmtDistributionSet dsSet,
final byte[] artifact) { final byte[] artifact) {
final List<MgmtSoftwareModule> modules = softwareModuleResource.createSoftwareModules( final List<MgmtSoftwareModule> modules = softwareModuleResource
new SoftwareModuleBuilder().name(scenario.getSmFwName()).version(dsSet.getVersion()).type("os").build()) .createSoftwareModules(new SoftwareModuleBuilder().name(scenario.getSmFwName() + "-os")
.version(dsSet.getVersion()).type("os").build())
.getBody(); .getBody();
modules.addAll(softwareModuleResource modules.addAll(softwareModuleResource.createSoftwareModules(
.createSoftwareModules( new SoftwareModuleBuilder().name(scenario.getSmSwName() + "-app").version(dsSet.getVersion() + ".")
new SoftwareModuleBuilder().name(scenario.getSmSwName()).version(dsSet.getVersion() + ".") .type("application").buildAsList(scenario.getAppModulesPerDistributionSet()))
.type("application").buildAsList(scenario.getAppModulesPerDistributionSet()))
.getBody()); .getBody());
for (int x = 0; x < scenario.getArtifactsPerSM(); x++) { for (int x = 0; x < scenario.getArtifactsPerSM(); x++) {

View File

@@ -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; 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; return object instanceof MultipartFile;
} }
private class HttpOutputMessageImpl implements HttpOutputMessage { private static final class HttpOutputMessageImpl implements HttpOutputMessage {
private final OutputStream body; private final OutputStream body;
private final HttpHeaders headers; private final HttpHeaders headers;
public HttpOutputMessageImpl(final OutputStream body, final HttpHeaders headers) { private HttpOutputMessageImpl(final OutputStream body, final HttpHeaders headers) {
this.body = body; this.body = body;
this.headers = headers; this.headers = headers;
} }

View File

@@ -13,8 +13,10 @@ hawkbit.password=admin
spring.main.show-banner=false spring.main.show-banner=false
hawkbit.scenarios.[0].cleanRepository=true
hawkbit.scenarios.[0].targets=0 hawkbit.scenarios.[0].targets=0
hawkbit.scenarios.[0].ds-name=gettingstarted-example hawkbit.scenarios.[0].ds-name=gettingstarted-example
hawkbit.scenarios.[0].distribution-sets=3 hawkbit.scenarios.[0].distribution-sets=3
hawkbit.scenarios.[0].sm-fw-name=gettingstarted-example 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

View File

@@ -10,17 +10,11 @@
--> -->
<configuration> <configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <include resource="org/springframework/boot/logging/logback/base.xml" />
<!-- Log message format -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<logger name="org.eclipse.hawkbit" level="info" /> <logger name="feign.Logger" level="debug" />
<root level="error"> <root level="INFO">
<appender-ref ref="STDOUT" /> <appender-ref ref="STDOUT" />
</root> </root>

View File

@@ -87,9 +87,7 @@ public class ArtifactStore implements ArtifactRepository {
/** /**
* Retrieves a {@link GridFSDBFile} from the store by it's MD5 hash. * Retrieves a {@link GridFSDBFile} from the store by it's MD5 hash.
* *
* @param tenant
* the tenant to retrieve the artifacts from, ignore case.
* @param md5Hash * @param md5Hash
* the md5-hash of the file to lookup. * the md5-hash of the file to lookup.
* @return The gridfs file object or {@code null} if no file exists. * @return The gridfs file object or {@code null} if no file exists.
@@ -100,9 +98,7 @@ public class ArtifactStore implements ArtifactRepository {
/** /**
* Retrieves a {@link GridFSDBFile} from the store by it's object id. * Retrieves a {@link GridFSDBFile} from the store by it's object id.
* *
* @param tenant
* the tenant to retrieve the artifacts from, ignore case.
* @param id * @param id
* the id of the file to lookup. * the id of the file to lookup.
* @return The gridfs file object or {@code null} if no file exists. * @return The gridfs file object or {@code null} if no file exists.
@@ -231,15 +227,13 @@ public class ArtifactStore implements ArtifactRepository {
* @return a paged list of artifacts mapped from the given dbFiles * @return a paged list of artifacts mapped from the given dbFiles
*/ */
private List<DbArtifact> map(final List<GridFSDBFile> dbFiles) { private List<DbArtifact> map(final List<GridFSDBFile> dbFiles) {
return dbFiles.stream().map(dbFile -> map(dbFile)).collect(Collectors.toList()); return dbFiles.stream().map(this::map).collect(Collectors.toList());
} }
/** /**
* Retrieves a list of {@link GridFSDBFile} from the store by all SHA1 * Retrieves a list of {@link GridFSDBFile} from the store by all SHA1
* hashes. * hashes.
* *
* @param tenant
* the tenant to retrieve the artifacts from, ignore case.
* @param sha1Hashes * @param sha1Hashes
* the sha1-hashes of the files to lookup. * the sha1-hashes of the files to lookup.
* @return list of artifacts * @return list of artifacts
@@ -252,8 +246,6 @@ public class ArtifactStore implements ArtifactRepository {
/** /**
* Retrieves a list of {@link GridFSDBFile} from the store by all ids. * Retrieves a list of {@link GridFSDBFile} from the store by all ids.
* *
* @param tenant
* the tenant to retrieve the artifacts from, ignore case.
* @param ids * @param ids
* the ids of the files to lookup. * the ids of the files to lookup.
* @return list of artfiacts * @return list of artfiacts

View File

@@ -10,18 +10,13 @@ package org.eclipse.hawkbit.artifact.repository;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
/** /**
* Auto configuration for the {@link ArtifactStore}. * Auto configuration for the {@link ArtifactStore}.
*
*
*
*/ */
@Configuration @Configuration
@ComponentScan
@ConditionalOnMissingBean(value = ArtifactRepository.class) @ConditionalOnMissingBean(value = ArtifactRepository.class)
@Import(value = MongoConfiguration.class) @Import(value = MongoConfiguration.class)
public class ArtifactStoreAutoConfiguration { public class ArtifactStoreAutoConfiguration {