@@ -182,6 +182,10 @@ private Task ExecuteWorkloadAsync(EventContext telemetryContext, CancellationTok
182182 {
183183 await this . PrepareOLTPMySQLDatabase ( telemetryContext , cancellationToken ) ;
184184 }
185+ else if ( this . Action == ClientAction . Cleanup )
186+ {
187+ await this . CleanUpDatabase ( telemetryContext , cancellationToken ) ;
188+ }
185189 else
186190 {
187191 await this . RunOLTPWorkloadAsync ( telemetryContext , cancellationToken ) ;
@@ -229,6 +233,35 @@ private async Task RunOLTPWorkloadAsync(EventContext telemetryContext, Cancellat
229233 }
230234 }
231235
236+ private async Task CleanUpDatabase ( EventContext telemetryContext , CancellationToken cancellationToken )
237+ {
238+ int tableCount = GetTableCount ( this . DatabaseScenario , this . TableCount , this . Workload ) ;
239+
240+ string serverIp = ( this . GetLayoutClientInstances ( ClientRole . Server , false ) ?? Enumerable . Empty < ClientInstance > ( ) )
241+ . FirstOrDefault ( ) ? . IPAddress
242+ ?? "localhost" ;
243+
244+ string sysbenchCleanupArguments = $ "--dbName { this . DatabaseName } --databaseSystem { this . DatabaseSystem } --benchmark { this . Benchmark } --tableCount { tableCount } --hostIpAddress { serverIp } ";
245+
246+ string script = $ "{ this . SysbenchPackagePath } /cleanup-database.py ";
247+
248+ using ( IProcessProxy process = await this . ExecuteCommandAsync (
249+ SysbenchExecutor . PythonCommand ,
250+ script + this . sysbenchExecutionArguments ,
251+ this . SysbenchPackagePath ,
252+ telemetryContext ,
253+ cancellationToken ) )
254+ {
255+ if ( ! cancellationToken . IsCancellationRequested )
256+ {
257+ await this . LogProcessDetailsAsync ( process , telemetryContext , "Sysbench" , logToFile : true ) ;
258+ process . ThrowIfErrored < WorkloadException > ( process . StandardError . ToString ( ) , ErrorReason . WorkloadFailed ) ;
259+
260+ this . CaptureMetrics ( process , telemetryContext , cancellationToken ) ;
261+ }
262+ }
263+ }
264+
232265 private async Task RunTPCCWorkloadAsync ( EventContext telemetryContext , CancellationToken cancellationToken )
233266 {
234267 int tableCount = GetTableCount ( this . Scenario , this . TableCount , this . Workload ) ;
@@ -288,7 +321,7 @@ private async Task PrepareOLTPMySQLDatabase(EventContext telemetryContext, Cance
288321 int threadCount = GetThreadCount ( this . SystemManager , this . DatabaseScenario , this . Threads ) ;
289322 int recordCount = GetRecordCount ( this . SystemManager , this . DatabaseScenario , this . RecordCount ) ;
290323
291- this . sysbenchLoggingArguments = $ "--dbName { this . DatabaseName } --databaseSystem { this . DatabaseSystem } --benchmark { this . Benchmark } --tableCount { tableCount } --recordCount { recordCount } --threadCount { threadCount } ";
324+ this . sysbenchLoggingArguments = $ "--dbName { this . DatabaseName } --databaseSystem { this . DatabaseSystem } --benchmark { this . Benchmark } --threadCount { threadCount } --tableCount { tableCount } --recordCount { recordCount } ";
292325 this . sysbenchPrepareArguments = $ "{ this . sysbenchLoggingArguments } --password { this . SuperUserPassword } ";
293326
294327 string serverIp = ( this . GetLayoutClientInstances ( ClientRole . Server , false ) ?? Enumerable . Empty < ClientInstance > ( ) )
0 commit comments