dcapwell commented on code in PR #3416: URL: https://github.com/apache/cassandra/pull/3416#discussion_r1777774867
########## test/unit/org/apache/cassandra/cql3/RandomSchemaV2Test.java: ########## @@ -0,0 +1,326 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.cql3; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import accord.utils.Gen; +import accord.utils.Gens; +import accord.utils.RandomSource; +import org.apache.cassandra.config.DatabaseDescriptor; +import org.apache.cassandra.cql3.ast.CreateIndexDDL; +import org.apache.cassandra.cql3.ast.CreateIndexDDL.Indexer; +import org.apache.cassandra.cql3.ast.Mutation; +import org.apache.cassandra.cql3.ast.ReferenceExpression; +import org.apache.cassandra.cql3.ast.Select; +import org.apache.cassandra.cql3.ast.Symbol; +import org.apache.cassandra.cql3.ast.TableReference; +import org.apache.cassandra.cql3.ast.Txn; +import org.apache.cassandra.db.Keyspace; +import org.apache.cassandra.db.marshal.AbstractType; +import org.apache.cassandra.db.marshal.CompositeType; +import org.apache.cassandra.db.marshal.DurationType; +import org.apache.cassandra.db.marshal.MapType; +import org.apache.cassandra.db.marshal.UTF8Type; +import org.apache.cassandra.index.Index; +import org.apache.cassandra.index.SecondaryIndexManager; +import org.apache.cassandra.index.sai.StorageAttachedIndex; +import org.apache.cassandra.schema.ColumnMetadata; +import org.apache.cassandra.schema.KeyspaceMetadata; +import org.apache.cassandra.schema.Schema; +import org.apache.cassandra.schema.TableMetadata; +import org.apache.cassandra.service.consensus.TransactionalMode; +import org.apache.cassandra.transport.ProtocolVersion; +import org.apache.cassandra.utils.AbstractTypeGenerators; +import org.apache.cassandra.utils.CassandraGenerators; +import org.assertj.core.api.Assertions; +import org.awaitility.Awaitility; + +import static accord.utils.Property.qt; +import static java.lang.String.format; + +public class RandomSchemaV2Test extends CQLTester +{ + @BeforeClass + public static void setUpClass() + { + prePrepareServer(); + + // When values are large SAI will drop them... soooo... disable that... this test does not care about perf but correctness + DatabaseDescriptor.getRawConfig().sai_frozen_term_size_warn_threshold = null; + DatabaseDescriptor.getRawConfig().sai_frozen_term_size_fail_threshold = null; + + // Once per-JVM is enough + prepareServer(); + } + + enum Mode { AccordEnabled, Default} + + @Test + public void test() + { + requireNetwork(); + Gen<ProtocolVersion> clientVersionGen = rs -> { + if (rs.decide(.8)) return null; + return rs.pickOrderedSet(ProtocolVersion.SUPPORTED); + }; + Gen<Mode> modeGen = Gens.enums().all(Mode.class); + qt().withExamples(100).forAll(Gens.random(), modeGen, clientVersionGen).check((rs, mode, protocolVersion) -> { + clearState(); + + KeyspaceMetadata ks = createKeyspace(rs); + TableMetadata metadata = createTable(rs, ks.name); + if (mode == Mode.AccordEnabled) + { + // enable accord + schemaChange(String.format("ALTER TABLE %s WITH " + TransactionalMode.full.asCqlParam(), metadata)); + metadata = Objects.requireNonNull(Schema.instance.getTableMetadata(ks.name, metadata.name)); + } + Map<ColumnMetadata, CreateIndexDDL> indexedColumns = createIndex(rs, metadata); + Mutation mutation = nonTransactionMutation(rs, metadata); + if (mode == Mode.AccordEnabled) + mutation = mutation.withoutTimestamp().withoutTTL(); // Accord doesn't allow custom timestamps or TTL Review Comment: we don't actually block `TTL` atm... I have a patch for that... I have too many things open atm... -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

