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

Exposing a port in options. #8

Merged
merged 3 commits into from
Oct 9, 2022
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var options = new MongoRunnerOptions
ConnectionTimeout = TimeSpan.FromSeconds(10), // Default: 30 seconds
ReplicaSetSetupTimeout = TimeSpan.FromSeconds(5), // Default: 10 seconds
AdditionalArguments = "--quiet", // Default: null
MongoPort = 27017, // Default: random port selection
};

// Disposing the runner will kill the MongoDB process (mongod) and delete the associated data directory
Expand Down
2 changes: 1 addition & 1 deletion src/EphemeralMongo.Core/MongoRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private IMongoRunner RunInternal()
// Ignored - this data directory might already be in use, we'll see later how mongod reacts
}

this._options.MongoPort = this._portFactory.GetRandomAvailablePort();
this._options.MongoPort ??= this._portFactory.GetRandomAvailablePort();

// Build MongoDB executable arguments
var arguments = string.Format(CultureInfo.InvariantCulture, "--dbpath {0} --port {1} --bind_ip 127.0.0.1", ProcessArgument.Escape(this._dataDirectory), this._options.MongoPort);
Expand Down
4 changes: 2 additions & 2 deletions src/EphemeralMongo.Core/MongoRunnerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ public TimeSpan ReplicaSetSetupTimeout

public Logger? StandardErrorLogger { get; set; }

public int? MongoPort { get; set; }

// Internal properties start here
internal string ReplicaSetName { get; set; } = "singleNodeReplSet";

internal int MongoPort { get; set; }

private static Exception? CheckDirectoryPathFormat(string? path)
{
if (path == null)
Expand Down
2 changes: 2 additions & 0 deletions src/EphemeralMongo.Core/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ EphemeralMongo.MongoRunnerOptions.StandardOuputLogger.get -> EphemeralMongo.Logg
EphemeralMongo.MongoRunnerOptions.StandardOuputLogger.set -> void
EphemeralMongo.MongoRunnerOptions.UseSingleNodeReplicaSet.get -> bool
EphemeralMongo.MongoRunnerOptions.UseSingleNodeReplicaSet.set -> void
EphemeralMongo.MongoRunnerOptions.MongoPort.get -> int?
EphemeralMongo.MongoRunnerOptions.MongoPort.set -> void
static EphemeralMongo.MongoRunner.Run(EphemeralMongo.MongoRunnerOptions? options = null) -> EphemeralMongo.IMongoRunner!