You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Respect failure rate option with mock responses #367
changed the title [-][BUG]: failure rate option is not effective when specifying mock response[/-][+]Respect failure rate option with mock responses[/+]on Oct 25, 2023
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?
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?
Yes. Some requests will be failed meanwhile other requests be mocked or passed through.
And I tried the config to set failure rate to 100. But the response is not error response but mock response. Maybe you can help double confirm it. m365proxy.exe -f 100 --mocks-file ./responses.sample.json
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:
Activity
[-][BUG]: failure rate option is not effective when specifying mock response[/-][+]Respect failure rate option with mock responses[/+]waldekmastykarz commentedon Oct 25, 2023
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.
waldekmastykarz commentedon Oct 25, 2023
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?
xzf0587 commentedon Oct 25, 2023
Yes. Some requests will be failed meanwhile other requests be mocked or passed through.
And I tried the config to set failure rate to 100. But the response is not error response but mock response. Maybe you can help double confirm it.
m365proxy.exe -f 100 --mocks-file ./responses.sample.jsonwaldekmastykarz commentedon Oct 26, 2023
Ah sorry, I misunderstood. Yes, with
-f 100you should see random errors rather than mocks. Let me confirm.waldekmastykarz commentedon Oct 26, 2023
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.
xzf0587 commentedon Oct 26, 2023
Well. Based on this configuration, the proxy can support random errors and mock response simultaneously.
Thanks.
garrytrinder commentedon Nov 3, 2023
A new page has been add to our document this Why are random errors not thrown when using mocks