K6를 이용한 로드 테스트
이른바 K6
goo로 제작된 부하 테스트 도구입니다.
그러나 사용자 측의 테스트 장면은javascript를 사용합니다.
K6의 장점
(이번에gitlab의grafana를 사용합니다)
inflexDB 구축
※ influmxv2는 지원되지 않으며, 버전은 1.8이어야 합니다.
docker-compose.yml
version: '3.8'
services:
  influxdb:
    image: influxdb:1.8
    ports:
      - "8086:8086"
    environment:
      - INFLUXDB_DB=k6
Data Source에 Influmx 추가
 
 대시보드 2587(k6 Load Testing Results Dashboard)은 다음과 같이 import을 실행합니다.
https://grafana.com/grafana/dashboards/2587
 
  
 샘플 테스트 코드
테스트 스크립트
performance-test.js
import http from 'k6/http';
import { check } from 'k6';
import {htmlReport} from "https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js";
import {jUnit, textSummary} from "https://jslib.k6.io/k6-summary/0.0.1/index.js";
const puturl = 'http://ci-service-counter:9080/counter/increment';
const geturl = 'http://ci-service-counter:9080/counter';
export const options = {
  stages: [
    { target: 10, duration: '5m' },
  ],
};
export default function () {
    const headers = { 'Content-Type': 'application/json' };
    const putJsonPayLoad = {"value": 1};
    http.put(puturl, JSON.stringify(putJsonPayLoad), { headers: headers });
    let countResponse = http.get(geturl);
    check(countResponse, { "status is 200": (r) => r.status === 200 });
}
// レポート出力設定
export function handleSummary(data) {
    console.log('Preparing the end-of-test summary...');
    return {
        stdout: textSummary(data, { indent: " ", enableColors: true }),
        "summary.html": htmlReport(data),
        'summary.xml': jUnit(data), // but also transform it and save it as a JUnit XML...
        'summary.json': JSON.stringify(data), // and a JSON with all the details...
    }
}
gitlab-ci.yaml
nativeit-k6:
  stage: it
  when: manual
  tags:
    - docker
  image:
    name: loadimpact/k6:latest
    entrypoint: ['']
  services:
    - name: ${CI_REGISTRY}/${CI_PROJECT_PATH}:1.2
      alias: ci-service-counter
  script:
    - echo "executing local k6 in k6 container..."
    - k6 run performance-test.js --out influxdb=http://192.**.**.**:8086/k6
  artifacts:
    paths:
      - summary.html
      - summary.xml
      - summary.json
    reports:
      junit: summary.xml
grafana 출력
 
 k6 테스트 보고서
 
  
 로그 출력
log
     ✓ status is 200
     checks.........................: 100.00% ✓ 107788     ✗ 0     
     data_received..................: 33 MB   110 kB/s
     data_sent......................: 32 MB   107 kB/s
     http_req_blocked...............: avg=8.82µs  min=800ns  med=1.5µs   max=1.47s    p(90)=2.5µs   p(95)=3.1µs  
     http_req_connecting............: avg=182ns   min=0s     med=0s      max=4.91ms   p(90)=0s      p(95)=0s     
     http_req_duration..............: avg=6.87ms  min=3.47ms med=6.15ms  max=306.01ms p(90)=9.59ms  p(95)=11.52ms
       { expected_response:true }...: avg=6.87ms  min=3.47ms med=6.15ms  max=306.01ms p(90)=9.59ms  p(95)=11.52ms
     http_req_failed................: 0.00%   ✓ 0          ✗ 215576
     http_req_receiving.............: avg=46.72µs min=9.1µs  med=47.1µs  max=6.29ms   p(90)=69.9µs  p(95)=82.9µs 
     http_req_sending...............: avg=11.07µs min=4.2µs  med=8.3µs   max=7.43ms   p(90)=21.1µs  p(95)=28.6µs 
     http_req_tls_handshaking.......: avg=0s      min=0s     med=0s      max=0s       p(90)=0s      p(95)=0s     
     http_req_waiting...............: avg=6.81ms  min=3.42ms med=6.09ms  max=305.94ms p(90)=9.52ms  p(95)=11.45ms
     http_reqs......................: 215576  718.541797/s
     iteration_duration.............: avg=13.9ms  min=7.63ms med=12.69ms max=1.48s    p(90)=18.54ms p(95)=21.72ms
     iterations.....................: 107788  359.270898/s
     vus............................: 9       min=1        max=9   
     vus_max........................: 10      min=10       max=10  
Reference
이 문제에 관하여(K6를 이용한 로드 테스트), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/KO_YAmajun/items/8f2433d1244a7d886275텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)