mountebank icon indicating copy to clipboard operation
mountebank copied to clipboard

ReadOnly mode

Open chrbala opened this issue 3 years ago • 1 comments

Expected behaviour

I would like a way to:

  1. hydrate the mountebank imposters data stored externally
  2. start an ephemeral mountebank server (i.e. one that exists for the duration of a CI build)
  3. guarantee that proxies don't hit the network

The broader context here is that I would like to have separate jobs for generating mocks and consuming them. The mock generation will use proxyOnce and persist the mocks somewhere. Then, test runs will download and hydrate these mocks. I would like to have confidence that the test runs are in fact using the mocks. To accomplish this, I want the mock server to only return persisted mocks, and not pass any requests through to the proxied server in this mode.

Actual behaviour

  • Using --datadir results in a PUT when the server is turned on, which erases all the old values.
  • There is no easy way to guarantee that proxies aren't being used.

Steps to reproduce

  1. Start a new server that proxies requests and uses a datadir
  2. Pass some requests to that server
  3. Restart the server
  4. Observe as the imposters have been deleted

Software versions used

OS         : OSX 11.6
mountebank : 2.5.0
node.js    : v14.18.1
Installation method : npm

chrbala avatar Jan 06 '22 17:01 chrbala

Hi there, I realize it's a two step process, but it seems to me that mb replay do the trick for you. See http://www.mbtest.org/docs/commandLine#replay

So the idea, on the second job, to do an mb start followed by an mb replay.

bbyars avatar Mar 14 '22 15:03 bbyars