Update for 1.3.2
This commit is contained in:
@@ -179,6 +179,7 @@ public class Deployer {
|
||||
}
|
||||
}
|
||||
appDefProps.putAll(deployable.getApplicationProperties());
|
||||
appDefProps.putAll(getThinProperties(deployable.getProperties()));
|
||||
Map<String, String> map = extractProperties("/" + deployable.getName() + ".yml");
|
||||
for (String key : map.keySet()) {
|
||||
appDefProps.put(key, map.get(key));
|
||||
@@ -222,6 +223,17 @@ public class Deployer {
|
||||
return id;
|
||||
}
|
||||
|
||||
private Map<String, String> getThinProperties(
|
||||
Map<String, String> properties) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for (String key : properties.keySet()) {
|
||||
if (key.startsWith(AppDeployer.PREFIX + "thin.")) {
|
||||
map.put(key, properties.get(key));
|
||||
}
|
||||
}
|
||||
return map ;
|
||||
}
|
||||
|
||||
private boolean shouldDeploy(Deployable deployable, DeployerProperties properties) {
|
||||
return shouldDeploy(deployable.getName(), properties);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class DeployerApplication {
|
||||
private static final Logger logger = LoggerFactory
|
||||
.getLogger(DeployerApplication.class);
|
||||
|
||||
private static final String DEFAULT_VERSION = "1.3.2.BUILD-SNAPSHOT";
|
||||
private static final String DEFAULT_VERSION = "1.3.2.RELEASE";
|
||||
|
||||
private String[] args;
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
exclusions.spring-cloud-deployer-local: org.springframework.cloud:spring-cloud-deployer-thin
|
||||
dependencies.spring-cloud-deplyer-thin: org.springframework.cloud:spring-cloud-deployer-local
|
||||
@@ -97,26 +97,32 @@ spring:
|
||||
launcher:
|
||||
deployables:
|
||||
configserver:
|
||||
properties:
|
||||
spring.cloud.deployer.thin.profile: rabbit
|
||||
application-properties:
|
||||
thin.profile: rabbit
|
||||
spring.cloud.bus.enabled: true
|
||||
eureka:
|
||||
properties:
|
||||
spring.cloud.deployer.thin.profile: rabbit
|
||||
application-properties:
|
||||
spring.cloud.bus.enabled: true
|
||||
thin.profile: rabbit
|
||||
h2:
|
||||
properties:
|
||||
spring.cloud.deployer.thin.profile: rabbit
|
||||
application-properties:
|
||||
spring.cloud.bus.enabled: true
|
||||
thin.profile: rabbit
|
||||
dataflow:
|
||||
properties:
|
||||
spring.cloud.deployer.thin.profile: rabbit
|
||||
application-properties:
|
||||
spring.cloud.bus.enabled: true
|
||||
thin.profile: rabbit
|
||||
hystrixdashboard:
|
||||
properties:
|
||||
spring.cloud.deployer.thin.profile: rabbit
|
||||
application-properties:
|
||||
spring.cloud.bus.enabled: true
|
||||
thin.profile: rabbit
|
||||
zipkin:
|
||||
properties:
|
||||
spring.cloud.deployer.thin.profile: rabbit
|
||||
application-properties:
|
||||
spring.cloud.bus.enabled: true
|
||||
thin.profile: rabbit
|
||||
spring.cloud.bus.enabled: true
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.launcher.deployer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Assume;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import org.springframework.boot.loader.thin.ArchiveUtils;
|
||||
import org.springframework.boot.loader.tools.LogbackInitializer;
|
||||
import org.springframework.cloud.deployer.spi.app.DeploymentState;
|
||||
import org.springframework.cloud.deployer.spi.core.AppDefinition;
|
||||
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest;
|
||||
import org.springframework.cloud.deployer.thin.ThinJarAppDeployer;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class LauncherAppDeployerTests {
|
||||
|
||||
static {
|
||||
LogbackInitializer.initialize();
|
||||
}
|
||||
|
||||
private static ThinJarAppDeployer deployer = new ThinJarAppDeployer();
|
||||
private static String resource;
|
||||
|
||||
@BeforeClass
|
||||
public static void skip() {
|
||||
try {
|
||||
resource = "maven://org.springframework.cloud.launcher:spring-cloud-launcher-configserver:"
|
||||
+ new DeployerApplication().getVersion();
|
||||
ArchiveUtils.getArchiveRoot(ArchiveUtils.getArchive(resource));
|
||||
}
|
||||
catch (Exception e) {
|
||||
Assume.assumeNoException(
|
||||
"Could not locate jar for tests. Please build spring-cloud-cli locally first.",
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
@Parameterized.Parameters
|
||||
public static List<Object[]> data() {
|
||||
// Repeat a couple of times to ensure it's consistent
|
||||
return Arrays.asList(new Object[2][0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rabbit() throws Exception {
|
||||
String first = deploy(resource, "spring.cloud.deployer.thin.profile=rabbit", "");
|
||||
// Deployment is blocking so it either failed or succeeded.
|
||||
assertThat(deployer.status(first).getState()).isEqualTo(DeploymentState.deployed);
|
||||
deployer.undeploy(first);
|
||||
}
|
||||
|
||||
private String deploy(String jarName, String deployment, String application, String... args)
|
||||
throws Exception {
|
||||
Resource resource = new FileSystemResource(
|
||||
ArchiveUtils.getArchiveRoot(ArchiveUtils.getArchive(jarName)));
|
||||
AppDefinition definition = new AppDefinition(resource.getFilename(),
|
||||
properties(application));
|
||||
AppDeploymentRequest request = new AppDeploymentRequest(definition, resource,
|
||||
properties(deployment), Arrays.asList(args));
|
||||
String deployed = deployer.deploy(request);
|
||||
return deployed;
|
||||
}
|
||||
|
||||
private Map<String, String> properties(String properties) {
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
Properties props = StringUtils.splitArrayElementsIntoProperties(
|
||||
StringUtils.commaDelimitedListToStringArray(properties), "=");
|
||||
if (props != null) {
|
||||
for (Object name : props.keySet()) {
|
||||
String key = (String) name;
|
||||
map.put(key, props.getProperty(key));
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user