From 39f6e426b6816964a1fb56c57ef7da1f422f0858 Mon Sep 17 00:00:00 2001 From: David Jensen Date: Mon, 12 Aug 2024 14:19:27 +0200 Subject: [PATCH 1/3] 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. /// From b39ac871b7bad03a101add34120a4d3b4a2526f8 Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:44:20 +0200 Subject: [PATCH 2/3] chore: Revert whitespace changes is Directory.Packages.props --- Directory.Packages.props | 128 +++++++++---------- src/Testcontainers.MsSql/MsSqlBuilder.cs | 2 +- src/Testcontainers.Pulsar/PulsarContainer.cs | 14 +- 3 files changed, 71 insertions(+), 73 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 4aef6890b..bae22338e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,67 +1,67 @@ - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Testcontainers.MsSql/MsSqlBuilder.cs b/src/Testcontainers.MsSql/MsSqlBuilder.cs index 819c8ffdd..270d19cad 100644 --- a/src/Testcontainers.MsSql/MsSqlBuilder.cs +++ b/src/Testcontainers.MsSql/MsSqlBuilder.cs @@ -138,7 +138,7 @@ public Task UntilAsync(IContainer container) } /// - private async Task UntilAsync(MsSqlContainer container) + private static async Task UntilAsync(MsSqlContainer container) { var sqlCmdFilePath = await container.GetSqlCmdFilePathAsync() .ConfigureAwait(false); diff --git a/src/Testcontainers.Pulsar/PulsarContainer.cs b/src/Testcontainers.Pulsar/PulsarContainer.cs index 82c56d7bb..301abe73b 100644 --- a/src/Testcontainers.Pulsar/PulsarContainer.cs +++ b/src/Testcontainers.Pulsar/PulsarContainer.cs @@ -63,7 +63,7 @@ public async Task CreateAuthenticationTokenAsync(TimeSpan expiryTime, Ca { int secondsToMilliseconds; - if (_configuration.Image.MatchVersion(IsVersionAffectedByRegression)) + if (_configuration.Image.MatchVersion(IsVersionAffectedByRegressionGh22811)) { 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; @@ -88,13 +88,6 @@ 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. /// @@ -125,4 +118,9 @@ internal Task CopyStartupScriptAsync(CancellationToken ct = default) return CopyAsync(Encoding.Default.GetBytes(startupScript.ToString()), PulsarBuilder.StartupScriptFilePath, Unix.FileMode755, ct); } + + private static bool IsVersionAffectedByRegressionGh22811(System.Version version) + { + return version.Major == 3 && ((version.Minor == 2 && version.Build is >= 0 and <= 3) || (version.Minor == 3 && version.Build == 0)); + } } \ No newline at end of file From 5690b5c183b3ee1326cbca9850bb0c8f295eb8a8 Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:48:37 +0200 Subject: [PATCH 3/3] chore: Rename member --- src/Testcontainers.Pulsar/PulsarContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Testcontainers.Pulsar/PulsarContainer.cs b/src/Testcontainers.Pulsar/PulsarContainer.cs index 301abe73b..927e60e5d 100644 --- a/src/Testcontainers.Pulsar/PulsarContainer.cs +++ b/src/Testcontainers.Pulsar/PulsarContainer.cs @@ -63,7 +63,7 @@ public async Task CreateAuthenticationTokenAsync(TimeSpan expiryTime, Ca { int secondsToMilliseconds; - if (_configuration.Image.MatchVersion(IsVersionAffectedByRegressionGh22811)) + if (_configuration.Image.MatchVersion(IsVersionAffectedByGhIssue22811)) { 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; @@ -119,7 +119,7 @@ internal Task CopyStartupScriptAsync(CancellationToken ct = default) return CopyAsync(Encoding.Default.GetBytes(startupScript.ToString()), PulsarBuilder.StartupScriptFilePath, Unix.FileMode755, ct); } - private static bool IsVersionAffectedByRegressionGh22811(System.Version version) + private static bool IsVersionAffectedByGhIssue22811(System.Version version) { return version.Major == 3 && ((version.Minor == 2 && version.Build is >= 0 and <= 3) || (version.Minor == 3 && version.Build == 0)); }