add sidecar test to test correct port registration with eureka
This commit is contained in:
76
netflix-sidecar/pom.xml
Normal file
76
netflix-sidecar/pom.xml
Normal file
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-sample-netflix-sidecar</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>spring-cloud-sample-netflix-sidecar</name>
|
||||
<description>Demo project for Spring Cloud</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.2.1.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<start-class>demo.DemoApplication</start-class>
|
||||
<java.version>1.7</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-parent</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-zuul</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-eureka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-netflix-sidecar</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<!--skip deploy (this is just a test module) -->
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
1
netflix-sidecar/run-server.sh
Executable file
1
netflix-sidecar/run-server.sh
Executable file
@@ -0,0 +1 @@
|
||||
python -m SimpleHTTPServer
|
||||
14
netflix-sidecar/src/main/java/demo/SidecarApplication.java
Normal file
14
netflix-sidecar/src/main/java/demo/SidecarApplication.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package demo;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.netflix.sidecar.EnableSidecar;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSidecar
|
||||
public class SidecarApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SidecarApplication.class, args);
|
||||
}
|
||||
}
|
||||
19
netflix-sidecar/src/main/resources/application.yml
Normal file
19
netflix-sidecar/src/main/resources/application.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
debug:
|
||||
spring:
|
||||
application:
|
||||
name: testNetflixSidecar
|
||||
server:
|
||||
port: 8001
|
||||
sidecar:
|
||||
port: 8000
|
||||
health-uri: http://localhost:8000/src/main/resources/health.json
|
||||
|
||||
eureka:
|
||||
password: password
|
||||
client:
|
||||
serviceUrl:
|
||||
defaultZone: http://user:${eureka.password}@localhost:8761/eureka/
|
||||
instance:
|
||||
leaseRenewalIntervalInSeconds: 10
|
||||
metadataMap:
|
||||
instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}}
|
||||
1
netflix-sidecar/src/main/resources/health.json
Normal file
1
netflix-sidecar/src/main/resources/health.json
Normal file
@@ -0,0 +1 @@
|
||||
{"status":"UP"}
|
||||
@@ -0,0 +1,34 @@
|
||||
package demo;
|
||||
|
||||
import com.netflix.appinfo.EurekaInstanceConfig;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
import org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = SidecarApplication.class)
|
||||
@WebAppConfiguration
|
||||
@DirtiesContext
|
||||
public class SidecarApplicationTests {
|
||||
|
||||
@Autowired
|
||||
EurekaInstanceConfig instanceConfig;
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void instanceConfigHasCorrectPort() {
|
||||
assertEquals("eureka instance config has wrong port", 8000, instanceConfig.getNonSecurePort());
|
||||
}
|
||||
|
||||
}
|
||||
1
pom.xml
1
pom.xml
@@ -21,6 +21,7 @@
|
||||
<module>feign</module>
|
||||
<module>feign-eureka</module>
|
||||
<module>eureka-noweb</module>
|
||||
<module>netflix-sidecar</module>
|
||||
<module>noweb</module>
|
||||
<module>hystrix</module>
|
||||
<module>turbine</module>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
server.port: 8989
|
||||
spring.application.name: turbine
|
||||
turbine.appConfig: simple
|
||||
turbine.clusterNameExpression: 'default'
|
||||
turbine.aggregator.clusterConfig: SIMPLE
|
||||
|
||||
Reference in New Issue
Block a user