Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
68ed7af
CNDB-17107 Use SCM HCD_1 as default for CC5 junit tests
djatnieks May 8, 2026
32083e2
Fix auth tests failing in storage compatibility mode
djatnieks May 9, 2026
2c8156f
Fix more tests when using storage compatibility mode
djatnieks May 11, 2026
ca2ab52
Fix more CIDR related tests
djatnieks May 11, 2026
af9c20e
Fix testAlterTableWithMemtable in SCM HCD_1 mode
djatnieks May 11, 2026
3ef2fd1
InstanceConfig should respect TEST_STORAGE_COMPATIBILITY_MODE system …
djatnieks May 11, 2026
ba15755
Fix more CIDR related tests
djatnieks May 11, 2026
650e5dd
Skip DropUDTWithRestartTests needing 5.0 version commit log and SSTab…
djatnieks May 11, 2026
67e0302
CIDRAuthorizerConfigTest is a distributed test and needs to use Cassa…
djatnieks May 11, 2026
7e8f75e
SchemaCQLHelperTest skip testing with 5.0 only Sharded memtables when…
djatnieks May 11, 2026
f1b1176
Fix SchemaCQLHelperTest.testCfmOptionsCQL
djatnieks May 11, 2026
709b688
Filter the parameter list in MemtableQuickTest and MemtableSizeTestBa…
djatnieks May 11, 2026
f1807b0
Fix test framework to respect SCM for CIDR features, remove productio…
djatnieks May 12, 2026
8a9a811
Fix CommitLogDescriptorTest.testVersions for SCM
djatnieks May 12, 2026
8b5b8e8
Ignore CompactionHistoryTest tests in SCM compatibility mode
djatnieks May 12, 2026
3264a32
Fix CreateTest for SCM and refactor common code with AlterTest to CQL…
djatnieks May 12, 2026
07d80a4
Fix RandomSchemaTest with update CassandraGenerators to filter sharde…
djatnieks May 12, 2026
e861b67
Fix checkstyle complaints
djatnieks May 12, 2026
38e342b
Fix SchemaLoader to not set or setup CIDRAuthorizer in DatabaseDescri…
djatnieks May 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/java/org/apache/cassandra/auth/AuthKeyspace.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,25 @@ private AuthKeyspace()
public static final String CIDR_PERMISSIONS = "cidr_permissions";
public static final String CIDR_GROUPS = "cidr_groups";
public static final String IDENTITY_TO_ROLES = "identity_to_role";
public static final Set<String> TABLE_NAMES = ImmutableSet.of(ROLES, ROLE_MEMBERS, ROLE_PERMISSIONS,
RESOURCE_ROLE_INDEX, NETWORK_PERMISSIONS,
CIDR_PERMISSIONS, CIDR_GROUPS,
IDENTITY_TO_ROLES);

/**
* Returns the set of table names that should exist in the system_auth keyspace.
* In compatibility mode (pre-5.0), CIDR and identity tables are excluded as they
* are Cassandra 5.0+ features.
*
* @return the set of table names appropriate for the current storage compatibility mode
*/
public static Set<String> tableNames()
{
if (DatabaseDescriptor.getStorageCompatibilityMode().isBefore(CassandraVersion.CASSANDRA_5_0.major))
return ImmutableSet.of(ROLES, ROLE_MEMBERS, ROLE_PERMISSIONS,
RESOURCE_ROLE_INDEX, NETWORK_PERMISSIONS);
else
return ImmutableSet.of(ROLES, ROLE_MEMBERS, ROLE_PERMISSIONS,
RESOURCE_ROLE_INDEX, NETWORK_PERMISSIONS,
CIDR_PERMISSIONS, CIDR_GROUPS,
IDENTITY_TO_ROLES);
}

public static final long SUPERUSER_SETUP_DELAY = SUPERUSER_SETUP_DELAY_MS.getLong();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ public enum CassandraRelevantProperties
*
* This is a dev/CI only property. Do not use otherwise.
*/
TEST_STORAGE_COMPATIBILITY_MODE("cassandra.test.storage_compatibility_mode", StorageCompatibilityMode.NONE.toString()),
TEST_STORAGE_COMPATIBILITY_MODE("cassandra.test.storage_compatibility_mode", StorageCompatibilityMode.HCD_1.toString()),
TEST_STRICT_LCS_CHECKS("cassandra.test.strict_lcs_checks"),
/** Turns some warnings into exceptions for testing. */
TEST_STRICT_RUNTIME_CHECKS("cassandra.strict.runtime.checks"),
Expand Down
2 changes: 1 addition & 1 deletion src/java/org/apache/cassandra/schema/SchemaConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public static Set<String> getLocalAndReplicatedSystemTableNames()
.addAll(SystemKeyspace.TABLE_NAMES)
.addAll(SchemaKeyspaceTables.ALL)
.addAll(TraceKeyspace.TABLE_NAMES)
.addAll(AuthKeyspace.TABLE_NAMES)
.addAll(AuthKeyspace.tableNames())
.addAll(SystemDistributedKeyspace.TABLE_NAMES)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ private InstanceConfig(int num,
.set("default_secondary_index", "sai")
.set("default_secondary_index_enabled", "true")

.set("storage_compatibility_mode", "NONE");
// Respect TEST_STORAGE_COMPATIBILITY_MODE system property (defaults to HCD_1 in tests)
.set("storage_compatibility_mode", CassandraRelevantProperties.TEST_STORAGE_COMPATIBILITY_MODE.getString());
}
this.featureFlags = EnumSet.noneOf(Feature.class);
this.jmxPort = jmx_port;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,18 @@
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.junit.Ignore;
import org.junit.Assume;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Session;
import org.apache.cassandra.config.CassandraRelevantProperties;
import org.apache.cassandra.db.Keyspace;
import org.apache.cassandra.distributed.Cluster;
import org.apache.cassandra.utils.CassandraVersion;
import org.apache.cassandra.utils.StorageCompatibilityMode;
import org.apache.cassandra.distributed.api.ConsistencyLevel;
import org.apache.cassandra.distributed.api.ICoordinator;
import org.apache.cassandra.distributed.api.IInstance;
Expand Down Expand Up @@ -301,6 +305,11 @@ public void loadCommitLogAndSSTablesWithDroppedColumnTestCassandra41() throws Ex
@Test
public void loadCommitLogAndSSTablesWithDroppedColumnTestCassandra5() throws Exception
{
// Skip this test if running in compatibility mode < 5.0, as it loads CC5.0 format commit logs and SSTables
StorageCompatibilityMode mode = CassandraRelevantProperties.TEST_STORAGE_COMPATIBILITY_MODE.getEnum(true, StorageCompatibilityMode.class);
Assume.assumeFalse("Test requires Cassandra 5.0+ format data",
mode != null && mode.isBefore(CassandraVersion.CASSANDRA_5_0.major));

// Cassandra limitations
// - user types cannot include other non-frozen udt
// - cannot drop non-frozen columns
Expand All @@ -311,6 +320,11 @@ public void loadCommitLogAndSSTablesWithDroppedColumnTestCassandra5() throws Exc
@Test
public void loadCommitLogAndSSTablesWithDroppedColumnTestCC50() throws Exception
{
// Skip this test if running in compatibility mode < 5.0, as it loads CC5.0 format commit logs and SSTables
StorageCompatibilityMode mode = CassandraRelevantProperties.TEST_STORAGE_COMPATIBILITY_MODE.getEnum(true, StorageCompatibilityMode.class);
Assume.assumeFalse("Test requires Cassandra 5.0+ format data",
mode != null && mode.isBefore(CassandraVersion.CASSANDRA_5_0.major));

loadCommitLogAndSSTablesWithDroppedColumnTest(CC50_PRODUCT_PATH);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,28 @@
import java.io.IOException;

import com.google.common.collect.ImmutableMap;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Test;

import org.apache.cassandra.config.CassandraRelevantProperties;
import org.apache.cassandra.config.ParameterizedClass;
import org.apache.cassandra.distributed.Cluster;
import org.apache.cassandra.distributed.test.TestBaseImpl;
import org.apache.cassandra.utils.CassandraVersion;
import org.apache.cassandra.utils.StorageCompatibilityMode;

public class CIDRAuthorizerConfigTest extends TestBaseImpl
{
@BeforeClass
public static void setup() throws Exception
{
// Skip this test if running in compatibility mode < 5.0, as CIDR authorization is a CC5.0+ feature
StorageCompatibilityMode mode = CassandraRelevantProperties.TEST_STORAGE_COMPATIBILITY_MODE.getEnum(true, StorageCompatibilityMode.class);
Assume.assumeFalse("CIDR features require Cassandra 5.0+",
mode != null && mode.isBefore(CassandraVersion.CASSANDRA_5_0.major));
}

@Test
public void testParameterizedClass() throws IOException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,19 @@
import com.google.common.collect.ImmutableSet;
import org.junit.Test;

import org.apache.cassandra.config.CassandraRelevantProperties;
import org.apache.cassandra.distributed.Cluster;
import org.apache.cassandra.distributed.api.Feature;
import org.apache.cassandra.distributed.api.IInstanceConfig;
import org.apache.cassandra.distributed.api.IInvokableInstance;
import org.apache.cassandra.distributed.shared.JMXUtil;
import org.apache.cassandra.distributed.test.TestBaseImpl;
import org.apache.cassandra.utils.CassandraVersion;
import org.apache.cassandra.utils.StorageCompatibilityMode;

public class JMXGetterCheckTest extends TestBaseImpl
{
private static final Set<String> IGNORE_ATTRIBUTES = ImmutableSet.of(
private static final Set<String> BASE_IGNORE_ATTRIBUTES = ImmutableSet.of(
"org.apache.cassandra.net:type=MessagingService:BackPressurePerHost", // throws unsupported saying the feature was removed... dropped in CASSANDRA-15375
"org.apache.cassandra.db:type=DynamicEndpointSnitch:Scores" // when running in multiple-port-one-IP mode, this fails

Expand All @@ -60,6 +63,21 @@ public class JMXGetterCheckTest extends TestBaseImpl
"org.apache.cassandra.db:type=StorageService:startNativeTransport" // causes multiple loops to fail
);

private static Set<String> getIgnoreAttributes()
{
// CIDR features require Cassandra 5.0+, skip CIDR-related attributes in compatibility mode
StorageCompatibilityMode mode = CassandraRelevantProperties.TEST_STORAGE_COMPATIBILITY_MODE.getEnum(true, StorageCompatibilityMode.class);
if (mode != null && mode.isBefore(CassandraVersion.CASSANDRA_5_0.major))
{
return ImmutableSet.<String>builder()
.addAll(BASE_IGNORE_ATTRIBUTES)
.add("org.apache.cassandra.db:type=CIDRFilteringMetricsTable:CountsMetricsFromVtable")
.add("org.apache.cassandra.db:type=CIDRFilteringMetricsTable:LatenciesMetricsFromVtable")
.build();
}
return BASE_IGNORE_ATTRIBUTES;
}

@Test
public void testGetters() throws Exception
{
Expand All @@ -81,6 +99,8 @@ public void testGetters() throws Exception
*/
public static void testAllValidGetters(Cluster cluster) throws Exception
{
Set<String> ignoreAttributes = getIgnoreAttributes();

for (IInvokableInstance instance: cluster)
{
if (instance.isShutdown())
Expand All @@ -101,7 +121,7 @@ public static void testAllValidGetters(Cluster cluster) throws Exception
for (MBeanAttributeInfo a : info.getAttributes())
{
String fqn = String.format("%s:%s", name, a.getName());
if (!a.isReadable() || IGNORE_ATTRIBUTES.contains(fqn))
if (!a.isReadable() || ignoreAttributes.contains(fqn))
continue;
try
{
Expand Down
16 changes: 14 additions & 2 deletions test/unit/org/apache/cassandra/SchemaLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,26 @@ public static void setupAuth(IRoleManager roleManager, IAuthenticator authentica
DatabaseDescriptor.setAuthenticator(authenticator);
DatabaseDescriptor.setAuthorizer(authorizer);
DatabaseDescriptor.setNetworkAuthorizer(networkAuthorizer);
DatabaseDescriptor.setCIDRAuthorizer(cidrAuthorizer);

// Only set and setup CIDR authorizer if storage compatibility mode supports it (5.0+)
// This matches the pattern in CQLTester and production behavior
if (!DatabaseDescriptor.getStorageCompatibilityMode().isBefore(5))
{
DatabaseDescriptor.setCIDRAuthorizer(cidrAuthorizer);
}

SchemaTestUtil.announceNewKeyspace(AuthKeyspace.metadata());
DatabaseDescriptor.getRoleManager().setup();
DatabaseDescriptor.getAuthenticator().setup();
DatabaseDescriptor.getInternodeAuthenticator().setupInternode();
DatabaseDescriptor.getAuthorizer().setup();
DatabaseDescriptor.getNetworkAuthorizer().setup();
DatabaseDescriptor.getCIDRAuthorizer().setup();

// Only setup CIDR authorizer if storage compatibility mode supports it (5.0+)
// This matches production behavior in StorageService.doAuthSetup()
if (!DatabaseDescriptor.getStorageCompatibilityMode().isBefore(5))
DatabaseDescriptor.getCIDRAuthorizer().setup();

Schema.instance.registerListener(new AuthSchemaChangeListener());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,21 @@
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import org.apache.cassandra.SchemaLoader;
import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.cql3.CQLTester;
import org.apache.cassandra.cql3.QueryProcessor;
import org.apache.cassandra.cql3.UntypedResultSet;
import org.apache.cassandra.db.Keyspace;
import org.apache.cassandra.db.marshal.UTF8Type;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.service.ClientState;
import org.apache.cassandra.utils.CassandraVersion;

import static org.apache.cassandra.auth.AuthKeyspace.CIDR_GROUPS;
import static org.apache.cassandra.auth.AuthKeyspace.CIDR_PERMISSIONS;
Expand All @@ -60,6 +63,9 @@ private static void setupSuperUser()
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
Assume.assumeFalse("CIDR features require Cassandra 5.0+",
DatabaseDescriptor.getStorageCompatibilityMode().isBefore(CassandraVersion.CASSANDRA_5_0.major));

SchemaLoader.prepareServer();

SchemaLoader.setupAuth(new AuthTestUtils.LocalCassandraRoleManager(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@
import java.util.Set;

import com.google.common.collect.ImmutableSet;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import org.apache.cassandra.SchemaLoader;
import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.cql3.CIDR;
import org.apache.cassandra.cql3.QueryProcessor;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.utils.CassandraVersion;

import static org.apache.cassandra.schema.SchemaConstants.AUTH_KEYSPACE_NAME;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
Expand All @@ -56,6 +59,9 @@ private static void setupSuperUser()
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
Assume.assumeFalse("CIDR features require Cassandra 5.0+",
DatabaseDescriptor.getStorageCompatibilityMode().isBefore(CassandraVersion.CASSANDRA_5_0.major));

SchemaLoader.prepareServer();

SchemaLoader.setupAuth(new AuthTestUtils.LocalCassandraRoleManager(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -45,6 +46,7 @@
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.exceptions.UnauthorizedException;
import org.apache.cassandra.service.ClientState;
import org.apache.cassandra.utils.CassandraVersion;
import org.assertj.core.api.Assertions;

import static java.lang.String.format;
Expand Down Expand Up @@ -72,6 +74,9 @@ private static void setupSuperUser()
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
Assume.assumeFalse("CIDR features require Cassandra 5.0+",
DatabaseDescriptor.getStorageCompatibilityMode().isBefore(CassandraVersion.CASSANDRA_5_0.major));

SchemaLoader.prepareServer();

SchemaLoader.setupAuth(new AuthTestUtils.LocalCassandraRoleManager(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.HashMap;

import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -37,6 +38,7 @@
import org.apache.cassandra.db.Keyspace;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.service.ClientState;
import org.apache.cassandra.utils.CassandraVersion;

import static org.apache.cassandra.auth.AuthKeyspace.CIDR_GROUPS;
import static org.apache.cassandra.auth.AuthKeyspace.CIDR_PERMISSIONS;
Expand All @@ -59,6 +61,9 @@ private static void setupSuperUser()
@BeforeClass
public static void defineSchema() throws ConfigurationException
{
Assume.assumeFalse("CIDR features require Cassandra 5.0+",
DatabaseDescriptor.getStorageCompatibilityMode().isBefore(CassandraVersion.CASSANDRA_5_0.major));

SchemaLoader.prepareServer();

SchemaLoader.setupAuth(new AuthTestUtils.LocalCassandraRoleManager(),
Expand Down
13 changes: 12 additions & 1 deletion test/unit/org/apache/cassandra/auth/GrantAndRevokeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import com.google.common.collect.Iterables;
import org.junit.After;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Test;

Expand All @@ -38,6 +39,7 @@
import org.apache.cassandra.schema.TableMetadata;
import org.apache.cassandra.service.CassandraDaemon;
import org.apache.cassandra.transport.ProtocolVersion;
import org.apache.cassandra.utils.CassandraVersion;

import static java.lang.String.format;
import static org.apache.cassandra.schema.SchemaConstants.LOCAL_SYSTEM_KEYSPACE_NAMES;
Expand Down Expand Up @@ -68,7 +70,7 @@ public static void setUpClass()
public void tearDown() throws Throwable
{
useSuperUser();
executeNet("DROP ROLE " + user);
executeNet("DROP ROLE IF EXISTS " + user);
}

@Test
Expand Down Expand Up @@ -490,6 +492,9 @@ public void testGrantOnVirtualKeyspaces() throws Throwable
@Test
public void testAddIdentityPermissions() throws Throwable
{
Assume.assumeFalse("ADD IDENTITY requires Cassandra 5.0+",
DatabaseDescriptor.getStorageCompatibilityMode().isBefore(CassandraVersion.CASSANDRA_5_0.major));

useSuperUser();

executeNet(String.format("CREATE ROLE %s WITH LOGIN = TRUE AND password='%s'", user, pass));
Expand All @@ -506,6 +511,9 @@ public void testAddIdentityPermissions() throws Throwable
@Test
public void testRemoveIdentityPermissionsWithSpecificRolePermission() throws Throwable
{
Assume.assumeFalse("DROP IDENTITY requires Cassandra 5.0+",
DatabaseDescriptor.getStorageCompatibilityMode().isBefore(CassandraVersion.CASSANDRA_5_0.major));

useSuperUser();

String simpleUser = "user_1";
Expand All @@ -528,6 +536,9 @@ public void testRemoveIdentityPermissionsWithSpecificRolePermission() throws Thr
@Test
public void testRemoveIdentityPermissions()
{
Assume.assumeFalse("DROP IDENTITY requires Cassandra 5.0+",
DatabaseDescriptor.getStorageCompatibilityMode().isBefore(CassandraVersion.CASSANDRA_5_0.major));

useSuperUser();

executeNet(String.format("CREATE ROLE %s WITH LOGIN = TRUE AND password='%s'", user, pass));
Expand Down
Loading
Loading