smiklosovic commented on code in PR #2197: URL: https://github.com/apache/cassandra/pull/2197#discussion_r1129983674
########## test/distributed/org/apache/cassandra/distributed/test/HintsDisabledTest.java: ########## @@ -0,0 +1,92 @@ +/* + * 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.distributed.test; + +import java.io.IOException; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +import org.junit.Test; + +import com.google.monitoring.runtime.instrumentation.common.util.concurrent.Uninterruptibles; +import org.apache.cassandra.db.ColumnFamilyStore; +import org.apache.cassandra.distributed.Cluster; +import org.apache.cassandra.distributed.api.ConsistencyLevel; +import org.apache.cassandra.distributed.api.IMessageFilters; + +import static org.apache.cassandra.distributed.api.Feature.GOSSIP; +import static org.apache.cassandra.distributed.api.Feature.NETWORK; +import static org.apache.cassandra.net.Verb.MUTATION_REQ; +import static org.assertj.core.api.Assertions.assertThat; + +public class HintsDisabledTest extends TestBaseImpl +{ + @Test + public void testHintedHandoffDisabled() throws IOException + { + try (Cluster cluster = init(Cluster.build(2) + .withDataDirCount(1) + .withConfig(config -> config.with(NETWORK, GOSSIP) + .set("hinted_handoff_enabled", false)) + .start(), 2)) + { + String createTableStatement = String.format("CREATE TABLE %s.cf (k text PRIMARY KEY, c1 text) " + + "WITH compaction = {'class': 'SizeTieredCompactionStrategy', 'enabled': 'false'} ", KEYSPACE); + cluster.schemaChange(createTableStatement); + + // each row has 1KB payload + Random random = new Random(0); + StringBuilder random1kbString = new StringBuilder(); + for (int i = 0; i < 1024; i++) + random1kbString.append((char)random.nextInt(127)); + + // Drop all messages from node1 to node2 so node2 will be empty + IMessageFilters.Filter drop1to2 = cluster.filters().verbs(MUTATION_REQ.id).from(1).to(2).drop(); + + final int totalRows = 10000; // total size: 10K x 1KB ~= 10MB + for (int i = 0; i < totalRows; ++i) + { + // write rows with timestamp 1 to have deterministic transfer size + cluster.coordinator(1).execute(withKeyspace("INSERT INTO %s.cf (k, c1) VALUES (?, ?) USING TIMESTAMP 1;"), + ConsistencyLevel.ONE, + String.valueOf(i), + random1kbString.toString()); + } + + // Flush and compact all nodes to generate a single sstable + cluster.forEach(node -> { + node.flush(KEYSPACE); + node.forceCompact(KEYSPACE, "cf"); + }); + + // wait 25s for hints to be dispatched Review Comment: but you are not waiting 25s, you sleep uninterruptibly 30s. -- 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]

