https://linen.dev logo
Title
t

TheUsharik

03/07/2023, 4:18 PM
Hello! I have a question about
repeatsAsScenarios
option if running WireMock as standalone app in docker container. Looks like this option is set to
false
by default because in the logs I see messages like
Not recording mapping for /some/url as this has already been received
In my case it's crucial to record and replay all such queries as a scenario. What can I do here?
r

Rob Elliot

03/07/2023, 4:27 PM
repeatsAsScenarios
is set when you start recording. How are you putting WireMock into record mode? Using the UI, or the Java DSL, or using an HTTP client? If via an HTTP Client, try this:
POST /__admin/recordings/start
{
  "targetBaseUrl": "<http://example.mocklab.io>",
  "repeatsAsScenarios": true
}
t

TheUsharik

03/07/2023, 4:28 PM
I simply pass
--record-mappings
options as a parameter to the docker container
fusion_wiremock:
    image: wiremock/wiremock:latest
    ports:
      - 8080:8080
      - 8443:8443
    volumes:
      - ./wiremock-recordings:/home/wiremock
    command: ['--verbose', '--https-port=8443', '--print-all-network-traffic', '--record-mappings', '--proxy-all=<https://someurl>']
Am I understand correctly that such things could be controlled only by HTTP requests to WireMock instance?
r

Rob Elliot

03/07/2023, 4:29 PM
Ah, I see - I'd forgotten you can set that. Let me look into it.
I think if you want more control over the behaviour you'll need to use the JSON API instead of just setting the command. There's no way to control the
--record-mappings
option beyond what you've used. See https://wiremock.org/docs/record-playback/
t

TheUsharik

03/07/2023, 4:36 PM
Ok. Thank you.
Is it worth to create an issue about such improvements or no one before was interested in that?
r

Rob Elliot

03/07/2023, 4:52 PM
The startup command line option is scheduled for removal, so I’m afraid not
t

TheUsharik

03/07/2023, 4:53 PM
Good to know😀
And in UI we also can't specify those options? Only by request to API?
r

Rob Elliot

03/07/2023, 5:06 PM
That’s right
t

TheUsharik

03/07/2023, 5:37 PM
@Rob Elliot on little extra question. If I need to set
repeatsAsScenarios
without starting of new recording. Which endpoint shall I call?
r

Rob Elliot

03/07/2023, 5:46 PM
You can't, as such. You should start WireMock without
'--record-mappings', '--proxy-all=<https://someurl>'
and then make the HTTP request:
POST /__admin/recordings/start
{
  "targetBaseUrl": "<http://example.mocklab.io>",
  "repeatsAsScenarios": true
}
t

TheUsharik

03/07/2023, 5:47 PM
I think my question is just about reset of the scenario.
r

Rob Elliot

03/07/2023, 6:04 PM
I don't know I'm afraid - not sure I fully understand what you're looking for?
t

TheUsharik

03/07/2023, 6:05 PM
I'm sure now. My problem was because the scenario shall be reset after run to be repeated.
Thanks