-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 oceanbase-ce module #7502
Conversation
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 your contribution! I have left some suggestions. Please, also take a look at at the build which just failed.
modules/oceanbase-ce/src/main/java/org/testcontainers/containers/OceanBaseContainer.java
Outdated
Show resolved
Hide resolved
modules/oceanbase-ce/src/main/java/org/testcontainers/containers/OceanBaseContainer.java
Outdated
Show resolved
Hide resolved
modules/oceanbase-ce/src/main/java/org/testcontainers/containers/OceanBaseContainer.java
Outdated
Show resolved
Hide resolved
Thank you for your review, I have addressed the comments in the latest commit. For the CI failure, it seems the container start failed, and I guess the reason may be the memory is not enought. To start the docker container of OceanBase, at least 2 cpu and 8g memory are required. |
I think this is a concern due to IIRC Docker Desktop provides a default of 4g or 8g so it will be at limit all the time not even allowing running other test in parallel. Is there any way to consume less resources. So far, I've seen DB2 consuming ~1.75g |
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 addressing the initial comments. Is there a web console provided with the image? Also it would be great if the image provides a directory where scripts can be copied and be part of the database initialization such as mysql does it due to the withInitScript limitation
modules/oceanbase-ce/src/test/java/org/testcontainers/junit/oceanbase/SimpleOceanBaseTest.java
Outdated
Show resolved
Hide resolved
We have a plan to achieve lightweight deployment, but it may be difficult to achieve it in the near future. Now we can't deploy the container on a free GitHub agent. For reference, we use the docker image through testcontainers on a self-hosted CI service in flink cdc. |
TBH, I think for now it will keep on hold if that the case 😕 Another option is to self-host the module as others do. |
OK, I understand. I would convert this pull request to a draft, and we can continue the process after oceanbase/oceanbase#1557 is basically completed. |
great! Thanks for your understanding! I'll be following the issue in order to get updates |
I updated the container class with the new image Currently the startup time is still more than 1 minute, I think we can use 3 min in this version and update it when oceanbase/oceanbase#1573 is released. WDYT? @eddumelendez |
Hi @whhe, great to see the improvements. Currently, 1 min is the maximum value we are setting. I would say reaching that limit would produce a not good experience when running tests, of course, it depends how those are set too. IMO, we can wait a little bit more and provide the best experience possible when the other issue is fixed. |
Thanks for the suggestion, I think it makes perfect sense, will update this PR with the new image later. |
fed062f
to
0210dcf
Compare
Hi @eddumelendez, I updated this PR with our latest docker image, which can start in less than 30s with FASTBOOT enabled. I think we can go back to the review process now. |
7011359
to
d2a6a21
Compare
@eddumelendez PTAL if you are available. |
Hi @eddumelendez, is there any plan for this pr? |
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 your contribution, @whhe ! and sorry for the late reply. I have left some comments and some more general:
- Rename the module to
oceanbase
. Is it ok for you? - Package should be
org.testcontainers.oceanbase
- Run
./gradlew spotlessApply
modules/oceanbase-ce/src/main/java/org/testcontainers/containers/OceanBaseContainer.java
Outdated
Show resolved
Hide resolved
modules/oceanbase-ce/src/main/java/org/testcontainers/containers/OceanBaseContainer.java
Outdated
Show resolved
Hide resolved
modules/oceanbase-ce/src/test/java/org/testcontainers/OceanBaseTestImages.java
Outdated
Show resolved
Hide resolved
modules/oceanbase-ce/src/main/java/org/testcontainers/containers/OceanBaseContainer.java
Outdated
Show resolved
Hide resolved
modules/oceanbase-ce/src/main/java/org/testcontainers/containers/OceanBaseContainer.java
Outdated
Show resolved
Hide resolved
if (StringUtils.isEmpty(tenantName)) { | ||
throw new IllegalArgumentException("Tenant name cannot be null or empty"); | ||
} | ||
if (SYSTEM_TENANT_NAME.equals(tenantName)) { | ||
throw new IllegalArgumentException("Tenant name cannot be " + SYSTEM_TENANT_NAME); | ||
} |
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.
wonder if those validations should be at the image level and avoid duplicating the validation.
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.
The response from the image may not be as direct as the error message here. It refers to the 'DEFAULT_DATABASE_NAME' in OracleContainer.
|
||
public String getJdbcUrl(String databaseName) { | ||
String additionalUrlParams = constructUrlParameters("?", "&"); | ||
String prefix = driverClassName.contains("mysql") ? "jdbc:mysql://" : "jdbc:oceanbase://"; |
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 think we should restrict more here because at first glance if any driverClassName different than mysql will choose oceanbase prefix, and not sure but that would be unexpected.
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.
The 'driverClassName' is verified in withDriverClassName
method, so its value is limited to these two options.
modules/oceanbase-ce/src/main/java/org/testcontainers/containers/OceanBaseContainer.java
Outdated
Show resolved
Hide resolved
Thanks for your review and sorry for the late reply, I just came back from the Chinese new year holiday. I will address the comments soon, but for the module name, I used 'oceanbase-ce' because the community will most likely release a 'oceanbase-xe' docker image in the future for the OceanBase Enterprise Edition. So I think we'd better keep it here. |
I think in that case the module can still be oceanbase and contain two implementations |
2057639
to
444cdb6
Compare
@eddumelendez PR updated, PTAL. |
@eddumelendez Look forward to your feedback. |
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 quick update! Left a couple of messages.
@Override | ||
protected void configure() { | ||
if (!DEFAULT_TEST_TENANT_NAME.equals(tenantName)) { | ||
withEnv("OB_TENANT_NAME", tenantName); | ||
} | ||
} |
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.
according to the docs, the default value for OB_TENAN_NAME
is test
. So we can just have
@Override | |
protected void configure() { | |
if (!DEFAULT_TEST_TENANT_NAME.equals(tenantName)) { | |
withEnv("OB_TENANT_NAME", tenantName); | |
} | |
} | |
@Override | |
protected void configure() { | |
withEnv("OB_TENANT_NAME", tenantName); | |
} |
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.
User can also use 'withEnv' method to set it manually, in this case if we do not check the value, there may be a mistake.
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 don't fully understand because the default is test
and the tenantName = DEFAULT_TEST_TENANT_NAME;
where DEFAULT_TEST_TENANT_NAME = "test"
. Unless, the right one should use SYSTEM_TENANT_NAME
instead
if (!SYSTEM_TENANT_NAME.equals(tenantName)) {
withEnv("OB_TENANT_NAME", tenantName);
}
Once we resolve this comment I can proceed and merge it
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'm considering this situation: someone use the container class but not set the tenant name with given method withTenant
, like new OceanBaseCEContainer("xxx").withEnv("OB_TENANT_NAME", "tc");
. In this case, as the tenantName field is still 'test', a 'test' tenant will be created, not user defined value 'tc'.
I'm not sure if we should deal with it. WDYT?
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 think that given there is a default value in the image itself. The withTenant
method and the withEnv
in configure
method can be omitted. If for some reason there is a need to modify it then new OceanBaseCEContainer(...).withEnv("OB_TENANT_NAME", "something");
that would a similar experience like running docker run
command. Otherwise, it would be a little bit confusing.
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.
The tenantName field here is required to construct the username used in jdbc connection, so I did not remove the withTenant
method in previous cleanup. I reconsidered about it and maybe use the default value with necessary description is better.
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.
Updated.
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 just noticed we were missing a test for this use case and also think a little bit more about it. In the configure
method we can add getEnvMap().computeIfAbsent("OB_TENAN_NAME", k -> tenantName != null ? tenantName : DEFAULT_TENANT_NAME)
or just getEnvMap().computeIfAbsent("OB_TENAN_NAME", k -> tenantName)
and we can keep withTenantName
. LMK if this can help to the use case described.
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.
Yes you are right, we can resolve it by using the envMap, but I think it's not necessary for now.
At present no other withXXX
method is provided in this container class and all env options are set by withEnv
, I think it's good and clean. Lets keep it like this.
modules/oceanbase/src/main/java/org/testcontainers/oceanbase/OceanBaseCEContainer.java
Show resolved
Hide resolved
modules/oceanbase/src/main/java/org/testcontainers/oceanbase/OceanBaseCEContainer.java
Outdated
Show resolved
Hide resolved
One last change, can we add an entry for oceanbase here, please? |
modules/oceanbase/src/main/java/org/testcontainers/oceanbase/OceanBaseCEContainer.java
Outdated
Show resolved
Hide resolved
modules/oceanbase/src/test/java/org/testcontainers/junit/oceanbase/SimpleOceanBaseCETest.java
Outdated
Show resolved
Hide resolved
modules/oceanbase/src/test/java/org/testcontainers/jdbc/oceanbase/OceanBaseJdbcDriverTest.java
Outdated
Show resolved
Hide resolved
modules/oceanbase/src/main/java/org/testcontainers/oceanbase/OceanBaseCEContainer.java
Outdated
Show resolved
Hide resolved
Thanks for your contribution, @whhe ! |
OceanBase is a distributed relational database developed by Ant Group, and its community edition is open sourced at https://github.com/oceanbase/oceanbase.
There is a docker image maintained by the official team, and in this pull request I add
OceanBaseContainer
andOceanBaseContainerProvider
for a newoceanbase-ce
module based on the docker image. https://github.com/oceanbase/oceanbase/tree/master/tools/docker/standalone.