-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 부하 테스트 자동화 구성 #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a253665
chore: 부하 테스트 secret 포인터 갱신
lsy1307 d7456ec
feat: 부하 테스트 RDS 인프라 구성
lsy1307 95da845
feat: 부하 테스트 실행 스크립트 추가
lsy1307 bdfb439
feat: 부하 테스트 GitHub Actions 실행 추가
lsy1307 9ef254a
feat: stage 생성 시 k6 파일 배치 추가
lsy1307 7d59011
fix: 부하 테스트 자동화 리뷰 반영
lsy1307 4878107
chore: 부하 테스트 plan 자동 검증 제외
lsy1307 4ebeb6c
feat: k6 전용 부하 생성 EC2 구성
lsy1307 c8a70cc
feat: EC2 기반 k6 실행 workflow 추가
lsy1307 b097ca9
fix: k6 실행 설정과 응답 검증 보강
lsy1307 4ad54c4
docs: EC2 기반 부하 테스트 절차 정리
lsy1307 628043a
feat: k6 응답 검증 보강
lsy1307 6f2247a
feat: RDS 스냅샷 기반 부하 테스트 구성
lsy1307 f6e3174
feat: 부하 테스트 시크릿 참조 갱신
lsy1307 ab1135c
feat: 레거시 부하 테스트 스크립트 제거
lsy1307 ea86883
feat: 부하 테스트 리뷰 항목 정리
lsy1307 23a3e57
feat: 부하 생성기 실행 후 정리 옵션 추가
lsy1307 5a0ac77
feat: 부하 테스트 datasource 시크릿 분리
lsy1307 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,65 @@ | ||
| name: Load Test Start | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| switch_stage_to_loadtest: | ||
| description: "Restart stage app with dev,loadtest profiles" | ||
| required: true | ||
| default: true | ||
| type: boolean | ||
| copy_prod_data: | ||
| description: "Copy prod RDS data to load test RDS" | ||
| required: true | ||
| default: true | ||
| type: boolean | ||
|
|
||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: load-test-environment | ||
| cancel-in-progress: false | ||
|
|
||
| env: | ||
| TF_VERSION: "1.10.5" | ||
|
|
||
| jobs: | ||
| start: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
| token: ${{ secrets.GH_PAT }} | ||
| persist-credentials: false | ||
|
|
||
| - uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | ||
| aws-region: ap-northeast-2 | ||
|
|
||
| - uses: hashicorp/setup-terraform@v3 | ||
| with: | ||
| terraform_version: ${{ env.TF_VERSION }} | ||
| terraform_wrapper: false | ||
|
|
||
| - name: Install jq | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y jq | ||
|
|
||
| - name: Start load test environment | ||
| run: | | ||
| args=() | ||
|
|
||
| if [ "${{ inputs.switch_stage_to_loadtest }}" = "true" ]; then | ||
| args+=(--switch-stage-to-loadtest) | ||
| fi | ||
|
|
||
| if [ "${{ inputs.copy_prod_data }}" != "true" ]; then | ||
| args+=(--skip-data-copy) | ||
| fi | ||
|
|
||
| bash scripts/load_test/start.sh "${args[@]}" |
This file contains hidden or 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,65 @@ | ||
| name: Load Test Stop | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| restore_stage_dev: | ||
| description: "Restart stage app with dev profile" | ||
| required: true | ||
| default: true | ||
| type: boolean | ||
| destroy_rds: | ||
| description: "Destroy load test Terraform stack" | ||
| required: true | ||
| default: true | ||
| type: boolean | ||
|
|
||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: load-test-environment | ||
| cancel-in-progress: false | ||
|
|
||
| env: | ||
| TF_VERSION: "1.10.5" | ||
|
|
||
| jobs: | ||
| stop: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive | ||
| token: ${{ secrets.GH_PAT }} | ||
| persist-credentials: false | ||
|
|
||
| - uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | ||
| aws-region: ap-northeast-2 | ||
|
|
||
| - uses: hashicorp/setup-terraform@v3 | ||
| with: | ||
| terraform_version: ${{ env.TF_VERSION }} | ||
| terraform_wrapper: false | ||
|
|
||
| - name: Install jq | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y jq | ||
|
|
||
| - name: Stop load test environment | ||
| run: | | ||
| args=() | ||
|
|
||
| if [ "${{ inputs.restore_stage_dev }}" = "true" ]; then | ||
| args+=(--restore-stage-dev) | ||
| fi | ||
|
|
||
| if [ "${{ inputs.destroy_rds }}" != "true" ]; then | ||
| args+=(--skip-terraform-destroy) | ||
| fi | ||
|
|
||
| bash scripts/load_test/stop.sh "${args[@]}" |
This file contains hidden or 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,7 @@ | ||
| { | ||
| "boardCode": "FREE", | ||
| "postCategory": "자유", | ||
| "title": "수강신청 어떻게 하나요?", | ||
| "content": "수강신청 방법을 잘 모르겠어요.", | ||
| "isQuestion": false | ||
| } |
This file contains hidden or 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,64 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # 작업 디렉터리 설정 | ||
| WORKDIR="/home/ubuntu" | ||
|
|
||
| ####################################################################### | ||
| # set-load-test.sh | ||
| # 사용 예: SQL_FILE_BASENAME=regular.sql ./set-load-test.sh | ||
| ####################################################################### | ||
|
|
||
| # 0. 필수 값 검증 | ||
| SQL_BASENAME="${SQL_FILE_BASENAME:-regular.sql}" | ||
| if [[ -z "$SQL_BASENAME" ]]; then | ||
| echo "❌ 사용할 덤프 파일이 입력되지 않았습니다." >&2 | ||
| echo "SQL_FILE_BASENAME={dump 파일 이름} ./set-load-test.sh 형식으로 인자를 전달해야합니다." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| SQL_SRC="$WORKDIR/load-test-setting/db/${SQL_BASENAME}" | ||
| if [[ ! -f "$SQL_SRC" ]]; then | ||
| echo "❌ 덤프 파일이 파일 시스템에 존재하지 않습니다: $SQL_SRC" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| # 1. 기존 어플리케이션, DB 중지 | ||
| docker compose -f "$WORKDIR/solid-connection-dev/docker-compose.dev.yml" down \ | ||
| || { echo "❌ 어플리케이션 도커 중지 실패: $WORKDIR/solid-connection-dev/docker-compose.dev.yml" >&2; exit 3; } | ||
| docker compose -f "$WORKDIR/mysql/docker-compose.mysql.yml" down \ | ||
| || { echo "❌ MySQL 도커 중지 실패: $WORKDIR/mysql/docker-compose.mysql.yml" >&2; exit 4; } | ||
|
|
||
| # 2. 부하 테스트용 DB 실행 | ||
| docker compose -f "$WORKDIR/load-test-setting/docker-compose.load-test.yml" up -d \ | ||
| || { echo "❌ 부하 테스트용 DB 실행 실패: docker-compose.load-test.yml" >&2; exit 5; } | ||
|
|
||
| # 3. MySQL 준비 대기 (최대 30초) | ||
| CONTAINER_NAME="load-test-db" | ||
| echo "⏳ MySQL이 준비될 때까지 대기 중 (최대 30초)..." | ||
| start_time=$(date +%s) | ||
| while ! docker exec "$CONTAINER_NAME" sh -c 'mysqladmin ping -h "127.0.0.1" --silent'; do | ||
| elapsed=$(( $(date +%s) - start_time )) | ||
| if [[ $elapsed -ge 30 ]]; then | ||
| echo "❌ MySQL 준비 시간 초과 (30초)" >&2 | ||
| exit 1 | ||
| fi | ||
| printf "." | ||
| sleep 1 | ||
| done | ||
| echo "✔️ MySQL 준비 완료." | ||
|
|
||
| # 4. dump 주입 | ||
| echo "📥 dump 파일 복사 → 컨테이너: $CONTAINER_NAME" | ||
| docker cp "$SQL_SRC" "${CONTAINER_NAME}:/tmp/dump.sql" \ | ||
| || { echo "❌ dump 복사 실패: $SQL_SRC → $CONTAINER_NAME:/tmp/dump.sql" >&2; exit 6; } | ||
|
|
||
| echo "⚙️ dump 이식" | ||
| docker exec -i "$CONTAINER_NAME" sh -c 'mysql -u root -proot < /tmp/dump.sql' \ | ||
| || { echo "❌ dump 이식 실패: 컨테이너 $CONTAINER_NAME" >&2; exit 7; } | ||
|
|
||
| # 5. 어플리케이션 다시 실행 | ||
| docker compose -f "$WORKDIR/solid-connection-dev/docker-compose.dev.yml" up -d \ | ||
| || { echo "❌ 어플리케이션 재시작 실패: $WORKDIR/solid-connection-dev/docker-compose.dev.yml" >&2; exit 8; } | ||
|
|
||
| echo "✅ 부하 테스트용 DB에 연결된 어플리케이션 실행 완료!" |
This file contains hidden or 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,53 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # 에러 발생 시 메시지 출력 | ||
| trap 'echo "❌ 오류 발생! 스크립트 실행이 중단되었습니다." >&2' ERR | ||
|
|
||
| export GO_VERSION=1.22.2 | ||
| export BASE_DIR=/home/ubuntu/solid-connection-load-test/k6 | ||
| export GOROOT=${BASE_DIR}/go | ||
| export GOPATH=${BASE_DIR}/go-workspace | ||
| export PATH=$PATH:$GOROOT/bin:$GOPATH/bin | ||
| export XK6_BIN=${GOPATH}/bin/xk6 | ||
| export K6_OUT=xk6-prometheus-rw | ||
| export K6_PROMETHEUS_RW_SERVER_URL=http://132.145.83.182:9090/api/v1/write | ||
| export K6_PROMETHEUS_RW_TREND_STATS="p(90),p(95),p(99),avg,min,max" | ||
| { | ||
| echo "export BASE_DIR=${BASE_DIR}" | ||
| echo "export GOROOT=${GOROOT}" | ||
| echo "export GOPATH=${GOPATH}" | ||
| echo "export PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin" | ||
| echo "export XK6_BIN=${GOPATH}/bin/xk6" | ||
| echo "export K6_OUT=xk6-prometheus-rw" | ||
| echo "export K6_PROMETHEUS_RW_SERVER_URL=http://146.56.46.8:9090/api/v1/write" | ||
| echo "K6_PROMETHEUS_RW_TREND_STATS=\"p(90),p(95),p(99),avg,min,max\"" | ||
| } >> ~/.bashrc | ||
|
|
||
| echo "📁 디렉토리 생성 및 이동: $BASE_DIR" | ||
| mkdir -p "$BASE_DIR" | ||
| cd "$BASE_DIR" | ||
|
|
||
| echo "⬇️ Go $GO_VERSION 다운로드 중..." | ||
| curl -OL "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" | ||
|
|
||
| echo "📦 Go 압축 해제 중..." | ||
| tar -xzf "go${GO_VERSION}.linux-amd64.tar.gz" | ||
| rm "go${GO_VERSION}.linux-amd64.tar.gz" | ||
|
|
||
| echo "✅ Go 버전 확인: $(go version)" | ||
|
|
||
| echo "⬇️ xk6 설치 중..." | ||
| go install go.k6.io/xk6/cmd/xk6@latest | ||
|
|
||
| echo "✅ xk6 설치 완료: $XK6_BIN" | ||
| $XK6_BIN --help > /dev/null && echo "✅ xk6 실행 가능" | ||
|
|
||
| echo "⚙️ Prometheus remote-write 플러그인을 포함한 K6 빌드 시작" | ||
| $XK6_BIN build --with github.com/grafana/xk6-output-prometheus-remote@latest | ||
|
|
||
| echo "✅ 빌드 완료: $(pwd)/k6" | ||
| ls -lh ./k6 | ||
|
|
||
| echo "🎉 설치가 성공적으로 완료되었습니다!" | ||
This file contains hidden or 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,5 @@ | ||
| { | ||
| "postCategory": "자유", | ||
| "title": "수강신청 어떻게 하나요?", | ||
| "content": "수강신청 방법을 잘 알겠어요." | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.