Skip to content

Commit 5d30d4c

Browse files
committed
fixing command line and metadata
1 parent 4444a8f commit 5d30d4c

7 files changed

Lines changed: 72 additions & 8 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)
2+
3+
Running the test with following options:
4+
Number of threads: 8
5+
Initializing random number generator from current time
6+
7+
8+
Initializing worker threads...
9+
10+
Threads started!
11+
12+
SQL statistics:
13+
queries performed:
14+
read: 9720106
15+
write: 0
16+
other: 0
17+
total: 9720106
18+
transactions: 9720106 (32400.24 per sec.)
19+
queries: 9720106 (32400.24 per sec.)
20+
ignored errors: 0 (0.00 per sec.)
21+
reconnects: 0 (0.00 per sec.)
22+
23+
Throughput:
24+
events/s (eps): 32400.2399
25+
time elapsed: 300.0011s
26+
total number of events: 9720106
27+
28+
Latency (ms):
29+
min: 0.16
30+
avg: 0.25
31+
max: 13.68
32+
95th percentile: 0.28
33+
sum: 2389444.97
34+
35+
Threads fairness:
36+
events (avg/stddev): 1215013.2500/22596.17
37+
execution time (avg/stddev): 298.6806/0.05
38+

src/VirtualClient/VirtualClient.Actions.UnitTests/Sysbench/SysbenchMetricsParserTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,17 @@ public void SysbenchParserParsesCorrectly()
4646
MetricAssert.Exists(metrics, "latency p95", 68.05, "milliseconds");
4747
MetricAssert.Exists(metrics, "latency sum", 7458385.25, "milliseconds");
4848
}
49+
50+
[Test]
51+
public void SysbenchParserParsesMetricsMetadataCorrectly()
52+
{
53+
string rawText = File.ReadAllText(Path.Combine(examplesDirectory, "SysbenchExample1.txt"));
54+
SysbenchMetricsParser parser = new SysbenchMetricsParser(rawText);
55+
56+
IList<Metric> metrics = parser.Parse();
57+
Assert.AreEqual(17, metrics.Count);
58+
Assert.IsTrue(metrics[0].Metadata.ContainsKey("sysbench_version"));
59+
Assert.IsTrue(metrics[0].Metadata["sysbench_version"].Equals("1.1.0"));
60+
}
4961
}
5062
}

src/VirtualClient/VirtualClient.Actions/Sysbench/SysbenchClientExecutor.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace VirtualClient.Actions
1010
using System.Threading;
1111
using System.Threading.Tasks;
1212
using Microsoft.Extensions.DependencyInjection;
13+
using Microsoft.Identity.Client;
1314
using Polly;
1415
using VirtualClient.Common;
1516
using VirtualClient.Common.Extensions;
@@ -140,6 +141,20 @@ private void CaptureMetrics(IProcessProxy process, EventContext telemetryContext
140141
{
141142
SysbenchMetricsParser parser = new SysbenchMetricsParser(text);
142143
IList<Metric> metrics = parser.Parse();
144+
string sysbenchVersion = null;
145+
146+
var sysbenchVersionMetric = metrics.FirstOrDefault();
147+
if (sysbenchVersionMetric != null && sysbenchVersionMetric.Metadata.TryGetValue("sysbench_version", out var versionValue))
148+
{
149+
sysbenchVersion = versionValue?.ToString();
150+
}
151+
152+
if (!string.IsNullOrEmpty(sysbenchVersion))
153+
{
154+
this.MetadataContract.Add("sysbench_version", sysbenchVersion, MetadataContractCategory.Dependencies);
155+
}
156+
157+
this.MetadataContract.Apply(telemetryContext);
143158

144159
this.Logger.LogMetrics(
145160
toolName: "Sysbench",
@@ -150,7 +165,8 @@ private void CaptureMetrics(IProcessProxy process, EventContext telemetryContext
150165
null,
151166
scenarioArguments: this.sysbenchLoggingArguments,
152167
this.Tags,
153-
telemetryContext);
168+
telemetryContext,
169+
toolVersion: sysbenchVersion);
154170
}
155171
catch (Exception exc)
156172
{
@@ -247,7 +263,7 @@ private async Task CleanUpDatabase(EventContext telemetryContext, CancellationTo
247263

248264
using (IProcessProxy process = await this.ExecuteCommandAsync(
249265
SysbenchExecutor.PythonCommand,
250-
script + this.sysbenchExecutionArguments,
266+
script + sysbenchCleanupArguments,
251267
this.SysbenchPackagePath,
252268
telemetryContext,
253269
cancellationToken))
@@ -256,8 +272,6 @@ private async Task CleanUpDatabase(EventContext telemetryContext, CancellationTo
256272
{
257273
await this.LogProcessDetailsAsync(process, telemetryContext, "Sysbench", logToFile: true);
258274
process.ThrowIfErrored<WorkloadException>(process.StandardError.ToString(), ErrorReason.WorkloadFailed);
259-
260-
this.CaptureMetrics(process, telemetryContext, cancellationToken);
261275
}
262276
}
263277
}

src/VirtualClient/VirtualClient.Actions/Sysbench/SysbenchConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private async Task PrepareOLTPMySQLDatabase(EventContext telemetryContext, Cance
8282
int threadCount = GetThreadCount(this.SystemManager, this.DatabaseScenario, this.Threads);
8383
int recordCount = GetRecordCount(this.SystemManager, this.DatabaseScenario, this.RecordCount);
8484

85-
string sysbenchLoggingArguments = $"--dbName {this.DatabaseName} --databaseSystem {this.DatabaseSystem} --benchmark {this.Benchmark} --tableCount {tableCount} --recordCount {recordCount} --threadCount {threadCount}";
85+
string sysbenchLoggingArguments = $"--dbName {this.DatabaseName} --databaseSystem {this.DatabaseSystem} --benchmark {this.Benchmark} --threadCount {threadCount} --tableCount {tableCount} --recordCount {recordCount}";
8686
this.sysbenchPrepareArguments = $"{sysbenchLoggingArguments} --password {this.SuperUserPassword}";
8787

8888
string serverIp = "localhost";

src/VirtualClient/VirtualClient.Actions/Sysbench/SysbenchExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ protected void AddMetric(string arguments, IProcessProxy process, EventContext t
417417

418418
List<Metric> metrics = new List<Metric>();
419419
double duration = (process.ExitTime - process.StartTime).TotalMinutes;
420-
metrics.Add(new Metric("PopulateDatabaseTime_Minutes", duration, "minutes", MetricRelativity.LowerIsBetter));
420+
metrics.Add(new Metric("PopulateDatabaseDuration", duration, "minutes", MetricRelativity.LowerIsBetter));
421421

422422
this.Logger.LogMetrics(
423423
toolName: "Sysbench",

src/VirtualClient/VirtualClient.Actions/Sysbench/SysbenchMetricsParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public SysbenchMetricsParser(string rawText)
3333
/// <inheritdoc/>
3434
public override IList<Metric> Parse()
3535
{
36-
var match = Regex.Match(this.RawText, @"sysbench\s+([\d\.]+-[\w\d]+)");
36+
var match = Regex.Match(this.RawText, @"sysbench\s+([\d]+\.[\d]+\.[\d]+(?:-\w+)?)");
3737
string sysbenchversion = match.Success ? match.Groups[1].Value : string.Empty;
3838
this.metricMetadata["sysbench_version"] = sysbenchversion;
3939
this.Preprocess();

src/VirtualClient/VirtualClient.Main/profiles/PERF-POSTGRESQL-SYSBENCH-OLTP.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
"Parameters": {
183183
"Scenario": "DownloadSysbenchPackage",
184184
"BlobContainer": "packages",
185-
"BlobName": "sysbench-1.0.20.rev2.zip",
185+
"BlobName": "sysbench-1.0.20.rev3.zip",
186186
"PackageName": "sysbench",
187187
"Extract": true
188188
}

0 commit comments

Comments
 (0)