Skip to content

Commit

Permalink
chore: Remove obsolete UntilOperationIsSucceeded wait strategy (#1202)
Browse files Browse the repository at this point in the history
  • Loading branch information
HofmeisterAn authored Jun 21, 2024
1 parent a94a1ea commit 7ecd79e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 128 deletions.
34 changes: 17 additions & 17 deletions src/Testcontainers.Pulsar/PulsarBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,7 @@ public sealed class PulsarBuilder : ContainerBuilder<PulsarBuilder, PulsarContai

public const string Username = "test-user";

private static readonly IReadOnlyDictionary<string, string> AuthenticationEnvVars;

static PulsarBuilder()
{
const string authenticationPlugin = "org.apache.pulsar.client.impl.auth.AuthenticationToken";
var authenticationEnvVars = new Dictionary<string, string>();
authenticationEnvVars.Add("authenticateOriginalAuthData", "false");
authenticationEnvVars.Add("authenticationEnabled", "true");
authenticationEnvVars.Add("authorizationEnabled", "true");
authenticationEnvVars.Add("authenticationProviders", "org.apache.pulsar.broker.authentication.AuthenticationProviderToken");
authenticationEnvVars.Add("brokerClientAuthenticationPlugin", authenticationPlugin);
authenticationEnvVars.Add("CLIENT_PREFIX_authPlugin", authenticationPlugin);
authenticationEnvVars.Add("PULSAR_PREFIX_authenticationRefreshCheckSeconds", "5");
authenticationEnvVars.Add("PULSAR_PREFIX_tokenSecretKey", "file://" + SecretKeyFilePath);
authenticationEnvVars.Add("superUserRoles", Username);
AuthenticationEnvVars = new ReadOnlyDictionary<string, string>(authenticationEnvVars);
}
private static readonly IReadOnlyDictionary<string, string> AuthenticationEnvVars = InitAuthenticationEnvVars();

/// <summary>
/// Initializes a new instance of the <see cref="PulsarBuilder" /> class.
Expand Down Expand Up @@ -126,6 +110,22 @@ protected override PulsarBuilder Merge(PulsarConfiguration oldValue, PulsarConfi
return new PulsarBuilder(new PulsarConfiguration(oldValue, newValue));
}

private static IReadOnlyDictionary<string, string> InitAuthenticationEnvVars()
{
const string authenticationPlugin = "org.apache.pulsar.client.impl.auth.AuthenticationToken";
var authenticationEnvVars = new Dictionary<string, string>();
authenticationEnvVars.Add("authenticateOriginalAuthData", "false");
authenticationEnvVars.Add("authenticationEnabled", "true");
authenticationEnvVars.Add("authorizationEnabled", "true");
authenticationEnvVars.Add("authenticationProviders", "org.apache.pulsar.broker.authentication.AuthenticationProviderToken");
authenticationEnvVars.Add("brokerClientAuthenticationPlugin", authenticationPlugin);
authenticationEnvVars.Add("CLIENT_PREFIX_authPlugin", authenticationPlugin);
authenticationEnvVars.Add("PULSAR_PREFIX_authenticationRefreshCheckSeconds", "5");
authenticationEnvVars.Add("PULSAR_PREFIX_tokenSecretKey", "file://" + SecretKeyFilePath);
authenticationEnvVars.Add("superUserRoles", Username);
return new ReadOnlyDictionary<string, string>(authenticationEnvVars);
}

/// <inheritdoc cref="IWaitUntil" />
private sealed class WaitUntil : IWaitUntil
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace DotNet.Testcontainers.Builders
[PublicAPI]
internal class RootlessUnixEndpointAuthenticationProvider : DockerEndpointAuthenticationProvider
{
private const string DockerSocket = "docker.sock";

/// <summary>
/// Initializes a new instance of the <see cref="RootlessUnixEndpointAuthenticationProvider" /> class.
/// </summary>
Expand Down Expand Up @@ -51,17 +53,17 @@ public override IDockerEndpointAuthenticationConfiguration GetAuthConfig()
protected static string GetSocketPathFromEnv()
{
var xdgRuntimeDir = Environment.GetEnvironmentVariable("XDG_RUNTIME_DIR");
return string.Join("/", xdgRuntimeDir, "docker.sock");
return string.Join("/", xdgRuntimeDir, DockerSocket);
}

protected static string GetSocketPathFromHomeDesktopDir()
{
return string.Join("/", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".docker", "desktop", "docker.sock");
return string.Join("/", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".docker", "desktop", DockerSocket);
}

protected static string GetSocketPathFromHomeRunDir()
{
return string.Join("/", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".docker", "run", "docker.sock");
return string.Join("/", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".docker", "run", DockerSocket);
}

protected static string GetSocketPathFromRunDir()
Expand All @@ -78,7 +80,7 @@ protected static string GetSocketPathFromRunDir()
uid = new Linux().GetUid();
}

return string.Join("/", string.Empty, "user", uid, "docker.sock");
return string.Join("/", string.Empty, "user", uid, DockerSocket);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,6 @@ public interface IWaitForContainerOS
[PublicAPI]
IWaitForContainerOS UntilMessageIsLogged(Regex pattern, Action<IWaitStrategy> waitStrategyModifier = null);

/// <summary>
/// Waits until the operation is completed successfully.
/// </summary>
/// <param name="operation">The operation to be executed.</param>
/// <param name="maxCallCount">The number of attempts before an exception is thrown.</param>
/// <param name="waitStrategyModifier">The wait strategy modifier to cancel the readiness check.</param>
/// <returns>A configured instance of <see cref="IWaitForContainerOS" />.</returns>
/// <exception cref="TimeoutException">Thrown when number of failed operations exceeded <paramref name="maxCallCount" />.</exception>
[PublicAPI]
[Obsolete("Use one of the other wait strategies in combination with the `Action<IWaitStrategy>` argument, and set the number of retries.")]
IWaitForContainerOS UntilOperationIsSucceeded(Func<bool> operation, int maxCallCount, Action<IWaitStrategy> waitStrategyModifier = null);

/// <summary>
/// Waits until the http request is completed successfully.
/// </summary>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ public IWaitForContainerOS UntilMessageIsLogged(Regex pattern, Action<IWaitStrat
return AddCustomWaitStrategy(new UntilMessageIsLogged(pattern), waitStrategyModifier);
}

/// <inheritdoc />
public virtual IWaitForContainerOS UntilOperationIsSucceeded(Func<bool> operation, int maxCallCount, Action<IWaitStrategy> waitStrategyModifier = null)
{
return AddCustomWaitStrategy(new UntilOperationIsSucceeded(operation, maxCallCount), waitStrategyModifier);
}

/// <inheritdoc />
public virtual IWaitForContainerOS UntilHttpRequestIsSucceeded(Func<HttpWaitStrategy, HttpWaitStrategy> request, Action<IWaitStrategy> waitStrategyModifier = null)
{
Expand Down

This file was deleted.

0 comments on commit 7ecd79e

Please sign in to comment.