-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
347 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...pollo/server/ConfigServerApplication.java → ...configserver/ConfigServerApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
spring: | ||
application: | ||
name: apollo-configserver | ||
cloud: | ||
config: | ||
server: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
spring: | ||
application: | ||
name: apollo-server | ||
cloud: | ||
zookeeper: | ||
connectString: 10.3.2.57:2181,10.3.2.58:2181,10.3.2.59:2181 |
31 changes: 31 additions & 0 deletions
31
...lo-configserver/src/test/java/com/ctrip/apollo/configserver/AbstractConfigServerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.ctrip.apollo.configserver; | ||
|
||
import java.io.IOException; | ||
|
||
import org.apache.curator.test.TestingServer; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.boot.test.SpringApplicationConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
|
||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@SpringApplicationConfiguration(classes = ConfigServerApplicationTestConfiguration.class) | ||
public abstract class AbstractConfigServerTest { | ||
|
||
private static TestingServer zkTestServer; | ||
|
||
@BeforeClass | ||
public static void beforeClass() throws Exception { | ||
zkTestServer = new TestingServer(2181, false); | ||
zkTestServer.start(); | ||
System.out.format("embedded zookeeper is up %s%n", zkTestServer.getConnectString()); | ||
} | ||
|
||
@AfterClass | ||
public static void afterClass() throws IOException { | ||
if (zkTestServer != null) { | ||
zkTestServer.close(); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
apollo-configserver/src/test/java/com/ctrip/apollo/configserver/AllTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.ctrip.apollo.configserver; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Suite; | ||
import org.junit.runners.Suite.SuiteClasses; | ||
|
||
@RunWith(Suite.class) | ||
@SuiteClasses({ | ||
|
||
}) | ||
public class AllTests { | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
...src/test/java/com/ctrip/apollo/configserver/ConfigServerApplicationTestConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.ctrip.apollo.configserver; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class ConfigServerApplicationTestConfiguration { | ||
|
||
} |
3 changes: 0 additions & 3 deletions
3
apollo-configserver/src/test/resources/application.properties
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
server: | ||
port: 8888 | ||
|
||
logging: | ||
level: | ||
org.springframework.cloud: 'DEBUG' | ||
|
||
spring: | ||
profiles: | ||
active: native | ||
datasource: | ||
url: jdbc:h2:file:~/fxapolloconfigdb;DB_CLOSE_ON_EXIT=FALSE | ||
username: sa | ||
password: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
spring: | ||
application: | ||
name: apollo-configserver | ||
|
||
cloud: | ||
zookeeper: | ||
connectString:localhost:2181 |
10 changes: 10 additions & 0 deletions
10
apollo-core/src/main/java/com/ctrip/apollo/core/ServiceIdConsts.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.ctrip.apollo.core; | ||
|
||
public class ServiceIdConsts { | ||
|
||
public static final String APOLLO_METASERVER = "apollo-metaserver"; | ||
|
||
public static final String APOLLO_CONFIGSERVER = "apollo-configserver"; | ||
|
||
public static final String APOLLO_PORTAL = "apollo-portal"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 13 additions & 1 deletion
14
apollo-metaserver/src/main/java/com/ctrip/apollo/metaserver/MetaServerApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
package com.ctrip.apollo.metaserver; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.cloud.client.ServiceInstance; | ||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; | ||
import org.springframework.context.ApplicationContext; | ||
|
||
import com.ctrip.apollo.metaserver.service.DiscoveryService; | ||
|
||
@SpringBootApplication | ||
@EnableDiscoveryClient | ||
public class MetaServerApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(MetaServerApplication.class, args); | ||
ApplicationContext context = SpringApplication.run(MetaServerApplication.class, args); | ||
List<ServiceInstance> metaServerServiceInstances = | ||
context.getBean(DiscoveryService.class).getMetaServerServiceInstances(); | ||
System.out.println(metaServerServiceInstances); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
apollo-metaserver/src/main/java/com/ctrip/apollo/metaserver/service/DiscoveryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.ctrip.apollo.metaserver.service; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.cloud.client.ServiceInstance; | ||
import org.springframework.cloud.client.discovery.DiscoveryClient; | ||
import org.springframework.stereotype.Service; | ||
|
||
import com.ctrip.apollo.core.ServiceIdConsts; | ||
|
||
@Service | ||
public class DiscoveryService { | ||
|
||
@Autowired | ||
private DiscoveryClient discoveryClient; | ||
|
||
public List<ServiceInstance> getConfigServerServiceInstances() { | ||
List<ServiceInstance> instances = | ||
discoveryClient.getInstances(ServiceIdConsts.APOLLO_CONFIGSERVER); | ||
return instances; | ||
} | ||
|
||
public List<ServiceInstance> getMetaServerServiceInstances() { | ||
List<ServiceInstance> instances = | ||
discoveryClient.getInstances(ServiceIdConsts.APOLLO_METASERVER); | ||
return instances; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
server: | ||
port: 80 | ||
|
||
spring: | ||
application: | ||
name: apollo-metaserver | ||
profiles: | ||
active: native |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
spring: | ||
cloud: | ||
zookeeper: | ||
connectString: 10.3.2.57:2181,10.3.2.58:2181,10.3.2.59:2181 |
31 changes: 31 additions & 0 deletions
31
apollo-metaserver/src/test/java/com/ctrip/apollo/metaserver/AbstractMetaServerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.ctrip.apollo.metaserver; | ||
|
||
import java.io.IOException; | ||
|
||
import org.apache.curator.test.TestingServer; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.boot.test.SpringApplicationConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
|
||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@SpringApplicationConfiguration(classes = MetaServerApplicationTestConfiguration.class) | ||
public abstract class AbstractMetaServerTest { | ||
|
||
private static TestingServer zkTestServer; | ||
|
||
@BeforeClass | ||
public static void beforeClass() throws Exception { | ||
zkTestServer = new TestingServer(2181, false); | ||
zkTestServer.start(); | ||
System.out.format("embedded zookeeper is up %s%n", zkTestServer.getConnectString()); | ||
} | ||
|
||
@AfterClass | ||
public static void afterClass() throws IOException { | ||
if (zkTestServer != null) { | ||
zkTestServer.close(); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
apollo-metaserver/src/test/java/com/ctrip/apollo/metaserver/AllTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.ctrip.apollo.metaserver; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Suite; | ||
import org.junit.runners.Suite.SuiteClasses; | ||
|
||
@RunWith(Suite.class) | ||
@SuiteClasses({ | ||
|
||
}) | ||
public class AllTests { | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
...ver/src/test/java/com/ctrip/apollo/metaserver/MetaServerApplicationTestConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.ctrip.apollo.metaserver; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; | ||
|
||
@SpringBootApplication | ||
//@EnableDiscoveryClient | ||
public class MetaServerApplicationTestConfiguration { | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...lo-metaserver/src/test/java/com/ctrip/apollo/metaserver/service/ServiceDiscoveryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.ctrip.apollo.metaserver.service; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.cloud.client.ServiceInstance; | ||
|
||
import com.ctrip.apollo.metaserver.AbstractMetaServerTest; | ||
|
||
public class ServiceDiscoveryTest extends AbstractMetaServerTest { | ||
|
||
@Autowired | ||
private DiscoveryService discoveryService; | ||
|
||
@Test | ||
public void testGetLocalMetaServerServices() { | ||
List<ServiceInstance> instances = discoveryService.getMetaServerServiceInstances(); | ||
System.out.println(instances); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
server: | ||
port: 80 | ||
|
||
spring: | ||
application: | ||
name: apollo-metaserver | ||
profiles: | ||
active: native |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
spring: | ||
cloud: | ||
zookeeper: | ||
connectString: localhost:2181 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.