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

failed execution breaks all other tests #17

Open
fczuardi opened this issue Oct 31, 2023 · 2 comments
Open

failed execution breaks all other tests #17

fczuardi opened this issue Oct 31, 2023 · 2 comments

Comments

@fczuardi
Copy link

K6 documentation recommends the use of k6 chaijs for handling errors, using the describe function.

However it does not work with tests that uses exec.command, a failed command execution exits k6 run as well :(

steps to reproduce

// mytest.js
import { describe} from "https://jslib.k6.io/k6chaijs/4.3.4.3/index.js";
import { check } from 'k6'
import exec from 'k6/x/exec';

export function setup (){}
export function teardown (){}
export default function(){

  describe("1", (t) => {
    check(1, {"1 === 1": n => n ===1}) 
  })
  describe("2", (t) => {
    check(1, {"1 === 1": n => n ===1}) 
    let out = exec.command("ls", ["non_existent_file"])
  })
  describe("3", (t) => {
    check(1, {"1 === 1": n => n ===1}) 
  })
}

expected behavior

  • one failed test wrapped in a "describe" dont interrupt the whole test suite

actual behavior

$ k6 version
k6 v0.45.1 ((devel), go1.20.5, linux/amd64)
Extensions:
  github.com/grafana/xk6-exec v0.3.0, k6/x/exec [js]

$ k6 run mytest.js 

          /\      |‾‾| /‾‾/   /‾‾/   
     /\  /  \     |  |/  /   /  /    
    /  \/    \    |     (   /   ‾‾\  
   /          \   |  |\  \ |  (‾)  | 
  / __________ \  |__| \__\ \_____/ .io

  execution: local
     script: mytest.js
     output: -

  scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
           * default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)

INFO[0015] 2023/10/31 11:48:12 exit status 2 on command: ls non_existent_file 
@fczuardi
Copy link
Author

fczuardi commented Oct 31, 2023

Even with a regular try/catch block this fails:

import { check } from 'k6'
import exec from 'k6/x/exec';

export function setup (){}
export function teardown (){}
export default function(){
  check(1, {"1 === 1": n => n === 1}) 
  check(2, {"2 === 2": n => n === 2}) 
  try {
    let out = exec.command("ls", ["non_existent_file"])
    //should be the same behavior as
    //throw new Error('My error message')
  } catch(e) {
    console.log(e.message)
  }
  check(3, {"3 === 3": n => n === 3}) 
}

@fczuardi
Copy link
Author

maybe duplicate or similar than #12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant