From 10fd68745d3d550f7730f46120fc30d2d8a1eb66 Mon Sep 17 00:00:00 2001 From: Luke Bakken Date: Thu, 17 Feb 2022 09:01:24 -0800 Subject: [PATCH] Update all projects to net6.0 Update versions to beta.4 Re-instate the ApiApproval test. Bump cache versions, add skip for ApiApproval on Linux Ensure net6.0 is available on Windows See if a longer close timeout fixes a flaky test. --- .github/workflows/main.yaml | 16 +++++++----- .github/workflows/nuget.yml | 4 +-- Docker/Dockerfile | 3 +-- .../RabbitMQ.Stream.Client.PerfTest.fsproj | 2 +- RabbitMQ.Stream.Client/Client.cs | 11 +++++--- RabbitMQ.Stream.Client/Consts.cs | 4 +-- .../RabbitMQ.Stream.Client.csproj | 8 +++--- Tests/ApiApproval.Approve.verified.txt | 25 ++++++++++++++----- Tests/ApiApproval.cs | 5 +++- Tests/Tests.csproj | 14 +++++------ 10 files changed, 57 insertions(+), 35 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 067ec3bb..ea314ef1 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -15,22 +15,26 @@ jobs: steps: - name: Clone repository uses: actions/checkout@v2 + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.x - name: Cache installers uses: actions/cache@v2 with: # Note: the cache path is relative to the workspace directory # https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action path: ~/installers - key: ${{ runner.os }}-v0-${{ hashFiles('tools/versions.json') }} + key: ${{ runner.os }}-v1-${{ hashFiles('tools/versions.json') }} - name: Cache NuGet packages uses: actions/cache@v2 with: path: | ~/.nuget/packages ~/AppData/Local/NuGet/v3-cache - key: ${{ runner.os }}-v1-nuget-${{ hashFiles('**/*.csproj') }} + key: ${{ runner.os }}-v2-nuget-${{ hashFiles('**/*.csproj') }} restore-keys: | - ${{ runner.os }}-v1-nuget- + ${{ runner.os }}-v2-nuget- - name: Install and start RabbitMQ run: ./tools/install.ps1 - name: List NuGet sources @@ -65,16 +69,16 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0.x + dotnet-version: 6.0.x - name: Cache NuGet packages uses: actions/cache@v2 with: path: | ~/.nuget/packages ~/.local/share/NuGet/v3-cache - key: ${{ runner.os }}-v1-nuget-${{ hashFiles('**/*.csproj') }} + key: ${{ runner.os }}-v2-nuget-${{ hashFiles('**/*.csproj') }} restore-keys: | - ${{ runner.os }}-v1-nuget- + ${{ runner.os }}-v2-nuget- - name: List NuGet sources run: dotnet nuget locals all --list - name: Restore diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index 4a879e04..88dc60b7 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -26,7 +26,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0.x + dotnet-version: 6.0.x - name: Restore dependencies run: dotnet restore - name: Build @@ -34,7 +34,7 @@ jobs: - name: Test run: dotnet test Tests/Tests.csproj --no-build --logger "console;verbosity=detailed" /p:AltCover=true - name: Publish RabbitMQ.Stream.Client - uses: brandedoutcast/publish-nuget@v2.5.2 + uses: brandedoutcast/publish-nuget@v2.5.5 with: PROJECT_FILE_PATH: RabbitMQ.Stream.Client/RabbitMQ.Stream.Client.csproj NUGET_KEY: ${{secrets.NUGET_API_KEY}} diff --git a/Docker/Dockerfile b/Docker/Dockerfile index d7bd120c..471f5a35 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,6 +1,5 @@ FROM pivotalrabbitmq/rabbitmq-stream - RUN wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb RUN dpkg -i packages-microsoft-prod.deb RUN rm packages-microsoft-prod.deb @@ -8,6 +7,6 @@ RUN rm packages-microsoft-prod.deb RUN apt-get update && \ apt-get install -y apt-transport-https && \ apt-get update && \ - apt-get install -y dotnet-sdk-5.0 + apt-get install -y dotnet-sdk-6.0 RUN apt-get install make -y diff --git a/RabbitMQ.Stream.Client.PerfTest/RabbitMQ.Stream.Client.PerfTest.fsproj b/RabbitMQ.Stream.Client.PerfTest/RabbitMQ.Stream.Client.PerfTest.fsproj index 7f14014f..b76481cd 100644 --- a/RabbitMQ.Stream.Client.PerfTest/RabbitMQ.Stream.Client.PerfTest.fsproj +++ b/RabbitMQ.Stream.Client.PerfTest/RabbitMQ.Stream.Client.PerfTest.fsproj @@ -2,7 +2,7 @@ Exe - net5.0 + net6.0 RabbitMQ.Stream.Client.Cmd diff --git a/RabbitMQ.Stream.Client/Client.cs b/RabbitMQ.Stream.Client/Client.cs index b7ff530d..fa1d8a8b 100644 --- a/RabbitMQ.Stream.Client/Client.cs +++ b/RabbitMQ.Stream.Client/Client.cs @@ -104,6 +104,8 @@ public int Write(Span span) public class Client : IClient { + private readonly TimeSpan defaultTimeout = TimeSpan.FromSeconds(10); + private uint correlationId = 0; // allow for some pre-amble private byte nextPublisherId = 0; @@ -278,14 +280,14 @@ await Request(corr => return result; } - private async ValueTask Request(Func request, int timeout = 10000) + private async ValueTask Request(Func request, TimeSpan? timeout = null) where TIn : struct, ICommand where TOut : struct, ICommand { var corr = NextCorrelationId(); var tcs = PooledTaskSource.Rent(); requests.TryAdd(corr, tcs); await Publish(request(corr)); - using CancellationTokenSource cts = new CancellationTokenSource(timeout); + using CancellationTokenSource cts = new CancellationTokenSource(timeout ?? defaultTimeout); await using (cts.Token.Register( valueTaskSource => ((ManualResetValueTaskSource) valueTaskSource).SetException( @@ -450,7 +452,8 @@ public async Task Close(string reason) return (CloseResponse) closeResponse; } - var result = await Request(corr => new CloseRequest(corr, reason)); + // TODO LRB timeout + var result = await Request(corr => new CloseRequest(corr, reason), TimeSpan.FromSeconds(30)); closeResponse = result; try @@ -568,4 +571,4 @@ void IValueTaskSource.OnCompleted(Action continuation, object state, sho void IValueTaskSource.OnCompleted(Action continuation, object state, short token, ValueTaskSourceOnCompletedFlags flags) => _logic.OnCompleted(continuation, state, token, flags); } -} \ No newline at end of file +} diff --git a/RabbitMQ.Stream.Client/Consts.cs b/RabbitMQ.Stream.Client/Consts.cs index e8328a49..e1e0a289 100644 --- a/RabbitMQ.Stream.Client/Consts.cs +++ b/RabbitMQ.Stream.Client/Consts.cs @@ -2,6 +2,6 @@ namespace RabbitMQ.Stream.Client { public static class Consts { - public const string ClientVersion = "1.0.0-beta.3"; + public const string ClientVersion = "1.0.0-beta.4"; } -} \ No newline at end of file +} diff --git a/RabbitMQ.Stream.Client/RabbitMQ.Stream.Client.csproj b/RabbitMQ.Stream.Client/RabbitMQ.Stream.Client.csproj index ad9bb3e6..e1c16c07 100644 --- a/RabbitMQ.Stream.Client/RabbitMQ.Stream.Client.csproj +++ b/RabbitMQ.Stream.Client/RabbitMQ.Stream.Client.csproj @@ -1,11 +1,11 @@ - net5.0 + net6.0 RabbitMQ.Stream.Client RabbitMQ.Stream.Client - 1.0.0-beta.3 - 1.0.0-beta.3 + 1.0.0-beta.4 + 1.0.0-beta.4 VMware https://github.com/rabbitmq/rabbitmq-stream-dotnet-client The RabbitMQ Stream .NET client is the official client library for C# (and, implicitly, other .NET languages) @@ -26,6 +26,6 @@ - + diff --git a/Tests/ApiApproval.Approve.verified.txt b/Tests/ApiApproval.Approve.verified.txt index 42889f8a..ce72a138 100644 --- a/Tests/ApiApproval.Approve.verified.txt +++ b/Tests/ApiApproval.Approve.verified.txt @@ -183,7 +183,7 @@ namespace RabbitMQ.Stream.Client public System.Threading.Tasks.Task Close(string reason) { } public System.Threading.Tasks.ValueTask CreateStream(string stream, System.Collections.Generic.IDictionary args) { } public System.Threading.Tasks.ValueTask Credit(byte subscriptionId, ushort credit) { } - public System.Threading.Tasks.Task> DeclarePublisher(string publisherRef, string stream, System.Action> confirmCallback, System.Action[]> errorCallback) { } + public System.Threading.Tasks.Task> DeclarePublisher(string publisherRef, string stream, System.Action> confirmCallback, System.Action[]> errorCallback) { } public System.Threading.Tasks.Task DeletePublisher(byte publisherId) { } public System.Threading.Tasks.ValueTask DeleteStream(string stream) { } public System.Threading.Tasks.ValueTask Publish(RabbitMQ.Stream.Client.Publish publishMsg) { } @@ -203,6 +203,7 @@ namespace RabbitMQ.Stream.Client public ClientParameters() { } protected ClientParameters(RabbitMQ.Stream.Client.ClientParameters original) { } public RabbitMQ.Stream.Client.AddressResolver AddressResolver { get; set; } + public string ClientProvidedName { get; set; } public System.Net.EndPoint Endpoint { get; set; } protected virtual System.Type EqualityContract { get; } public System.Action MetadataHandler { get; set; } @@ -272,7 +273,7 @@ namespace RabbitMQ.Stream.Client } public static class Consts { - public const string ClientVersion = "1.0.0-beta.3"; + public const string ClientVersion = "1.0.0-beta.4"; } public class Consumer : RabbitMQ.Stream.Client.AbstractEntity, System.IDisposable { @@ -281,10 +282,11 @@ namespace RabbitMQ.Stream.Client public System.Threading.Tasks.Task StoreOffset(ulong offset) { } public static System.Threading.Tasks.Task Create(RabbitMQ.Stream.Client.ClientParameters clientParameters, RabbitMQ.Stream.Client.ConsumerConfig config, RabbitMQ.Stream.Client.StreamInfo metaStreamInfo) { } } - public class ConsumerConfig : System.IEquatable + public class ConsumerConfig : RabbitMQ.Stream.Client.INamedEntity, System.IEquatable { public ConsumerConfig() { } protected ConsumerConfig(RabbitMQ.Stream.Client.ConsumerConfig original) { } + public string ClientProvidedName { get; set; } public System.Func ConnectionClosedHandler { get; set; } protected virtual System.Type EqualityContract { get; } public System.Func MessageHandler { get; set; } @@ -435,6 +437,10 @@ namespace RabbitMQ.Stream.Client System.Buffers.ReadOnlySequence UnCompress(System.Buffers.ReadOnlySequence source, uint dataLen, uint unCompressedDataSize); int Write(System.Span span); } + public interface INamedEntity + { + string ClientProvidedName { get; set; } + } public interface IOffsetType { RabbitMQ.Stream.Client.OffsetTypeEnum OffsetType { get; } @@ -526,6 +532,10 @@ namespace RabbitMQ.Stream.Client public System.Buffers.ReadOnlySequence UnCompress(System.Buffers.ReadOnlySequence source, uint dataLen, uint unCompressedDataSize) { } public int Write(System.Span span) { } } + public class OffsetNotFoundException : RabbitMQ.Stream.Client.ProtocolException + { + public OffsetNotFoundException(string s) { } + } public enum OffsetTypeEnum { First = 1, @@ -632,10 +642,11 @@ namespace RabbitMQ.Stream.Client public System.Threading.Tasks.ValueTask Send(ulong publishingId, System.Collections.Generic.List subEntryMessages, RabbitMQ.Stream.Client.CompressionType compressionType) { } public static System.Threading.Tasks.Task Create(RabbitMQ.Stream.Client.ClientParameters clientParameters, RabbitMQ.Stream.Client.ProducerConfig config, RabbitMQ.Stream.Client.StreamInfo metaStreamInfo) { } } - public class ProducerConfig : System.IEquatable + public class ProducerConfig : RabbitMQ.Stream.Client.INamedEntity, System.IEquatable { public ProducerConfig() { } protected ProducerConfig(RabbitMQ.Stream.Client.ProducerConfig original) { } + public string ClientProvidedName { get; set; } public System.Action ConfirmHandler { get; set; } public System.Func ConnectionClosedHandler { get; set; } protected virtual System.Type EqualityContract { get; } @@ -675,7 +686,7 @@ namespace RabbitMQ.Stream.Client { public const ushort Key = 4; public byte PublisherId { get; } - public System.ValueTuple<, >[] PublishingErrors { get; } + public System.ValueTuple[] PublishingErrors { get; } public int SizeNeeded { get; } public int Write(System.Span span) { } } @@ -734,6 +745,7 @@ namespace RabbitMQ.Stream.Client AccessRefused = 16, PreconditionFailed = 17, PublisherDoesNotExist = 18, + OffsetNotFound = 19, } public class Routing : RabbitMQ.Stream.Client.IRouting { @@ -861,11 +873,12 @@ namespace RabbitMQ.Stream.Client public System.Threading.Tasks.Task StreamExists(string stream) { } public static System.Threading.Tasks.Task Create(RabbitMQ.Stream.Client.StreamSystemConfig config) { } } - public class StreamSystemConfig : System.IEquatable + public class StreamSystemConfig : RabbitMQ.Stream.Client.INamedEntity, System.IEquatable { public StreamSystemConfig() { } protected StreamSystemConfig(RabbitMQ.Stream.Client.StreamSystemConfig original) { } public RabbitMQ.Stream.Client.AddressResolver AddressResolver { get; set; } + public string ClientProvidedName { get; set; } public System.Collections.Generic.IList Endpoints { get; set; } protected virtual System.Type EqualityContract { get; } public string Password { get; set; } diff --git a/Tests/ApiApproval.cs b/Tests/ApiApproval.cs index cba1306f..df4a240c 100644 --- a/Tests/ApiApproval.cs +++ b/Tests/ApiApproval.cs @@ -29,6 +29,7 @@ // Copyright (c) 2007-2020 VMware, Inc. All rights reserved. //--------------------------------------------------------------------------- +using System; using System.Threading.Tasks; using RabbitMQ.Stream.Client; @@ -43,9 +44,11 @@ namespace Tests [UsesVerify] public class ApiApproval { - [Fact(Skip="Fails on Linux")] + [SkippableFact] public Task Approve() { + Skip.IfNot(OperatingSystem.IsWindows()); + string publicApi = typeof(Client).Assembly.GeneratePublicApi(new ApiGeneratorOptions { ExcludeAttributes = new[] diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index b86d77e0..24dca65b 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -1,22 +1,22 @@ - net5.0 - + net6.0 false - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all