Skip to content

Commit c849c61

Browse files
committed
Adding layout reference
1 parent 3b2346f commit c849c61

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

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;
@@ -28,6 +31,8 @@ public class NetworkingWorkloadExecutor : VirtualClientComponent
2831
{
2932
private static readonly object LockObject = new object();
3033
private static Task heartbeatTask;
34+
private static Regex layoutServerIPRegex = new Regex(@"\$\.\s*layout\.serverip\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
35+
private static Regex layoutClientIPRegex = new Regex(@"\$\.\s*layout\.clientip\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
3136

3237
// Contains the background running process for the server-side
3338
// networking workload tool.
@@ -597,6 +602,8 @@ protected override async Task InitializeAsync(EventContext telemetryContext, Can
597602
EventContext.PersistentProperties["role"] = this.Role;
598603

599604
this.InitializeApiClients();
605+
606+
this.InlineLayoutReferences();
600607
}
601608

602609
/// <summary>
@@ -1135,6 +1142,23 @@ private void StopServerTool(EventContext telemetryContext)
11351142
}
11361143
}
11371144

1145+
private void InlineLayoutReferences()
1146+
{
1147+
string serverIPAddress = this.GetLayoutClientInstances(ClientRole.Server).First().IPAddress;
1148+
string clientIPAddress = this.GetLayoutClientInstances(ClientRole.Client).First().IPAddress;
1149+
1150+
foreach (var key in this.Parameters.Keys.ToList())
1151+
{
1152+
var original = this.Parameters[key]?.ToString();
1153+
1154+
var updated = layoutServerIPRegex.Replace(original, serverIPAddress);
1155+
updated = layoutClientIPRegex.Replace(updated, clientIPAddress);
1156+
1157+
this.Parameters[key] = updated;
1158+
1159+
}
1160+
}
1161+
11381162
/// <summary>
11391163
/// Used to track and managed the execution of the background server-side workload
11401164
/// 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
@@ -991,7 +991,7 @@ private static bool EvaluateParameterSpecificExpressions(IServiceCollection depe
991991
if (!cancellationToken.IsCancellationRequested)
992992
{
993993
// Groups[0] = the full matched text (e.g. {Port})
994-
// Groups]1] = the capture group (e.g. 1234).
994+
// Groups[1] = the capture group (e.g. 1234).
995995
if (parameters.TryGetValue(match.Groups[1].Value, out IConvertible value))
996996
{
997997
matchesFound = true;

0 commit comments

Comments
 (0)