Skip to content

Commit 636480c

Browse files
committed
remote tenant name config
1 parent e1a303f commit 636480c

File tree

1 file changed

+3
-30
lines changed

1 file changed

+3
-30
lines changed

modules/oceanbase/src/main/java/org/testcontainers/oceanbase/OceanBaseCEContainer.java

+3-30
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.testcontainers.oceanbase;
22

3-
import org.apache.commons.lang3.StringUtils;
43
import org.testcontainers.containers.JdbcDatabaseContainer;
54
import org.testcontainers.utility.DockerImageName;
65

@@ -27,8 +26,6 @@ public class OceanBaseCEContainer extends JdbcDatabaseContainer<OceanBaseCEConta
2726

2827
private static final Integer RPC_PORT = 2882;
2928

30-
private static final String SYSTEM_TENANT_NAME = "sys";
31-
3229
private static final String DEFAULT_TEST_TENANT_NAME = "test";
3330

3431
private static final String DEFAULT_USERNAME = "root";
@@ -37,8 +34,6 @@ public class OceanBaseCEContainer extends JdbcDatabaseContainer<OceanBaseCEConta
3734

3835
private static final String DEFAULT_DATABASE_NAME = "test";
3936

40-
private String tenantName = DEFAULT_TEST_TENANT_NAME;
41-
4237
public OceanBaseCEContainer(String dockerImageName) {
4338
this(DockerImageName.parse(dockerImageName));
4439
}
@@ -73,7 +68,9 @@ public String getDatabaseName() {
7368

7469
@Override
7570
public String getUsername() {
76-
return DEFAULT_USERNAME + "@" + tenantName;
71+
// In OceanBase, the jdbc username is related to the name of user, tenant and cluster, if a tenant name other than
72+
// the default value 'test' is used, you should manually construct the jdbc username by yourself.
73+
return DEFAULT_USERNAME + "@" + DEFAULT_TEST_TENANT_NAME;
7774
}
7875

7976
@Override
@@ -85,28 +82,4 @@ public String getPassword() {
8582
protected String getTestQueryString() {
8683
return "SELECT 1";
8784
}
88-
89-
/**
90-
* Set the non-system tenant to be created for testing.
91-
*
92-
* @param tenantName the name of tenant to be created
93-
* @return this
94-
*/
95-
public OceanBaseCEContainer withTenant(String tenantName) {
96-
if (StringUtils.isEmpty(tenantName)) {
97-
throw new IllegalArgumentException("Tenant name cannot be null or empty");
98-
}
99-
if (SYSTEM_TENANT_NAME.equals(tenantName)) {
100-
throw new IllegalArgumentException("Tenant name cannot be " + SYSTEM_TENANT_NAME);
101-
}
102-
this.tenantName = tenantName;
103-
return self();
104-
}
105-
106-
@Override
107-
protected void configure() {
108-
if (!DEFAULT_TEST_TENANT_NAME.equals(tenantName)) {
109-
withEnv("OB_TENANT_NAME", tenantName);
110-
}
111-
}
11285
}

0 commit comments

Comments
 (0)