Skip to content

Commit

Permalink
update for new image
Browse files Browse the repository at this point in the history
  • Loading branch information
whhe committed Jun 24, 2024
1 parent 3ab85bc commit 8639ab3
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 7 deletions.
23 changes: 19 additions & 4 deletions .github/workflows/java-test-oceanbase-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ on:
server_ip:
required: false
type: string
default: '127.0.0.1'
default: ''
rs_list:
required: false
type: string
default: '127.0.0.1:2882:2881'
default: ''
init_sql:
required: false
type: string
Expand All @@ -57,12 +57,27 @@ jobs:
uses: oceanbase/setup-oceanbase-ce@v1
with:
image_name: oceanbase-ce
container_name: oceanbase-ce
mode: ${{ inputs.mode }}
sql_port: ${{ inputs.port }}
sys_root_password: ${{ inputs.sys_password }}
tenant_name: ${{ inputs.test_tenant }}
tenant_root_password: ${{ inputs.test_password }}
init_sql: ${{ inputs.init_sql }}

- name: Set server IP
id: set_server_ip
run: |
if [ -z "${{ inputs.server_ip }}" ]; then
echo "server_ip is not set. Getting IP from container..."
container_ip=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' oceanbase-ce)
echo "Container IP is $container_ip. Setting server_ip to container IP."
echo "server_ip=$container_ip" >> $GITHUB_OUTPUT
else
echo "server_ip is already set to ${{ inputs.server_ip }}."
echo "server_ip=${{ inputs.server_ip }}" >> $GITHUB_OUTPUT
fi
- name: Checkout repository
uses: actions/checkout@v4

Expand All @@ -82,8 +97,8 @@ jobs:
test_tenant: ${{ inputs.test_tenant }}
test_username: 'root@${{ inputs.test_tenant }}'
test_password: ${{ inputs.test_password }}
server_ip: ${{ inputs.server_ip }}
rs_list: ${{ inputs.rs_list }}
server_ip: ${{ steps.set_server_ip.outputs.server_ip }}
rs_list: ${{ steps.set_server_ip.outputs.server_ip }}:2882:2881
run: |
cd test
mvn verify -Dtest=OceanBaseCETest -DfailIfNoTests=false
21 changes: 18 additions & 3 deletions .github/workflows/test-oceanbase-ce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,24 @@ jobs:
image_file: oceanbase-ce.tar
mode: slim
port: 1234
sys_password: ''
test_tenant: test
test_password: 123456
server_ip: 127.0.0.1
rs_list: 127.0.0.1:2882:2881
init_sql: "ALTER USER root IDENTIFIED BY '123456'"
init_sql: "USE test;
CREATE TABLE user(id INT(10) PRIMARY KEY, name VARCHAR(20));
INSERT INTO user VALUES (1, 'tom'), (2, 'jerry');"

test-mini:
needs: build
uses: ./.github/workflows/java-test-oceanbase-ce.yml
with:
cache_key: oceanbase-ce
image_file: oceanbase-ce.tar
mode: mini
port: 1234
sys_password: 1234567
test_tenant: mini
test_password: 7654321
init_sql: "USE test;
CREATE TABLE user(id INT(10) PRIMARY KEY, name VARCHAR(20));
INSERT INTO user VALUES (1, 'tom'), (2, 'jerry');"
2 changes: 2 additions & 0 deletions test/src/test/java/com/oceanbase/test/OceanBaseCETest.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public void testOceanBaseCE(

if ("sys".equals(tenantName)) {
checkServerIP(conn);
} else {
Assertions.assertEquals(2, Utils.getTableRowsCount(conn, "user"));
}
} catch (SQLException e) {
Assertions.fail(e);
Expand Down
8 changes: 8 additions & 0 deletions test/src/test/java/com/oceanbase/test/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ public static String getRSList(Connection connection) {
rs -> rs.next() ? rs.getString("VALUE") : null);
}

public static int getTableRowsCount(Connection connection, String tableName) {
return (int)
query(
connection,
"SELECT COUNT(1) FROM " + tableName,
rs -> rs.next() ? rs.getInt(1) : 0);
}

@FunctionalInterface
interface ResultSetConsumer {
Object apply(ResultSet rs) throws SQLException;
Expand Down

0 comments on commit 8639ab3

Please sign in to comment.