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

Fix ExecScriptAsync on MongoDbTestcontainer #565

Conversation

ptimothee
Copy link

MongoDbTestcontainer ExecScriptAsync should execute mongosh scripts

await this.CopyFileAsync(tempScriptFile, Encoding.Default.GetBytes(script), 493, 0, 0, ct)
.ConfigureAwait(false);

return await this.ExecAsync(new[] { "mongo", "db", tempScriptFile }, ct);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we just use the new MongoDB Shell (mongosh) and remove ExecMongoScriptAsync?

Copy link
Author

Choose a reason for hiding this comment

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

Absolutely. This was just in case there was a desire to support the legacy shell while it is still available. Will remove, thanks.

await this.CopyFileAsync(tempScriptFile, Encoding.Default.GetBytes(scriptContent), 493, 0, 0, ct)
.ConfigureAwait(false);

return await this.ExecAsync(new[] { "mongosh", "--port", this.ContainerPort.ToString(CultureInfo.InvariantCulture), "--eval", $"load('{tempScriptFile}')" }, ct)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we pass the ConnectionString to mongosh (at least username and password)?

Copy link
Author

Choose a reason for hiding this comment

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

Agreed but will need to look into this one. After supplying the credentials to the mongosh I'm able to connect however my user did not have permissions to run scripts it seems. Will need to look into setting up that user before hand when usr/pwd are configured with the container builder.

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

Successfully merging this pull request may close these issues.

None yet

2 participants