vendredi 10 janvier 2020

Karate 0.9.5.RC5 - 'retry until' function somehow does not respect my 'retry' configuration in karate-config.js

I have following test:

Feature: News API

  Background:
    * url baseUrl

  Scenario: get news index
    Given path "/"
    And retry until responseStatus == 200
    When method get
    Then status 200
    And match response contains "News service up and running"

and the following karate-config.js

function fn() {
    // get java system property 'karate.env'
    var env = karate.env;
    karate.log('karate.env system property was:', env);

    var config = {
        baseUrl: 'http://localhost:8080',
    };

    karate.configure('retry', {count: 5, interval: 6000});
    karate.configure('connectTimeout', 5000);
    karate.configure('readTimeout', 5000);

    return config;
}

and the following error in the console after executing the tests with the maven-failsafe-plugin:

...
[INFO] Running newsservice.NewsServiceIT
[main] INFO  o.a.http.impl.execchain.RetryExec - I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {}->http://localhost:8080: The target server failed to respond
[main] INFO  o.a.http.impl.execchain.RetryExec - Retrying request to {}->http://localhost:8080
[main] INFO  o.a.http.impl.execchain.RetryExec - I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {}->http://localhost:8080: The target server failed to respond
[main] INFO  o.a.http.impl.execchain.RetryExec - Retrying request to {}->http://localhost:8080
[main] INFO  o.a.http.impl.execchain.RetryExec - I/O exception (org.apache.http.NoHttpResponseException) caught when processing request to {}->http://localhost:8080: The target server failed to respond
[main] INFO  o.a.http.impl.execchain.RetryExec - Retrying request to {}->http://localhost:8080
[main] ERROR com.intuit.karate - org.apache.http.NoHttpResponseException: localhost:8080 failed to respond, http call failed after 2 milliseconds for URL: http://localhost:8080/
[main] ERROR com.intuit.karate - http request failed: 
org.apache.http.NoHttpResponseException: localhost:8080 failed to respond
---------------------------------------------------------
feature: classpath:newsservice/news/news-index.feature
scenarios:  1 | passed:  0 | failed:  1 | time: 0.7678
---------------------------------------------------------

HTML report: (paste into browser to view) | Karate version: 0.9.5.RC5
...

Before the tests start, I boot up my Spring Boot application and this takes some time (~5-7 seconds) and I know that the test does not succeed because the Sprint Boot app has not yet started.

That's why I've tried to use this retry until feature of Karate to make sure it retries after some intervals.

But it seems that the retry config is not respected according to the console output. It seems so that it always only try 3 times...

I have also tried to set the retry config in the test file itself like in the Karate docs with:

* configure retry = { count: 10, interval: 5000 }

but this also did not work.

Maybe you have a hint why it does not work or do I still miss something?

Thanks for support!

Aucun commentaire:

Enregistrer un commentaire