Skip to content
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

테스트 Develope -> Main 동기화 #233

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions script/articleTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//지도에서 글타래 찾기 테스트
import http from "k6/http";
import { check, sleep } from "k6";

// Test configuration
export const options = {
thresholds: {
// Assert that 99% of requests finish within 3000ms.
http_req_duration: ["p(99) < 6000"],
},
stages: [
{ duration: "1m", target: 250 }, // 0 -> 250명 증가 30초 동안
// { duration: "10s", target: 500 }, // 10초간 500명 유지
{ duration: "1m", target: 0 }, // 1분동안 250 -> 0으로 감소
],
};

// Authentication token
const TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cGUiOiJKV1QifQ.eyJyb2xlIjoiUk9MRV9BRE1JTiIsIm5pY2tuYW1lIjoiSm9obkRvZSIsImNhdGVnb3J5IjoiQUNDRVNTX1RPS0VOIiwidXNlcklkIjoiYXpzQWQ0MTIxMjMiLCJlbWFpbCI6InJrcmt3bmoxMDQ2MjAwQGdtYWlsLmNvbSIsIm1lbWJlcklkIjo3OCwiaWF0IjoxNzMzNzI1MTkzLCJleHAiOjE3MzM3MjY5OTN9.RsLpLeL28uGsu8lKPnQ53qiAYWb2miregfk8bp3E8ds"; // 여기에 실제 토큰을 입력하세요

// Simulated user behavior
export default function () {
// Request payload
const payload = JSON.stringify({
southWestLat: 35.4600,
southWestLon: 127.1390,
northEastLat: 38.5170,
northEastLon: 120.8220,
});

// HTTP headers
const headers = {
"Content-Type": "application/json",
"Authorization": `Bearer ${TOKEN}`,
};

// Send POST request
const url = "http://mallangplace.ap-northeast-2.elasticbeanstalk.com/api/v1/articles/public/articlesMarkers?articleType=lost";
const res = http.post(url, payload, { headers });

// Validate response
if (res.status === 200 && res.body) {
try {
const responseBody = JSON.parse(res.body);

check(responseBody, {
"response is not empty": () => responseBody.length > 0,
});
} catch (e) {
console.error("JSON parsing failed: ", e.message);
}
} else {
console.error(`Request failed. Status: ${res.status}, Body: ${res.body}`);
}

sleep(1);
}
53 changes: 53 additions & 0 deletions script/boardTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//게시글 전체 글 조회 테스트
import http from "k6/http";
import { check, sleep } from "k6";

// Test configuration
export const options = {
thresholds: {
// Assert that 99% of requests finish within 3000ms.
http_req_duration: ["p(99) < 3000"],
},
stages: [
{ duration: "1m", target: 1000 }, // 0 -> 15명 증가 30초 동안
// { duration: "10s", target: 500 }, // 1분간 15명 유지
{ duration: "1m", target: 0 }, // 20초 동안 15 -> 0으로 감소
],
};

// Authentication token
const TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cGUiOiJKV1QifQ.eyJyb2xlIjoiUk9MRV9BRE1JTiIsIm5pY2tuYW1lIjoi6rmA64-Z7ZiEIiwiY2F0ZWdvcnkiOiJBQ0NFU1NfVE9LRU4iLCJ1c2VySWQiOiJ0ZXN0MTIzNDEyMyIsImVtYWlsIjoidGVzdC5lbWFpbDIwMTI0QHByb3ZpZGVyLm5ldCIsIm1lbWJlcklkIjoxMjMsImlhdCI6MTczMzczOTYyNSwiZXhwIjoxNzMzNzQxNDI1fQ.LwgSGH-387LHQFtc51OBvPEtPGv7x_iQOmks6kpM-b8"; // 여기에 실제 토큰을 입력하세요

// Simulated user behavior
export default function () {

// HTTP headers
const headers = {
"Content-Type": "application/json",
"Authorization": `Bearer ${TOKEN}`,
};

// Send POST request
const url = "http://mallangplace.ap-northeast-2.elasticbeanstalk.com/api/v1/board/community/?page=1";

// Send GET request
const res = http.get(url, { headers });

// Validate response
if (res.status === 200 && res.body) {
try {
const responseBody = JSON.parse(res.body);

check(responseBody, {
"response is not empty": () => responseBody.content.length > 0, // content는 백엔드의 응답 구조 확인 필요
"status is 200": () => res.status === 200,
});
} catch (e) {
console.error("JSON parsing failed: ", e.message);
}
} else {
console.error(`Request failed. Status: ${res.status}, Body: ${res.body}`);
}

sleep(1);
}
21 changes: 21 additions & 0 deletions script/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3.7'

services:
influxdb:
image: influxdb:1.8
container_name: k6-influxdb-1
ports:
- "8086:8086"
environment:
- INFLUXDB_DB=k6
- INFLUXDB_ADMIN_USER=admin
- INFLUXDB_ADMIN_PASSWORD=admin

grafana:
image: grafana/grafana:9.3.8
container_name: k6-grafana-1
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
Loading