team, trying to add both scenario and state for mo...
# help
d
team, trying to add both scenario and state for mock purpose. It is working in my local, but not over an environment. Any quick possible reasone that you might know
{
"priority": 2,
"scenarioName": "To do list",
"requiredScenarioState": "Started",
"request": {
"method": "POST",
"urlPathPattern": "/wiremock/resource/3",
"bodyPatterns": [
{
"matchesXPath": "//resource/2[contains(text(),'000879654321')]"
}
]
},
"response": {
"status": 202
},
"serveEventListeners": [
{
"name": "recordState",
"parameters": {
"context": "sss",
"list": {
"addFirst": {
"SId": "{{xPath request.body '//SId/text()'}}"
}
}
}
}
]
}
l
No idea off the top of my head. Could you give more details of what you mean when you say it isn’t working ? Are both scenarios and state not working or just one of them ?
And when you say “over and environment” do you mean in CI or are you running your Wiremock instance in one of your environments?
d
The first stub of scenario is working as expected. 2nd and 3rd stub is not at all executing. Running wiremock in pre_prod env. I might need to look the logs there to understand why it's not pocking that stub
Anyway I have found alternative way using some priority and other stuff, But will look upon it definitely bit later
l
Yeah. If it is working locally then it definitely sounds environmental. Would be good to see what the logs say if anything. Are you starting it in verbose mode in pre production?
d
nope, due to memory issue. But will enable it to debug same.
tried to check logs, it's only saying [path] /wiremock/resource/1 | /wiremock/resource/resource22/1 <<<<< URL does not match
state functionality as below is working-
Copy code
"customMatcher": {
  "name": "state-matcher",
  "parameters": {
    "hasContext": "getRes1"
  }
}
but it is NOT working in an environment if I change same to below-
Copy code
"customMatcher": {
  "name": "state-matcher",
  "parameters": {
    "hasContext": "getRes1",
    "listSizeMoreThan": "0"
  }
}
Things I checked, still it is yet to work • used same command at local to check which is being used at env level-> seems fine • used same version at env level w.r.t. local one
Pls help me with- do we need any extension or similar need to be added in command or similar at docker level
l
It is really hard to know what is going on in your environment unfortunately. Might be worth trying to break the problem up a little. For example, focus on why the url is not being matched in your environment but it is locally. Once you have figured that out you can then move onto the state functionality. For example, in your request, why is it referencing
resource22
in the url when it isn't in the mocked url ?
d
why the url is not being matched in your environment but it is locally: Because it evaluates condition first in order to match that URL right. It seems locally it supports
"listSizeMoreThan": "0"
but not over env, not sure why
why is it referencing
resource22
in the url when it isn't in the mocked url ?: It's an another request mocked. It is trying to match nearest URL that as above mentioned condition didn't satisfy
l
I am not sure why the list size check on the customer matcher would not be working in your environment but it is locally. Maybe in your environment something is stopping the items being added to the list ?? Maybe @Dirk Bolte might have an idea?
d
I wonder whether the extension might not be loaded correctly. When loaded correctly, you should see the following extensions on startup:
stateTransaction,state-matcher,state,recordState,deleteState
. In case you run with verbose on, you should see various log outputs (e.g.
list::addFirst
). The standalone extension as of version 0.8.0 still uses it's own store implementation (caffeine), so there should be no environment dependency. TBOMK caffeine does not clean up the cache by itself on OOM, so limited memory should not have an impact (just because I saw memory mentioned above)
d
We are using docker based architecture on environment level. I tried locally using jar based command as below- java -Xms256m -Xmx2048m -cp "wiremock-standalone.jar:wiremock-state-extension.jar" wiremock.Run --verbose --global-response-templating --disable-gzip --disable-request-logging --no-request-journal I can see all these things locally - e.g.
list::addFirst
But I need to get access to see things at environment level. I'm on that. Lil surprised to see
"hasContext": "getRes1"
work alone but not with
"listSizeMoreThan": "0"
. As both are part of state feature only. I see in our docker file- FROM wiremock/wiremock:3.9.0-alpine I am wondering what is alpine doing here
l
Alpine is one of the images we provide. You don't have to use alpine though if you wanted to try something different - https://hub.docker.com/r/wiremock/wiremock
d
Okay 👍