Your source of geek knowledge

Y

Latest stories

Integration Tests in Service Fabric – The structure

I

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

B

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

M

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

M

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

R

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

M

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

M

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...

MultiProducerConcurrentConsumer – Start it

M

In the previous instalment, we discussed the technique of preallocating and reuse to save allocations during runtime. In this post, I will introduce the heart of the MPCC which is the start method and the timer loop outline. The MPCC can get started at any time after construction. If the component is started, it will start pushing items to the pump delegate whenever the batch size is reached or the push interval. This is how the Start method looks like The MPCC can be started once only. There...

Recent Posts