LinkedInAttic / sepia

Sepia is a VCR-like module for node.js that records HTTP interactions, then plays them back exactly like the first time they were invoked
Apache License 2.0
279 stars 32 forks source link

Debug support in Sepia #4

Closed salvipriyanka closed 10 years ago

salvipriyanka commented 10 years ago

Feature for debugging sepia cache misses. This feature will allow Sepia to search for the best matching request for which a cache miss occurred, so that differences can be known easily & sepia filters can be added.

When fixtures are recorded with debug mode=true, all the incoming requests are saved as '.request' files with the same MD5 hashname calculated for the request.

Later during playback when there is a cache miss, the '.missing' file is compared with all the '.request' files in the same directory as the '.missing file', non-recursively(the .request has to be at the same directory level), for similarity and best matching '.request' fixture filename is provided in the Error thrown by Sepia.

If verbose mode is true, the best matching fixture request is printed in blue in the same format as the cache miss.

====[ cache miss ]==== hashParts: [ [ 'method', 'post' ], [ 'url', 'https:.mysite.com' ], [ 'body', 'client_headers=abcabc' ], [ 'headerNames', [ 'authorization', ] ], [ 'cookieNames', [] ] ]

filename:/43cc751a4d1dae7ec149e05b084d7f3d.headers

==== Best matching Fixture ==== to : /43cc751a4d1dae7ec149e05b084d7f3d.missing filename: /564e11a8776c5b7ddc8ce94e14c5376d.request hashParts: [ [ 'method', 'post' ], [ 'url', 'https:.mysite.com' ], [ 'body', 'client_headers=12345' ], [ 'headerNames', [ 'authorization', ] ],

[ 'cookieNames', [] ] ]