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

Problem with MacOSX #43

Closed
oddball opened this issue Nov 22, 2017 · 11 comments
Closed

Problem with MacOSX #43

oddball opened this issue Nov 22, 2017 · 11 comments

Comments

@oddball
Copy link

oddball commented Nov 22, 2017

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

@JohannesHoppe
Copy link
Member

No Mac here. But I can investigate as soon as my first Mac arrives. (hopefully sooner than later)

@JohannesHoppe
Copy link
Member

Please test this again with Mongo2Go 2.2.1 which will be released soon!

@JohannesHoppe
Copy link
Member

I pushed v2.2.1 to nuget.org. Could you please test it?

@oddball
Copy link
Author

oddball commented Nov 23, 2017

Sadly no difference when updated to 2.2.1 .
But I was before on 2.1.0 and I can see someone else leaving a comment "dont update to 2.2.0". Going to investigate tomorrow.
However, I did do a git pull on mongo2go repo and ran

dotnet restore
dotnet build
dotnet test src/Mongo2GoTests/Mongo2GoTests.csproj

With the result

Total tests: 29. Passed: 29. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 14.3335 Seconds

On my macbook

@oddball
Copy link
Author

oddball commented Nov 24, 2017

Turns out I am forced to use
targetFramework="net461"
I dont suppose this 2.2.1 will be backported?

@JohannesHoppe
Copy link
Member

I could do that.

The main new features are:

  1. uses temporary directory instead of C:\data\db -- optional, because this can be also changed by method parameter
  2. the bugfix which is making the binaries executable for MacOS and Linux

Let's see if you need that bugfix. Could you please install Mongo2Go 1.1.0 and make the binaries executable (chmod+x) by hand? If that works, I will backport that change to the 1.x branch.

@oddball
Copy link
Author

oddball commented Nov 27, 2017

chmod +x ../packages/Mongo2Go.2.1.0/tools/mongodb-osx-x86_64-3.2.7/bin/mongo*

made no difference for me, but

rm ../packages/Mongo2Go.2.1.0/tools/mongodb-linux-x86_64-3.2.7/bin/mongod

resulted in

System.IO.FileNotFoundException : Could not find file "packages/Mongo2Go.2.1.0/tools/mongodb-linux-x86_64-3.2.7/bin/mongod"

Which leads me to believe that that it does not resolve to osx bin when on mac. Sadly moving the osx bin files to the linux folder results in the usual

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 : "1", ConnectionMode : "Automatic", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/localhost:27018" }", EndPoint: "Unspecified/localhost:27018", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> System.Net.Sockets.SocketException: Connection refused

I am not sure why 2.1.0 works with a package.config on Windows and Linux like below, I am not using 1.10

<packages>
...
  <package id="Mongo2Go" version="2.1.0" targetFramework="net461" />
....
</packages>

@ash23
Copy link

ash23 commented May 29, 2018

I can confirm this seems to be related to the target framework (netcoreapp2.0 vs net461) rather than the OS under which Mongo2Go is used.
I.e., also when targeting netcoreapp2.0 under Windows Mongo2Go seems to cause the program to freeze (as soon as the program attempts to access MongoDB via the c# driver). Also the mongod process (launched by Mongo2Go) becomes inaccessible, i.e you cannot even connect to the database using other tools such as NoSql Manager for MongoDB. As soon as the c# application is killed the mongod process again is accessible using other tools.

However when targeting net461 under Windows everything works fine without any problems.

@JohannesHoppe
Copy link
Member

I'm confused. Does anybody has a working solution?

@oddball
Copy link
Author

oddball commented Jun 6, 2018

I am no longer in position to try this on Mac. Cant help anymore.

@JohannesHoppe
Copy link
Member

I was able to successfully run dotnet test src/Mongo2GoTests on my mac with .NET core 2.1.301.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants