1

I am trying to build a polling feature using retry until syntax. My test is using retry in two scenarios.

First one works fine and but the second retry scenario is always failing. with msg too many retry attempts: 2

Here is how my feature looks like

Given path brokerResult.activationPlan
    And header Authorization = oauthToken
    When method get
    Then status 200
    And retry until response.blocks == '#[13]' && karate.jsonPath(response, "$.blocks[?(@.block_status=='ACTIVE')]")== '#[3]'

Execute some more scenario to change the state.

 Given path brokerResult.activationPlan
    And header Authorization = oauthToken
    When method get
    Then status 200
    And retry until karate.jsonPath(response, "$.blocks[?(@.block_status=='FINISHED')]") == '#[3]'

Here this scenario always fails.

I am on Karate version: 0.9.2

My question is does JSON path evaluation works with retry until which I am assuming yes as my first scenario works. what is that I am missing to make the second scenario work.

  • 1
    i am not sure if we can use `marker` for ***non-match*** js evaluation. but i am surprised to see it worked for the first scenario, can you try using karate.match(karate.jsonPath(response, "$.blocks[?(@.block_status=='FINISHED')]"), '#[3]') – Babu Sekaran May 22 '19 at 11:40
  • 1
    by `marker` i meant `'#[3]'` and please try this instead `karate.match(karate.jsonPath(response, "$.blocks[?(@.block_status=='FINISHED')]"), '#[3]').pass` – Babu Sekaran May 22 '19 at 12:08

1 Answers1

1

No, JSON-path or "fuzzy match" markers do NOT work for retry until.

Please read this answer for more explanation: https://stackoverflow.com/a/55823180/143475

This should give you a hint to solve your case:

* def isActive = function(x){ var temp = karate.jsonPath(x, "$.blocks[?(@.block_status=='ACTIVE')]"); return temp.length == 3 }
* def response = { blocks: [{ block_status: 'ACTIVE' }, { block_status: 'ACTIVE' }, { block_status: 'ACTIVE' }] }
* def result = isActive(response)
* match result == true
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248