Skip to content

Commit a51eba1

Browse files
committed
Remove Db2 handling
1 parent 88810cf commit a51eba1

File tree

2 files changed

+12
-129
lines changed

2 files changed

+12
-129
lines changed

.github/workflows/permission-check.yaml

Lines changed: 0 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -709,111 +709,3 @@ jobs:
709709
with:
710710
name: yugabytedb_2_permission_integration_test_reports
711711
path: core/build/reports/tests/integrationTestJdbcPermission
712-
713-
integration-test-permission-jdbc-db2-11-5:
714-
name: Db2 11.5 Permission Integration Test
715-
runs-on: ubuntu-latest
716-
717-
services:
718-
db2:
719-
image: icr.io/db2_community/db2:11.5.9.0
720-
env:
721-
DB2INSTANCE: db2inst1
722-
DB2INST1_PASSWORD: db2inst1
723-
DBNAME: test_db
724-
LICENSE: accept
725-
ports:
726-
- 50000:50000
727-
options: --privileged --name db2
728-
729-
steps:
730-
- uses: actions/checkout@v4
731-
732-
- name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }})
733-
uses: actions/setup-java@v4
734-
with:
735-
java-version: ${{ env.JAVA_VERSION }}
736-
distribution: ${{ env.JAVA_VENDOR }}
737-
738-
- name: Setup Gradle
739-
uses: gradle/actions/setup-gradle@v4
740-
741-
- name: Wait for the container to be ready
742-
timeout-minutes: 10
743-
run: |
744-
while ! docker logs db2 2>&1 | grep -q "Setup has completed"
745-
do
746-
echo "Container is not yet ready"
747-
sleep 5s
748-
done
749-
echo "Container is ready"
750-
751-
- name: Create OS user for Db2
752-
run: |
753-
docker exec db2 bash -c "useradd -m -s /bin/bash test"
754-
docker exec db2 bash -c "echo \"test:test\" | sudo chpasswd"
755-
docker exec db2 bash -c "usermod -aG db2iadm1 test"
756-
757-
- name: Execute Gradle 'integrationTestJdbcPermission' task
758-
run: ./gradlew integrationTestJdbcPermission -Dscalardb.jdbc.url="jdbc:db2://localhost:50000/test_db" -Dscalardb.jdbc.username=db2inst1 -Dscalardb.jdbc.password=db2inst1
759-
760-
- name: Upload Gradle test reports
761-
if: always()
762-
uses: actions/upload-artifact@v4
763-
with:
764-
name: db2_11.5_permission_integration_test_reports
765-
path: core/build/reports/tests/integrationTestJdbcPermission
766-
767-
integration-test-permission-jdbc-db2-12-1:
768-
name: Db2 12.1 Permission Integration Test
769-
runs-on: ubuntu-latest
770-
771-
services:
772-
db2:
773-
image: icr.io/db2_community/db2:12.1.1.0
774-
env:
775-
DB2INSTANCE: db2inst1
776-
DB2INST1_PASSWORD: db2inst1
777-
DBNAME: test_db
778-
LICENSE: accept
779-
ports:
780-
- 50000:50000
781-
options: --privileged --name db2
782-
783-
steps:
784-
- uses: actions/checkout@v4
785-
786-
- name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }})
787-
uses: actions/setup-java@v4
788-
with:
789-
java-version: ${{ env.JAVA_VERSION }}
790-
distribution: ${{ env.JAVA_VENDOR }}
791-
792-
- name: Setup Gradle
793-
uses: gradle/actions/setup-gradle@v4
794-
795-
- name: Wait for the container to be ready
796-
timeout-minutes: 10
797-
run: |
798-
while ! docker logs db2 2>&1 | grep -q "Setup has completed"
799-
do
800-
echo "Container is not yet ready"
801-
sleep 5s
802-
done
803-
echo "Container is ready"
804-
805-
- name: Create OS user for Db2
806-
run: |
807-
docker exec db2 bash -c "useradd -m -s /bin/bash test"
808-
docker exec db2 bash -c "echo \"test:test\" | sudo chpasswd"
809-
docker exec db2 bash -c "usermod -aG db2iadm1 test"
810-
811-
- name: Execute Gradle 'integrationTestJdbcPermission' task
812-
run: ./gradlew integrationTestJdbcPermission -Dscalardb.jdbc.url="jdbc:db2://localhost:50000/test_db" -Dscalardb.jdbc.username=db2inst1 -Dscalardb.jdbc.password=db2inst1
813-
814-
- name: Upload Gradle test reports
815-
if: always()
816-
uses: actions/upload-artifact@v4
817-
with:
818-
name: db2_12.1_permission_integration_test_reports
819-
path: core/build/reports/tests/integrationTestJdbcPermission

core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcPermissionTestUtils.java

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,25 @@ public JdbcPermissionTestUtils(Properties properties) {
2121

2222
@Override
2323
public void createNormalUser(String userName, String password) {
24-
if (!JdbcTestUtils.isDb2(rdbEngine)) {
25-
try (Connection connection = dataSource.getConnection()) {
26-
String createUserSql = getCreateUserSql(userName, password);
27-
try (Statement statement = connection.createStatement()) {
28-
statement.execute(createUserSql);
29-
}
30-
} catch (SQLException e) {
31-
throw new RuntimeException("Failed to create user: " + userName, e);
24+
try (Connection connection = dataSource.getConnection()) {
25+
String createUserSql = getCreateUserSql(userName, password);
26+
try (Statement statement = connection.createStatement()) {
27+
statement.execute(createUserSql);
3228
}
29+
} catch (SQLException e) {
30+
throw new RuntimeException("Failed to create user: " + userName, e);
3331
}
3432
}
3533

3634
@Override
3735
public void dropNormalUser(String userName) {
38-
if (!JdbcTestUtils.isDb2(rdbEngine)) {
39-
try (Connection connection = dataSource.getConnection()) {
40-
String dropUserSql = getDropUserSql(userName);
41-
try (Statement statement = connection.createStatement()) {
42-
statement.execute(dropUserSql);
43-
}
44-
} catch (SQLException e) {
45-
throw new RuntimeException("Failed to drop user: " + userName, e);
36+
try (Connection connection = dataSource.getConnection()) {
37+
String dropUserSql = getDropUserSql(userName);
38+
try (Statement statement = connection.createStatement()) {
39+
statement.execute(dropUserSql);
4640
}
41+
} catch (SQLException e) {
42+
throw new RuntimeException("Failed to drop user: " + userName, e);
4743
}
4844
}
4945

@@ -133,11 +129,6 @@ private String[] getGrantPermissionStatements(String userName) {
133129
String.format("ALTER ROLE [db_datareader] ADD MEMBER %s", userName),
134130
String.format("ALTER ROLE [db_datawriter] ADD MEMBER %s", userName)
135131
};
136-
} else if (JdbcTestUtils.isDb2(rdbEngine)) {
137-
return new String[] {
138-
String.format("GRANT DBADM ON DATABASE TO USER %s", userName),
139-
String.format("GRANT DATAACCESS ON DATABASE TO USER %s", userName)
140-
};
141132
} else {
142133
throw new UnsupportedOperationException(
143134
"Granting permissions is not supported for " + rdbEngine);

0 commit comments

Comments
 (0)