added zuul test with config server located by discovery.
test fails with discovery NPE (lifecycle problem), but the app works.
This commit is contained in:
1
pom.xml
1
pom.xml
@@ -26,6 +26,7 @@
|
||||
<module>oauth2-ribbon</module>
|
||||
<module>hystrix</module>
|
||||
<module>turbine</module>
|
||||
<module>zuul-config-discovery</module>
|
||||
<module>zuul-proxy</module>
|
||||
<module>zuul-proxy-eureka</module>
|
||||
</modules>
|
||||
|
||||
3
zuul-config-discovery/README.md
Executable file
3
zuul-config-discovery/README.md
Executable file
@@ -0,0 +1,3 @@
|
||||
Test with zuul server, eureka and config server. Config server is located by discovery.
|
||||
|
||||
Test that zuul server updates routes when new routes are added (at least doesn't fail with a stack overflow exception)
|
||||
110
zuul-config-discovery/pom.xml
Executable file
110
zuul-config-discovery/pom.xml
Executable file
@@ -0,0 +1,110 @@
|
||||
<?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-zuul-config-discovery</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>spring-cloud-sample-zuul-config-discovery</name>
|
||||
<description>Demo project for Spring Cloud</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-parent</artifactId>
|
||||
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.7</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-eureka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-zuul</artifactId>
|
||||
</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>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>http://repo.spring.io/libs-snapshot-local</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>http://repo.spring.io/libs-milestone-local</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-releases</id>
|
||||
<name>Spring Releases</name>
|
||||
<url>http://repo.spring.io/libs-release-local</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>http://repo.spring.io/libs-snapshot-local</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>http://repo.spring.io/libs-milestone-local</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
</project>
|
||||
15
zuul-config-discovery/src/main/java/demo/ZuulConfigDiscoveryApplication.java
Executable file
15
zuul-config-discovery/src/main/java/demo/ZuulConfigDiscoveryApplication.java
Executable file
@@ -0,0 +1,15 @@
|
||||
package demo;
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableZuulProxy
|
||||
public class ZuulConfigDiscoveryApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new SpringApplicationBuilder(ZuulConfigDiscoveryApplication.class).web(true).run(args);
|
||||
}
|
||||
|
||||
}
|
||||
29
zuul-config-discovery/src/main/resources/application.yml
Normal file
29
zuul-config-discovery/src/main/resources/application.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
info:
|
||||
component: Zuul Server
|
||||
|
||||
endpoints:
|
||||
restart:
|
||||
enabled: true
|
||||
shutdown:
|
||||
enabled: true
|
||||
sensitive: false
|
||||
|
||||
logging:
|
||||
level:
|
||||
org.springframework.security: DEBUG
|
||||
org.springframework.web: DEBUG
|
||||
org.springframework.boot: INFO
|
||||
#com.netflix.discovery: 'OFF'
|
||||
ROOT: INFO
|
||||
|
||||
eureka:
|
||||
instance:
|
||||
leaseRenewalIntervalInSeconds: 10
|
||||
statusPageUrlPath: /admin/info
|
||||
healthCheckUrlPath: /admin/health
|
||||
|
||||
management:
|
||||
port: ${MGMT_SERVER_PORT:8766}
|
||||
|
||||
server:
|
||||
port: ${SERVER_PORT:8765}
|
||||
15
zuul-config-discovery/src/main/resources/bootstrap.yml
Executable file
15
zuul-config-discovery/src/main/resources/bootstrap.yml
Executable file
@@ -0,0 +1,15 @@
|
||||
spring:
|
||||
application:
|
||||
name: zuulConfigDiscoveryTest
|
||||
cloud:
|
||||
config:
|
||||
username: user
|
||||
password: password
|
||||
failFast: true
|
||||
discovery:
|
||||
enabled: true
|
||||
|
||||
eureka:
|
||||
client:
|
||||
serviceUrl:
|
||||
defaultZone: http://user::password@localhost:8761/eureka/
|
||||
@@ -0,0 +1,28 @@
|
||||
package demo;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.WebIntegrationTest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = ZuulConfigDiscoveryApplication.class)
|
||||
@WebIntegrationTest(randomPort = true)
|
||||
@DirtiesContext
|
||||
public class ZuulConfigDiscoveryApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
private int port;
|
||||
|
||||
|
||||
//FIXME: works fine when running the app, but not as a test
|
||||
@Test
|
||||
@Ignore
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user