Posts

Showing posts from February, 2024

MongoDB in Mock Mode: Acting the Server Part

Image
  In the contemporary software development landscape, unit tests have become paramount for ensuring software quality. A prevalent practice during these tests involves mocking outgoing calls to decouple the code under test from external dependencies. Imagine, for a moment, a scenario where instead of writing mocks with pre-defined behaviours, you duplicate the behaviour of a real-world server. Picture a restaurant where the chef's apprentice mimics each of the chef's moves in real-time, creating an identical dish concurrently. That's precisely what we're diving into here. By leveraging the genuine network interactions between the MongoDB client driver and the server, we can emulate the MongoDB server's behaviour, acting almost like the database server itself. Introducing Keploy: Bringing the Mocking Concept to Life Keploy harnesses the aforementioned concept to mock MongoDB operations within test cases. Instead of relying on static mock responses, it captures and use...

Capture gRPC Traffic going out from a Server

Image
  How does  gRPC  work? A quick Google search would tell you that it uses  HTTP/2.0  under the hood, but that's about it. Most available guides talk about gRPC internals by assuming that you are already deeply familiar with  HTTP/2.0 , and the only proper documentation for HTTP/2 is the official RFC document, which doesn't contain implementation details, and talks in abstract terms. All of this might be a bit difficult to grasp, unless you've inspected the capture gRPC traffic manually, at least once. In this blog, we try to capture (log) the request and response from a gRPC client and server. This version assumes that you have access to the source code of the server. NOTE : It is also possible to log the traffic without having access to the source code of the client or server. We will discuss this in future blogs. Start a gRPC Server The  official documentation  guides you on how to create a gRPC server. The  core component  is: func m...