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

chore: Update Testcontainers for .NET #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

HofmeisterAn
Copy link

@HofmeisterAn HofmeisterAn commented Oct 12, 2023

What does this PR do?

Hi 👋, I noticed that the project is currently using an outdated version of Testcontainers for .NET. This pull request updates the version to the latest release.

Furthermore, this pull request applies Testcontainers' best practices. It is typically preferred to utilize the WithResourceMapping API to copy files into the container rather than binding them. This is especially crucial when dealing with different Docker environments, as binding a volume can sometimes fail, particularly in remote Docker setups. This also eliminates the need to create the temporary script file on the test host.

Furthermore, I have introduced a wait strategy as part of this pull request. Wait strategies are necessary to indicate the readiness of the container (service inside the container) or serving as a status indicator once the container's entry point has completed its execution.

Why is it important?

-

Related issues

-

.WithCommand("sh", tempScriptFile)
.Build();
.WithImage(image)
.WithBindMount(srcDirectoryPath, "/src")
Copy link
Author

Choose a reason for hiding this comment

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

It is recommended to utilize the WithResourceMapping API here too. This adjustment will ensure that the implementation works correct with remote Docker hosts. I have not made the changes because I am unsure about the file sizes.

.WithImage(image)
.WithBindMount(srcDirectoryPath, "/src")
.WithResourceMapping(Encoding.Default.GetBytes(input), $"/src/{tempScriptFile}")
.WithWaitStrategy(Wait.ForUnixContainer().AddCustomWaitStrategy(new ScriptCompleted()))
Copy link
Author

Choose a reason for hiding this comment

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

The wait strategy I have implemented assumes that the container's startup process should wait until the shell script has completed.

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.

1 participant