Skip to content

Commit

Permalink
[Feat] Set up environment for performance testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnsugyeong committed Sep 22, 2024
1 parent 8a87e04 commit 96ad974
Show file tree
Hide file tree
Showing 9 changed files with 422 additions and 347 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/deploy-performance-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: waggle dev CI/CD

on:
push:
branches:
- performance-test

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'adopt'

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.DEV_AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build with Gradle & Upload Image to ECR
run: ./gradlew -Pdev clean jib

- name: Get current time
uses: josStorer/get-current-time@v2
id: current-time
with:
format: YYYYMMDD_HH-mm-ss
utcOffset: "+09:00"

- name: Generate deployment package
run: |
mkdir -p deploy/.platform/nginx/conf.d
cp docker-compose.yml deploy/docker-compose.yml
cp -r .ebextensions-dev deploy/.ebextensions
cp .platform/nginx/conf.d/proxy-dev.conf deploy/.platform/nginx/conf.d/proxy.conf
cd deploy && zip -r deploy.zip .
- name: Beanstalk Deploy
uses: einaregilsson/beanstalk-deploy@v21
with:
aws_access_key: ${{ secrets.TEST_AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }}
application_name: waggle-prod
environment_name: Waggle-prod-env
version_label: waggle-prod-${{steps.current-time.outputs.formattedTime}}
region: ${{ secrets.DEV_AWS_REGION }}
deployment_package: deploy/deploy.zip
wait_for_environment_recovery: 500
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
- "2181:2181"

application:
image: 471112861132.dkr.ecr.ap-northeast-2.amazonaws.com/waggle-dev:latest
image: 654654421569.dkr.ecr.ap-northeast-2.amazonaws.com/waggle/prod:latest
ports:
- "8080:8080"
depends_on:
Expand Down
2 changes: 1 addition & 1 deletion profile-dev.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jib {
}
}
to {
image = "471112861132.dkr.ecr.ap-northeast-2.amazonaws.com/waggle-dev"
image = "654654421569.dkr.ecr.ap-northeast-2.amazonaws.com/waggle/prod"
tags = ["latest", "${project.name}-" + System.currentTimeMillis()]
}
container {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
package com.example.waggle.domain.chat.presentation.controller;

import static com.example.waggle.global.util.PageUtil.CHAT_ROOM_SIZE;

import com.example.waggle.domain.chat.application.ChatMessageQueryService;
import com.example.waggle.domain.chat.application.ChatRoomCommandService;
import com.example.waggle.domain.chat.application.ChatRoomQueryService;
import com.example.waggle.domain.chat.persistence.entity.ChatMessage;
import com.example.waggle.domain.chat.persistence.entity.ChatRoom;
import com.example.waggle.domain.chat.presentation.converter.ChatConverter;
import com.example.waggle.domain.chat.presentation.dto.ChatMessageDto;
import com.example.waggle.domain.chat.presentation.dto.ChatResponse.ActiveChatRoomDto;
import com.example.waggle.domain.chat.presentation.dto.ChatResponse.ActiveChatRoomListDto;
import com.example.waggle.domain.chat.presentation.dto.ChatResponse.ChatMessageListDto;
import com.example.waggle.domain.chat.presentation.dto.ChatResponse.ChatRoomDetailDto;
import com.example.waggle.domain.chat.presentation.dto.ChatResponse.ChatRoomJoinDto;
import com.example.waggle.domain.chat.presentation.dto.ChatResponse.ChatRoomListDto;
import com.example.waggle.domain.chat.presentation.dto.ChatResponse.*;
import com.example.waggle.domain.chat.presentation.dto.ChatRoomRequest;
import com.example.waggle.domain.member.application.MemberQueryService;
import com.example.waggle.domain.member.persistence.entity.Member;
Expand All @@ -24,28 +17,25 @@
import com.example.waggle.global.annotation.auth.AuthUser;
import com.example.waggle.global.util.ObjectUtil;
import com.example.waggle.global.util.PageUtil;
import com.example.waggle.security.jwt.dto.JwtToken;
import com.example.waggle.security.jwt.service.TokenService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import static com.example.waggle.global.util.PageUtil.CHAT_ROOM_SIZE;

@Slf4j
@RequiredArgsConstructor
Expand All @@ -59,6 +49,7 @@ public class ChatApiController {
private final ChatRoomQueryService chatRoomQueryService;
private final ChatMessageQueryService chatMessageQueryService;
private final MemberQueryService memberQueryService;
private final TokenService tokenService;

@Operation(summary = "채팅방 생성 🔑", description = "사용자가 새로운 채팅방을 생성합니다. 생성 성공 시 채팅방의 고유 ID를 반환합니다.")
@ApiErrorCodeExample({
Expand Down Expand Up @@ -224,4 +215,9 @@ public ApiResponseDto<ChatRoomListDto> searchChatRoomListExcludingUser(
ChatConverter.toChatRoomListDto(
chatRoomQueryService.getPagedChatRoomListByKeywordExcludingMember(member, keyword, pageable)));
}

@GetMapping("/test")
public ApiResponseDto<JwtToken> test(@RequestParam("memberId") Long memberId) {
return ApiResponseDto.onSuccess(tokenService.generateTestToken(memberId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ private RequestMatcher[] permitAllRequest() {
antMatcher(HttpMethod.GET, "/api/recommends/{boardId}/memberList"),
antMatcher(HttpMethod.GET, "/api/follows/list/**"),
antMatcher(HttpMethod.GET, "/api/chat/rooms/**"),
antMatcher(HttpMethod.GET, "/api/chat/test"),
antMatcher("/ws/chat/**"),
antMatcher("/chat/**"),
antMatcher("/webjars/**"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ public interface TokenService {
boolean logout(String refreshToken);

boolean existsRefreshToken(String refreshToken);

JwtToken generateTestToken(Long memberId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,18 @@ private Claims parseClaims(String accessToken) {
public boolean existsRefreshToken(String refreshToken) {
return redisService.getValue(refreshToken) != null;
}

@Override
public JwtToken generateTestToken(Long memberId) {
Member member = memberQueryService.getMemberById(memberId);
if (!member.getAuthProvider().equals(WAGGLE)) {
throw new AuthenticationHandler(ErrorStatus.AUTH_PROVIDER_IS_NOT_MATCH);
}
Authentication authentication;
authentication = new UsernamePasswordAuthenticationToken(member, "", member.getAuthorities());

JwtToken jwtToken = generateToken(authentication);
jwtToken.setMember(MemberConverter.toMemberSummaryDto(member));
return jwtToken;
}
}
Loading

0 comments on commit 96ad974

Please sign in to comment.