Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executor and Parser for onboarding MongoDB #213

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
04:56:24.570 [Thread-16] DEBUG org.mongodb.driver.protocol.update - Updating documents in namespace ycsb.usertable on connection [connectionId{localValue:17, serverValue:34}] to server localhost:27017
04:56:24.571 [Thread-16] DEBUG org.mongodb.driver.protocol.update - Update completed
04:56:24.571 [Thread-16] DEBUG org.mongodb.driver.protocol.update - Updating documents in namespace ycsb.usertable on connection [connectionId{localValue:17, serverValue:34}] to server localhost:27017
04:56:24.571 [Thread-16] DEBUG org.mongodb.driver.protocol.update - Update completed
04:56:24.571 [Thread-16] DEBUG org.mongodb.driver.protocol.query - Sending query of namespace ycsb.usertable on connection [connectionId{localValue:17, serverValue:34}] to server localhost:27017
04:56:24.572 [Thread-16] DEBUG org.mongodb.driver.protocol.query - Query completed
04:56:24.572 [Thread-16] DEBUG org.mongodb.driver.protocol.update - Updating documents in namespace ycsb.usertable on connection [connectionId{localValue:17, serverValue:34}] to server localhost:27017
04:56:24.572 [Thread-16] DEBUG org.mongodb.driver.protocol.update - Update completed
04:56:24.572 [Thread-16] DEBUG org.mongodb.driver.protocol.update - Updating documents in namespace ycsb.usertable on connection [connectionId{localValue:17, serverValue:34}] to server localhost:27017
04:56:24.573 [Thread-16] DEBUG org.mongodb.driver.protocol.update - Update completed
04:56:24.573 [Thread-16] DEBUG org.mongodb.driver.protocol.query - Sending query of namespace ycsb.usertable on connection [connectionId{localValue:17, serverValue:34}] to server localhost:27017
04:56:24.573 [Thread-16] DEBUG org.mongodb.driver.protocol.query - Query completed
04:56:24.573 [Thread-16] DEBUG org.mongodb.driver.protocol.update - Updating documents in namespace ycsb.usertable on connection [connectionId{localValue:17, serverValue:34}] to server localhost:27017
04:56:24.574 [Thread-16] DEBUG org.mongodb.driver.protocol.update - Update completed
04:56:24.574 [Thread-16] DEBUG org.mongodb.driver.protocol.query - Sending query of namespace ycsb.usertable on connection [connectionId{localValue:17, serverValue:34}] to server localhost:27017
04:56:24.574 [Thread-16] DEBUG org.mongodb.driver.protocol.query - Query completed
04:56:24.574 [Thread-16] DEBUG org.mongodb.driver.protocol.update - Updating documents in namespace ycsb.usertable on connection [connectionId{localValue:17, serverValue:34}] to server localhost:27017
04:56:24.575 [Thread-16] DEBUG org.mongodb.driver.protocol.update - Update completed
08:32:27.881 [cluster-ClusterId{value='654b468a9bbaa7610f22769c', description='null'}-localhost:27017] DEBUG org.mongodb.driver.connection - Closing connection connectionId{localValue:1, serverValue:1}
[OVERALL], RunTime(ms), 188018.0
[OVERALL], Throughput(ops/sec), 5318.639704709123
[CLEANUP], Operations, 16.0
[CLEANUP], AverageLatency(us), 628.3125
[CLEANUP], MinLatency(us), 1.0
[CLEANUP], MaxLatency(us), 10031.0
[CLEANUP], 95thPercentileLatency(us), 5.0
[CLEANUP], 99thPercentileLatency(us), 10031.0
[INSERT], Operations, 1000000.0
[INSERT], AverageLatency(us), 2962.514545
[INSERT], MinLatency(us), 176.0
[INSERT], MaxLatency(us), 659967.0
[INSERT], 95thPercentileLatency(us), 5859.0
[INSERT], 99thPercentileLatency(us), 9199.0
[INSERT], Return=OK, 1000000
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
08:32:27.881 [cluster-ClusterId{value='654b468a9bbaa7610f22769c', description='null'}-localhost:27017] DEBUG org.mongodb.driver.connection - Closing connection connectionId{localValue:1, serverValue:1}
[OVERALL], RunTime(ms), 273802.0
[OVERALL], Throughput(ops/sec), 3652.274271188669
[CLEANUP], Operations, 16.0
[CLEANUP], AverageLatency(us), 1170.75
[CLEANUP], MinLatency(us), 2.0
[CLEANUP], MaxLatency(us), 18671.0
[CLEANUP], 95thPercentileLatency(us), 36.0
[CLEANUP], 99thPercentileLatency(us), 18671.0
[INSERT], Operations, 1000000.0
[INSERT], AverageLatency(us), 4326.729145
[INSERT], MinLatency(us), 264.0
[INSERT], MaxLatency(us), 829439.0
[INSERT], 95thPercentileLatency(us), 8567.0
[INSERT], 99thPercentileLatency(us), 14039.0
[INSERT], Return=OK, 1000000
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[OVERALL], RunTime(ms), 210252.0
[OVERALL], Throughput(ops/sec), 4756.197325114625
[READ], Operations, 500209.0
[READ], AverageLatency(us), 3193.3359775613794
[READ], MinLatency(us), 139.0
[READ], MaxLatency(us), 306431.0
[READ], 95thPercentileLatency(us), 6959.0
[READ], 99thPercentileLatency(us), 13231.0
[READ], Return=OK, 500209
[CLEANUP], Operations, 16.0
[CLEANUP], AverageLatency(us), 648.5625
[CLEANUP], MinLatency(us), 1.0
[CLEANUP], MaxLatency(us), 10351.0
[CLEANUP], 95thPercentileLatency(us), 7.0
[CLEANUP], 99thPercentileLatency(us), 10351.0
[UPDATE], Operations, 499791.0
[UPDATE], AverageLatency(us), 3456.1790108265254
[UPDATE], MinLatency(us), 242.0
[UPDATE], MaxLatency(us), 333567.0
[UPDATE], 95thPercentileLatency(us), 7631.0
[UPDATE], 99thPercentileLatency(us), 14175.0
[UPDATE], Return=OK, 499791
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[OVERALL], RunTime(ms), 212686.0
[OVERALL], Throughput(ops/sec), 4701.766924010043
[READ], Operations, 499980.0
[READ], AverageLatency(us), 3222.582387295492
[READ], MinLatency(us), 147.0
[READ], MaxLatency(us), 462335.0
[READ], 95thPercentileLatency(us), 7003.0
[READ], 99thPercentileLatency(us), 12895.0
[READ], Return=OK, 499980
[CLEANUP], Operations, 16.0
[CLEANUP], AverageLatency(us), 602.4375
[CLEANUP], MinLatency(us), 1.0
[CLEANUP], MaxLatency(us), 9615.0
[CLEANUP], 95thPercentileLatency(us), 7.0
[CLEANUP], 99thPercentileLatency(us), 9615.0
[UPDATE], Operations, 500020.0
[UPDATE], AverageLatency(us), 3499.336832526699
[UPDATE], MinLatency(us), 236.0
[UPDATE], MaxLatency(us), 356351.0
[UPDATE], 95thPercentileLatency(us), 7775.0
[UPDATE], 99thPercentileLatency(us), 13983.0
[UPDATE], Return=OK, 500020
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[OVERALL], RunTime(ms), 705.0
[OVERALL], Throughput(ops/sec), 141.84397163120568
[READ], Operations, 48.0
[READ], AverageLatency(us), 25801.666666666668
[READ], MinLatency(us), 917.0
[READ], MaxLatency(us), 115839.0
[READ], 95thPercentileLatency(us), 111551.0
[READ], 99thPercentileLatency(us), 115839.0
[READ], Return=NOT_FOUND, 48
[CLEANUP], Operations, 16.0
[CLEANUP], AverageLatency(us), 828.625
[CLEANUP], MinLatency(us), 0.0
[CLEANUP], MaxLatency(us), 13247.0
[CLEANUP], 95thPercentileLatency(us), 7.0
[CLEANUP], 99thPercentileLatency(us), 13247.0
[UPDATE], Operations, 52.0
[UPDATE], AverageLatency(us), 27971.326923076922
[UPDATE], MinLatency(us), 1482.0
[UPDATE], MaxLatency(us), 116799.0
[UPDATE], 95thPercentileLatency(us), 116223.0
[UPDATE], 99thPercentileLatency(us), 116351.0
[UPDATE], Return=NOT_FOUND, 52
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@

namespace VirtualClient.Actions
{
using Moq;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using VirtualClient.Common;
using VirtualClient.Common.Telemetry;
using VirtualClient.Contracts;

[TestFixture]
[Category("Unit")]
public class MongoDBExecutorTests
{
private MockFixture mockFixture;
private DependencyPath mockPackage, mockYCSBPackage;
private ConcurrentBuffer defaultOutput = new ConcurrentBuffer();


[SetUp]
public void Setup()
{

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove extra whitespace

this.mockFixture = new MockFixture();
this.mockFixture.Setup(PlatformID.Unix);
this.mockPackage = new DependencyPath("mongodb", this.mockFixture.PlatformSpecifics.GetPackagePath("mongodb"));
this.mockYCSBPackage = new DependencyPath("ycsb", this.mockFixture.PlatformSpecifics.GetPackagePath("ycsb"));
this.mockFixture.PackageManager.OnGetPackage().ReturnsAsync(this.mockPackage);
this.mockFixture.Parameters = new Dictionary<string, IConvertible>()
{
{ nameof(MongoDBExecutor.Scenario), "" },
{ nameof(MongoDBExecutor.PackageName), "mongodb" },
{ nameof(MongoDBExecutor.YCSBPackageName), "ycsb" }
};

string currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string resultsPath = Path.Combine(currentDirectory, "Examples", "MongoDB", "MongoInsertData01.txt");
string results = File.ReadAllText(resultsPath);
this.defaultOutput.Clear();
this.defaultOutput.Append(results);
}

[Test]
[TestCase(PlatformID.Unix, Architecture.X64)]
public async Task MongoDBExecutorInitializesItsDependenciesAsExpected(PlatformID platform, Architecture architecture)
{
this.Setup();
using (TestMongoDBExecutor executor = new TestMongoDBExecutor(this.mockFixture))
{
this.mockFixture.ProcessManager.OnCreateProcess = (command, arguments, workingDirectory) =>
{
return this.mockFixture.Process;
};

await executor.InitializeAsync(EventContext.None, CancellationToken.None)
.ConfigureAwait(false);

string mongoDBExpectedPath = this.mockFixture.PlatformSpecifics.Combine(this.mockPackage.Path) ;

Assert.AreEqual(mongoDBExpectedPath, executor.GetMongoProcessPath);
}
}



private class TestMongoDBExecutor : MongoDBExecutor
{
public TestMongoDBExecutor(MockFixture fixture)
: base(fixture.Dependencies, fixture.Parameters)
{
}

public new Task InitializeAsync(EventContext telemetryContext, CancellationToken cancellationToken)
{
return base.InitializeAsync(telemetryContext, cancellationToken);
}

public new Task ExecuteAsync(EventContext context, CancellationToken cancellationToken)
{
this.InitializeAsync(context, cancellationToken).GetAwaiter().GetResult();
return base.ExecuteAsync(context, cancellationToken);
}

public string GetMongoProcessPath => base.MongoDBPackagePath;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, remove extra white space



}

}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace VirtualClient.Actions
{
using NUnit.Framework;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add unit test for the executor

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

public class MongoDBMetricsParserTests
{
private string rawText;
private MongoDBMetricsParser testParser;

[SetUp]
public void Setup()
{
string workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string outputPath = Path.Combine(workingDirectory, @"Examples\MongoDB\MongoOperationsData03.txt");
this.rawText = File.ReadAllText(outputPath);
this.testParser = new MongoDBMetricsParser(this.rawText);
}
[Test]
public void MongoDBMetricsParserParsesAsExpected()
{
this.testParser.Parse();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here please check each metrics individually

Assert.IsNotNull(this.testParser.Sections["Metrics"]);
}
}
}
Loading