-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from crossoverJie/route-test
[test] Route & server support test
- Loading branch information
Showing
7 changed files
with
141 additions
and
30 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
46 changes: 46 additions & 0 deletions
46
...forward-route/src/test/java/com/crossoverjie/cim/route/service/impl/AbstractBaseTest.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,46 @@ | ||
package com.crossoverjie.cim.route.service.impl; | ||
|
||
import com.clevercloud.testcontainers.zookeeper.ZooKeeperContainer; | ||
import com.redis.testcontainers.RedisContainer; | ||
import java.time.Duration; | ||
import java.util.List; | ||
import org.junit.After; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.testcontainers.junit.jupiter.Container; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
public class AbstractBaseTest { | ||
|
||
@Container | ||
static RedisContainer redis = new RedisContainer(DockerImageName.parse("redis:7.4.0")); | ||
|
||
private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName | ||
.parse("zookeeper") | ||
.withTag("3.9.2"); | ||
|
||
private static final Duration DEFAULT_STARTUP_TIMEOUT = Duration.ofSeconds(60); | ||
|
||
@Container | ||
static final ZooKeeperContainer | ||
zooKeeperContainer = new ZooKeeperContainer(DEFAULT_IMAGE_NAME, DEFAULT_STARTUP_TIMEOUT); | ||
|
||
|
||
@BeforeAll | ||
public static void before(){ | ||
redis.setExposedPorts(List.of(6379)); | ||
redis.setPortBindings(List.of("6379:6379")); | ||
redis.start(); | ||
|
||
zooKeeperContainer.setExposedPorts(List.of(2181)); | ||
zooKeeperContainer.setPortBindings(List.of("2181:2181")); | ||
zooKeeperContainer.start(); | ||
} | ||
|
||
@AfterAll | ||
public static void after(){ | ||
redis.stop(); | ||
zooKeeperContainer.stop(); | ||
} | ||
|
||
} |
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
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
spring: | ||
application: | ||
name: cim-forward-route | ||
data: | ||
redis: | ||
host: 127.0.0.1 | ||
port: 6379 | ||
jedis: | ||
pool: | ||
max-active: 100 | ||
max-idle: 100 | ||
max-wait: 1000 | ||
min-idle: 10 | ||
# web port | ||
server: | ||
port: 8083 | ||
|
||
logging: | ||
level: | ||
root: info | ||
|
||
# enable swagger | ||
springdoc: | ||
swagger-ui: | ||
enabled: true | ||
|
||
app: | ||
zk: | ||
addr: 127.0.0.1:2181 | ||
connect: | ||
timeout: 30000 | ||
root: /route | ||
|
||
# route strategy | ||
#app.route.way=com.crossoverjie.cim.common.route.algorithm.loop.LoopHandle | ||
|
||
# route strategy | ||
#app.route.way=com.crossoverjie.cim.common.route.algorithm.random.RandomHandle | ||
|
||
# route strategy | ||
route: | ||
way: | ||
handler: com.crossoverjie.cim.common.route.algorithm.consistenthash.ConsistentHashHandle | ||
|
||
#app.route.way.consitenthash=com.crossoverjie.cim.common.route.algorithm.consistenthash.SortArrayMapConsistentHash | ||
|
||
consitenthash: com.crossoverjie.cim.common.route.algorithm.consistenthash.TreeMapConsistentHash | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
cim-server/src/test/com/crossoverjie/cim/server/util/NettyAttrUtilTest.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