Skip to content

Commit

Permalink
【fix】支持JDK11
Browse files Browse the repository at this point in the history
  • Loading branch information
TangLeDaily committed Aug 16, 2023
1 parent c8fca81 commit 26c2ff2
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/actions/common/dubbo/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ description: "do something common for all test"
runs:
using: "composite"
steps:
- name: Set up JDK 8
- name: Set up JDK ${{ env.javaVersion }}
uses: actions/setup-java@v3
with:
java-version: '8'
java-version: ${{ env.javaVersion }}
distribution: 'adopt'
cache: maven
- name: download middlewares
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/common/spring/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ description: "do something common for all test"
runs:
using: "composite"
steps:
- name: Set up JDK 8
- name: Set up JDK ${{ env.javaVersion }}
uses: actions/setup-java@v3
with:
java-version: '8'
java-version: ${{ env.javaVersion }}
distribution: 'adopt'
cache: maven
- name: download zookeeper
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/scenarios/backend/memory/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ description: "Auto test for Backend"
runs:
using: "composite"
steps:
- name: Set up JDK 8
- name: Set up JDK ${{ env.javaVersion }}
uses: actions/setup-java@v2
with:
java-version: '8'
java-version: ${{ env.javaVersion }}
distribution: 'adopt'
cache: maven
- name: Set up python
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/backend_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
needs: [ build-agent-and-cache, download-midwares-and-cache ]
steps:
- uses: actions/checkout@v2
- name: set java version to environment
run: |
echo "javaVersion=8" >> $GITHUB_ENV
- name: start backend use memory test
uses: ./.github/actions/scenarios/backend/memory
- name: start backend use redis test
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/dubbo_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 100
- name: set java version to environment
run: |
echo "javaVersion=8" >> $GITHUB_ENV
- name: common operations
uses: ./.github/actions/common/dubbo
- name: (dubbo router) test for ${{ matrix.dubbo-version }}-${{ matrix.dubbo-versions }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/spring_integration_test_1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 100
- name: set java version to environment
run: |
echo "javaVersion=8" >> $GITHUB_ENV
- name: common operations
uses: ./.github/actions/common/spring
- name: (graceful) test for springboot=${{ matrix.springBootVersion }} springCloudVersion=${{ matrix.springCloudVersion }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/spring_integration_test_2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 100
- name: set java version to environment
run: |
echo "javaVersion=8" >> $GITHUB_ENV
- name: common operations
uses: ./.github/actions/common/spring
- name: (spring router) test for springboot=${{ matrix.springBootVersion }} springCloudVersion=${{ matrix.springCloudVersion }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@

import com.huaweicloud.integration.common.MetricEnum;
import com.huaweicloud.integration.utils.RequestUtils;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.springframework.util.Assert;

import java.util.HashMap;
import java.util.Map;
import java.util.Arrays;
import java.util.List;

/**
* 监控测试类
Expand All @@ -34,7 +37,6 @@
*/
@EnabledIfEnvironmentVariable(named = "TEST_TYPE", matches = "monitor")
public class MonitorTest {

/**
* 监控采集URL
*/
Expand All @@ -46,6 +48,19 @@ public class MonitorTest {

private static final String TPS = "tps";

private static final List<String> JDK8_MONOPOLIZE_INDEX_LIST = Arrays.asList("code_cache_init", "code_cache_max",
"code_cache_used", "code_cache_committed");

private static final List<String> JDK9PLUS_MONOPOLIZE_INDEX_LIST = Arrays.asList("non_nmethods_init",
"non_nmethods_max",
"non_nmethods_used", "non_nmethods_committed",
"profiled_nmethods_init", "profiled_nmethods_max",
"profiled_nmethods_used", "profiled_nmethods_committed",
"non_profiled_nmethods_init", "non_profiled_nmethods_max",
"non_profiled_nmethods_used", "non_profiled_nmethods_committed",
"epsilon_heap_init", "epsilon_heap_max",
"epsilon_heap_used", "epsilon_heap_committed");

@Test
public void testMonitor() {
String string = RequestUtils.get(URL, new HashMap<>(), String.class);
Expand All @@ -63,10 +78,24 @@ public void testMonitor() {
}
Assert.notEmpty(map, "解析响应结果获取指标信息失败");
for (MetricEnum metricEnum : MetricEnum.values()) {
Assert.isTrue(map.containsKey(metricEnum.getName()), "缺少指标信息" + metricEnum.getName());
String metricEnumName = metricEnum.getName();
// 当JDK大于8时,JDK8独有的指标则忽略
if (javaVersionGreaterThanJDK8() && JDK8_MONOPOLIZE_INDEX_LIST.contains(metricEnumName)) {
continue;
}
// 当JDK小于等于8时,JDK9及以上版本独有的指标则忽略
if (!javaVersionGreaterThanJDK8() && JDK9PLUS_MONOPOLIZE_INDEX_LIST.contains(metricEnumName)) {
continue;
}
Assert.isTrue(map.containsKey(metricEnumName), "缺少指标信息" + metricEnumName);
}
}

private boolean javaVersionGreaterThanJDK8() {
String javaVersion[] = System.getProperty("java.version").split("\\.");
return Integer.valueOf(javaVersion[0]) >= 9;
}

@Test
public void testFlowControlMonitor() {
String res = RequestUtils.get(REQ_URL, new HashMap<>(), String.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import java.util.HashMap;
import java.util.Map;
import java.util.Arrays;
import java.util.List;

/**
* 监控测试类
Expand All @@ -46,6 +48,19 @@ public class MonitorTest {

private static final String TPS = "tps";

private static final List<String> JDK8_MONOPOLIZE_INDEX_LIST = Arrays.asList("code_cache_init", "code_cache_max",
"code_cache_used", "code_cache_committed");

private static final List<String> JDK9PLUS_MONOPOLIZE_INDEX_LIST = Arrays.asList("non_nmethods_init",
"non_nmethods_max",
"non_nmethods_used", "non_nmethods_committed",
"profiled_nmethods_init", "profiled_nmethods_max",
"profiled_nmethods_used", "profiled_nmethods_committed",
"non_profiled_nmethods_init", "non_profiled_nmethods_max",
"non_profiled_nmethods_used", "non_profiled_nmethods_committed",
"epsilon_heap_init", "epsilon_heap_max",
"epsilon_heap_used", "epsilon_heap_committed");

@Test
public void testMonitor() {
String string = RequestUtils.get(URL, new HashMap<>(), String.class);
Expand All @@ -63,10 +78,24 @@ public void testMonitor() {
}
Assertions.assertFalse(map.isEmpty(), "解析响应结果获取指标信息失败");
for (MetricEnum metricEnum : MetricEnum.values()) {
Assertions.assertTrue(map.containsKey(metricEnum.getName()), "缺少指标信息" + metricEnum.getName());
String metricEnumName = metricEnum.getName();
// 当JDK大于8时,JDK8独有的指标则忽略
if (javaVersionGreaterThanJDK8() && JDK8_MONOPOLIZE_INDEX_LIST.contains(metricEnumName)) {
continue;
}
// 当JDK小于等于8时,JDK9及以上版本独有的指标则忽略
if (!javaVersionGreaterThanJDK8() && JDK9PLUS_MONOPOLIZE_INDEX_LIST.contains(metricEnumName)) {
continue;
}
Assertions.assertTrue(map.containsKey(metricEnumName), "缺少指标信息" + metricEnumName);
}
}

private boolean javaVersionGreaterThanJDK8() {
String javaVersion[] = System.getProperty("java.version").split("\\.");
return Integer.valueOf(javaVersion[0]) >= 9;
}

@Test
public void testFlowControlMonitor() {
String res = RequestUtils.get(REQ_URL, new HashMap<>(), String.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
* @since 2022-08-02
*/
public enum MemoryType {

/**
* 堆内存
*/
Expand Down Expand Up @@ -111,27 +110,56 @@ public enum MemoryType {
OLD_EDEN_SPACE_SERIAL("Tenured Gen", MetricEnum.OLD_GEN_INIT, MetricEnum.OLD_GEN_USED, MetricEnum.OLD_GEN_MAX,
MetricEnum.OLD_GEN_COMMITTED),
/**
* SERIAL年轻代Eden指标信息
* G1年轻代Eden指标信息
*/
EDEN_SPACE_G1("G1 Eden Space", MetricEnum.EDEN_INIT, MetricEnum.EDEN_USED, MetricEnum.EDEN_MAX,
MetricEnum.EDEN_COMMITTED),

/**
* SERIAL年轻代Survivor指标信息
* G1年轻代Survivor指标信息
*/
SURVIVOR_SPACE_G1("G1 Survivor Space", MetricEnum.SURVIVOR_INIT, MetricEnum.SURVIVOR_USED,
MetricEnum.SURVIVOR_MAX, MetricEnum.SURVIVOR_COMMITTED),

/**
* SERIAL老年代指标枚举
* G1老年代指标枚举
*/
OLD_EDEN_SPACE_G1("G1 Old Gen", MetricEnum.OLD_GEN_INIT, MetricEnum.OLD_GEN_USED, MetricEnum.OLD_GEN_MAX,
MetricEnum.OLD_GEN_COMMITTED),
/**
* CodeCache内存池
*/
CODE_CACHE_G1("CodeCache", MetricEnum.CODE_CACHE_INIT, MetricEnum.CODE_CACHE_USED, MetricEnum.CODE_CACHE_MAX,
MetricEnum.CODE_CACHE_COMMITTED);
MetricEnum.CODE_CACHE_COMMITTED),

/**
* JDK11存储经过性能分析的编译代码的codeCache内存池
*/
PROFILED_NMETHODS("CodeHeap 'profiled nmethods'", MetricEnum.PROFILED_NMETHODS_INIT,
MetricEnum.PROFILED_NMETHODS_USED,
MetricEnum.PROFILED_NMETHODS_MAX,
MetricEnum.PROFILED_NMETHODS_COMMITTED),

/**
* JDK11存储未经过性能分析的编译代码的codeCache内存池
*/
NON_PROFILED_NMETHODS("CodeHeap 'non-profiled nmethods'", MetricEnum.NON_PROFILED_NMETHODS_INIT,
MetricEnum.NON_PROFILED_NMETHODS_USED, MetricEnum.NON_PROFILED_NMETHODS_MAX,
MetricEnum.NON_PROFILED_NMETHODS_COMMITTED),

/**
* JDK11存储其他类型编译代码的codeCache内存池
*/
NON_NMETHODS("CodeHeap 'non-nmethods'", MetricEnum.NON_NMETHODS_INIT, MetricEnum.NON_NMETHODS_USED,
MetricEnum.NON_NMETHODS_MAX,
MetricEnum.NON_NMETHODS_COMMITTED),

/**
* Epsilon收集器指标枚举
*/
EPSILON_HEAP("Epsilon Heap", MetricEnum.EPSILON_HEAP_INIT, MetricEnum.EPSILON_HEAP_USED,
MetricEnum.EPSILON_HEAP_MAX,
MetricEnum.EPSILON_HEAP_COMMITTED);

/**
* 类型
Expand Down Expand Up @@ -161,10 +189,10 @@ public enum MemoryType {
/**
* 构造方法
*
* @param type 类型
* @param initEnum 初始化枚举
* @param usedEnum 已使用对应的枚举
* @param maxEnum 最大值对应的枚举
* @param type 类型
* @param initEnum 初始化枚举
* @param usedEnum 已使用对应的枚举
* @param maxEnum 最大值对应的枚举
* @param committedEnum 提交值对应的枚举
*/
MemoryType(String type, MetricEnum initEnum, MetricEnum usedEnum, MetricEnum maxEnum, MetricEnum committedEnum) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* @since 2022-08-02
*/
public enum MetricEnum {

/**
* JVM内存指标信息
*/
Expand Down Expand Up @@ -329,7 +328,88 @@ public enum MetricEnum {
/**
* 平均响应时间
*/
AVG_RESPONSE_TIME("avg_response_time", "the number is number of response time");
AVG_RESPONSE_TIME("avg_response_time", "the number is number of response time"),

/**
* JDK11存储其他类型编译代码的codeCache初始值
*/
NON_NMETHODS_INIT("non_nmethods_init", "the number is init of non_nmethods"),

/**
* JDK11存储其他类型编译代码的codeCache使用值
*/
NON_NMETHODS_USED("non_nmethods_used", "the number is used of non_nmethods"),

/**
* JDK11存储其他类型编译代码的codeCache最大值
*/
NON_NMETHODS_MAX("non_nmethods_max", "the number is max of non_nmethods"),

/**
* JDK11存储其他类型编译代码的codeCache提交值
*/
NON_NMETHODS_COMMITTED("non_nmethods_committed", "the number is committed of non_nmethods"),

/**
* JDK11存储经过性能分析的编译代码的codeCache初始值
*/
PROFILED_NMETHODS_INIT("profiled_nmethods_init", "the number is init of profiled nmethods"),

/**
* JDK11存储经过性能分析的编译代码的codeCache使用值
*/
PROFILED_NMETHODS_USED("profiled_nmethods_used", "the number is used of profiled nmethods"),

/**
* JDK11存储经过性能分析的编译代码的codeCache最大值
*/
PROFILED_NMETHODS_MAX("profiled_nmethods_max", "the number is max of profiled nmethods"),

/**
* JDK11存储经过性能分析的编译代码的codeCache提交值
*/
PROFILED_NMETHODS_COMMITTED("profiled_nmethods_committed", "the number is committed of profiled nmethods"),

/**
* JDK11存储未经过性能分析的编译代码的codeCache初始值
*/
NON_PROFILED_NMETHODS_INIT("non_profiled_nmethods_init", "the number is init of non-profiled nmethods"),

/**
* JDK11存储未经过性能分析的编译代码的codeCache使用值
*/
NON_PROFILED_NMETHODS_USED("non_profiled_nmethods_used", "the number is used of non-profiled nmethods"),

/**
* JDK11存储未经过性能分析的编译代码的codeCache最大值
*/
NON_PROFILED_NMETHODS_MAX("non_profiled_nmethods_max", "the number is max of non-profiled nmethods"),

/**
* JDK11存储未经过性能分析的编译代码的codeCache提交值
*/
NON_PROFILED_NMETHODS_COMMITTED("non_profiled_nmethods_committed",
"the number is committed of non-profiled nmethods"),

/**
* JDK11的Epsilon收集器初始值
*/
EPSILON_HEAP_INIT("epsilon_heap_init", "the number is init of Epsilon Heap"),

/**
* JDK11的Epsilon收集器使用值
*/
EPSILON_HEAP_USED("epsilon_heap_used", "the number is used of Epsilon Heap"),

/**
* JDK11的Epsilon收集器最大值
*/
EPSILON_HEAP_MAX("epsilon_heap_max", "the number is max of Epsilon Heap"),

/**
* JDK11的Epsilon收集器提交值
*/
EPSILON_HEAP_COMMITTED("epsilon_heap_committed", "the number is committed of Epsilon Heap");

/**
* 名称
Expand Down
Loading

0 comments on commit 26c2ff2

Please sign in to comment.