-
Notifications
You must be signed in to change notification settings - Fork 2
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 #36 from joon6093/main
feat : 통계 조회 성능 개선 및 nGrinder를 이용한 성능 테스트
- Loading branch information
Showing
19 changed files
with
205 additions
and
45 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
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,16 @@ | ||
version: '3.8' | ||
services: | ||
controller: | ||
image: ngrinder/controller | ||
restart: always | ||
ports: | ||
- "9000:80" | ||
- "16001:16001" | ||
- "12000-12009:12000-12009" | ||
volumes: | ||
- ./ngrinder-controller:/opt/ngrinder-controller | ||
agent: | ||
image: ngrinder/agent | ||
restart: always | ||
links: | ||
- controller |
68 changes: 68 additions & 0 deletions
68
api/docker-compose-nGrinder/scripts/ReadStatisticsTest.groovy
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,68 @@ | ||
import static net.grinder.script.Grinder.grinder | ||
import static org.junit.Assert.* | ||
import static org.hamcrest.Matchers.* | ||
import net.grinder.script.GTest | ||
import net.grinder.script.Grinder | ||
import net.grinder.scriptengine.groovy.junit.GrinderRunner | ||
import net.grinder.scriptengine.groovy.junit.annotation.BeforeProcess | ||
import net.grinder.scriptengine.groovy.junit.annotation.BeforeThread | ||
import org.junit.Before | ||
import org.junit.BeforeClass | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.ngrinder.http.HTTPRequest | ||
import org.ngrinder.http.HTTPRequestControl | ||
import org.ngrinder.http.HTTPResponse | ||
import org.ngrinder.http.cookie.Cookie | ||
import org.ngrinder.http.cookie.CookieManager | ||
|
||
/** | ||
* A simple example using the HTTP plugin that shows the retrieval of a single page via HTTP. | ||
* | ||
* This script is automatically generated by ngrinder. | ||
* | ||
* @author admin | ||
*/ | ||
@RunWith(GrinderRunner) | ||
class TestRunner { | ||
|
||
public static GTest test | ||
public static HTTPRequest request | ||
public static Map<String, String> headers = [:] | ||
public static Map<String, Object> params = [:] | ||
public static List<Cookie> cookies = [] | ||
|
||
@BeforeProcess | ||
public static void beforeProcess() { | ||
HTTPRequestControl.setConnectionTimeout(300000) | ||
test = new GTest(1, "host.docker.internal") | ||
request = new HTTPRequest() | ||
grinder.logger.info("before process.") | ||
} | ||
|
||
@BeforeThread | ||
public void beforeThread() { | ||
test.record(this, "test") | ||
grinder.statistics.delayReports = true | ||
grinder.logger.info("before thread.") | ||
} | ||
|
||
@Before | ||
public void before() { | ||
request.setHeaders(headers) | ||
CookieManager.addCookies(cookies) | ||
grinder.logger.info("before. init headers and cookies") | ||
} | ||
|
||
@Test | ||
public void test() { | ||
HTTPResponse response = request.GET("http://host.docker.internal:8080/api/results/v1/statistics") | ||
|
||
if (response.statusCode == 301 || response.statusCode == 302) { | ||
grinder.logger.warn("Warning. The response may not be correct. The response code was {}.", response.statusCode) | ||
} else { | ||
assertThat(response.statusCode, is(200)) | ||
} | ||
} | ||
} |
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
19 changes: 0 additions & 19 deletions
19
api/src/main/java/org/meotppo/webti/dto/result/StatisticDTO.java
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
batch/src/main/java/org/meotppo/webti/job/StatisticJobConfig.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
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
2 changes: 1 addition & 1 deletion
2
batch/src/main/java/org/meotppo/webti/job/reader/ReaderConfig.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
19 changes: 19 additions & 0 deletions
19
domain/src/main/java/org/meotppo/webti/domain/config/jpa/QuerydslConfig.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,19 @@ | ||
package org.meotppo.webti.domain.config.jpa; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import jakarta.persistence.EntityManager; | ||
import jakarta.persistence.PersistenceContext; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class QuerydslConfig { | ||
|
||
@PersistenceContext | ||
private EntityManager entityManager; | ||
|
||
@Bean | ||
public JPAQueryFactory jpaQueryFactory() { | ||
return new JPAQueryFactory(entityManager); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
domain/src/main/java/org/meotppo/webti/domain/dto/result/StatisticDTO.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,25 @@ | ||
package org.meotppo.webti.domain.dto.result; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.querydsl.core.annotations.QueryProjection; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import java.time.LocalDateTime; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
public class StatisticDTO { | ||
private String result; | ||
private Long count; | ||
private Long matchCount; | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") | ||
private LocalDateTime modifiedAt; | ||
|
||
@QueryProjection | ||
public StatisticDTO(String result, Long count, Long matchCount, LocalDateTime modifiedAt) { | ||
this.result = result; | ||
this.count = count; | ||
this.matchCount = matchCount; | ||
this.modifiedAt = modifiedAt; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...omain/entity/mongo/result/TestResult.java → ...n/entity/mongo/testresult/TestResult.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
9 changes: 9 additions & 0 deletions
9
.../java/org/meotppo/webti/domain/repository/jpa/statistics/QuerydslStatisticRepository.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,9 @@ | ||
package org.meotppo.webti.domain.repository.jpa.statistics; | ||
|
||
import org.meotppo.webti.domain.dto.result.StatisticDTO; | ||
|
||
import java.util.List; | ||
|
||
public interface QuerydslStatisticRepository { | ||
List<StatisticDTO> findAllStatisticDtos(); | ||
} |
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
30 changes: 30 additions & 0 deletions
30
...main/java/org/meotppo/webti/domain/repository/jpa/statistics/StatisticRepositoryImpl.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,30 @@ | ||
package org.meotppo.webti.domain.repository.jpa.statistics; | ||
|
||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
import org.meotppo.webti.domain.dto.result.QStatisticDTO; | ||
import org.meotppo.webti.domain.dto.result.StatisticDTO; | ||
|
||
import java.util.List; | ||
|
||
import static org.meotppo.webti.domain.entity.jpa.statistics.QStatistic.statistic; | ||
|
||
@RequiredArgsConstructor | ||
public class StatisticRepositoryImpl implements QuerydslStatisticRepository { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public List<StatisticDTO> findAllStatisticDtos() { | ||
return queryFactory | ||
.select(new QStatisticDTO( | ||
statistic.developerProfile.result, | ||
statistic.count, | ||
statistic.matchCount, | ||
statistic.modifiedAt | ||
)) | ||
.from(statistic) | ||
.fetch(); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...ry/mongo/result/TestResultRepository.java → ...ongo/testresult/TestResultRepository.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