Skip to content

Commit cf8036a

Browse files
committed
Configure additional values for maximum test compatibility
1 parent 55998ca commit cf8036a

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎test/Npgsql.Tests/Support/AssemblySetUp.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public async Task Setup()
4444
// Connection to the default connection string failed, use Docker to run PostgreSQL
4545
_postgreSqlContainer = new PostgreSqlBuilder(ContainerImage).WithName(ContainerName).Build();
4646
await _postgreSqlContainer.StartAsync();
47-
await _postgreSqlContainer.EnableSslAsync();
47+
await _postgreSqlContainer.ConfigureAsync();
4848

4949
TestUtil.ConnectionString = _postgreSqlContainer.GetConnectionString();
5050
CheckConnection();

‎test/Npgsql.Tests/Support/PostgreSqlContainerExtensions.cs‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@
44
using System.Text;
55
using System.Threading.Tasks;
66
using DotNet.Testcontainers.Configurations;
7+
using Npgsql.Tests.Replication;
78
using Testcontainers.PostgreSql;
89

910
namespace Npgsql.Tests.Support;
1011

1112
static class PostgreSqlContainerExtensions
1213
{
13-
public static async Task EnableSslAsync(this PostgreSqlContainer container)
14+
/// <summary>
15+
/// Configures the container for maximum test compatibility.
16+
/// <list type="bullet">
17+
/// <item>Enable SSL for <see cref="SecurityTests"/></item>
18+
/// <item>Configure wal_level to <c>logical</c> and max_wal_senders to <c>50</c> for <see cref="SafeReplicationTestBase{T}"/></item>
19+
/// <item>Configure max_prepared_transactions to <c>100</c> for <see cref="DistributedTransactionTests"/></item>
20+
/// </list>
21+
/// </summary>
22+
public static async Task ConfigureAsync(this PostgreSqlContainer container)
1423
{
1524
var now = DateTimeOffset.UtcNow;
1625
const UnixFileModes certMode = UnixFileModes.UserRead | UnixFileModes.UserWrite | UnixFileModes.GroupRead | UnixFileModes.OtherRead;
@@ -21,6 +30,9 @@ public static async Task EnableSslAsync(this PostgreSqlContainer container)
2130
ALTER SYSTEM SET ssl = 'on';
2231
ALTER SYSTEM SET ssl_cert_file = '{sslCertPath}';
2332
ALTER SYSTEM SET ssl_key_file = '{sslKeyPath}';
33+
ALTER SYSTEM SET wal_level = 'logical';
34+
ALTER SYSTEM SET max_wal_senders = '50';
35+
ALTER SYSTEM SET max_prepared_transactions = '100';
2436
""";
2537

2638
var uid = uint.Parse((await container.ExecAsync(["id", "-u", "postgres"])).Stdout);

0 commit comments

Comments
 (0)