Skip to content

Commit

Permalink
remove and translate chinese to english in collector,script,push,remo…
Browse files Browse the repository at this point in the history
…ting and manager module (#1774)

Signed-off-by: Manan Pujara <[email protected]>
Signed-off-by: Logic <[email protected]>
Co-authored-by: Logic <[email protected]>
  • Loading branch information
MananPoojara and zqr10159 authored Apr 18, 2024
1 parent 4627fb5 commit 7d5082f
Show file tree
Hide file tree
Showing 16 changed files with 127 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class AlertDefineControllerTest {

@BeforeEach
void setUp() {
// standaloneSetup: 独立安装, 不集成web环境测试
// standaloneSetup: Standalone setup, not integrated with a web environment for testing
this.mockMvc = MockMvcBuilders.standaloneSetup(alertDefineController).build();

this.alertDefine = AlertDefine.builder()
Expand Down Expand Up @@ -99,7 +99,7 @@ void setUp() {

@Test
void addNewAlertDefine() throws Exception {
// 模拟客户端往服务端发送请求
// Simulate the client sending a request to the server
mockMvc.perform(MockMvcRequestBuilders.post("/api/alert/define")
.contentType(MediaType.APPLICATION_JSON)
.content(JsonUtil.toJson(this.alertDefine)))
Expand All @@ -120,7 +120,7 @@ void modifyAlertDefine() throws Exception {

@Test
void getAlertDefine() throws Exception {
// 模拟getAlertDefine返回数据
// Simulate returning data from getAlertDefine
Mockito.when(alertDefineService.getAlertDefine(this.alertDefine.getId()))
.thenReturn(this.alertDefine);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

/**
* Test case for {@link AlertDefinesController}
* 测试mock处的数据是否正确,测试返回的数据格式是否正确
* Test whether the data mocked at the mock is correct, and test whether the format of the returned data is correct
*
*
*/
Expand All @@ -59,50 +59,50 @@ class AlertDefinesControllerTest {
@Mock
AlertDefineService alertDefineService;

// 参数如下,为了避免默认值干扰,默认值已经被替换
// Parameters to avoid default values interference, default values have been replaced
List<Long> ids = Stream.of(6565463543L, 6565463544L).collect(Collectors.toList());
Byte priority = Byte.parseByte("1");
String sort = "gmtCreate";
String order = "asc";
Integer pageIndex = 1;
Integer pageSize = 7;

// 参数集合
// Parameter collection
Map<String, Object> content = new HashMap<String, Object>();

// 用于mock的对象
// Object for mock
PageRequest pageRequest;

// 由于specification被使用于动态代理,所以无法mock
// 缺失的调试参数是ids、priority
// 缺失部分已经通过手动输出测试
// Since the specification is used in dynamic proxy, it cannot be mocked
// Missing debugging parameters are ids, priority
// The missing part has been manually output for testing

@BeforeEach
void setUp() {
this.mockMvc = MockMvcBuilders.standaloneSetup(alertDefinesController).build();

// 配置测试内容
// Configure test content
content.put("ids", ids);
content.put("priority", priority);
content.put("sort", sort);
content.put("order", order);
content.put("pageIndex", pageIndex);
content.put("pageSize", pageSize);

// mock的pageRequest
// Mocked pageRequest
Sort sortExp = Sort.by(new Sort.Order(Sort.Direction.fromString(content.get("order").toString()), content.get("sort").toString()));
pageRequest = PageRequest.of(((Integer) content.get("pageIndex")).intValue(), ((Integer) content.get("pageSize")).intValue(), sortExp);
}

// @Test
// todo: fix this test
void getAlertDefines() throws Exception {
// 测试mock正确性
// 虽然无法mock对象,但是可以用class文件去存根
// Test the correctness of the mock
// Although objects cannot be mocked, stubs can be stored using class files
// Mockito.when(alertDefineService.getAlertDefines(Mockito.any(Specification.class), Mockito.argThat(new ArgumentMatcher<PageRequest>() {
// @Override
// public boolean matches(PageRequest pageRequestMidden) {
// // 看源码有三个方法要对比,分别是getPageNumber()、getPageSize()getSort()
// // There are three methods in the source code that need to be compared, namely getPageNumber(), getPageSize(), getSort()
// if(pageRequestMidden.getPageSize() == pageRequest.getPageSize() &&
// pageRequestMidden.getPageNumber() == pageRequest.getPageNumber() &&
// pageRequestMidden.getSort().equals(pageRequest.getSort())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void setUp() {
// todo: fix this test
void getAlerts() throws Exception {

//定义要用到的测试值
// Define the test values
String sortField = "id";
String orderType = "asc";
int pageIndex = 0;
Expand All @@ -80,7 +80,7 @@ void getAlerts() throws Exception {
Page<Alert> alertPage = new PageImpl<>(Collections.singletonList(Alert.builder().build()));


//打桩
// Stubbing
Mockito.when(
alertService.getAlerts(
Mockito.any(Specification.class)
Expand Down Expand Up @@ -153,7 +153,7 @@ void applyAlertDefinesStatus() throws Exception {

@Test
void getAlertsSummary() throws Exception {
//打桩
// Stubbing
Mockito.when(alertService.getAlertsSummary()).thenReturn(new AlertSummary());

mockMvc.perform(
Expand Down
32 changes: 16 additions & 16 deletions collector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,15 @@
<configuration>
<classesDirectory>target/classes/</classesDirectory>
<archive>
<!--生成的jar包不包含maven描述相关文件-->
<!--Generated JAR does not include Maven descriptor-related files-->
<addMavenDescriptor>false</addMavenDescriptor>
<manifest>
<!--项目启动类-->
<!--Project startup class-->
<mainClass>org.apache.hertzbeat.collector.Collector</mainClass>
<useUniqueVersions>false</useUniqueVersions>
<!--第三方JAR加入类构建的路径maven-dependency-plugin-->
<!--Third-party JARs are added to the classpath using maven-dependency-plugin-->
<addClasspath>true</addClasspath>
<!--外部依赖jar包的位置-->
<!--Location of external dependency JARs-->
<classpathPrefix>lib/</classpathPrefix>
</manifest>
<manifestEntries>
Expand All @@ -283,9 +283,9 @@
<executions>
<execution>
<id>without-jdk</id>
<!--绑定的maven操作-->
<!--Bound Maven operation-->
<phase>package</phase>
<!--运行一次-->
<!--Run once-->
<goals>
<goal>single</goal>
</goals>
Expand All @@ -297,9 +297,9 @@
</execution>
<execution>
<id>make-macos-arm64</id>
<!--绑定的maven操作-->
<!--Bound Maven operation-->
<phase>package</phase>
<!--运行一次-->
<!--Run once-->
<goals>
<goal>single</goal>
</goals>
Expand All @@ -311,9 +311,9 @@
</execution>
<execution>
<id>make-macos-amd64</id>
<!--绑定的maven操作-->
<!--Bound Maven operation-->
<phase>package</phase>
<!--运行一次-->
<!--Run once-->
<goals>
<goal>single</goal>
</goals>
Expand All @@ -325,9 +325,9 @@
</execution>
<execution>
<id>make-linux-arm64</id>
<!--绑定的maven操作-->
<!--Bound Maven operation-->
<phase>package</phase>
<!--运行一次-->
<!--Run once-->
<goals>
<goal>single</goal>
</goals>
Expand All @@ -339,9 +339,9 @@
</execution>
<execution>
<id>make-linux-amd64</id>
<!--绑定的maven操作-->
<!--Bound Maven operation-->
<phase>package</phase>
<!--运行一次-->
<!--Run once-->
<goals>
<goal>single</goal>
</goals>
Expand All @@ -353,9 +353,9 @@
</execution>
<execution>
<id>make-windows-64</id>
<!--绑定的maven操作-->
<!--Bound Maven operation-->
<phase>package</phase>
<!--运行一次-->
<!--Run once-->
<goals>
<goal>single</goal>
</goals>
Expand Down
42 changes: 21 additions & 21 deletions manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--thymeleaf依赖-->
<!--thymeleaf-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- freemaker依赖 -->
<!-- freemarker -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
Expand Down Expand Up @@ -217,15 +217,15 @@
<configuration>
<classesDirectory>target/classes/</classesDirectory>
<archive>
<!--生成的jar包不包含maven描述相关文件-->
<!--Exclude maven descriptors from generated JAR-->
<addMavenDescriptor>false</addMavenDescriptor>
<manifest>
<!--项目启动类-->
<!--Main class of the project-->
<mainClass>org.apache.hertzbeat.manager.Manager</mainClass>
<useUniqueVersions>false</useUniqueVersions>
<!--第三方JAR加入类构建的路径maven-dependency-plugin-->
<!--Add third-party JARs to the classpath using maven-dependency-plugin-->
<addClasspath>true</addClasspath>
<!--外部依赖jar包的位置-->
<!--Location of external dependency JARs-->
<classpathPrefix>lib/</classpathPrefix>
</manifest>
<manifestEntries>
Expand All @@ -245,17 +245,17 @@
</activation>
<build>
<plugins>
<!--关键插件,maven提供的assembly插件,需要放在最后-->
<!--Critical plugin, assembly plugin provided by maven, should be placed last-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin.version}</version>
<executions>
<execution>
<id>make-zip</id>
<!--绑定的maven操作-->
<!--Bound maven operation-->
<phase>package</phase>
<!--运行一次-->
<!--Run once-->
<goals>
<goal>single</goal>
</goals>
Expand All @@ -281,9 +281,9 @@
<executions>
<execution>
<id>make-macos-arm64</id>
<!--绑定的maven操作-->
<!--Bound maven operation-->
<phase>package</phase>
<!--运行一次-->
<!--Run once-->
<goals>
<goal>single</goal>
</goals>
Expand All @@ -295,9 +295,9 @@
</execution>
<execution>
<id>make-macos-amd64</id>
<!--绑定的maven操作-->
<!--Bound maven operation-->
<phase>package</phase>
<!--运行一次-->
<!--Run once-->
<goals>
<goal>single</goal>
</goals>
Expand All @@ -309,9 +309,9 @@
</execution>
<execution>
<id>make-linux-arm64</id>
<!--绑定的maven操作-->
<!--Bound maven operation-->
<phase>package</phase>
<!--运行一次-->
<!--Run once-->
<goals>
<goal>single</goal>
</goals>
Expand All @@ -323,9 +323,9 @@
</execution>
<execution>
<id>make-linux-amd64</id>
<!--绑定的maven操作-->
<!--Bound maven operation-->
<phase>package</phase>
<!--运行一次-->
<!--Run once-->
<goals>
<goal>single</goal>
</goals>
Expand All @@ -337,9 +337,9 @@
</execution>
<execution>
<id>make-windows-64</id>
<!--绑定的maven操作-->
<!--Bound maven operation-->
<phase>package</phase>
<!--运行一次-->
<!--Run once-->
<goals>
<goal>single</goal>
</goals>
Expand All @@ -351,9 +351,9 @@
</execution>
<execution>
<id>make-docker-compose-script</id>
<!--绑定的maven操作-->
<!--Bound maven operation-->
<phase>package</phase>
<!--运行一次-->
<!--Run once-->
<goals>
<goal>single</goal>
</goals>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<maven-pmd-plugin.version>3.21.0</maven-pmd-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!--hertzbeat 相关模块-->
<!--hertzbeat related modules-->
<hertzbeat.version>2.0-SNAPSHOT</hertzbeat.version>

<springdoc.version>2.3.0</springdoc.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/**
* push controller
*/
@Tag(name = "Metrics Push API | 监控数据推送API")
@Tag(name = "Metrics Push API")
@RestController
@RequestMapping(value = "/api/push", produces = {APPLICATION_JSON_VALUE})
public class PushController {
Expand All @@ -41,17 +41,17 @@ public class PushController {
private PushService pushService;

@PostMapping
@Operation(summary = "Push metric data to hertzbeat", description = "推送监控数据到hertzbeat")
@Operation(summary = "Push metric data to hertzbeat", description = "Push metric data to hertzbeat")
public ResponseEntity<Message<Void>> pushMetrics(@RequestBody PushMetricsDto pushMetricsDto) {
pushService.pushMetricsData(pushMetricsDto);
return ResponseEntity.ok(Message.success("Push success"));
}

@GetMapping()
@Operation(summary = "Get metric data for hertzbeat", description = "获取监控数据")
@Operation(summary = "Get metric data for hertzbeat", description = "Get metric data for hertzbeat")
public ResponseEntity<Message<PushMetricsDto>> getMetrics(
@Parameter(description = "监控id", example = "6565463543") @RequestParam("id") final Long id,
@Parameter(description = "上一次拉取的时间", example = "6565463543") @RequestParam("time") final Long time) {
@Parameter(description = "Monitor ID", example = "6565463543") @RequestParam("id") final Long id,
@Parameter(description = "Last pull time", example = "6565463543") @RequestParam("time") final Long time) {
PushMetricsDto pushMetricsDto = pushService.getPushMetricData(id, time);
return ResponseEntity.ok(Message.success(pushMetricsDto));
}
Expand Down
Loading

0 comments on commit 7d5082f

Please sign in to comment.