Skip to content

Conversation

@KodaiD
Copy link
Contributor

@KodaiD KodaiD commented Jun 25, 2025

Description

This PR adds integration tests for the list of permissions required by ScalarDB per underlying storage. The list is helpful for users to know what permissions they need where they have restricted permissions rather than full admin access.

Related issues and/or PRs

N/A

Changes made

  • Added new integration tests for DistributedStorage and DistributedStorageAdmin implementations:
    • Cassandra
    • DynamoDB
    • JDBC (MySQL)
  • Created GitHub Actions workflow to run permission tests

Checklist

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • I have considered whether similar issues could occur in other products, components, or modules if this PR is for bug fixes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

Release notes

N/A

@KodaiD KodaiD requested a review from Copilot June 25, 2025 06:58
@KodaiD KodaiD self-assigned this Jun 25, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds permission-based integration tests for Cassandra, DynamoDB, and JDBC storage backends in ScalarDB. It introduces a PermissionTestUtils interface, two abstract test bases for storage and admin operations, concrete implementations for each backend, and updates build scripts and GitHub workflows to include these new tests.

  • New PermissionTestUtils interface and implementations for JDBC, DynamoDB, and Cassandra
  • Abstract test bases (DistributedStoragePermissionIntegrationTestBase and DistributedStorageAdminPermissionIntegrationTestBase) with concrete integration tests
  • Updated build.gradle and GitHub Actions workflow to run permission integration tests

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
integration-test/src/main/java/com/scalar/db/util/PermissionTestUtils.java Defines common interface for creating/granting users
integration-test/src/main/java/com/scalar/db/api/DistributedStoragePermissionIntegrationTestBase.java Adds base tests for storage operations with normal user
integration-test/src/main/java/com/scalar/db/api/DistributedStorageAdminPermissionIntegrationTestBase.java Adds base tests for admin operations with normal user
core/src/integration-test/java/com/scalar/db/storage/jdbc/* JDBC-specific PermissionTestUtils, tests, and env
core/src/integration-test/java/com/scalar/db/storage/dynamo/* Dynamo-specific PermissionTestUtils, tests, and env
core/src/integration-test/java/com/scalar/db/storage/cassandra/* Cassandra-specific PermissionTestUtils, tests, and env
core/build.gradle Adds new source sets and tasks for permission tests
.github/workflows/test-permission.yaml Workflow to run permission tests on GitHub Actions
Comments suppressed due to low confidence (2)

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

  • [nitpick] There's an unintended trailing backslash in this comment. Please remove '\' for clarity.
  }

integration-test/src/main/java/com/scalar/db/util/PermissionTestUtils.java:3

  • [nitpick] To support try-with-resources and clearer lifecycle management, consider having this interface extend AutoCloseable.
public interface PermissionTestUtils {

@KodaiD KodaiD changed the title Permission list Add permission list management Jun 25, 2025
@@ -0,0 +1,199 @@
name: Test Permissions
Copy link
Contributor Author

@KodaiD KodaiD Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For JDBC databases, only MySQL is tested for now.

Comment on lines +3 to +4
on:
workflow_dispatch:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the job is assumed to be run manually, for example, when a new release is made.

Comment on lines +15 to +23
exclude '**/com/scalar/db/storage/cassandra/CassandraPermissionTestUtils.java'
exclude '**/com/scalar/db/storage/dynamo/DynamoPermissionTestUtils.java'
exclude '**/com/scalar/db/storage/jdbc/JdbcPermissionTestUtils.java'
exclude '**/com/scalar/db/storage/cassandra/CassandraPermissionIntegrationTest.java'
exclude '**/com/scalar/db/storage/dynamo/DynamoPermissionIntegrationTest.java'
exclude '**/com/scalar/db/storage/jdbc/JdbcPermissionIntegrationTest.java'
exclude '**/com/scalar/db/storage/cassandra/CassandraAdminPermissionIntegrationTest.java'
exclude '**/com/scalar/db/storage/dynamo/DynamoAdminPermissionIntegrationTest.java'
exclude '**/com/scalar/db/storage/jdbc/JdbcAdminPermissionIntegrationTest.java'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid the permission tests are run in the CI, the test files are excluded.

Comment on lines +43 to +44
@Override
protected void waitForNamespaceCreation() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because CassandraAdmin does not have the wait for table creation mechanism, we need to prepare it in the test.

return properties;
}

public static Properties getPropertiesForNormalUser(String testName) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To test the permission list, a normal user is created and used for the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To handle non-emulator DynamoDB, the option to distinguish between emulator and non-emulator is added.


@Override
protected Map<String, String> getCreationOptions() {
return ImmutableMap.of(DynamoAdmin.NO_SCALING, "false", DynamoAdmin.NO_BACKUP, "false");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To test under the environment assuming the production environment, the scaling and the backup are enabled.

Comment on lines +65 to +73
@Override
public void createNormalUser(String userName, String password) {
// Do nothing for DynamoDB.
}

@Override
public void dropNormalUser(String userName) {
// Do nothing for DynamoDB.
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current implementation assumes that the same IAM user is used for tests. Only the IAM policy is updated for each test.


on:
workflow_dispatch:
pull_request:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To ensure the workflow runs correctly, a pull request trigger is added. It will be removed before merging.

@KodaiD
Copy link
Contributor Author

KodaiD commented Jul 1, 2025

Since it is going to be a big PR, I will split it into smaller PRs for each backend.

@KodaiD KodaiD closed this Jul 1, 2025
@brfrn169 brfrn169 deleted the permission-list branch July 8, 2025 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant