GithubHelp home page GithubHelp logo

mongo2go / mongo2go Goto Github PK

View Code? Open in Web Editor NEW
375.0 20.0 69.0 473.56 MB

Mongo2Go - MongoDB for .NET integration tests

License: MIT License

C# 99.54% Batchfile 0.22% Shell 0.25%
c-sharp mongodb mongoexport mongoimport dotnet dotnet-core dotnet-standard

mongo2go's People

Contributors

0xced avatar alexzeitler avatar asimmon avatar avrum avatar bannerflow-hassaan avatar bastianeicher avatar corentinaltepe avatar cottsak avatar dannybies avatar g3n7 avatar johanneshoppe avatar jsweetland-ar avatar kenoma avatar krippz avatar kubal5003 avatar mahisatyanarayana avatar marcpiechura avatar marioleed avatar mjebrahimi avatar onyxmaster avatar realliangshiwei avatar stanko-culaja-kolotree avatar vannevelj avatar vikkol avatar zmira avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mongo2go's Issues

prevent windows firewall popup

Can we prevent the Windows Firewall popup from appearing?

I'm getting it when I reset the test environment or restart VS, etc.

Possibility to pass port to Start or to StartForDebugging

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

  • It chooses always the default port and there is no way of selecting another
  • If the mongoDb process is running and the port is used, it figures that MongoDb is already running (thus selecting the installed instance)

That is not the desired behavior. I would like:

  • To be able to pass a port
  • If not, that MongoDbRunner chooses a port that isn't already in use.

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

Hardcoded path passed to MongoDbRunner constructor

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.

MongoDbRunner.Start() not work correctly in vs 2017 test tool with xunit project

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

IOException on Dispose() method calling

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.

Problem with MacOSX

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

Any chance we could update to 3.2.6

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.

Question: Using Mongo2Go with xUnit and Mock

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?

Mongo2Go sometimes not able to pick up data in collection

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

Multiple processes don't seem to work in parallel

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?

System.ObjectDisposedException : Cannot access a disposed object while running test

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.

Add binaries for MongoDB 3.4

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)

Working on windows 8

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.

Instable on Linux

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;
        }

    }
}

Option to set the default port for StartForDebugging()

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.

  • Add an optional parameter port which defaults to MongoDbDefaults.DefaultPort
  • Add an optional parameter searchForAvailablePort which defaults to false. When set to true it will use portPool.GetNextOpenPort() to find the next available open port.

Mongo2Go fails in a long-running integration test

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.

Custom Bson Serialization

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?

mongo2go linux netcore 1.1

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

Feature Compatibility Version

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

Request for support of different versions of mongod server

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

Issues/Workarounds for VSTS Test Assemblies task

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.
  • Packages are stored in this folder under {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?

Error on Linux System.ComponentModel.Win32Exception

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)

Can't run unit tests for Mongo2Go project

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?

Invalid file path on Linux when using netcore3.0-preview

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.

process and data not cleaning up when I stop a test

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.

Can't run Mongo2Go on VSTS / Azure Devops

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

Getting port on mono fails

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

mongod.exe remains active after tests complete

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?

Difference in performance between Start and StartForDebugging

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!

Mongo2Go.MonogDbBinariesNotFoundException v2

@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).

2.1.0 is not compatible with netcoreapp1.1/1.0

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.