Your source of geek knowledge


Latest stories

Integration Tests in Service Fabric – Test definition


In the last post I gave an overview of the conventions that drive the solution structure and define the test applications. All the code I’m going to explore in this, and future blog posts can be found on my ServiceFabric.Testing repository. The code in the repository doesn’t use the OrderShipping analogy used in the post, but I’ll hope you still get the point ;). The OrderShippingTests project stateful service has to inherit from the stateful service called AbstractTestRunner...

Integration Tests in Service Fabric – The structure


In my last post, I gave a quick overview how running tests inside Service Fabric looks like both from Visual Studio and Jetbrains Rider. To be able to dive deeper into the infrastructure, I want to present the high-level component pieces first. Every project has its own conventions how tests are componentized and structured around the production code. Many teams I’ve seen usually have a dedicated assembly per production assembly which contains a certain category of tests. For example, if...

Better way of running integration tests inside Service Fabric


In the last post, I showed how you could run integration tests inside Service Fabric. The approach I showed has one mature problem: It is not possible to reliably run these tests from within your favourite IDE of choices like Visual Studio or Jetbrains Rider. Today I’ll show you a more sophisticated approach to run tests inside Service Fabric including support to run the tests from within any IDE that allows running NUnit tests. Here is a short video how it looks like. The video is...

MultiProducerConcurrentConsumer – Asynchronous synchronisation


In the last post I explained how the push in batches up to the concurrency per slot works. This post covers the asynchronous synchronisation approach I used to unleash the push in batches when the batch size is reached. In the code shown in the Push It post I simplified the synchronisation primitive and called it syncEvent. In reality, the code uses a TaskCompletionSource for synchronisation. The MPCC declares a field of type TaskCompletionSource<bool>. For the MPCC the TResult type of...

MultiProducerConcurrentConsumer – Push in batches up to concurrency per slot


In the previous post I introduced the PushInBatches method who’s responsibility it is to start the PushInBatchesUpToConcurrencyPerQueueForAGivenSlot process. In this post I will focus on the mouthful method above. Like the name of the method already suggest its responsibility is to push items for a slot in batches to the pump delegate while respecting the concurrency settings per slot as provided by the user and explained in the introduction post. Without further ado here is the whole...

Running integration tests inside Service Fabric


I’m currently diving into Service Fabric. One of the difficult things that you’ll be faced with when you write code against the Service Fabric APIs is how you can integration test those components. Infrastructure like the reliable state manager is only available inside Service Fabric. So somehow you need to run the tests that are testing the components that use infrastructure like reliable state manager inside the cluster. In this post, I show you an approach which allows running...

MultiProducerConcurrentConsumer – Push in batches


In the last post, I introduced the push method and the timer loop of the MultiProducerConcurrentConsumer. In this post, I’ll focus on the actual PushInBatches method that gets called by the timer loop. When the method is entered it first checks whether there is anything to push. Since numberOfPushedItems is accessed by multiple threads it uses Interlocked to read it and compare the returned value. When there is nothing to push a completed task is return. By not using the async keyword...

MultiProducerConcurrentConsumer – Push it


In the last post, I introduced the start procedure for the MultiProducerConcurrentConsumer including a rough outline of the timer loop responsible for pushing items in batches after the push interval is elapsed. To understand how the batch size affects the push let me first explain the push method. The push method’s responsibility is primarily to insert the item of type TItem into the right slot. To achieve that the passed in slot number is range checked against the available number of...

Recent Posts