Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP/S reponse record and replay #75

Open
bramhaghosh opened this issue Feb 26, 2016 · 7 comments
Open

HTTP/S reponse record and replay #75

bramhaghosh opened this issue Feb 26, 2016 · 7 comments
Assignees
Milestone

Comments

@bramhaghosh
Copy link
Member

Provide support for HTTP/S response record and replay

Users have asked for the capability to record responses from external services, and then to use those responses as a mechanism to stub out the external service during the execution of a test run.

Proposed Record Mode Workflow

  1. Put Martian into RECORD mode
  2. Instruct Martian to record responses to requests that match a provided keyGen() function.
  3. Provide Martian with the path to the db in which to save responses (bolt?).
  4. As requests that match the provided keyGen() come across, Martian captures the response that comes back from the HTTP roundtrip.
  5. For each response for request that matches the keyGen(), Martian adds a header with a known name (X-Martian-Key) where the value is a string representation of the output of keyGen().
  6. While in RECORD mode, any response modifiers will be applied before capture, maybe. Depends on where on the stack the record/replay modifier lives.
  7. Martian holds the responses in memory, and when Martian leaves RECORD mode, the responses are written to the filesystem to the provided path and filename.

Proposed Replay Mode Workflow

  1. Put Martian into REPLAY mode and tell it where the response cache db and the keyGen() used in RECORD mode
  2. Martian parses the response cache db and holds it in memory
  3. As requests that match the provided keyGen() come across, Martian grabs any matching response from the cache db, deletes the X-Martian-Key header, and returns the cached response.
  4. Martian applies any other modifiers on the stack - this is where you'd want to put modifiers that remove "dynamic" headers (datetime, etc.)
  5. Martian returns the modified cached response.
@bramhaghosh bramhaghosh self-assigned this Feb 26, 2016
@bramhaghosh bramhaghosh added this to the v2.1.0 milestone Feb 26, 2016
@bootstraponline
Copy link

Is this still planned? I think it'd be great for testing.

@bramhaghosh
Copy link
Member Author

bramhaghosh commented Jan 19, 2017 via email

@bootstraponline
Copy link

Awesome! Thanks for the info.

@bootstraponline
Copy link

Is there an updated ETA?

@hueich
Copy link
Collaborator

hueich commented Sep 9, 2017

How should the keyGen() function be passed in? In the JSON config? Or in another modifier before it?

@hueich hueich self-assigned this Sep 9, 2017
@hueich
Copy link
Collaborator

hueich commented Oct 15, 2017

An initial implementation is being worked on in the "caching" branch, for those interested.

@bootstraponline
Copy link

It'd be helpful to demo a simple use case of record/playback for Java using okhttp. If this can be used as a wiremock alternative for Android testing, that'd be excellent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants