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

Copy of tc-java#3893 #626

Closed
DanielHabenicht opened this issue Oct 22, 2022 · 4 comments
Closed

Copy of tc-java#3893 #626

DanielHabenicht opened this issue Oct 22, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@DanielHabenicht
Copy link
Contributor

Describe the bug
The mysql container does not allow the username root for the MYSQL_USER, which makes the current TestContainerConfiguration not useful as the container will fail to start.

public override string Username
{
get => this.Environments["MYSQL_USER"];
set => this.Environments["MYSQL_USER"] = value;
}

To Reproduce

_container = new TestcontainersBuilder<MySqlTestcontainer>()
    .WithDatabase(new MySqlTestcontainerConfiguration { Database = "datadonation", Username = "root", Password = "example" })
    .WithImage("mysql:8.0.29")
    .WithCleanUp(true)
    .Build();

Expected behavior
Should incoporate the possibility to use root user (e.g. for migrations)

Additional context
Basically a copy of testcontainers/testcontainers-java#3893 for dotnet.

@HofmeisterAn
Copy link
Collaborator

You can probably use the MariaDbTestcontainerConfiguration. Nevertheless, it would make sense to support it for the MySQL too. Probably it is better to inherit one configuration and adjust it to the Java behavior? Would you like to create a pull request?

@HofmeisterAn HofmeisterAn added the enhancement New feature or request label Oct 22, 2022
@DanielHabenicht
Copy link
Contributor Author

I don't think it would make sense to have the same configuration for two different things.
This is also not about allowing another variable to be passed in, but about abstracting the more complicated container settings to one that works as expected from the current interface.

Basically:

new MySqlTestcontainerConfiguration { 
    Username = "standarduser", 
    Password = "standardpassword"
}

should set: MYSQL_USER="standarduser" and MYSQL_PASSWORD="standardpassword"

new MySqlTestcontainerConfiguration { 
    Username = "root", 
    Password = "rootpassword"
}

should set: MYSQL_ROOT_PASSWORD="rootpassword"

While still giving the right connectionString.

DanielHabenicht added a commit to DanielHabenicht/testcontainers-dotnet that referenced this issue Oct 22, 2022
@DanielHabenicht
Copy link
Contributor Author

I made a draft here #629

@HofmeisterAn
Copy link
Collaborator

I don't think it would make sense to have the same configuration for two different things.

What I meant by that is, MySQL and MariaDB shares the same configuration. Right now, the configuration is copied and pasted. I think we can just inherit from one or the other and get rid of the copy and paste code.

DanielHabenicht added a commit to DanielHabenicht/testcontainers-dotnet that referenced this issue Oct 23, 2022
HofmeisterAn added a commit that referenced this issue Oct 24, 2022
@HofmeisterAn HofmeisterAn self-assigned this Oct 24, 2022
@HofmeisterAn HofmeisterAn added this to the 2.2.0 milestone Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants