You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by jo...@apache.org on 2022/06/18 14:00:01 UTC
[incubator-shenyu] branch master updated: [type:Integration Test] Add redis modle test for cache-plugin (#3578)
This is an automated email from the ASF dual-hosted git repository.
jooks pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 6e906a69f [type:Integration Test] Add redis modle test for cache-plugin (#3578)
6e906a69f is described below
commit 6e906a69fc4d7553612f2b78997eefd1d2787c70
Author: 尔等同学 <37...@users.noreply.github.com>
AuthorDate: Sat Jun 18 21:59:56 2022 +0800
[type:Integration Test] Add redis modle test for cache-plugin (#3578)
* add redis test for cache plugin
* fix checkstyle
---
.../test/http/combination/CachePluginTest.java | 36 +++++++++++++++-------
1 file changed, 25 insertions(+), 11 deletions(-)
diff --git a/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/combination/CachePluginTest.java b/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/combination/CachePluginTest.java
index 54713c1eb..d21a8fd53 100644
--- a/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/combination/CachePluginTest.java
+++ b/shenyu-integrated-test/shenyu-integrated-test-http/src/test/java/org/apache/shenyu/integrated/test/http/combination/CachePluginTest.java
@@ -27,8 +27,6 @@ import org.apache.shenyu.integratedtest.common.AbstractPluginDataInit;
import org.apache.shenyu.integratedtest.common.helper.HttpHelper;
import org.apache.shenyu.integratedtest.common.result.ResultBean;
import org.apache.shenyu.web.controller.LocalPluginController.RuleLocalData;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.io.IOException;
@@ -39,28 +37,48 @@ import java.util.concurrent.Future;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public final class CachePluginTest extends AbstractPluginDataInit {
private static final String TEST_CACHE_PATH = "/http/test/cache";
- @BeforeEach
- public void setup() throws IOException {
+ @Test
+ public void testMemoryModle() throws IOException, ExecutionException, InterruptedException {
String pluginResult = initPlugin(PluginEnum.CACHE.getName(),
"{\"cacheType\":\"memory\"}");
assertThat(pluginResult, is("success"));
String selectorAndRulesResult =
initSelectorAndRules(PluginEnum.CACHE.getName(), "", buildSelectorConditionList(), buildRuleLocalDataList());
assertThat(selectorAndRulesResult, is("success"));
+ assertTrue(testPass());
+ cleanPluginData(PluginEnum.CACHE.getName());
}
@Test
- public void testPass() throws ExecutionException, InterruptedException {
+ public void testRedisModle() throws IOException, ExecutionException, InterruptedException {
+ String pluginResult = initPlugin(PluginEnum.CACHE.getName(), "{\"cacheType\":\"redis\","
+ + "\"database\":\"0\","
+ + "\"mode\":\"standalone\","
+ + "\"url\":\"shenyu-redis:6379\","
+ + "\"password\":\"abc\","
+ + "\"maxIdle\":\"8\","
+ + "\"minIdle\":\"0\","
+ + "\"maxActive\":\"8\","
+ + "\"maxWait\":\"-1\"}");
+ assertThat(pluginResult, is("success"));
+ String selectorAndRulesResult =
+ initSelectorAndRules(PluginEnum.CACHE.getName(), "", buildSelectorConditionList(), buildRuleLocalDataList());
+ assertThat(selectorAndRulesResult, is("success"));
+ assertTrue(testPass());
+ cleanPluginData(PluginEnum.CACHE.getName());
+ }
+
+ private boolean testPass() throws ExecutionException, InterruptedException {
Future<ResultBean> resp0 = this.getService().submit(() -> HttpHelper.INSTANCE.getFromGateway(TEST_CACHE_PATH, ResultBean.class));
Thread.sleep(2000);
Future<ResultBean> resp1 = this.getService().submit(() -> HttpHelper.INSTANCE.getFromGateway(TEST_CACHE_PATH, ResultBean.class));
- assertEquals(resp0.get().getMsg(), resp1.get().getMsg());
+ return resp0.get().getMsg().equals(resp1.get().getMsg());
}
private static List<ConditionData> buildSelectorConditionList() {
@@ -85,8 +103,4 @@ public final class CachePluginTest extends AbstractPluginDataInit {
return Collections.singletonList(ruleLocalData);
}
- @AfterEach
- public void clean() throws IOException {
- cleanPluginData(PluginEnum.CACHE.getName());
- }
}