Help! Thousands of mappings & memory overload. #1015
-
I'm looking for away to setup the server to record and save a few thousands requests that I will later use for testing and development. However, in order to use the static mappings, the server is currently loading everything in to memory on startup and sucking up all my ram and taking in excess of 10 minutes to spin up. I was thinking about saving the responses somehow using a hash for a folder name or filename that I generate from the request, and only fetching the response/mapping from the filesystem if a request hash matches with a recorded mapping. Any clue on how I could set that up? Anyone? Example of how I'm expecting the setup to work, but have yet to be able to save any mappings using it. void SetupMappings(WireMockServer server)
{
for (int currentPage = 1; currentPage <= 5000; currentPage++)
{
var builder = new ProductRequestBuilder<VirtualProductRequest>();
var productRequest = builder.AddCategoryId(23621)
.AddInclude(ProductInclude.ExcludeAll)
.AddFilter(ProductFilter.Orderable)
.SetPageSize(500)
.SetPage(currentPage)
.Build();
var requestJson = JsonConvert.SerializeObject(productRequest);
var serverRequest = Request
.Create()
.WithPath("/v2/products/virtual")
.WithBody(new JsonMatcher(requestJson))
.UsingPost();
var filePath = Directory.GetCurrentDirectory();
var requestId = Guid.NewGuid().ToString();
filePath = $@"{filePath}\__admin\mappings\__files\category\{requestId}.json";
var serverResponse = Response
.Create()
.WithBodyFromFile(filePath);
server
.Given(serverRequest)
.WithGuid(requestId)
.RespondWith(serverResponse);
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I resolved the issue by creating an implementation of the IFileSystemHandler:
|
Beta Was this translation helpful? Give feedback.
I resolved the issue by creating an implementation of the IFileSystemHandler: