Skip to content

Commit ed0ff3a

Browse files
ericavellaErica Vellanoweth
andauthored
configuring postgres serverIp for client/server connections (#319)
* configuring serverIp for client/server connections * tests * bumping version --------- Co-authored-by: Erica Vellanoweth <[email protected]>
1 parent 9b4a8b8 commit ed0ff3a

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

.pipelines/azure-pipelines-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ resources:
1616
options: --entrypoint=""
1717

1818
variables:
19-
VcVersion : 1.14.28
19+
VcVersion : 1.14.29
2020
ROOT: $(Build.SourcesDirectory)
2121
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
2222
ENABLE_PRS_DELAYSIGN: 1

.pipelines/azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pool:
1818
vmImage: windows-latest
1919

2020
variables:
21-
VcVersion : 1.14.28
21+
VcVersion : 1.14.29
2222
ROOT: $(Build.SourcesDirectory)
2323
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
2424
ENABLE_PRS_DELAYSIGN: 1

src/VirtualClient/VirtualClient.Actions.FunctionalTests/HammerDBProfileTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ private IEnumerable<string> GetUnixProfileExpectedCommands(bool singleVM)
234234
"sudo apt list python3",
235235

236236
$"python3 {this.postgreSQLPackagePath}/install-server.py",
237-
$"python3 {this.postgreSQLPackagePath}/configure-server.py --dbName hammerdbtest --password [A-Za-z0-9+/=]+ --port 5432 --sharedMemoryBuffer [0-9]+",
237+
$"python3 {this.postgreSQLPackagePath}/configure-server.py --dbName hammerdbtest --password [A-Za-z0-9+/=]+ --port 5432 --sharedMemoryBuffer [0-9]+ --serverIp 1.2.3.5",
238238

239239
$"python3 {this.hammerdbPackagePath}/configure-workload-generator.py --workload tpcc --sqlServer postgresql --port 5432 --virtualUsers [0-9]+ --warehouseCount [0-9]+ --password [A-Za-z0-9+/=]+ --dbName hammerdbtest --hostIPAddress",
240240
$"python3 {this.hammerdbPackagePath}/populate-database.py --createDBTCLPath createDB.tcl",
@@ -271,7 +271,7 @@ private IEnumerable<string> GetWindowsProfileExpectedCommands(bool singleVM)
271271
return new List<string>()
272272
{
273273
$"python3 {this.postgreSQLPackagePath}/install-server.py",
274-
$"python3 {tempPostgreSqlPackagePath}/configure-server.py --dbName hammerdbtest --password [A-Za-z0-9+/=]+ --port 5432 --sharedMemoryBuffer [0-9]+",
274+
$"python3 {tempPostgreSqlPackagePath}/configure-server.py --dbName hammerdbtest --password [A-Za-z0-9+/=]+ --port 5432 --sharedMemoryBuffer [0-9]+ --serverIp 1.2.3.5",
275275

276276
$"python3 {temphammerdbPackagePath}/configure-workload-generator.py --workload tpcc --sqlServer postgresql --port 5432 --virtualUsers [0-9]+ --warehouseCount [0-9]+ --password [A-Za-z0-9+/=]+ --dbName hammerdbtest --hostIPAddress",
277277
$"python3 {this.hammerdbPackagePath}/populate-database.py --createDBTCLPath createDB.tcl",

src/VirtualClient/VirtualClient.Dependencies.UnitTests/PostgreSQLServer/PostgreSQLServerConfigurationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public async Task PostgreSQLServerConfigurationExecutesTheExpectedProcessForConf
5454

5555
string[] expectedCommands =
5656
{
57-
$"python3 {tempPackagePath}/configure-server.py --dbName hammerdbtest --password [A-Za-z0-9+/=]+ --port 5432 --sharedMemoryBuffer [0-9]+",
57+
$"python3 {tempPackagePath}/configure-server.py --dbName hammerdbtest --password [A-Za-z0-9+/=]+ --port 5432 --sharedMemoryBuffer [0-9]+ --serverIp 1.2.3.5",
5858
};
5959

6060
int commandNumber = 0;

src/VirtualClient/VirtualClient.Dependencies/PostgreSQLServer/PostgreSQLServerConfiguration.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace VirtualClient.Dependencies
66
using System;
77
using System.Collections.Generic;
88
using System.Linq;
9+
using System.Net;
910
using System.Security.Cryptography;
1011
using System.Text;
1112
using System.Threading;
@@ -178,7 +179,9 @@ await this.DistributePostgreSQLDatabaseAsync(telemetryContext, cancellationToken
178179

179180
private async Task ConfigurePostgreSQLServerAsync(EventContext telemetryContext, CancellationToken cancellationToken)
180181
{
181-
string arguments = $"{this.packageDirectory}/configure-server.py --dbName {this.DatabaseName} --password {this.SuperUserPassword} --port {this.Port} --sharedMemoryBuffer {this.SharedMemoryBuffer}";
182+
string serverIp = this.GetServerIpAddress();
183+
184+
string arguments = $"{this.packageDirectory}/configure-server.py --dbName {this.DatabaseName} --password {this.SuperUserPassword} --port {this.Port} --sharedMemoryBuffer {this.SharedMemoryBuffer} --serverIp {serverIp}";
182185

183186
using (IProcessProxy process = await this.ExecuteCommandAsync(
184187
"python3",
@@ -255,6 +258,20 @@ private async Task<string> GetPostgreSQLInnodbDirectoriesAsync(CancellationToken
255258
return diskPaths;
256259
}
257260

261+
private string GetServerIpAddress()
262+
{
263+
string serverIPAddress = IPAddress.Loopback.ToString();
264+
265+
if (this.IsMultiRoleLayout())
266+
{
267+
ClientInstance serverInstance = this.GetLayoutClientInstances(ClientRole.Server).First();
268+
IPAddress.TryParse(serverInstance.IPAddress, out IPAddress serverIP);
269+
serverIPAddress = serverIP.ToString();
270+
}
271+
272+
return serverIPAddress;
273+
}
274+
258275
/// <summary>
259276
/// Supported PostgreSQL Server configuration actions.
260277
/// </summary>

0 commit comments

Comments
 (0)