Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Apache Pulsar module #1103

Merged
merged 16 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Testcontainers.Pulsar/PulsarBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private async Task<bool> UntilAsync(PulsarContainer container)
{
try
{
_authToken = await container.CreateAuthenticationTokenAsync(TimeSpan.FromDays(365))
_authToken = await container.CreateAuthenticationTokenAsync(TimeSpan.FromHours(1))
.ConfigureAwait(false);

_ = _httpWaitStrategy.WithHeader("Authorization", "Bearer " + _authToken.Trim());
Expand Down
7 changes: 6 additions & 1 deletion src/Testcontainers.Pulsar/PulsarContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,14 @@ public async Task<string> CreateAuthenticationTokenAsync(TimeSpan expire = defau
"--subject",
PulsarBuilder.Username,
"--expiry-time",
$"{expire.TotalSeconds}s",
"",
};

if (_configuration.Image.FullName is "apachepulsar/pulsar:3.2.0" or "apachepulsar/pulsar:3.2.1" or "apachepulsar/pulsar:3.2.2" or "apachepulsar/pulsar:3.2.3")
command[8] = $"{expire.TotalSeconds * 1000}s";
else
command[8] = $"{expire.TotalSeconds}s";

HofmeisterAn marked this conversation as resolved.
Show resolved Hide resolved
var tokensResult = await ExecAsync(command, ct)
.ConfigureAwait(false);

Expand Down
2 changes: 1 addition & 1 deletion tests/Testcontainers.Pulsar.Tests/PulsarContainerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public PulsarAuthConfiguration()

protected override async Task<IPulsarClient> CreateClientAsync(CancellationToken ct = default)
{
var authToken = await _pulsarContainer.CreateAuthenticationTokenAsync(TimeSpan.FromDays(365), ct)
var authToken = await _pulsarContainer.CreateAuthenticationTokenAsync(TimeSpan.FromHours(1), ct)
.ConfigureAwait(false);

return PulsarClient.Builder().ServiceUrl(new Uri(_pulsarContainer.GetBrokerAddress())).Authentication(new TokenAuthentication(authToken)).Build();
Expand Down
Loading