Skip to content

Commit

Permalink
build: uses .NET SDK 7.0
Browse files Browse the repository at this point in the history
deps(client): uses Grpc.Net instead of Grpc.Core
fix: camunda-community-hub#348
  • Loading branch information
xlegalles committed May 31, 2023
1 parent 8d793ee commit f6c67e0
Show file tree
Hide file tree
Showing 30 changed files with 3,401 additions and 3,384 deletions.
2 changes: 1 addition & 1 deletion Client.Cloud.Example/Client.Cloud.Example.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
Expand Down
4 changes: 1 addition & 3 deletions Client.Examples/Client.Examples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

Expand All @@ -12,8 +12,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.19" />
<PackageReference Include="Newtonsoft.Json" version="13.0.3" />
<PackageReference Include="NLog" Version="5.2.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.0" />
Expand Down
4 changes: 1 addition & 3 deletions Client.IntegrationTests/Client.IntegrationTests.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.19" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.2.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.0" />
<PackageReference Include="nunit" Version="3.13.3" />
Expand Down
169 changes: 85 additions & 84 deletions Client.IntegrationTests/ZeebeIntegrationTestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,110 +8,111 @@
using NLog.Extensions.Logging;
using Zeebe.Client;

namespace Client.IntegrationTests;

public class ZeebeIntegrationTestHelper
namespace Client.IntegrationTests
{
public const string LatestVersion = "1.2.4";

public const ushort ZeebePort = 26500;

private readonly string version;
private IZeebeClient client;

private ITestcontainersContainer container;
private int count = 1;

private ZeebeIntegrationTestHelper(string version)
public class ZeebeIntegrationTestHelper
{
this.version = version;
}
public const string LatestVersion = "1.2.4";

public static ZeebeIntegrationTestHelper Latest()
{
return new ZeebeIntegrationTestHelper(LatestVersion);
}
public const ushort ZeebePort = 26500;

public ZeebeIntegrationTestHelper WithPartitionCount(int count)
{
this.count = count;
return this;
}
private readonly string version;
private IZeebeClient client;

public static ZeebeIntegrationTestHelper OfVersion(string version)
{
return new ZeebeIntegrationTestHelper(version);
}

public async Task<IZeebeClient> SetupIntegrationTest()
{
container = CreateZeebeContainer();
await container.StartAsync();
private ITestcontainersContainer container;
private int count = 1;

client = CreateZeebeClient();
await AwaitBrokerReadiness();
return client;
}
private ZeebeIntegrationTestHelper(string version)
{
this.version = version;
}

public async Task TearDownIntegrationTest()
{
try
public static ZeebeIntegrationTestHelper Latest()
{
client.Dispose();
client = null;
return new ZeebeIntegrationTestHelper(LatestVersion);
}
finally

public ZeebeIntegrationTestHelper WithPartitionCount(int count)
{
await container.StopAsync();
container = null;
this.count = count;
return this;
}
}

private TestcontainersContainer CreateZeebeContainer()
{
return new TestcontainersBuilder<TestcontainersContainer>()
.WithImage(new DockerImage("camunda", "zeebe", version))
.WithPortBinding(ZeebePort, true)
.WithEnvironment("ZEEBE_BROKER_CLUSTER_PARTITIONSCOUNT", count.ToString())
.Build();
}
public static ZeebeIntegrationTestHelper OfVersion(string version)
{
return new ZeebeIntegrationTestHelper(version);
}

private IZeebeClient CreateZeebeClient()
{
var loggerFactory = LoggerFactory.Create(loggingBuilder =>
public async Task<IZeebeClient> SetupIntegrationTest()
{
// configure Logging with NLog
loggingBuilder.ClearProviders();
loggingBuilder.SetMinimumLevel(LogLevel.Trace);
var path = Path.Combine(Directory.GetCurrentDirectory(), "NLog.config");
loggingBuilder.AddNLog(path);
});

// It has to be a valid Uri
// e.g. IP address without scheme or hostname with scheme
var host = "http://" + container.Hostname + ":" + container.GetMappedPublicPort(ZeebePort);

return ZeebeClient.Builder()
.UseLoggerFactory(loggerFactory)
.UseGatewayAddress(host)
.UsePlainText()
.Build();
}
container = CreateZeebeContainer();
await container.StartAsync();

private async Task AwaitBrokerReadiness()
{
var ready = false;
do
client = CreateZeebeClient();
await AwaitBrokerReadiness();
return client;
}

public async Task TearDownIntegrationTest()
{
try
{
var topology = await client.TopologyRequest().Send();
ready = topology.Brokers[0].Partitions.Count >= count;
client.Dispose();
client = null;
}
catch (Exception)
finally
{
// retry
await container.StopAsync();
container = null;
}
} while (!ready);
}

private TestcontainersContainer CreateZeebeContainer()
{
return new TestcontainersBuilder<TestcontainersContainer>()
.WithImage(new DockerImage("camunda", "zeebe", version))
.WithPortBinding(ZeebePort, true)
.WithEnvironment("ZEEBE_BROKER_CLUSTER_PARTITIONSCOUNT", count.ToString())
.Build();
}

private IZeebeClient CreateZeebeClient()
{
var loggerFactory = LoggerFactory.Create(loggingBuilder =>
{
// configure Logging with NLog
loggingBuilder.ClearProviders();
loggingBuilder.SetMinimumLevel(LogLevel.Trace);
var path = Path.Combine(Directory.GetCurrentDirectory(), "NLog.config");
loggingBuilder.AddNLog(path);
});

// It has to be a valid Uri
// e.g. IP address without scheme or hostname with scheme
var host = "http://" + container.Hostname + ":" + container.GetMappedPublicPort(ZeebePort);

return ZeebeClient.Builder()
.UseLoggerFactory(loggerFactory)
.UseGatewayAddress(host)
.UsePlainText()
.Build();
}

private async Task AwaitBrokerReadiness()
{
var ready = false;
do
{
try
{
var topology = await client.TopologyRequest().Send();
ready = topology.Brokers[0].Partitions.Count >= count;
}
catch (Exception)
{
// retry
}
} while (!ready);
}
}
}
Loading

0 comments on commit f6c67e0

Please sign in to comment.