@@ -10,11 +10,12 @@ namespace VirtualClient.Actions
10
10
using System . Runtime . InteropServices ;
11
11
using System . Threading ;
12
12
using System . Threading . Tasks ;
13
- using Microsoft . CodeAnalysis . Scripting ;
14
13
using Moq ;
15
14
using NUnit . Framework ;
16
15
using VirtualClient . Common ;
16
+ using VirtualClient . Common . Contracts ;
17
17
using VirtualClient . Contracts ;
18
+ using static VirtualClient . Actions . SysbenchOLTPExecutor ;
18
19
19
20
[ TestFixture ]
20
21
[ Category ( "Functional" ) ]
@@ -54,8 +55,13 @@ public void SysbenchOLTPWorkloadProfileActionsWillNotBeExecutedIfTheWorkloadPack
54
55
[ TestCase ( "PERF-MYSQL-SYSBENCH-OLTP.json" , PlatformID . Unix , Architecture . X64 ) ]
55
56
public async Task SysbenchOLTPWorkloadProfileExecutesTheExpectedWorkloadsOnUnixPlatform ( string profile , PlatformID platform , Architecture architecture )
56
57
{
57
- IEnumerable < string > expectedCommands = this . GetProfileExpectedCommands ( platform , architecture ) ;
58
+ IEnumerable < string > expectedCommands = this . GetProfileExpectedCommands ( singleVM : false ) ;
58
59
this . SetupDefaultMockBehaviors ( platform , architecture ) ;
60
+
61
+ this . mockFixture . Setup ( PlatformID . Unix , architecture , this . clientAgentId ) . SetupLayout (
62
+ new ClientInstance ( this . clientAgentId , "1.2.3.4" , "Client" ) ,
63
+ new ClientInstance ( this . serverAgentId , "1.2.3.5" , "Server" ) ) ;
64
+
59
65
this . SetupApiClient ( this . serverAgentId , serverIPAddress : "1.2.3.5" ) ;
60
66
61
67
string scriptPath = this . mockFixture . PlatformSpecifics . GetScriptPath ( "sysbencholtp" ) ;
@@ -86,44 +92,106 @@ public async Task SysbenchOLTPWorkloadProfileExecutesTheExpectedWorkloadsOnUnixP
86
92
}
87
93
}
88
94
89
- private IEnumerable < string > GetProfileExpectedCommands ( PlatformID platform , Architecture architecture )
95
+ [ Test ]
96
+ [ TestCase ( "PERF-MYSQL-SYSBENCH-OLTP.json" , PlatformID . Unix , Architecture . X64 ) ]
97
+ public async Task SysbenchOLTPWorkloadProfileExecutesTheExpectedWorkloadsOnSingleVMUnixPlatform ( string profile , PlatformID platform , Architecture architecture )
90
98
{
91
- return new List < string > ( )
99
+ IEnumerable < string > expectedCommands = this . GetProfileExpectedCommands ( singleVM : true ) ;
100
+ this . SetupDefaultMockBehaviors ( platform , architecture ) ;
101
+
102
+ this . mockFixture . Setup ( PlatformID . Unix , architecture , this . clientAgentId ) . SetupLayout (
103
+ new ClientInstance ( this . serverAgentId , "1.2.3.5" , "Server" ) ) ;
104
+
105
+ this . SetupApiClient ( this . serverAgentId , serverIPAddress : "1.2.3.5" ) ;
106
+
107
+ string scriptPath = this . mockFixture . PlatformSpecifics . GetScriptPath ( "sysbencholtp" ) ;
108
+
109
+ string balancedClientScript = this . mockFixture . PlatformSpecifics . Combine ( scriptPath , "balanced-client.sh" ) ;
110
+ string balancedServerScript = this . mockFixture . PlatformSpecifics . Combine ( scriptPath , "balanced-server.sh" ) ;
111
+ string inMemoryScript = this . mockFixture . PlatformSpecifics . Combine ( scriptPath , "in-memory.sh" ) ;
112
+
113
+ this . mockFixture . SetupFile ( balancedServerScript ) ;
114
+ this . mockFixture . SetupFile ( balancedClientScript ) ;
115
+ this . mockFixture . SetupFile ( inMemoryScript ) ;
116
+
117
+ this . mockFixture . ProcessManager . OnCreateProcess = ( command , arguments , workingDir ) =>
92
118
{
93
- "git clone https://github.com/akopytov/sysbench.git /home/user/tools/VirtualClient/packages/sysbench" ,
94
-
95
- "sudo ./autogen.sh" ,
96
- "sudo ./configure" ,
97
- "sudo make -j" ,
98
- "sudo make install" ,
99
-
100
- $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_write --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 cleanup",
101
- $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_common --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 prepare",
102
- $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_write --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
103
- $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_only --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
104
- $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_delete --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
105
- $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_insert --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
106
- $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_update_index --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
107
- $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_update_non_index --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
108
- $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench select_random_points --threads=64 --tables=1 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
109
- $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench select_random_ranges --threads=64 --tables=1 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run"
119
+ IProcessProxy process = this . mockFixture . CreateProcess ( command , arguments , workingDir ) ;
120
+ if ( arguments . Contains ( "run" , StringComparison . OrdinalIgnoreCase ) )
121
+ {
122
+ process . StandardOutput . Append ( TestDependencies . GetResourceFileContents ( "Results_SysbenchOLTP.txt" ) ) ;
123
+ }
124
+
125
+ return process ;
110
126
} ;
127
+
128
+ using ( ProfileExecutor executor = TestDependencies . CreateProfileExecutor ( profile , this . mockFixture . Dependencies ) )
129
+ {
130
+ await executor . ExecuteAsync ( ProfileTiming . OneIteration ( ) , CancellationToken . None ) . ConfigureAwait ( false ) ;
131
+ WorkloadAssert . CommandsExecuted ( this . mockFixture , expectedCommands . ToArray ( ) ) ;
132
+ }
133
+ }
134
+
135
+ private IEnumerable < string > GetProfileExpectedCommands ( bool singleVM )
136
+ {
137
+ if ( singleVM )
138
+ {
139
+ return new List < string > ( )
140
+ {
141
+ "git clone https://github.com/akopytov/sysbench.git /home/user/tools/VirtualClient/packages/sysbench" ,
142
+
143
+ "sudo ./autogen.sh" ,
144
+ "sudo ./configure" ,
145
+ "sudo make -j" ,
146
+ "sudo make install" ,
147
+
148
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_write --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 cleanup",
149
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_common --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 prepare",
150
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_write --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 run",
151
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_only --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 run",
152
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_delete --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 run",
153
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_insert --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 run",
154
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_update_index --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 run",
155
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_update_non_index --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 run",
156
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench select_random_points --threads=64 --tables=1 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 run",
157
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench select_random_ranges --threads=64 --tables=1 --table-size=10000 --mysql-db=sbtest --mysql-host=127.0.0.1 --time=1200 run"
158
+ } ;
159
+ }
160
+ else
161
+ {
162
+ return new List < string > ( )
163
+ {
164
+ "git clone https://github.com/akopytov/sysbench.git /home/user/tools/VirtualClient/packages/sysbench" ,
165
+
166
+ "sudo ./autogen.sh" ,
167
+ "sudo ./configure" ,
168
+ "sudo make -j" ,
169
+ "sudo make install" ,
170
+
171
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_write --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 cleanup",
172
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_common --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 prepare",
173
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_write --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
174
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_read_only --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
175
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_delete --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
176
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_insert --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
177
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_update_index --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
178
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench oltp_update_non_index --threads=64 --tables=10 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
179
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench select_random_points --threads=64 --tables=1 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run",
180
+ $ "sudo /home/user/tools/VirtualClient/packages/sysbench/src/sysbench select_random_ranges --threads=64 --tables=1 --table-size=10000 --mysql-db=sbtest --mysql-host=1.2.3.5 --time=1200 run"
181
+ } ;
182
+ }
111
183
}
112
184
113
185
private void SetupApiClient ( string serverName , string serverIPAddress )
114
186
{
115
187
IPAddress . TryParse ( serverIPAddress , out IPAddress ipAddress ) ;
116
- IApiClient apiClient = this . mockFixture . ApiClientManager . GetOrCreateApiClient ( serverName , ipAddress ) ;
188
+ IApiClient apiClient = this . mockFixture . ApiClientManager . GetOrCreateApiClient ( serverIPAddress , ipAddress ) ;
117
189
}
118
190
119
191
private void SetupDefaultMockBehaviors ( PlatformID platform , Architecture architecture )
120
192
{
121
193
this . mockFixture . Setup ( platform , architecture ) ;
122
194
this . mockFixture . SetupWorkloadPackage ( "sysbench" , expectedFiles : "sysbench" ) ;
123
- this . mockFixture . Setup ( PlatformID . Unix , architecture , this . clientAgentId ) . SetupLayout (
124
- new ClientInstance ( this . clientAgentId , "1.2.3.4" , "Client" ) ,
125
- new ClientInstance ( this . serverAgentId , "1.2.3.5" , "Server" ) ) ;
126
-
127
195
this . mockFixture . SystemManagement . Setup ( mgr => mgr . GetCpuInfoAsync ( It . IsAny < CancellationToken > ( ) ) )
128
196
. ReturnsAsync ( new CpuInfo ( "cpu" , "description" , 4 , 8 , 4 , 4 , false ) ) ;
129
197
}
0 commit comments