-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add jdbc it case * update ci * update github action job name
- Loading branch information
Showing
10 changed files
with
292 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Build Main | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
java-version: '8' | ||
distribution: 'zulu' | ||
cache: 'maven' | ||
- name: Maven Install | ||
run: mvn clean install -DskipTests=true | ||
|
||
test-jdbc: | ||
name: Test (flink-connector-oceanbase) | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
java-version: '8' | ||
distribution: 'zulu' | ||
cache: 'maven' | ||
- name: Maven Test | ||
run: mvn verify -pl :flink-connector-oceanbase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Build PR | ||
|
||
on: | ||
pull_request: | ||
paths-ignore: | ||
- 'docs/**' | ||
- '**.md' | ||
- '.*' | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
java-version: '8' | ||
distribution: 'zulu' | ||
cache: 'maven' | ||
- name: Maven Install | ||
run: mvn clean install -DskipTests=true | ||
|
||
test-jdbc: | ||
name: Test (flink-connector-oceanbase) | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
java-version: '8' | ||
distribution: 'zulu' | ||
cache: 'maven' | ||
- name: Maven Test | ||
run: mvn verify -pl :flink-connector-oceanbase |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
...k-connector-oceanbase/src/test/java/com/oceanbase/connector/flink/OceanBaseContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package com.oceanbase.connector.flink; | ||
|
||
import org.testcontainers.containers.JdbcDatabaseContainer; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
import java.time.Duration; | ||
|
||
public class OceanBaseContainer extends JdbcDatabaseContainer<OceanBaseContainer> { | ||
|
||
public static final String DOCKER_IMAGE_NAME = "oceanbase/oceanbase-ce"; | ||
|
||
private static final DockerImageName DEFAULT_IMAGE_NAME = | ||
DockerImageName.parse(DOCKER_IMAGE_NAME); | ||
|
||
private static final Integer SQL_PORT = 2881; | ||
private static final Integer RPC_PORT = 2882; | ||
|
||
private static final String DEFAULT_USERNAME = "root"; | ||
private static final String DEFAULT_PASSWORD = ""; | ||
private static final String DEFAULT_TENANT_NAME = "test"; | ||
private static final String DEFAULT_DATABASE_NAME = "test"; | ||
|
||
private String tenantName = DEFAULT_TENANT_NAME; | ||
|
||
public OceanBaseContainer(String dockerImageName) { | ||
this(DockerImageName.parse(dockerImageName)); | ||
} | ||
|
||
public OceanBaseContainer(DockerImageName dockerImageName) { | ||
super(dockerImageName); | ||
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME); | ||
|
||
this.waitStrategy = | ||
Wait.forLogMessage(".*boot success!.*", 1) | ||
.withStartupTimeout(Duration.ofMinutes(5)); | ||
|
||
addExposedPorts(SQL_PORT, RPC_PORT); | ||
} | ||
|
||
@Override | ||
public String getDriverClassName() { | ||
return "com.oceanbase.jdbc.Driver"; | ||
} | ||
|
||
public Integer getSqlPort() { | ||
return getActualPort(SQL_PORT); | ||
} | ||
|
||
public Integer getActualPort(int port) { | ||
return "host".equals(getNetworkMode()) ? port : getMappedPort(port); | ||
} | ||
|
||
@Override | ||
public String getJdbcUrl() { | ||
return getJdbcUrl(DEFAULT_DATABASE_NAME); | ||
} | ||
|
||
public String getJdbcUrl(String databaseName) { | ||
String additionalUrlParams = constructUrlParameters("?", "&"); | ||
return "jdbc:oceanbase://" | ||
+ getHost() | ||
+ ":" | ||
+ getSqlPort() | ||
+ "/" | ||
+ databaseName | ||
+ additionalUrlParams; | ||
} | ||
|
||
public OceanBaseContainer withTenant(String tenantName) { | ||
this.tenantName = tenantName; | ||
return this; | ||
} | ||
|
||
public String getTenantName() { | ||
return tenantName; | ||
} | ||
|
||
@Override | ||
public String getDatabaseName() { | ||
return DEFAULT_DATABASE_NAME; | ||
} | ||
|
||
@Override | ||
public String getUsername() { | ||
return DEFAULT_USERNAME + "@" + tenantName; | ||
} | ||
|
||
@Override | ||
public String getPassword() { | ||
return DEFAULT_PASSWORD; | ||
} | ||
|
||
@Override | ||
protected String getTestQueryString() { | ||
return "SELECT 1"; | ||
} | ||
|
||
@Override | ||
protected void waitUntilContainerStarted() { | ||
getWaitStrategy().waitUntilReady(this); | ||
} | ||
|
||
@Override | ||
protected void configure() { | ||
withEnv("MODE", "slim"); | ||
withEnv("OB_TENANT_NAME", tenantName); | ||
} | ||
} |
Oops, something went wrong.