tedvanderveen / service-fabric-run-tests

This project is a Docker image designed to run Service Fabric oriented unit-tests (.NET Core) on Linux.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What this image is about?

This image is designed to run Service Fabric oriented unit-tests (.NET Core) on Linux.

The latest version can be found on DockerHub.

Why is that needed?

Consider the following simple test:

public class MyStatefulService : Microsoft.ServiceFabric.Services.Runtime.StatefulService
{
    public MyStatefulService(
        StatefulServiceContext serviceContext)
        : base(serviceContext)
    {
    }

    protected override Task RunAsync(
        CancellationToken cancellationToken)
    {
        if (cancellationToken.IsCancellationRequested)
        {
            throw new InvalidOperationException();
        }
        return Task.CompletedTask;
    }
}

public class MyStatefulServiceTests
{
    [Fact]
    public async Task RunAsync_Should_raise_InvalidOperationException_When_CancellationToken_is_cancelled()
    {
        // Arrange
        var instance = new MyStatefulService(MockStatefulServiceContextFactory.Default);
        var cancellationTokenSource = new CancellationTokenSource();
        
        // Act, Assert
        cancellationTokenSource.Cancel();

        await Assert.ThrowsAsync<InvalidOperationException>(() => instance.InvokeRunAsync(cancellationTokenSource.Token));
    }
}

Despite it's simplicity this unit-test requires installed servicefabric runtime and servicefabricsdkcommon package installed to run. These packages cannot be installed as part of container build see issue.

The image solves the exactly this problem by performing manual copy of the required files from the packages.

Tags

  • latest

    The latest tag is the same as runtime.ver-dotnetsdk.ver with the latest available version of runtime and sdk.

  • latest-light

    The latest-light tag is the same as runtime.ver-light with the latest available version of runtime.

  • <runtime.ver-dotnetsdk.ver>

    When image is tagged as runtime.ver-dotnetsdk.ver format i.e. images like 6.4.634.1-2.2 this indicates that current image has binaries from servicefabric=6.4.634.1 runtime and has dotnet-2.2-sdk installed.

  • <runtime.ver-light>

    When image is tagged as runtime.ver-light format i.e. image tag 6.4.634.1-light this indicates that current image has binaries from servicefabric=6.4.634.1 runtime installed. The purpose of this image is to provide more flexibility for scenarios where version of dotnet sdk can vary significantly.

Authors

This project is owned and maintained by Coherent Solutions.

About

This project is a Docker image designed to run Service Fabric oriented unit-tests (.NET Core) on Linux.

License:MIT License


Languages

Language:Dockerfile 100.0%