@@ -8,7 +8,7 @@ namespace VirtualClient.Actions
88 using System . Linq ;
99 using System . Net ;
1010 using System . Runtime . InteropServices ;
11- using System . Text ;
11+ using System . Text . RegularExpressions ;
1212 using System . Threading ;
1313 using System . Threading . Tasks ;
1414 using Moq ;
@@ -35,7 +35,7 @@ public void SetupFixture()
3535
3636 ComponentTypeCache . Instance . LoadComponentTypes ( TestDependencies . TestDirectory ) ;
3737
38- this . mockFixture . SetupPackage ( "wget" , expectedFiles : "linux-x64/wget2" ) ;
38+ this . mockFixture . SetupPackage ( "wget" , null , "linux-x64/wget2" ) ;
3939 this . mockFixture . SetupFile ( "redis" , "redis-6.2.1/src/redis-server" , new byte [ 0 ] ) ;
4040 this . mockFixture . SystemManagement . Setup ( mgr => mgr . GetCpuInfoAsync ( It . IsAny < CancellationToken > ( ) ) )
4141 . ReturnsAsync ( new CpuInfo ( "AnyName" , "AnyDescription" , 1 , 4 , 1 , 0 , true ) ) ;
@@ -45,48 +45,33 @@ public void SetupFixture()
4545 [ TestCase ( "PERF-REDIS.json" ) ]
4646 public async Task RedisMemtierWorkloadProfileInstallsTheExpectedDependenciesOfServerOnUnixPlatform ( string profile )
4747 {
48- using var memoryProcess = new InMemoryProcess
49- {
50- StandardOutput = new ConcurrentBuffer (
51- new StringBuilder ( "Redis server v=7.0.15 sha=00000000 malloc=jemalloc-5.1.0 bits=64 build=abc123" ) ) ,
52- OnStart = ( ) => true ,
53- OnHasExited = ( ) => true
54- } ;
55-
56- this . mockFixture . ProcessManager . OnCreateProcess = ( command , arguments , workingDir ) =>
57- {
58- IProcessProxy process = this . mockFixture . CreateProcess ( command , arguments , workingDir ) ;
59- if ( arguments ? . Contains ( "redis-server" ) == true && arguments ? . Contains ( "--version" ) == true )
60- {
61- return memoryProcess ;
62- }
48+ this . mockFixture
49+ . TrackProcesses ( )
50+ . SetupProcessOutput (
51+ "redis-server.*--version" ,
52+ "Redis server v=7.0.15 sha=00000000 malloc=jemalloc-5.1.0 bits=64 build=abc123" ) ;
6353
64- return process ;
65- } ;
6654 using ( ProfileExecutor executor = TestDependencies . CreateProfileExecutor ( profile , this . mockFixture . Dependencies ) )
6755 {
6856 await executor . ExecuteAsync ( ProfileTiming . OneIteration ( ) , CancellationToken . None )
6957 . ConfigureAwait ( false ) ;
7058
71- // Workload dependency package expectations
7259 WorkloadAssert . WorkloadPackageInstalled ( this . mockFixture , "redis" ) ;
60+
61+ this . mockFixture . Tracking . AssertCommandsExecuted ( "redis-server.*--version" ) ;
7362 }
7463 }
7564
7665 [ Test ]
7766 [ TestCase ( "PERF-REDIS.json" ) ]
7867 public async Task RedisMemtierWorkloadProfileExecutesTheWorkloadAsExpectedOfServerOnUnixPlatformMultiVM ( string profile )
7968 {
80- List < string > expectedCommands = new List < string > ( ) ;
81-
82- int port = 6379 ;
83- Enumerable . Range ( 0 , 4 ) . ToList ( ) . ForEach ( core =>
84- expectedCommands . Add ( $ "sudo bash -c \" numactl -C { core } /.+/redis-server --port { port + core } --protected-mode no --io-threads 4 --maxmemory-policy noeviction --ignore-warnings ARM64-COW-BUG --save & \" " ) ) ;
69+ this . mockFixture
70+ . TrackProcesses ( )
71+ . SetupProcessOutput (
72+ "redis-server.*--version" ,
73+ "Redis server v=7.0.15 sha=00000000 malloc=jemalloc-5.1.0 bits=64 build=abc123" ) ;
8574
86- // Setup the expectations for the workload
87- // - Workload package is installed and exists.
88- // - Workload binaries/executables exist on the file system.
89- // - Expected processes are executed.
9075 IPAddress . TryParse ( "1.2.3.5" , out IPAddress ipAddress ) ;
9176 IApiClient apiClient = this . mockFixture . ApiClientManager . GetOrCreateApiClient ( "1.2.3.5" , ipAddress ) ;
9277
@@ -105,29 +90,20 @@ public async Task RedisMemtierWorkloadProfileExecutesTheWorkloadAsExpectedOfServ
10590 } ) ;
10691
10792 await apiClient . CreateStateAsync ( nameof ( ServerState ) , state , CancellationToken . None ) ;
108- using var memoryProcess = new InMemoryProcess
109- {
110- StandardOutput = new ConcurrentBuffer (
111- new StringBuilder ( "Redis server v=7.0.15 sha=00000000 malloc=jemalloc-5.1.0 bits=64 build=abc123" ) ) ,
112- OnStart = ( ) => true ,
113- OnHasExited = ( ) => true
114- } ;
115-
116- this . mockFixture . ProcessManager . OnCreateProcess = ( command , arguments , workingDir ) =>
117- {
118- IProcessProxy process = this . mockFixture . CreateProcess ( command , arguments , workingDir ) ;
119- if ( arguments ? . Contains ( "redis-server" ) == true && arguments ? . Contains ( "--version" ) == true )
120- {
121- return memoryProcess ;
122- }
123-
124- return process ;
125- } ;
12693
12794 using ( ProfileExecutor executor = TestDependencies . CreateProfileExecutor ( profile , this . mockFixture . Dependencies ) )
12895 {
12996 await executor . ExecuteAsync ( ProfileTiming . OneIteration ( ) , CancellationToken . None ) ;
130- WorkloadAssert . CommandsExecuted ( this . mockFixture , expectedCommands . ToArray ( ) ) ;
97+
98+ this . mockFixture . Tracking . AssertCommandsExecutedInOrder (
99+ $ "sudo chmod \\ +x.*redis-server",
100+ $ "sudo bash -c \\ \" numactl -C 0.*redis-server --port 6379.*\\ \" ",
101+ $ "sudo bash -c \\ \" numactl -C 1.*redis-server --port 6380.*\\ \" ",
102+ $ "sudo bash -c \\ \" numactl -C 2.*redis-server --port 6381.*\\ \" ",
103+ $ "sudo bash -c \\ \" numactl -C 3.*redis-server --port 6382.*\\ \" ") ;
104+
105+ this . mockFixture . Tracking . AssertCommandExecutedTimes ( "chmod.*redis-server" , 1 ) ;
106+ this . mockFixture . Tracking . AssertCommandExecutedTimes ( "numactl.*redis-server" , 4 ) ;
131107 }
132108 }
133109 }
0 commit comments