Preqin had built a number of tests which verified interactions with Elasticsearch. These tests communicated with a networked deployment of Elasticsearch which had led to a number of problems. Fortunately Elastic Mint were on hand to provide the solution.
Elastic Mint client Preqin, have built a significant amount of their system around the capabilities of Elasticsearch. Recognising from the start the importance of automated tests they had built a number of tests which verified interactions with Elasticsearch. The only problem was that these tests communicated with a networked deployment of Elasticsearch. This led to a number of problems:
Taken together these problems meant that Preqin were considering removing these tests as it wasn’t clear that the benefit of having them outweighed the risks of removing them.
Elastic Mint investigated this problem and found a tool that could resolve the problem – an open-source library called Elasticsearch Inside. This library provides an in-memory copy of Elasticsearch which could be started locally at the beginning of a test run and then stopped at the end. As everything is run locally there is no longer a need to be connected to a network and there is no chances of test runs interfering with each other.
Additionally Elastic Mint brought XUnit into the solution. Up to this point Preqin had been using NUnit as their testing framework. XUnit brought the ability to easily perform an action before and after running a group of tests in different test classes. We built a framework for use in the test project that performed the following things:
Having proved our approached Elastic Mint then shared what we had done in a tech talk with Preqin’s engineering department.
The end result was that tests became reliable, test runs became faster, and the patterns were adopted in multiple projects, thus helping Preqin to maintain confidence in the quality of their codebase.