Skip to content

Commit be3077a

Browse files
committed
Adding layout reference
1 parent f9ef8b8 commit be3077a

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/VirtualClient/VirtualClient.Actions/Network/NetworkingWorkload/NTttcp/NTttcpClientExecutor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace VirtualClient.Actions.NetworkPerformance
55
{
66
using System;
77
using System.Collections.Generic;
8+
using System.Linq;
89
using Microsoft.Extensions.DependencyInjection;
910
using VirtualClient.Contracts;
1011

src/VirtualClient/VirtualClient.Actions/Network/NetworkingWorkload/NetworkingWorkloadExecutor.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ namespace VirtualClient.Actions.NetworkPerformance
99
using System.Linq;
1010
using System.Net;
1111
using System.Net.Http;
12+
using System.Text.RegularExpressions;
1213
using System.Threading;
1314
using System.Threading.Tasks;
15+
using Microsoft.AspNetCore.Hosting.Server;
16+
using Microsoft.CodeAnalysis.CSharp.Syntax;
1417
using Microsoft.Extensions.DependencyInjection;
1518
using Newtonsoft.Json.Linq;
1619
using Polly;
@@ -30,6 +33,8 @@ public class NetworkingWorkloadExecutor : VirtualClientComponent
3033
{
3134
private static readonly object LockObject = new object();
3235
private static Task heartbeatTask;
36+
private static Regex layoutServerIPRegex = new Regex(@"\$\.\s*layout\.serverip\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
37+
private static Regex layoutClientIPRegex = new Regex(@"\$\.\s*layout\.clientip\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
3338

3439
// Contains the background running process for the server-side
3540
// networking workload tool.
@@ -599,6 +604,8 @@ protected override async Task InitializeAsync(EventContext telemetryContext, Can
599604
EventContext.PersistentProperties["role"] = this.Role;
600605

601606
this.InitializeApiClients();
607+
608+
this.InlineLayoutReferences();
602609
}
603610

604611
/// <summary>
@@ -1137,6 +1144,23 @@ private void StopServerTool(EventContext telemetryContext)
11371144
}
11381145
}
11391146

1147+
private void InlineLayoutReferences()
1148+
{
1149+
string serverIPAddress = this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress;
1150+
string clientIPAddress = this.GetLayoutClientInstances(ClientRole.Client).First().IPAddress;
1151+
1152+
foreach (var key in this.Parameters.Keys.ToList())
1153+
{
1154+
var original = this.Parameters[key]?.ToString();
1155+
1156+
var updated = layoutServerIPRegex.Replace(original, serverIPAddress);
1157+
updated = layoutClientIPRegex.Replace(updated, clientIPAddress);
1158+
1159+
this.Parameters[key] = updated;
1160+
1161+
}
1162+
}
1163+
11401164
/// <summary>
11411165
/// Used to track and managed the execution of the background server-side workload
11421166
/// process over a long running period of time.

src/VirtualClient/VirtualClient.Core/ProfileExpressionEvaluator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ private static bool EvaluateParameterSpecificExpressions(IServiceCollection depe
10001000
if (!cancellationToken.IsCancellationRequested)
10011001
{
10021002
// Groups[0] = the full matched text (e.g. {Port})
1003-
// Groups]1] = the capture group (e.g. 1234).
1003+
// Groups[1] = the capture group (e.g. 1234).
10041004
if (parameters.TryGetValue(match.Groups[1].Value, out IConvertible value))
10051005
{
10061006
matchesFound = true;

0 commit comments

Comments
 (0)