From 39f6e426b6816964a1fb56c57ef7da1f422f0858 Mon Sep 17 00:00:00 2001 From: David Jensen Date: Mon, 12 Aug 2024 14:19:27 +0200 Subject: [PATCH] chore: Update Pulsar version and improve affected version check The default Pulsar image version changed from "3.2.3" to "3.0.6" due to a known regression impacting versions "3.2.0-3.2.3" and "3.3.0". The regression resulted in the expiry time being converted to an incorrect unit of time. The revision improves the check for affected versions by introducing the 'IsVersionAffectedByRegression' method, which accepts a version and returns true if the version is impacted by the regression. The formatting of the PulsarContainer.cs and PulsarBuilder.cs files was also updated for better readability. In addition, the `docs/modules/index.md` file was updated to reflect the new Pulsar version, making it easier for users to use the correct version. --- Directory.Packages.props | 130 +++++++++---------- docs/modules/index.md | 2 +- src/Testcontainers.Pulsar/PulsarBuilder.cs | 2 +- src/Testcontainers.Pulsar/PulsarContainer.cs | 11 +- 4 files changed, 76 insertions(+), 69 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 79222b5b3..4aef6890b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,67 +1,67 @@ - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/modules/index.md b/docs/modules/index.md index 1bd6f315c..38e925ce5 100644 --- a/docs/modules/index.md +++ b/docs/modules/index.md @@ -57,7 +57,7 @@ await moduleNameContainer.StartAsync(); | Papercut | `jijiechen/papercut:latest` | [NuGet](https://www.nuget.org/packages/Testcontainers.Papercut) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Papercut) | | PostgreSQL | `postgres:15.1` | [NuGet](https://www.nuget.org/packages/Testcontainers.PostgreSql) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.PostgreSql) | | PubSub | `gcr.io/google.com/cloudsdktool/google-cloud-cli:446.0.1-emulators` | [NuGet](https://www.nuget.org/packages/Testcontainers.PubSub) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.PubSub) | -| Pulsar | `apachepulsar/pulsar:3.2.3` | [NuGet](https://www.nuget.org/packages/Testcontainers.Pulsar) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Pulsar) | +| Pulsar | `apachepulsar/pulsar:3.0.6` | [NuGet](https://www.nuget.org/packages/Testcontainers.Pulsar) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Pulsar) | | RabbitMQ | `rabbitmq:3.11` | [NuGet](https://www.nuget.org/packages/Testcontainers.RabbitMq) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.RabbitMq) | | RavenDB | `ravendb/ravendb:5.4-ubuntu-latest` | [NuGet](https://www.nuget.org/packages/Testcontainers.RavenDb) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.RavenDb) | | Redis | `redis:7.0` | [NuGet](https://www.nuget.org/packages/Testcontainers.Redis) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Redis) | diff --git a/src/Testcontainers.Pulsar/PulsarBuilder.cs b/src/Testcontainers.Pulsar/PulsarBuilder.cs index 4834a025e..51f2c75b5 100644 --- a/src/Testcontainers.Pulsar/PulsarBuilder.cs +++ b/src/Testcontainers.Pulsar/PulsarBuilder.cs @@ -4,7 +4,7 @@ namespace Testcontainers.Pulsar; [PublicAPI] public sealed class PulsarBuilder : ContainerBuilder { - public const string PulsarImage = "apachepulsar/pulsar:3.2.3"; + public const string PulsarImage = "apachepulsar/pulsar:3.0.6"; public const ushort PulsarBrokerDataPort = 6650; diff --git a/src/Testcontainers.Pulsar/PulsarContainer.cs b/src/Testcontainers.Pulsar/PulsarContainer.cs index e856d5203..82c56d7bb 100644 --- a/src/Testcontainers.Pulsar/PulsarContainer.cs +++ b/src/Testcontainers.Pulsar/PulsarContainer.cs @@ -63,9 +63,9 @@ public async Task CreateAuthenticationTokenAsync(TimeSpan expiryTime, Ca { int secondsToMilliseconds; - if (_configuration.Image.Tag.StartsWith("3.2") || _configuration.Image.Tag.StartsWith("latest")) + if (_configuration.Image.MatchVersion(IsVersionAffectedByRegression)) { - Logger.LogWarning("The 'apachepulsar/pulsar:3.2.?' image contains a regression. The expiry time is converted to the wrong unit of time: https://github.com/apache/pulsar/issues/22811."); + Logger.LogWarning("The 'apachepulsar/pulsar:3.2.0-3' and '3.3.0' images contains a regression. The expiry time is converted to the wrong unit of time: https://github.com/apache/pulsar/issues/22811."); secondsToMilliseconds = 1000; } else @@ -88,6 +88,13 @@ public async Task CreateAuthenticationTokenAsync(TimeSpan expiryTime, Ca return tokensResult.Stdout; } + private bool IsVersionAffectedByRegression(System.Version version) + { + return version.Major == 3 + && ((version.Minor == 2 && version.Build is >= 0 and <= 3) || + (version.Minor == 3 && version.Build == 0)); + } + /// /// Copies the Pulsar startup script to the container. ///