Wiremock: Delete a stub which was saved using admin API does not remove from backing store

Created on 25 Dec 2019  路  6Comments  路  Source: tomakehurst/wiremock

The stub which was saved using Admin API endpoint /__admin/mappings/save DOES NOT get deleted from backing store.

Version of WireMock: wiremock-standalone-2.24.1
Started with CLI: java -jar wiremock-standalone-2.24.1.jar --port 8181
Steps to reproduce:
All steps should be executed using admin API

  1. Post a stub
    Example:
{
    "request": {
        "method": "GET",
        "url": "/some/thing"
    },
    "response": {
        "status": 200,
        "body": "Hello world!",
        "headers": {
            "Content-Type": "text/plain"
        }
    }
}
  1. Persist stub using /__admin/mappings/save
  2. Delete the stub using /__admin/mappings/{stubMappingId}
  3. Verify the stub is deleted from backing store

Actual Behaviour:
The stub does not get deleted from backing store

Expected Behaviour:
The stub should also be deleted from backing store

Bug

Most helpful comment

For clarity - I'm planning to fix the persistent flag problem, just not change the semantics of the API call.

All 6 comments

This is an annoying bug because it deletes the mock "in memory" but not on disk, as the result it is not idempotent: if you do twice the DELETE it generates an error "status 404 reading WiremockClient#deleteStub(UUID)" the second time.

Do you think you could seize this bug opportunity to make the DELETE indempotent ?

It's already idempotent. The problem is here is just that when you persist a stub via the save call it doesn't mark it as persistent, so doesn't attempt to delete it from the disk when removed from the set.

Yes, it does get removed from desk on delete if it's persisted by setting a persistent attribute to true. That's the workaround we follow to eradicate the duplicates currently since the deletion didn't work and all the undeleted stubs get loaded on server restart.

For clarity - I'm planning to fix the persistent flag problem, just not change the semantics of the API call.

That'll be great

Was this page helpful?
0 / 5 - 0 ratings