mock-server / mockserver

MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).
http://mock-server.com
Apache License 2.0
4.6k stars 1.07k forks source link

Maximum Expectations Limit #794

Closed ghost closed 4 years ago

ghost commented 4 years ago

Describe the issue

It seems that the MockServer can only use the last 1000 expectations configured. Is this true? If it is so, is there any way to increase that?

What you are trying to do

I have created an application that generates the required mocks to our complex environment. It all works well when it generates less than 1000 expectations. If it goes over 1000, some of them (it seems to be the first ones) stop working as the MockServer replies with a 404 NotFound. I have tried to remove some of the expectations to configure less than 1000 and the very same expectations that were not found start to work normally.

MockServer version

5.6.1

To Reproduce Steps to reproduce the issue:

  1. How you are running MockServer

Docker

  1. Code you used to create expectations

A Node application that uses the "mockserver-client": "5.6.1"

  1. What error you saw

The MockServer gives no error on configuration (it accepts all the requests). When the MockServer gets requests, expectations older than the 1000th last configured one are NotFound 404.

Expected behaviour

It should use all the expectations configured and not only the last 1000.

jamesdbloom commented 4 years ago

There is no know limitation except the maxExpectations configuration https://mock-server.com/mock_server/configuration_properties.html#button_configuration_max_expectations.

Can you please provide a reproducer so I can test this.

ghost commented 4 years ago

I have been looking into the MockServer code and it seems a maximum limit is set based on the JVM heap memory or the configured maximum limit (5000?), whatever is lower. So I have increased my JVM heap memory from default 256mb to 2GB and the issue seems to persist. Any ideia?

ghost commented 4 years ago

It is easy to reproduce. I simply configure more than a 1000 expectations and and then request the very first one that has been configured. It gives a 404 NotFound.

scenario.zip

I use an app (that I did not develop) to configure those mocks, but as far as I understood, it simply converts those json files into the appropiate format to be used by the MockServerClient. I see no reference to configurations, specially to the maximum limit.

jamesdbloom commented 4 years ago

Which version of MockServer are you using, as this code in this area was only recently changed.

ghost commented 4 years ago

I believe it is the same as the client, 5.6.1.

ghost commented 4 years ago

After your comments I have decided to give it a couple of tests,

VERSION RESULT
5.6.1 NotFound
5.7.0 Success
5.8.0 Success
5.9.0 Success
5.10.0 Success

So I guess the issue has been solved/changed in the meantime and a simple upgrade should solve the issue. I guess this can be closed. What do you say?

jamesdbloom commented 4 years ago

yes sounds good I'm going to close the issue, thanks for the update