Java Heap space error for response with huge payload | karate 1.0.1

Viewed 331

We are currently using karate 0.9.6 in our testing framework and requirement is somehow to match entire response body with file stored as a json(it's a finance based application where we need to verify entire response body)

I am trying to migrate to 1.0.1 as per the upgrade guide

The scenario in which we are asserting against the saved response is failing with Java Heap space error after upgrading to 1.0.1

Due to security constraint i can't put the response body here so i tried with open source api with large response body and it is failing to with below use case

Given url "https://jsonplaceholder.typicode.com/photos"
And json expected_resp =read('classpath:<path_to_saved_file>/response.json')
When method GET 
Then status 200
Then match response  == '#(^^expected_resp)'

enter image description here

PS: I've already all the steps mentioned in here

1 Answers

Sorry that's not enough info to replicate. I tried the following and it works:

Given url "https://jsonplaceholder.typicode.com/photos"
When method GET 
Then status 200

We have anyway opened an issue, but will close it within a day or two if we can't replicate: https://github.com/intuit/karate/issues/1572

This is an open-source project and we depend on contributions or at least better information from you.

EDIT: solution for very large JSON arrays is to sort the array (now easily possible in Karate 1.0) and then do an exact match - which will avoid the memory that is needed to do a contains match.

* def sorted = karate.sort(response, x => x.id)
* match sorted == read('photos.json')
Related