landro / TesTcl

when you don't have the balls to test your F5 BIG-IP iRules directly in production
https://testcl.com
BSD 3-Clause "New" or "Revised" License
98 stars 30 forks source link

Return ok with failed tests #63

Closed olanystrom closed 5 years ago

olanystrom commented 5 years ago

It looks like it returns OK even if I get failed test on verification. Can I make it return error on verification failure.

it "should allow casino10-qa.test.example.com" {
  source anon-hostheader_class.tcl

  on IP::client_addr return "1.2.3.4" 
  on HTTP::host return "casino10-qa.test.example.com"
  on HTTP::uri return "/init"
  verify "service-gateway-qa-gateway-anon.ocptest.example.com" "service-gateway-qa-ERROR-anon.ocptest.example.com" == {HTTP::header Host}
  endstate pool ocp_dev_infranodes_443
  run test_suppliers.irule test.suppliers-irule
}

And results

 **************************************************************************
* it should allow casino10-qa.test.example.com
**************************************************************************
-> Test failure!!
-> -> Verification 'service-gateway-qa-gateway-anon.ocptest.example.com' failed - expression: {service-gateway-qa-ERROR-anon.ocptest.example.com} == {service-gateway-qa-gateway-anon.ocptest.example.com}
error     Verification 'service-gateway-qa-gateway-anon.ocptest.example.com' failed - expression: {service-gateway-qa-ERROR-anon.ocptest.example.com} == {service-gateway-qa-gateway-anon.ocptest.example.com}
(venv) [olanys@netman02 test-f5-config]$ echo $?
0

As you can see we get 0 (ok) as returncode, and so the test-suite says everything is OK.

landro commented 5 years ago

Try calling “stats” command at the very end of your test file

  1. okt. 2019 kl. 11:29 skrev olanystrom notifications@github.com:

 It looks like it returns OK even if I get failed test on verification. Can I make it return error on verification failure.

it "should allow casino10-qa.test.example.com" { source anon-hostheader_class.tcl

on IP::client_addr return "1.2.3.4" on HTTP::host return "casino10-qa.test.suppliers.atg.se" on HTTP::uri return "/init" verify "service-gateway-qa-gateway-anon.ocptest.example.com" "service-gateway-qa-ERROR-anon.ocptest.example.com" == {HTTP::header Host} endstate pool ocp_dev_infranodes_443 run test_suppliers.irule test.suppliers-irule }

And results


  • it should allow casino10-qa.test.example.com

    -> Test failure!! -> -> Verification 'service-gateway-qa-gateway-anon.ocptest.example.com' failed - expression: {service-gateway-qa-ERROR-anon.ocptest.example.com} == {service-gateway-qa-gateway-anon.ocptest.example.com} error Verification 'service-gateway-qa-gateway-anon.ocptest.example.com' failed - expression: {service-gateway-qa-ERROR-anon.ocptest.example.com} == {service-gateway-qa-gateway-anon.ocptest.example.com} (venv) [olanys@netman02 test-f5-config]$ echo $? 0

As you can see we get 0 (ok) as returncode, and so the test-suite says everything is OK.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

olanystrom commented 5 years ago

That works perfectly. I missed the stats in the examplefile.