Respect failure rate option with mock responses #1231
-
DescriptionThere will be not failed response if the mock file is used. Expected behaviourthe failure mock can be triggered in mock response mode. Actual behaviourno failure response Steps to reproduce
Microsoft 365 Developer Proxy Version0.10.0 Operating system (environment)Windows ShellPowerShell Additional InfoNo response |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
Hey @xzf0587, this is a currently known limitation, but I fully agree that you should be able to use them in conjunction. We'll get on it. |
Beta Was this translation helpful? Give feedback.
-
Just to clarify, if you set failure rate to 100, the mocks will never be triggered. You're basically saying that you want all requests to be failed by the (Graph)RandomErrorPlugin. If you'd like mocks to work, you'd need to lower the failure rate so that some requests are passed through, and those requests that aren't being failed would then be served from mocks. Does that make sense? |
Beta Was this translation helpful? Give feedback.
-
Yes. Some requests will be failed meanwhile other requests be mocked or passed through. |
Beta Was this translation helpful? Give feedback.
-
Ah sorry, I misunderstood. Yes, with |
Beta Was this translation helpful? Give feedback.
-
OK, so this works as expected with a small adjustment of the configuration. By default, our config is similar to: {
"plugins": [
// [...] trimmed for brevity
{
"name": "GraphMockResponsePlugin",
"enabled": true,
"pluginPath": "plugins\\m365-developer-proxy-plugins.dll",
"configSection": "mocksPlugin"
},
{
"name": "GraphRandomErrorPlugin",
"enabled": true,
"pluginPath": "plugins\\m365-developer-proxy-plugins.dll",
"configSection": "graphRandomErrorsPlugin"
}
// [...] trimmed for brevity
],
// [...] trimmed for brevity
} Proxy executes plugins in the order they're defined in the config. In this case, mocks are executed before random error so if you have a mock defined for a URL, it will never reach the random error. If you want both random errors and mocks, you could change the order of plugins to: {
"plugins": [
// [...] trimmed for brevity
{
"name": "GraphRandomErrorPlugin",
"enabled": true,
"pluginPath": "plugins\\m365-developer-proxy-plugins.dll",
"configSection": "graphRandomErrorsPlugin"
},
{
"name": "GraphMockResponsePlugin",
"enabled": true,
"pluginPath": "plugins\\m365-developer-proxy-plugins.dll",
"configSection": "mocksPlugin"
}
// [...] trimmed for brevity
],
// [...] trimmed for brevity
} That way, random errors will be handled first, and any request that's not randomly failed, will be compared against mocks. There's something to say for both use cases, which is why we made it configurable. I hope this helps. @garrytrinder we should look into clarifying this in our docs. |
Beta Was this translation helpful? Give feedback.
-
Well. Based on this configuration, the proxy can support random errors and mock response simultaneously. |
Beta Was this translation helpful? Give feedback.
-
A new page has been add to our document this Why are random errors not thrown when using mocks |
Beta Was this translation helpful? Give feedback.
OK, so this works as expected with a small adjustment of the configuration.
By default, our config is similar to:
Proxy executes plugins in the order they're defined in the config. In this case, mocks are exe…