-
Notifications
You must be signed in to change notification settings - Fork 40
Backport to branch(3.16) : Add Cassandra permission test #2833
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,88 @@ | ||
| name: Test Permissions | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| TERM: dumb | ||
| JAVA_VERSION: '8' | ||
| JAVA_VENDOR: 'temurin' | ||
|
|
||
| jobs: | ||
| integration-test-permission-cassandra-3-0: | ||
| name: Cassandra 3.0 Permission Integration Test | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: ${{ env.JAVA_VERSION }} | ||
| distribution: ${{ env.JAVA_VENDOR }} | ||
|
|
||
| - name: Setup Gradle | ||
| uses: gradle/actions/setup-gradle@v4 | ||
|
|
||
| - name: Start Cassandra with authentication enabled | ||
| run: | | ||
| docker run -d --name cassandra \ | ||
| -p 9042:9042 \ | ||
| -e CASSANDRA_PASSWORD_SEEDER=yes \ | ||
| -e CASSANDRA_PASSWORD=cassandra \ | ||
| -e CASSANDRA_AUTHENTICATOR=PasswordAuthenticator \ | ||
| -e CASSANDRA_AUTHORIZER=CassandraAuthorizer \ | ||
| bitnami/cassandra:3.0 | ||
|
|
||
| - name: Wait for Cassandra to be ready | ||
| run: sleep 30 | ||
|
|
||
| - name: Execute Gradle 'integrationTestCassandraPermission' task | ||
| run: ./gradlew integrationTestCassandraPermission | ||
|
|
||
| - name: Upload Gradle test reports | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cassandra_3.0_permission_integration_test_reports | ||
| path: core/build/reports/tests/integrationTestCassandraPermission | ||
|
|
||
| integration-test-permission-cassandra-3-11: | ||
| name: Cassandra 3.11 Permission Integration Test | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up JDK ${{ env.JAVA_VERSION }} (${{ env.JAVA_VENDOR }}) | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: ${{ env.JAVA_VERSION }} | ||
| distribution: ${{ env.JAVA_VENDOR }} | ||
|
|
||
| - name: Setup Gradle | ||
| uses: gradle/actions/setup-gradle@v4 | ||
|
|
||
| - name: Start Cassandra with authentication enabled | ||
| run: | | ||
| docker run -d --name cassandra \ | ||
| -p 9042:9042 \ | ||
| -e CASSANDRA_PASSWORD_SEEDER=yes \ | ||
| -e CASSANDRA_PASSWORD=cassandra \ | ||
| -e CASSANDRA_AUTHENTICATOR=PasswordAuthenticator \ | ||
| -e CASSANDRA_AUTHORIZER=CassandraAuthorizer \ | ||
| bitnami/cassandra:3.11 | ||
|
|
||
| - name: Wait for Cassandra to be ready | ||
| run: sleep 30 | ||
|
|
||
| - name: Execute Gradle 'integrationTestCassandraPermission' task | ||
| run: ./gradlew integrationTestCassandraPermission | ||
|
|
||
| - name: Upload Gradle test reports | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cassandra_3.11_permission_integration_test_reports | ||
| path: core/build/reports/tests/integrationTestCassandraPermission |
This file contains hidden or 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
141 changes: 141 additions & 0 deletions
141
...on-test/java/com/scalar/db/storage/cassandra/CassandraAdminPermissionIntegrationTest.java
This file contains hidden or 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,141 @@ | ||
| package com.scalar.db.storage.cassandra; | ||
|
|
||
| import static com.scalar.db.storage.cassandra.CassandraPermissionTestUtils.MAX_RETRY_COUNT; | ||
| import static com.scalar.db.storage.cassandra.CassandraPermissionTestUtils.SLEEP_BETWEEN_RETRIES_SECONDS; | ||
|
|
||
| import com.google.common.util.concurrent.Uninterruptibles; | ||
| import com.scalar.db.api.DistributedStorageAdminPermissionIntegrationTestBase; | ||
| import com.scalar.db.util.AdminTestUtils; | ||
| import com.scalar.db.util.PermissionTestUtils; | ||
| import java.util.Collections; | ||
| import java.util.Map; | ||
| import java.util.Properties; | ||
| import org.junit.jupiter.api.Disabled; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| public class CassandraAdminPermissionIntegrationTest | ||
| extends DistributedStorageAdminPermissionIntegrationTestBase { | ||
| @Override | ||
| protected Properties getProperties(String testName) { | ||
| return CassandraEnv.getProperties(testName); | ||
| } | ||
|
|
||
| @Override | ||
| protected Properties getPropertiesForNormalUser(String testName) { | ||
| return CassandraEnv.getPropertiesForNormalUser(testName); | ||
| } | ||
|
|
||
| @Override | ||
| protected AdminTestUtils getAdminTestUtils(String testName) { | ||
| return new CassandraAdminTestUtils(getProperties(testName)); | ||
| } | ||
|
|
||
| @Override | ||
| protected PermissionTestUtils getPermissionTestUtils(String testName) { | ||
| return new CassandraPermissionTestUtils(getProperties(testName)); | ||
| } | ||
|
|
||
| @Override | ||
| protected Map<String, String> getCreationOptions() { | ||
| return Collections.singletonMap(CassandraAdmin.REPLICATION_FACTOR, "1"); | ||
| } | ||
|
|
||
| @Override | ||
| protected void waitForNamespaceCreation() { | ||
| try { | ||
| AdminTestUtils utils = getAdminTestUtils(TEST_NAME); | ||
| int retryCount = 0; | ||
| while (retryCount < MAX_RETRY_COUNT) { | ||
| if (utils.namespaceExists(NAMESPACE)) { | ||
| utils.close(); | ||
| return; | ||
| } | ||
| Uninterruptibles.sleepUninterruptibly( | ||
| SLEEP_BETWEEN_RETRIES_SECONDS, java.util.concurrent.TimeUnit.SECONDS); | ||
| retryCount++; | ||
| } | ||
| utils.close(); | ||
| throw new RuntimeException("Namespace was not created after " + MAX_RETRY_COUNT + " retries"); | ||
| } catch (Exception e) { | ||
| throw new RuntimeException("Failed to wait for namespace creation", e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected void waitForTableCreation() { | ||
| try { | ||
| AdminTestUtils utils = getAdminTestUtils(TEST_NAME); | ||
| int retryCount = 0; | ||
| while (retryCount < MAX_RETRY_COUNT) { | ||
| if (utils.tableExists(NAMESPACE, TABLE)) { | ||
| utils.close(); | ||
| return; | ||
| } | ||
| Uninterruptibles.sleepUninterruptibly( | ||
| SLEEP_BETWEEN_RETRIES_SECONDS, java.util.concurrent.TimeUnit.SECONDS); | ||
| retryCount++; | ||
| } | ||
| utils.close(); | ||
| throw new RuntimeException("Table was not created after " + MAX_RETRY_COUNT + " retries"); | ||
| } catch (Exception e) { | ||
| throw new RuntimeException("Failed to wait for table creation", e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected void waitForNamespaceDeletion() { | ||
| try { | ||
| AdminTestUtils utils = getAdminTestUtils(TEST_NAME); | ||
| int retryCount = 0; | ||
| while (retryCount < MAX_RETRY_COUNT) { | ||
| if (!utils.namespaceExists(NAMESPACE)) { | ||
| utils.close(); | ||
| return; | ||
| } | ||
| Uninterruptibles.sleepUninterruptibly( | ||
| SLEEP_BETWEEN_RETRIES_SECONDS, java.util.concurrent.TimeUnit.SECONDS); | ||
| retryCount++; | ||
| } | ||
| utils.close(); | ||
| throw new RuntimeException("Namespace was not deleted after " + MAX_RETRY_COUNT + " retries"); | ||
| } catch (Exception e) { | ||
| throw new RuntimeException("Failed to wait for namespace deletion", e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected void waitForTableDeletion() { | ||
| try { | ||
| AdminTestUtils utils = getAdminTestUtils(TEST_NAME); | ||
| int retryCount = 0; | ||
| while (retryCount < MAX_RETRY_COUNT) { | ||
| if (!utils.tableExists(NAMESPACE, TABLE)) { | ||
| utils.close(); | ||
| return; | ||
| } | ||
| Uninterruptibles.sleepUninterruptibly( | ||
| SLEEP_BETWEEN_RETRIES_SECONDS, java.util.concurrent.TimeUnit.SECONDS); | ||
| retryCount++; | ||
| } | ||
| utils.close(); | ||
| throw new RuntimeException("Table was not deleted after " + MAX_RETRY_COUNT + " retries"); | ||
| } catch (Exception e) { | ||
| throw new RuntimeException("Failed to wait for table deletion", e); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| @Override | ||
| @Disabled("Import-related functionality is not supported in Cassandra") | ||
| public void getImportTableMetadata_WithSufficientPermission_ShouldSucceed() {} | ||
|
|
||
| @Test | ||
| @Override | ||
| @Disabled("Import-related functionality is not supported in Cassandra") | ||
| public void addRawColumnToTable_WithSufficientPermission_ShouldSucceed() {} | ||
|
|
||
| @Test | ||
| @Override | ||
| @Disabled("Import-related functionality is not supported in Cassandra") | ||
| public void importTable_WithSufficientPermission_ShouldSucceed() {} | ||
| } |
This file contains hidden or 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
61 changes: 61 additions & 0 deletions
61
...gration-test/java/com/scalar/db/storage/cassandra/CassandraPermissionIntegrationTest.java
This file contains hidden or 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,61 @@ | ||
| package com.scalar.db.storage.cassandra; | ||
|
|
||
| import static com.scalar.db.storage.cassandra.CassandraPermissionTestUtils.MAX_RETRY_COUNT; | ||
| import static com.scalar.db.storage.cassandra.CassandraPermissionTestUtils.SLEEP_BETWEEN_RETRIES_SECONDS; | ||
|
|
||
| import com.google.common.util.concurrent.Uninterruptibles; | ||
| import com.scalar.db.api.DistributedStoragePermissionIntegrationTestBase; | ||
| import com.scalar.db.util.AdminTestUtils; | ||
| import com.scalar.db.util.PermissionTestUtils; | ||
| import java.util.Collections; | ||
| import java.util.Map; | ||
| import java.util.Properties; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| public class CassandraPermissionIntegrationTest | ||
| extends DistributedStoragePermissionIntegrationTestBase { | ||
| @Override | ||
| protected Properties getProperties(String testName) { | ||
| return CassandraEnv.getProperties(testName); | ||
| } | ||
|
|
||
| @Override | ||
| protected Properties getPropertiesForNormalUser(String testName) { | ||
| return CassandraEnv.getPropertiesForNormalUser(testName); | ||
| } | ||
|
|
||
| @Override | ||
| protected PermissionTestUtils getPermissionTestUtils(String testName) { | ||
| return new CassandraPermissionTestUtils(getProperties(testName)); | ||
| } | ||
|
|
||
| @Override | ||
| protected AdminTestUtils getAdminTestUtils(String testName) { | ||
| return new CassandraAdminTestUtils(getProperties(testName)); | ||
| } | ||
|
|
||
| @Override | ||
| protected Map<String, String> getCreationOptions() { | ||
| return Collections.singletonMap(CassandraAdmin.REPLICATION_FACTOR, "1"); | ||
| } | ||
|
|
||
| @Override | ||
| protected void waitForTableCreation() { | ||
| try { | ||
| AdminTestUtils utils = getAdminTestUtils(TEST_NAME); | ||
| int retryCount = 0; | ||
| while (retryCount < MAX_RETRY_COUNT) { | ||
| if (utils.tableExists(NAMESPACE, TABLE)) { | ||
| utils.close(); | ||
| return; | ||
| } | ||
| Uninterruptibles.sleepUninterruptibly(SLEEP_BETWEEN_RETRIES_SECONDS, TimeUnit.SECONDS); | ||
| retryCount++; | ||
| } | ||
| utils.close(); | ||
| throw new RuntimeException("Table was not created after " + MAX_RETRY_COUNT + " retries"); | ||
| } catch (Exception e) { | ||
| throw new RuntimeException("Failed to wait for table creation", e); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider extracting the property keys
PROP_CASSANDRA_NORMAL_USERNAMEandPROP_CASSANDRA_NORMAL_PASSWORDinto a common configuration class to avoid duplication and improve maintainability.