-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
feat: Add Gitlab CE module #1135
base: develop
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for testcontainers-dotnet ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Sorry for the late response. I will try to review the module next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I have some questions before I continue the review.
/// <summary> | ||
/// This is the default image for gitlab community edition. | ||
/// </summary> | ||
public const string GitlabImage = "gitlab/gitlab-ce"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please pin the version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing. I tested with the latest image, with is version 16.11.1 .
.WithWaitStrategy(Wait.ForUnixContainer().UntilFileExists("/etc/gitlab/initial_root_password")) | ||
.WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(80)) | ||
.WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(22)) | ||
.WithWaitStrategy(Wait.ForUnixContainer().UntilContainerIsHealthy()) | ||
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request => request.ForPath("/users/sign_in").ForStatusCode(HttpStatusCode.OK))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This overrides the previous wait strategies. You need to add the wait strategy once (you can chain the until members though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed the WaitStrategy so that the previous strategy will not be overwritten.
/// <returns>Returns the initial root password generated by gitlab.</returns> | ||
private async Task<string> GetInitialRootPassword() | ||
{ | ||
var byteArray = await ReadFileAsync("/etc/gitlab/initial_root_password"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testcontainers allows uploading files before the container starts. Can we upload the initial_root_password
file to specify the password? Can we simply use basic authentication? This would make the module simpler and should be enough for testing purposes (I guess).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I checked last night if there is some easier method to provide a root password and there a sereval ways. You can set the root password with an environment variable named GITLAB_ROOT_PASSWORD
(see here for dokumentation). Another way would be to provide a file named root_password.txt
in the root directory. This is documented here.
I would strongly prefer to set the root password via an environment variable, would either way would be valid. I try to find some time this week to resolve this.
If you have an preferred implementation than just let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed now. I've selected the approach via an environment variable just to keep it simple.
Set version of docker image to 16.11.1
Fixed WaitStrategy so that all conditions are met and are not overwritten by latest condition.
Add support to set the root password for gitlab
What does this PR do?
Implemented a TestContainer for Gitlab. This can be used to test projects that use the API of gitlab without relying on an actual instance of gitlab.
Why is it important?
This can be super useful to create integration tests for projects that need access to the Gitlab-API. For example this can be used to test a tool that generates an merge request after running a custom pipeline.
How to test this PR
This PR can be tested if someone generates a personal access token and uses it to authenticates against the gitlab testcontainer.
To run this test in your shell: