2017-11-17 18 views
1

가 난 오류를 K6의 처음 사용자를 반환하고 난 이미 스크립트 실행 오류 얻을 관리했습니다실행 K6 스크립트는

"요청 실패 [33merror [0m ="를 HTTPS를 가져 오기 : /// : 0 후 정지는

스크립트 k6.js "리디렉션 : 나는이 오류와 해결책은 무엇인가 이유는 무엇

import http from "k6/http"; 
import { sleep } from "k6"; 

export let options = { 
stages: [ 
    { duration: "30s", target: 20 }, 
    { duration: "1m30s", target: 10 }, 
    { duration: "20s", target: 0 }, 
    ] 
}; 

export default function() { 
    let res = http.get("https://<our_page_URL>/"); 
    check(res, { 
    "status code MUST be 200": (res) => res.status == 200, 
    }) || fail("status code was *not* 200"); 
    sleep(1); 
} 

+0

왜 당신은'|| 'options.throw'를'true'로 설정하는 대신에'fail()'검사를 사용합니까? – Sander

+0

좋은 질문입니다. 나는 k6 페이지에서이 예제를 발견하고 나에게 유용하게 보였다. 그래서 그것이 어떻게 작동 하는지를보기 위해 그것을 사용했다. 불행히도 options.throw를 사용하는 방법을 모르지만 문서를 살펴볼 것입니다. – jurijk

+0

@Sander & jurijk 나는 문서가 옵션 앞에 쓰여졌다 고 생각한다. 실종되었다. 이것을 지적 해 주셔서 감사합니다. 문서를 업데이트 할 수 있는지 확인하겠습니다! – Ragnar

답변

2

maxRedirects 옵션을 설정해야합니다. maxRedirects은 k6가 요청을 포기하고 ("$ MAX_REDIRECT_VALUE가 리디렉션 된 후 $ PATH가 중단 된 Get $ PATH를 중지합니다") k6이 따르는 최대 HTTP 리디렉션 수입니다.

CLI 인수 또는 스크립트 옵션으로 옵션을 전달할 수 있습니다. 이 옵션에 대한 자세한 https://docs.k6.io/docs/options

export let options = { 
    // Max redirects to follow (default is 10) 
    maxRedirects: 10 
}; 

에서 기본값은 10이므로 할당되는 기본값을 건너 뛰는 버그 가능성이있다.

작동 원리를 테스트하기 위해 redirect example입니다.

import http from "k6/http"; 
import {check} from "k6"; 

export let options = { 
    // Max redirects to follow (default is 10) 
    maxRedirects: 5 
}; 

export default function() { 
    // If redirecting more than options.maxRedirects times, the last response will be returned 
    let res = http.get("https://httpbin.org/redirect/6"); 
    check(res, { 
     "is status 302": (r) => r.status === 302 
    }); 

    // The number of redirects to follow can be controlled on a per-request level as well 
    res = http.get("https://httpbin.org/redirect/1", {redirects: 1}); 
    console.log(res.status); 
    check(res, { 
     "is status 200": (r) => r.status === 200, 
     "url is correct": (r) => r.url === "https://httpbin.org/get" 
    }); 
} 
+0

ppcano : 이것으로 하루가 절약되었습니다! 고맙습니다! 이제 마침내 오류가 없으며 나머지는 완벽하게 작동합니다. – jurijk

+0

@jurijk : 도와 드리겠습니다. 슬랙 대화 이후에 이미 문제를 해결했다고 생각했기 때문에 이전에 질문에 답하지 않았습니다. 어쨌든 질문이 있거나 도움이 필요하면 알려주십시오. 버그에 대한 github 문제도 열어 둡니다. https://github.com/loadimpact/k6/issues/369 – ppcano