Skip to content

Commit 1ed9ba0

Browse files
authored
feat: websocket controller (#46)
* dev: jacoco testCoverage setup * chore: initial setup test coverage of agent * dev: multi module test coverage setup * dev: jacoco pr comment html path change * dev: jacoco pr comment xml path change * dev: sse event receiver * chore: agentUrl field setting * chore: remove unused init boolean print log * fix: doOnComplete change * dev: implement jacoco-aggregate reporter * fix: duplicated onComplete #43 * dev: migration to bm-controller package * dev: testing sse and scheduler thread * chore: move package of common files * dev: notice for target server http load sender place * dev: receive TemplateInfo from controller * chore: apply additional param
1 parent 721d99a commit 1ed9ba0

File tree

131 files changed

+999
-478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+999
-478
lines changed

bm-agent/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
FROM amazoncorretto:17-alpine3.16-jdk
2-
ARG JAR_PATH=/build/libs
32

43
WORKDIR /app
54

6-
COPY ${JAR_PATH}/bm-agent-1.0.0.jar /app/app.jar
5+
COPY /build/libs/bm-agent-1.0.0.jar /app/app.jar
76

87
ENTRYPOINT java -jar app.jar

bm-agent/build.gradle

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ plugins {
66
id 'io.spring.dependency-management' version '1.1.4'
77
}
88

9-
group = 'org.benchmark'
9+
group = 'org.benchmarker'
1010
version = '0.0.1-SNAPSHOT'
1111

1212
def excludeJacocoTestCoverageReport = [
13+
// bmagent
14+
'org/benchmarker/bmagent/**',
1315
]
1416

1517
java {
@@ -34,6 +36,8 @@ dependencies {
3436
implementation 'org.springframework.boot:spring-boot-starter-web'
3537
compileOnly 'org.projectlombok:lombok'
3638
annotationProcessor 'org.projectlombok:lombok'
39+
// add webflux
40+
implementation 'org.springframework.boot:spring-boot-starter-webflux'
3741
testImplementation 'org.springframework.boot:spring-boot-starter-test'
3842
testImplementation 'org.springframework.boot:spring-boot-testcontainers'
3943
testImplementation 'org.testcontainers:junit-jupiter'
@@ -72,12 +76,12 @@ jacocoTestCoverageVerification {
7276
limit {
7377
counter = 'LINE'
7478
value = 'COVEREDRATIO'
75-
minimum = 0.00
79+
minimum = 0.60
7680
}
7781
limit {
7882
counter = 'METHOD'
7983
value = 'COVEREDRATIO'
80-
minimum = 0.00
84+
minimum = 0.60
8185
}
8286
}
8387
}

bm-agent/src/main/java/org/benchmark/bmagent/BmAgentApplication.java renamed to bm-agent/src/main/java/org/benchmarker/bmagent/BmAgentApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.benchmark.bmagent;
1+
package org.benchmarker.bmagent;
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;

bm-agent/src/main/java/org/benchmark/bmagent/consts/SseManageConsts.java renamed to bm-agent/src/main/java/org/benchmarker/bmagent/consts/SseManageConsts.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.benchmark.bmagent.consts;
1+
package org.benchmarker.bmagent.consts;
22

33
public interface SseManageConsts {
44
Long SSE_TIMEOUT = 600000L;

bm-agent/src/main/java/org/benchmark/bmagent/controller/AgentApiController.java renamed to bm-agent/src/main/java/org/benchmarker/bmagent/controller/AgentApiController.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
package org.benchmark.bmagent.controller;
1+
package org.benchmarker.bmagent.controller;
22

33

44
import java.util.Map;
55
import lombok.RequiredArgsConstructor;
66
import lombok.extern.slf4j.Slf4j;
7-
import org.benchmark.bmagent.schedule.SchedulerStatus;
8-
import org.benchmark.bmagent.service.IScheduledTaskService;
9-
import org.benchmark.bmagent.service.ISseManageService;
7+
import org.benchmarker.bmagent.schedule.SchedulerStatus;
8+
import org.benchmarker.bmagent.service.IScheduledTaskService;
9+
import org.benchmarker.bmagent.service.ISseManageService;
10+
import org.benchmarker.bmcommon.dto.TemplateInfo;
1011
import org.springframework.http.ResponseEntity;
1112
import org.springframework.web.bind.annotation.GetMapping;
1213
import org.springframework.web.bind.annotation.PathVariable;
1314
import org.springframework.web.bind.annotation.PostMapping;
15+
import org.springframework.web.bind.annotation.RequestBody;
1416
import org.springframework.web.bind.annotation.RequestMapping;
1517
import org.springframework.web.bind.annotation.RequestParam;
1618
import org.springframework.web.bind.annotation.RestController;
@@ -35,10 +37,10 @@ public class AgentApiController {
3537
*/
3638
@PostMapping("/templates/{template_id}")
3739
public SseEmitter startSSE(@PathVariable("template_id") Long templateId,
38-
@RequestParam("action") String action) {
40+
@RequestParam("action") String action, @RequestBody TemplateInfo templateInfo) {
3941

4042
if (action.equals("start")) {
41-
return sseManageService.start(templateId);
43+
return sseManageService.start(templateId, templateInfo);
4244
} else {
4345
sseManageService.stop(templateId);
4446
return null;

bm-agent/src/main/java/org/benchmark/bmagent/controller/GlobalExceptionHandler.java renamed to bm-agent/src/main/java/org/benchmarker/bmagent/controller/GlobalExceptionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.benchmark.bmagent.controller;
1+
package org.benchmarker.bmagent.controller;
22

33
import java.io.IOException;
44
import lombok.extern.slf4j.Slf4j;
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package org.benchmarker.bmagent.pref;
2+
3+
import java.util.concurrent.ConcurrentHashMap;
4+
import org.benchmarker.bmagent.service.MapManager;
5+
import org.benchmarker.bmcommon.dto.TestResult;
6+
import org.benchmarker.bmagent.service.ISseManageService;
7+
import org.springframework.stereotype.Component;
8+
9+
/**
10+
* ResultManagerService for managing TestResult
11+
*
12+
* <p>
13+
* After bmagent send multiple HTTP request to target server, calculated delays and others things need
14+
* to be added in resultHashMap
15+
* </p>
16+
*
17+
* <p>
18+
* resultHashMap will be used by {@link ISseManageService} to send
19+
* TestResult to client
20+
* </p>
21+
*
22+
* @see ISseManageService
23+
*/
24+
@Component
25+
public class ResultManagerService implements MapManager<Long, TestResult> {
26+
27+
/**
28+
* ConcurrentHashMap for storing TestResult by its id
29+
*/
30+
private final ConcurrentHashMap<Long, TestResult> resultHashMap = new ConcurrentHashMap<>();
31+
32+
/**
33+
* Find TestResult from resultHashMap
34+
*
35+
* @param id {@link Long}
36+
* @return {@link TestResult} or null
37+
*/
38+
@Override
39+
public TestResult find(Long id) {
40+
if (resultHashMap.containsKey(id)) {
41+
return resultHashMap.get(id);
42+
}
43+
return null;
44+
}
45+
46+
/**
47+
* Save TestResult to resultHashMap
48+
* @param id {@link Long}
49+
* @param object {@link TestResult}
50+
*/
51+
@Override
52+
public void save(Long id, TestResult object) {
53+
resultHashMap.put(id, object);
54+
}
55+
56+
/**
57+
* Remove TestResult from resultHashMap
58+
* @param id {@link Long}
59+
*/
60+
@Override
61+
public void remove(Long id) {
62+
resultHashMap.remove(id);
63+
}
64+
}

bm-agent/src/main/java/org/benchmark/bmagent/schedule/ScheduledTaskService.java renamed to bm-agent/src/main/java/org/benchmarker/bmagent/schedule/ScheduledTaskService.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
package org.benchmark.bmagent.schedule;
1+
package org.benchmarker.bmagent.schedule;
22

3-
import java.util.Map;
4-
import java.util.concurrent.CompletableFuture;
53
import java.util.concurrent.Executors;
64
import java.util.concurrent.ScheduledExecutorService;
75
import java.util.concurrent.TimeUnit;
86
import lombok.extern.slf4j.Slf4j;
9-
import org.benchmark.bmagent.service.AbstractScheduledTaskService;
7+
import org.benchmarker.bmagent.service.AbstractScheduledTaskService;
108
import org.springframework.stereotype.Component;
119

1210

bm-agent/src/main/java/org/benchmark/bmagent/schedule/SchedulerStatus.java renamed to bm-agent/src/main/java/org/benchmarker/bmagent/schedule/SchedulerStatus.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.benchmark.bmagent.schedule;
1+
package org.benchmarker.bmagent.schedule;
22

33
public enum SchedulerStatus {
44
RUNNING, SHUTDOWN, TERMINATED

bm-agent/src/main/java/org/benchmark/bmagent/service/AbstractScheduledTaskService.java renamed to bm-agent/src/main/java/org/benchmarker/bmagent/service/AbstractScheduledTaskService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package org.benchmark.bmagent.service;
1+
package org.benchmarker.bmagent.service;
22

33
import java.util.Map;
44
import java.util.concurrent.ConcurrentHashMap;
55
import java.util.concurrent.ScheduledExecutorService;
6-
import org.benchmark.bmagent.schedule.SchedulerStatus;
6+
import org.benchmarker.bmagent.schedule.SchedulerStatus;
77

88
/**
99
* Abstract class for the scheduled task service

0 commit comments

Comments
 (0)