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

Adding admin route for resetting a specific scenario by name #1079

Closed
wants to merge 6 commits into from

Conversation

matthewwilson
Copy link

@matthewwilson matthewwilson commented Feb 5, 2019

This PR adds a new admin endpoint:

POST /scenarios/reset/{scenarioName}

This will reset the state of the given scenario name.

I believe this will fix issue #847 as well as suit a use case for our own project.

@matthewwilson
Copy link
Author

@tomakehurst not sure why travis is failing, tests are passing locally for me. Am I missing a step before I should have created the PR?

@matthewwilson
Copy link
Author

Looks like travis is failing because:

java.lang.IllegalArgumentException: resource swagger/wiremock-admin-api.json not found.

Is this file supposed to be autogenerated?

@matthewwilson
Copy link
Author

Got the build passing however not sure it is the best solution. The issue was that the generateAPIDocs task was not running before test. I tried making test depend on generateAPIDocs however that didn't fix it. Last resort was to move the tasks out of the subtasks project and call generateAPIDocs before test in the travis file.

@szekar1
Copy link
Contributor

szekar1 commented Sep 15, 2020

Hi @tomakehurst @matthewwilson,
any plans of including this in upcoming releases?

Best Regards,
Karol

@FrankSandou
Copy link

Hi ,@tomakehurst @matthewwilson,
Could you add this in next release?i need this functional

@tomakehurst
Copy link
Member

@FrankSandou there's a workaround for this which is to create a stub (mapped to a URL that's not in the API you're mocking) that resets the relevant scenario when you request it.

@FrankSandou
Copy link

@FrankSandou there's a workaround for this which is to create a stub (mapped to a URL that's not in the API you're mocking) that resets the relevant scenario when you request it.

I need for one scenario reset state , not for all , could you add this feature in release (hotfix) @tomakehurst

Best regards, Frank

@tomakehurst
Copy link
Member

The workaround is for resetting single scenario state.

@FrankSandou
Copy link

The workaround is for resetting single scenario state.
@tomakehurst
Yes, i need this , could you merge in master?

Best regards, Frank

@tomakehurst
Copy link
Member

No, I mean the workaround I described works for a single scenario. You don't need this PR to be merged to be able to set a single scenario's state - just create a stub that does that for you.

@FrankSandou
Copy link

FrankSandou commented Dec 14, 2020

No, I mean the workaround I described works for a single scenario. You don't need this PR to be merged to be able to set a single scenario's state - just create a stub that does that for you.

Hmm, how i can reset one state for one scenario, if i have 5 scenarios with different states?, only this fix, please merge this , i need this very , and wait for this api routing ... @tomakehurst

Best regards, Frank

@tomakehurst
Copy link
Member

I'm sorry, but I'm not planning to do a WireMock release in the timeframe you're hoping for.

I suggest you configure a stub for each scenario you want to reset and the make a request that matches the appropriate stub when you want to perform the reset.

@FrankSandou
Copy link

I'm sorry, but I'm not planning to do a WireMock release in the timeframe you're hoping for.

I suggest you configure a stub for each scenario you want to reset and the make a request that matches the appropriate stub when you want to perform the reset.

I'm sorry, but I'm not planning to do a WireMock release in the timeframe you're hoping for.

@tomakehurst are you planned release in next year January or February ?
I hope and wait for this feature in next release .
Best regards, Frank

@matthewwilson
Copy link
Author

@FrankSandou it looks like the workaround suggested by @tomakehurst will work.

Let's say you have a stub that is in a state called "state-1" and you want to reset it back to "started". Simply define another stub that exists purely to reset the state. E.g.

{
    "scenarioName": "My Scenario",
    "requiredScenarioState": "state-1",
    "newScenarioState": "started",
    "request": {
        "method": "POST",
        "url": "/state-management/reset-my-scenario"
    },
    "response": {
        "status": 200
    }
}

@tomakehurst tomakehurst added this to To do in WireMock 2.32.0 Nov 2, 2021
@tomakehurst tomakehurst moved this from To do to In progress in WireMock 2.32.0 Nov 3, 2021
@tomakehurst tomakehurst moved this from In progress to To do in WireMock 2.32.0 Nov 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants