mongo2go / mongo2go Goto Github PK
View Code? Open in Web Editor NEWMongo2Go - MongoDB for .NET integration tests
License: MIT License
Mongo2Go - MongoDB for .NET integration tests
License: MIT License
Can we prevent the Windows Firewall popup from appearing?
I'm getting it when I reset the test environment or restart VS, etc.
I am writing integration tests, for which I would like to use Mongo2go (great idea, by the way).
I have MongoDb server installed on my machine. That instance should be for regular usage of the application.
And I am seeing that MongoDbRunner.StartDebugging, instead of returning a brand new instance, is selecting the one that is installed.
After checking the code, at the private constructor of MongoDbrunner, I have verified that indeed
That is not the desired behavior. I would like:
If you want, I could even try and develop it by myself and do a pull request.
What do you think?
Thanks a lot by the way
Are there any plans to support .NET Core in the future?
There's a hardcoded data path used in the MongoDbRunner.StartUnitTest(IPortPool portPool, IFileSystem fileSystem, IMongoDbProcessStarter processStarter, IMongoBinaryLocator mongoBin) method:
return new MongoDbRunner(portPool, fileSystem, processStarter, mongoBin, "C:\\data\\db");
This is an oversight, I'm sure - you can pass that parameter in Start and StartForDebugging methods but it's unavailable in StartUnitTest. This is a bad thing, since some people, including me, need to specify the used data directory.
For those that have met the same problem, as a quick and dirty workaround you can simply use reflection to call the constructor yourself (it's generally a big no-no to be touching private constructors, but this'll get you moving):
_dataDir = @"c:\my\own\path\to\data";
var constructor = typeof(MongoDbRunner).GetConstructor(
BindingFlags.NonPublic | BindingFlags.Instance,
null,
new Type[]
{
typeof(IPortPool),
typeof(IFileSystem),
typeof(IMongoDbProcessStarter),
typeof(IMongoBinaryLocator),
typeof(string)
}, null);
_runner = (MongoDbRunner)constructor.Invoke(new object[]
{
PortPool.GetInstance, new FileSystem(), new MongoDbProcessStarter(), new MongoBinaryLocator(null), _dataDir
});
Summarized: StartUnitTest could use another parameter to let us define what data directory to use.
I believe it's because this check was added:
https://jira.mongodb.org/browse/CSHARP-2561
Just change the test suite from 2.7.0 to 2.8.0, still passes. Change to 2.8.1 - failure!
MongoDbRunner.Start()
not work in vs 2017 test tool with xunit project in run test operation
and debug test operatioin
MongoDbRunner.StartForDebugging()
is done with run test operation
and debug test operatioin
in vs 2017 test tool with xunit project.
MongoDbRunner.Start()
and MongoDbRunner.StartForDebugging()
all correct in dotnet test
command line tool
I'm trying to start Mongo2Go as following:
MongoDbRunner.Start(dataPath);
It works fine, but throws IOException on callings Dispose()
method ("...unable to access local.0 file...").
At the same time MongoDbRunner.StartForDebugging(dataPath)
works ok.
Looks like mongo process still running when trying to delete data files in case of .Start()
method.
I'm not sure what is the root cause of this (could be a deadlock) but I did some digging and commenting out following lines in "StartAndWaitForReady" method of "ProcessControl.cs" class fixes the issue.
process.CancelErrorRead();
process.CancelOutputRead();
I got a test case that works well on Windows, and with Mono on Linux, but it fails with Mono on MacOSX.
Test framework used is Nunit
[Test]
public async Task TestMongo2Go()
{
var tmpDir = System.IO.Path.GetTempPath();
MongoDbRunner _mongodb = MongoDbRunner.Start(tmpDir);
var _mongoClient = new MongoClient(_mongodb.ConnectionString);
IMongoDatabase db = _mongoClient.GetDatabase("unittest");
var role = new Role { Name = "ALL PERMISSIONS", PermissionTypes = new List<string> { "ALL PERMISSIONS", "READ_ALL" } };
await db.GetCollection<Role>("role").InsertOneAsync(role);
var user = new User { Name = "unittest", PersonalNumber = "123", RoleIds = new List<ObjectId> { role.Id } };
await db.GetCollection<User>("user").InsertOneAsync(user);
var users = await db.GetCollection<User>("user").Find(u => true).ToListAsync();
Assert.AreEqual(1, users.Count);
}
Stack trace is:
TestMono.TestMongo2GoUser
System.TimeoutException : A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = WritableServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "8", ConnectionMode : "Automatic", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 8, EndPoint : "Unspecified/localhost:27024" }", EndPoint: "Unspecified/localhost:27024", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> System.Net.Sockets.SocketException: Connection refused
No firewall and ping localhost works
Any suggestions would be appreciated
Might be related to this: aspnet/Hosting#1537
I am trying to use $lookup
and would love to be able to test using mongo2go. I am going to look at how to update this but if its easy for y'all to do it, I would certainly appreciate it.
I think we should try to model this after how Json.Net is making things work.
I am having a hard time setting up the integration tests with Mongo2Go for our app
( which implements Repository pattern) and project requirements to use xUnit (and Mock ).
If anyone is using Mongo2Go with xUnit and Mock, whould you please share some examples?
Hi !
It would be great if we could be able to run MongoDB with the option --storageEngine inMemory (https://docs.mongodb.com/manual/core/inmemory/) appended to the final cmd line. In order to achieve fastest tests !
Thanks !
Using Mongo2Go for mocking the mongo db calls. Below would be the structure am, using. Environment: .Net Core 2.0 / VS 2017
Helper.cs -> Creates the the Mongo2Go runner instance the returns the same (Non single-ton)
In any test class I am getting the runner instance like new Helper<T>().GetRunnerinstance()
and using the same instance for all test cases/methods. below would a small sample code as how using Mongo2Go
this.mockRepository.Setup(x => x.AddDocumentAsync(It.IsAny<ABC>()))
.Callback(() => this.Helper.Collection.InsertOneAsync(abc))
.Returns(Task.FromResult<ABC>(abc));
in above piece of code, am using MOQ and calling a local Mongo2Go call instead of actual repository call. Then to verify or assert am trying to get the same inserted local data like
var data = await this.Helper.Collection.Find(new BsonDocument(nameof(ABC.Name), Constants.Name)).ToListAsync();
var actual = data.Single(); // this line behaves wired
When I run all the test cases either from VS or through command prompt dotnet test
the code line data.Single()
fails with exception ... empty collection, no elements. The reason is obvious that the mongo Find()
call didn't fetch any result through it should have since I have just inserted the same record.
Very strange thing is that, it runs absolutely fine when I debug the test but fails when just run only that test or all test discovered.
Any idea, why is it behaving so? Please help
Exception: Second path fragment must not be a drive or UNC name.
I am going to look into this tonight, but after updating to the alpha Mongo2Go no longer works for me locally.
So after working through the other issue, I find that I started getting these errors:
They seem to be related to changing from the Non-SSL distribution of MongoDB to the SSL version:
cd84523
I'm using [assembly: CollectionBehavior(DisableTestParallelization = true)]
to ensure that my test processes don't run along side each other. When I remove this switch the processes hang (if there is more than one running at a time) and no tests complete.
I've tested this when running another mongod.exe process running (another local server) and with the [assembly: CollectionBehavior(DisableTestParallelization = true)]
tests pass, without, they hang. So I know it's not about the total number of concurrent mongod.exe processes on the system.
If they're using different ports and different folders on disk, why the contention?
Setup for this issue: OSX, dotnet core 2.2, Mongo2Go latest version, NUnit.
First thing, thanks for the work on this! Nice little project you have here and I appreciate having this as an option.
I have a method I'm testing that looks like this:
public async Task<Thing> FindAsync(string id)
{
var mongoCollection = this.getMongoCollection();
var results = await mongoCollection.FindAsync(
thing => thing.Id == id
);
if (results.Any())
{
return results.First();
}
return null;
}
I start up Mongo2Go with NUnit so that it will only be configured once at the beginning of running the test suite and then holding onto references to each of these during the execution of each test:
private MongoDbRunner _runner;
private MongoClient _client;
private IMongoDatabase _fakeDb;
[OneTimeSetUp]
public void Init()
{
_runner = MongoDbRunner.Start();
_client = new MongoClient(_runner.ConnectionString);
_fakeDb = _client.GetDatabase("ThingiesIntegrationTest");
var sampleThing = new Thing();
sampleThing.Id = "abc123";
_fakeDb.GetCollection<Thing>("Thingies")
.InsertOne(sampleThing);
var test = _fakeDb.GetCollection<FileSummary>("Thingies")
.Find(f => f.Id == sampleFileSummary.Id);
}
The test itself that's exercising the conditional in the code is:
[Test]
public async Task FindAsync_Locates_Thing()
{
var realThingId = "abc123";
var thing = await Repository.FindAsync(realThingId);
Assert.That(
thing.Id, Is.EqualTo(realThingId), "Thing ID's do not match");
}
When I execute the tests in this setup, I get the following exception:
System.ObjectDisposedException : Cannot access a disposed object.
Object name: 'AsyncCursor`1'.
Stack Trace:
at MongoDB.Driver.Core.Operations.AsyncCursor`1.ThrowIfDisposed()
at MongoDB.Driver.Core.Operations.AsyncCursor`1.MoveNext(CancellationToken cancellationToken)
at MongoDB.Driver.IAsyncCursorExtensions.GetFirstBatch[TDocument](IAsyncCursor`1 cursor, CancellationToken cancellationToken)
at MongoDB.Driver.IAsyncCursorExtensions.First[TDocument](IAsyncCursor`1 cursor, CancellationToken cancellationToken)
at Thingies.Repositories.ThingieRepository.FindAsync(String id) in /Users/asdf/Code/project/Repositories/ThingieRepository.cs:line 38
at NUnit.Framework.Internal.AsyncInvocationRegion.AsyncTaskInvocationRegion.WaitForPendingOperationsToComplete(Object invocationResult)
at NUnit.Framework.Internal.Commands.TestMethodCommand.RunAsyncTestMethod(TestExecutionContext context)
I'm not exactly sure why the cursor is being disposed of after invoking Any()
on it. If I omit that line and re-run this test, it passes as expected. I can also work around this issue by changing to AsyncCursor.FirstOrDefault()
for my scenario, but I'd like to know what I'm doing wrong.
I'm glad to dig in and provide more detailed information (or even a PR if it comes to it). I need a pointer on what information I should get and where to begin looking at things. Or if I am just using this wrong, I'll correct that mistake myself.
So that I can be assured that each test run, the state of the store is the same.
Would you accept a PR for MongoDb Driver 2.3.0 which also requires a .NET Version >= 4.5?
The signature of the MongoDbRunner.Start
changed to have the data file path as the second position, and because of its default nature, this causes people using this param currently to silently start passing it as the first position.
c3cf907#diff-6d23e8d4af4d1612bdb0bbe25330c40bR32
This should be reversed to keep from tripping people up.
It would be great if we could be able to run MongoDB 3.4 (personally I need it since there are new Aggregation framework operators which I am using)
I'm try to run some integration tests with mongo2go under windows 8 but try allways fail on the dispose method. It creates the database on c:/data without a problem.
Cheers.
The testcase below is rock solid on windows, but fails almost every time on Linux, making impossible to run CI on https://circleci.com/ or https://travis-ci.com/ or any other Linux based CI service.
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyUnitTest
{
[TestFixture]
class TestMongo2go
{
[Test]
public async Task TestStartMany()
{
var old_runners = new List<Mongo2Go.MongoDbRunner>();
Mongo2Go.MongoDbRunner _mongodb;
for (int i = 0; i < 25; i++)
{
string tmpDir = System.IO.Path.GetTempPath();
_mongodb = Mongo2Go.MongoDbRunner.Start(tmpDir);
Console.WriteLine("_mongodb.State: " + _mongodb.State);
bool dbUp = ProbeForMongoDbConnection(_mongodb.ConnectionString, "unittest");
Console.WriteLine("Connection to " + _mongodb.ConnectionString + " was " + (dbUp ? "successful!" : "NOT successful!"));
Assert.IsTrue(dbUp, "mongodb is not alive");
old_runners.Add(_mongodb);
}
foreach (Mongo2Go.MongoDbRunner runner in old_runners)
{
runner.Dispose();
}
}
private static bool ProbeForMongoDbConnection(string connectionString, string dbName)
{
var probeTask =
Task.Run(() =>
{
var isAlive = false;
var client = new MongoDB.Driver.MongoClient(connectionString);
for (var k = 0; k < 6; k++)
{
client.GetDatabase(dbName);
var server = client.Cluster.Description.Servers.FirstOrDefault();
isAlive = (server != null &&
server.HeartbeatException == null &&
server.State == MongoDB.Driver.Core.Servers.ServerState.Connected);
if (isAlive)
{
break;
}
System.Threading.Thread.Sleep(300);
}
return isAlive;
});
probeTask.Wait();
return probeTask.Result;
}
}
}
I would like to be able to set a port when running StartForDebugging() as the current default port (27017) may be in use on my local machine which in turn causes my integration tests to fail.
I thought of two options on how to implement this, I'd be happy to create a PR if this is something that you want to add to Mongo2Go.
I've set up a collection fixture with MongoDb to be able to test a long running migration job that includes inserting transforming data and inserting millions of records into a MongoDb instance. Tested it on a few smaller files and it worked just fine, yesterday, set it up to work on an actual input file and went home.
Today I was greeted by an error message saying:
Message: MongoDB.Driver.MongoConnectionException : An exception occurred while opening a connection to the server.
---- System.Net.Sockets.SocketException : Only one usage of each socket address (protocol/network address/port) is normally permitted 127.0.0.1:27021
This happened exactly an hour into the test. It looks like for some reason, at that point there was an attempt to start up another instance of MongoDb, which failed? Not sure why that would happen.
I'm using Xunit 2.3.1 and Mongo2Go 2.2.4 and the target framework of my test project is .NET framework 4.6.1.
I use custom Bson serialization in my app:
var pack = new ConventionPack {new CamelCaseElementNameConvention()};
ConventionRegistry.Register("camelCaseConvention", pack, t => true);
BsonClassMap.RegisterClassMap<MyDocument>(m =>
{
m.AutoMap();
m.SetIdMember(m.GetMemberMap(e => e.MyId));
});
If I register my naming convention (code from above) in integration tests with Mongo2Go
, I got error:
System.ArgumentException
An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at MongoDB.Bson.Serialization.BsonClassMap.RegisterClassMap(BsonClassMap classMap)
If I do not register my naming convention, I got error:
System.FormatException
Element '_id' does not match any field or property of class MongoDB.Bson.Serialization.BsonClassMapSerializer`1.DeserializeClass(BsonDeserializationContext context)
at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
Is it possible to teach Mongo2Go
to work with custom serializations? What do you think from architecture side?
Hello,
I have an issue with mongo2go in a linux environment, using the 2.0.0-aplha1 version.
the method MakeFileExecutable() throws an exception :
Invalid File or Directory attributes value
at System.IO.FileSystemInfo.System.IO.IFileSystemObject.set_Attributes(FileAttributes value)
at System.IO.UnixFileSystem.SetAttributes(String fullPath, FileAttributes attributes)
at System.IO.File.SetAttributes(String path, FileAttributes fileAttributes)
/data/projects/Mongo2Go/src/Mongo2Go/Helper/FileSystem.cs(35,0): at Mongo2Go.Helper.FileSystem.MakeFileExecutable(String path)
/data/projects/Mongo2Go/src/Mongo2Go/MongoDbRunner.cs(137,0): at Mongo2Go.MongoDbRunner.MakeMongoBinarysExecutable()
/data/projects/Mongo2Go/src/Mongo2Go/MongoDbRunner.cs(120,0): at Mongo2Go.MongoDbRunner..ctor(IPortPool portPool, IFileSystem fileSystem, IMongoDbProcessStarter processStarter, IMongoBinaryLocator mongoBin, String dataDirectory)
/data/projects/Mongo2Go/src/Mongo2Go/MongoDbRunner.cs(37,0): at Mongo2Go.MongoDbRunner.Start(String dataDirectory, String searchPatternOverride)
if I comment this line, everything works as excepted.
Thanks
Hello,
I'm using mongo's new "decimal128" type that came in v3.4 and unfortunately I get errors when running my tests with mongo2go. I've confirmed that the errors go away when testing against a db that's using featureCompatibiltyVersion 3.4. Is it possible to change the featureCompatibilityVersion of mongo2go so it will work with 3.4 features?
Thanks,
-Nick
Hi,
Currently the Mongo2Go supports only one version of mongod server (ie is 4.0.3). Could we add support for different versions? It would be great if we can support different flavours such as RHEL or Ubuntu, etc...
I would like to high light some information here.
In javascript world, there are mongodb package downloaders that support this
https://www.npmjs.com/package/mongodb-prebuilt
https://www.npmjs.com/package/mongodb-download
These package facilitating downloading of mongodb server version from the "https://fastdl.mongodb.org" based on the target os version.
providing this flexibility would be great in C# world.
If you are okay with the idea, I can also work on getting the feature implemented. (I might need some information and help)
Regards,
Nachiappan
I'm using VSTS with VS2017 hosted agent and had issue trying to get Mongo2Go to work. I restore my packages using MSBuild's restore.
MSBuild /t:restore
restores packages to %USERPROFILE%/.nuget
by default, which is inaccessible from the directory searcher.{Name}\{Version}
currently it assumes {Name}*{Version}*
I worked around this by creating a copy files task with the following settings:
Source Folder: $(USERPROFILE)\.nuget\packages\mongo2go\2.1.0\tools
Contents: **
Target Folder: $(System.DefaultWorkingDirectory)\tools
Unsure what best course of action would be. Allowing an absolute path to packages would be one option? Or making it search %USERPROFILE%/.nuget/packages
as well. That would perhaps be better?
Im using Mongo2Go 2.2.8 with Xunit, targeting framework netcoreapp2.1
In Windows everything works fine, but in Linux (Docker Container from microsoft/dotnet:2.1.302-sdk-alpine3.7) when I try to execute "dotnet test" I get the following error "System.ComponentModel.Win32Exception"
First I had some problems with the locate of binaries and I fixed with:
var _runner = MongoDbRunner.Start("MongoData/", "tools/mongodb-linux*/bin", "/root/.nuget/packages/mongo2go/2.2.8");
I checked permissions inside container on folder "MongoData" (generated in /bin/debug/netcoreapp2.1/) and in the folder of binaries, all are root:root. The binaries have the execute bit.
UPDATE:
If I run dotnet test from my linux machine (Centos7), everything works fine, its a problem with container.
Any ideas ?
Stack Trace is:
Failed SendAsync Test Valid
Error Message: System.ComponentModel.Win32Exception : No such file or directory
Stack Trace:
at Interop.Sys.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setUser, UInt32 userId, UInt32 groupId, Int32& lpChildPid, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean shouldThrow)
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at Mongo2Go.Helper.ProcessControl.StartAndWaitForReady(Process process, Int32 timeoutInSeconds, String processReadyIdentifier, String windowTitle)
at Mongo2Go.Helper.MongoDbProcessStarter.Start(String binariesDirectory, String dataDirectory, Int32 port, Boolean doNotKill, Boolean singleNodeReplSet)
at Mongo2Go.MongoDbRunner..ctor(IPortPool portPool, IFileSystem fileSystem, IMongoDbProcessStarter processStarter, IMongoBinaryLocator mongoBin, String dataDirectory, Boolean singleNodeReplSet)
at Mongo2Go.MongoDbRunner.Start(String dataDirectory, String binariesSearchPatternOverride, String binariesSearchDirectory, Boolean singleNodeReplSet)
I downloaded source code of Mongo2Go, but have trouble with running tests. They use MSpec, I can't discover them with adapter nor in console (dotnet test). There is a file in solution NO_TESTS.txt. Does it mean they cannot be run now?
Can you run these tests on latest build? Any hints how?
My project the way I have it right now works perfectly fine locally (Windows) and on Teamcity, both on .NET Core 2.1. If I update to .NET Core 3.0-preview it continues to work locally but on Teamcity it breaks with the following error:
Error Message:
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] System.AggregateException : One or more errors occurred. (Could not find a part of the path '/in/tests/unit/MyPackage.Tests/bin/Release/netcoreapp3.0/~/.nuget/packages'.) (The following constructor parameters did not have matching fixture data: MongoIntegrationFixture mongoIntegrationFixture)
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] ---- System.IO.DirectoryNotFoundException : Could not find a part of the path '/in/tests/unit/MyPackage.Tests/bin/Release/netcoreapp3.0/~/.nuget/packages'.
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] ---- The following constructor parameters did not have matching fixture data: MongoIntegrationFixture mongoIntegrationFixture
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] Stack Trace:
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj]
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] ----- Inner Stack Trace #1 (System.IO.DirectoryNotFoundException) -----
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] at System.IO.Enumeration.FileSystemEnumerator`1..ctor(String directory, EnumerationOptions options)
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options)
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] at System.IO.Enumeration.FileSystemEnumerableFactory.UserDirectories(String directory, String expression, EnumerationOptions options)
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] at System.IO.Directory.GetDirectories(String path, String searchPattern)
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] at Mongo2Go.Helper.FolderSearch.FindFolder(String startPath, String searchPattern)
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] at Mongo2Go.Helper.FolderSearch.FindFolderUpwards(String startPath, String searchPattern)
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] at Mongo2Go.Helper.MongoBinaryLocator.FindBinariesDirectory(IList`1 searchDirectories)
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] at Mongo2Go.Helper.MongoBinaryLocator.ResolveBinariesDirectory()
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] at Mongo2Go.Helper.MongoBinaryLocator.get_Directory()
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] at Mongo2Go.MongoDbRunner.MakeMongoBinarysExecutable()
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] at Mongo2Go.MongoDbRunner..ctor(IPortPool portPool, IFileSystem fileSystem, IMongoDbProcessStarter processStarter, IMongoBinaryLocator mongoBin, String dataDirectory, Boolean singleNodeReplSet)
[20:02:01] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] at Mongo2Go.MongoDbRunner.Start(String dataDirectory, String binariesSearchPatternOverride, String binariesSearchDirectory, Boolean singleNodeReplSet)
I run it with MongoDbRunner.Start(singleNodeReplSet: true);
In an attempt to solve it I have tried publishing a package with the change as suggested in #61 (comment) but that didn't fix it. It gives the following output:
==>Error Message:
[20:45:31] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] ==> System.AggregateException : One or more errors occurred. (Could not find Mongo binaries using the search patterns "tools/mongodb-linux*/bin", "packages/Mongo2Go*/tools/mongodb-linux*/bin", and "packages/mongo2go/*/tools/mongodb-linux*/bin". You can override the search pattern and directory when calling MongoDbRunner.Start. We have detected the OS as Linux 4.14.42-61.37.amzn2.x86_64 #1 SMP Mon May 21 23:43:11 UTC 2018.
[20:45:31] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] ==>We walked up to root directory from the following locations.
[20:45:31] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] ==> /in/tests/unit/MyPackage.Tests/bin/Release/netcoreapp3.0
[20:45:31] [/in/tests/unit/MyPackage.Tests/MyPackage.Tests.csproj] ==>/root/.nuget/packages) (The following constructor parameters did not have matching fixture data: MongoIntegrationFixture mongoIntegration)
I currently don't have ssh access to our build servers so I can't take a look on the actual machine but figured I'd let you know regardless. Any idea what this might be? As evident from the stacktrace, we're running a linux distro.
I will start by using travis-ci and get things working there.
So I'm running my tests in the R# runner and debugging locally. Before my using
block completes I'm stopping the test which AFAIK should call the finaliser on the MongoDbRunner
instance. Only, I suspect that, we're not getting past this line https://github.com/JohannesHoppe/Mongo2Go/blob/master/src/Mongo2Go/MongoDbRunner.IDisposable.cs#L28 and we should be. The result is that my process stays alive when it should terminate and my data folder is not cleaned up.
If this can be resolved, then perhaps #16 is moot.
Currently, I’m working with Mongo2Go for unit test. But when I build my Project on VSTS and see it doesn’t work properly. You can check the following error
2018-08-09T09:06:03.9933372Z [xUnit.net 00:00:40.97] xxxxxxx.BackEnd.Tests.Project.ProjectReadServiceTests.TestGetProjectDetailAsync [FAIL]
2018-08-09T09:06:04.0574498Z Failed xxxxxxx.BackEnd.Tests.Project.ProjectReadServiceTests.TestGetProjectDetailAsync
2018-08-09T09:06:04.0574987Z Error Message:
2018-08-09T09:06:04.0575333Z System.AggregateException : One or more errors occurred. (A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "2", ConnectionMode : "Automatic", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 2, EndPoint : "127.0.0.1:27019" }", EndPoint: "127.0.0.1:27019", State: "Disconnected", Type: "Unknown" }] }.)
2018-08-09T09:06:04.0575882Z ---- System.TimeoutException : A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "2", ConnectionMode : "Automatic", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 2, EndPoint : "127.0.0.1:27019" }", EndPoint: "127.0.0.1:27019", State: "Disconnected", Type: "Unknown" }] }.
2018-08-09T09:06:04.0576249Z Stack Trace:
2018-08-09T09:06:04.0576430Z at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
2018-08-09T09:06:04.0576638Z at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
2018-08-09T09:06:04.0576802Z at System.Threading.Tasks.Task.Wait()
2018-08-09T09:06:04.0577004Z at xxxxxxx.BackEnd.Tests.Project.ProjectReadServiceTests.TestGetProjectDetailAsync() in D:\a\1\s\Tests\xxxxxxx.BackEnd.Tests\Project\ProjectReadServiceTests.cs:line 116
2018-08-09T09:06:04.0577230Z ----- Inner Stack Trace -----
2018-08-09T09:06:04.0577420Z at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description)
2018-08-09T09:06:04.0577636Z at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask)
2018-08-09T09:06:04.0577823Z at MongoDB.Driver.Core.Clusters.Cluster.<WaitForDescriptionChangedAsync>d__50.MoveNext()
2018-08-09T09:06:04.0578017Z --- End of stack trace from previous location where exception was thrown ---
2018-08-09T09:06:04.0578597Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-08-09T09:06:04.0578857Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-08-09T09:06:04.0579088Z at MongoDB.Driver.Core.Clusters.Cluster.<SelectServerAsync>d__43.MoveNext()
2018-08-09T09:06:04.0579303Z --- End of stack trace from previous location where exception was thrown ---
2018-08-09T09:06:04.0579791Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-08-09T09:06:04.0580027Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-08-09T09:06:04.0580245Z at MongoDB.Driver.MongoClient.<AreSessionsSupportedAfterSeverSelctionAsync>d__37.MoveNext()
2018-08-09T09:06:04.0580455Z --- End of stack trace from previous location where exception was thrown ---
2018-08-09T09:06:04.0580694Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-08-09T09:06:04.0580901Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-08-09T09:06:04.0581107Z at MongoDB.Driver.MongoClient.<AreSessionsSupportedAsync>d__34.MoveNext()
2018-08-09T09:06:04.0581326Z --- End of stack trace from previous location where exception was thrown ---
2018-08-09T09:06:04.0581817Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-08-09T09:06:04.0582028Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-08-09T09:06:04.0582227Z at MongoDB.Driver.MongoClient.<StartImplicitSessionAsync>d__26.MoveNext()
2018-08-09T09:06:04.0582406Z --- End of stack trace from previous location where exception was thrown ---
2018-08-09T09:06:04.0582762Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-08-09T09:06:04.0582941Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-08-09T09:06:04.0583294Z at MongoDB.Driver.MongoCollectionImpl`1.<UsingImplicitSessionAsync>d__91`1.MoveNext()
2018-08-09T09:06:04.0583494Z --- End of stack trace from previous location where exception was thrown ---
2018-08-09T09:06:04.0583670Z at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2018-08-09T09:06:04.0584382Z at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2018-08-09T09:06:04.0584581Z at MongoDB.Driver.MongoCollectionBase`1.<InsertOneAsync>d__64.MoveNext()
2018-08-09T09:06:04.1605265Z 2018-08-09T09:06:04.159+0000 I CONTROL [initandlisten] MongoDB starting : pid=3112 port=27020 dbpath=C:\Users\XXX\AppData\Local\Temp\xdol0kvu.gus34704c47a97744dda37b_27020 64-bit host=factoryvm-az49
It would be great to run MongoDB 3.6.x. Looks like .NET Driver 2.5 supports MongoDB 3.6.
Hi,
In your code base, I see only one set of binaries for linux.
MongoDB distributes different binaries for Ubuntu 16.04 Linux, RHEL 7.2, and so on.
Now that one binary is working for different flavors of linux in this case.
What will be impact (difference in behavior) for for the mongodb test server running in Ubuntu and RHEL.
Regards,
Nachi
Hi, I was wondering if anyone has encountered a similar issue when using 'mongo2Go' on 'TeamCity'. It works absolutely brilliantly on my local machine, but, once I push my test to the server hosted locally by us i.e. the company I work for, it gives the above error during build. Any suggestion(s) would be appreciated.
-Thanks in advance.
Hi.
Is it possible to have custom arguments passed to the running MongoDb instance?
For example, quiet
(https://docs.mongodb.com/manual/reference/parameters/#param.quiet) or systemLog.quiet
(https://docs.mongodb.com/manual/reference/configuration-options/#systemLog.quiet).
I have see that the MongoDb arguments are defined in MongoDbProcessStarter.cs
and don't allow custom arguments. Is there any other way?
Thanks.
Hi we would like to use Mongo2Go in a cross platform environment, but we hit bit of a snag since:
IPEndPoint[] tcpConnInfoArray = IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners();
is not implemented by mono :(
I was thinking of providing a mono compatible implementation of this, how does that sound?
/cheers
Krippz
While running MongoDbRunner.Start()
I get the following error:
Error parsing command line: unrecognised option '--sslMode'
It happened after updating Mongo2Go to newer version. The latest working version is 2.2.1
OS: Windows 10
I'm using the default net core XUnit project, but targeting net461.
When I run several tests, sometimes mongod.exe instances remain active until I can terminate them.
I shall attempt to put together a small repro when I get time.
P.S. Any reason this is targeting net standard 1.6 instead of an earlier version?
Hi,
Thank you very much for this project, it has helped me out a lot!
While creating integration tests I have noticed that there is a significant performance hit when using MongoDbRunner.Start() versus MongoDbRunner.StartForDebugging().
I am running MongoDbRunner.Start() for every single test and I dispose the runner after the test has completed. For 23 integration tests this takes around 1 minute. If I change this to StartForDebugging my tests take around 3 seconds.
I was wondering why there is such a big difference? And if there is something that I can setup to make my tests run faster with .Start().
Thanks!
Currently all actions are logged, it would be nice to be able to change level or silence it.
@nickmkk commented here regarding isse #39
Is this supposed to be fixed? I'm still getting this error with v2.2.6 in projects that use PackageReference nuget packages. In my case the actual binaries are here C:\Users\nickm\.nuget\packages\mongo2go\2.2.6\tools\mongodb-win32-x86_64-2008plus-ssl-3.6.1\bin
since the PackageReference option just uses packages from the global cache.
Mongo2Go.MonogDbBinariesNotFoundException
Could not find Mongo binaries using the search pattern of "tools\mongodb-win32*\bin". We walked up to root directory from C:\...\bin\Debug and packages\Mongo2Go*\tools\mongodb-win32*\bin. You can override the search pattern when calling MongoDbRunner.Start. We have detected the OS as Microsoft Windows 10.0.17134
at Mongo2Go.Helper.MongoBinaryLocator.ResolveBinariesDirectory()
at Mongo2Go.Helper.MongoBinaryLocator.get_Directory()
at Mongo2Go.MongoDbRunner..ctor(IPortPool portPool, IFileSystem fileSystem, IMongoDbProcessStarter processStarter, IMongoBinaryLocator mongoBin, String dataDirectory)
at Mongo2Go.MongoDbRunner.Start(String dataDirectory, String searchPatternOverride)
I think "ResolveBinariesDirectory" should look for the binaries in the current users global cache if they are not found. It would solve this issue for people who use PackageReference(which is the nuget standard going forward).
I get the following error if I try to add Mongo2Go 2.1.0 to my .Net Core 1.1 project.
2.0.0-alpha1 works though.
Errors in c:\Projects\****\sln\Test\Test.csproj
Package Mongo2Go 2.1.0 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package Mongo2Go 2.1.0 supports: net (.NETFramework,Version=v0.0)
One or more packages are incompatible with .NETCoreApp,Version=v1.1.
I am using the latest SDK.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.