mirror of https://github.com/apache/cassandra
Merge branch 'cassandra-4.0' into trunk
This commit is contained in:
commit
b0855914ef
|
|
@ -169,6 +169,7 @@
|
|||
<option name="TEST_OBJECT" value="class" />
|
||||
<option name="VM_PARAMETERS" value="-Dcassandra.config=file://$PROJECT_DIR$/test/conf/cassandra.yaml -Dlogback.configurationFile=file://$PROJECT_DIR$/test/conf/logback-test.xml -Dcassandra.logdir=$PROJECT_DIR$/build/test/logs -Djava.library.path=$PROJECT_DIR$/lib/sigar-bin -Dlegacy-sstable-root=$PROJECT_DIR$/test/data/legacy-sstables -Dinvalid-legacy-sstable-root=$PROJECT_DIR$/test/data/invalid-legacy-sstables -Dcassandra.ring_delay_ms=1000 -Dcassandra.skip_sync=true -ea -XX:MaxMetaspaceSize=384M -XX:SoftRefLRUPolicyMSPerMB=0 -Dcassandra.strict.runtime.checks=true -Dlegacy-sstable-root=$PROJECT_DIR$/test/data/legacy-sstables -Dinvalid-legacy-sstable-root=$PROJECT_DIR$/test/data/invalid-legacy-sstables -Dmigration-sstable-root=$PROJECT_DIR$/test/data/migration-sstables -Dcassandra.ring_delay_ms=1000 -Dcassandra.tolerate_sstable_size=true -Dcassandra.skip_sync=true" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<fork_mode value="class" />
|
||||
<option name="WORKING_DIRECTORY" value="" />
|
||||
<option name="ENV_VARIABLES" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
|
|
|
|||
|
|
@ -41,14 +41,12 @@ import org.junit.AfterClass;
|
|||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.monitoring.runtime.instrumentation.AllocationRecorder;
|
||||
import com.google.monitoring.runtime.instrumentation.Sampler;
|
||||
import com.sun.management.ThreadMXBean;
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.cql3.QueryOptions;
|
||||
import org.apache.cassandra.cql3.QueryProcessor;
|
||||
|
|
@ -78,7 +76,6 @@ import org.apache.cassandra.utils.FBUtilities;
|
|||
import org.apache.cassandra.utils.ObjectSizes;
|
||||
import org.apache.cassandra.utils.concurrent.Refs;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class CompactionAllocationTest
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompactionAllocationTest.class);
|
||||
|
|
|
|||
|
|
@ -1,55 +0,0 @@
|
|||
package org.apache.cassandra;
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
import org.junit.runners.BlockJUnit4ClassRunner;
|
||||
import org.junit.runners.model.FrameworkMethod;
|
||||
import org.junit.runners.model.InitializationError;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class OrderedJUnit4ClassRunner extends BlockJUnit4ClassRunner
|
||||
{
|
||||
|
||||
public OrderedJUnit4ClassRunner(Class aClass) throws InitializationError
|
||||
{
|
||||
super(aClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<FrameworkMethod> computeTestMethods()
|
||||
{
|
||||
final List<FrameworkMethod> list = super.computeTestMethods();
|
||||
try
|
||||
{
|
||||
final List<FrameworkMethod> copy = new ArrayList<FrameworkMethod>(list);
|
||||
Collections.sort(copy, MethodComparator.getFrameworkMethodComparatorForJUnit4());
|
||||
return copy;
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,14 +27,13 @@ import org.junit.AfterClass;
|
|||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import com.datastax.driver.core.Cluster;
|
||||
import com.datastax.driver.core.Session;
|
||||
import com.datastax.driver.core.exceptions.AuthenticationException;
|
||||
import com.datastax.driver.core.exceptions.SyntaxError;
|
||||
import com.datastax.driver.core.exceptions.UnauthorizedException;
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.config.OverrideConfigurationLoader;
|
||||
import org.apache.cassandra.config.ParameterizedClass;
|
||||
|
|
@ -54,7 +53,6 @@ import static org.junit.Assert.assertTrue;
|
|||
* Non authenticated tests are covered in {@link AuditLoggerTest}
|
||||
*/
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class AuditLoggerAuthTest
|
||||
{
|
||||
private static EmbeddedCassandraService embedded;
|
||||
|
|
|
|||
|
|
@ -31,9 +31,7 @@ import com.google.common.base.Throwables;
|
|||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.db.Keyspace;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
|
||||
|
|
@ -42,7 +40,6 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class DatabaseDescriptorTest
|
||||
{
|
||||
@BeforeClass
|
||||
|
|
|
|||
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* 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.validation.operations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.datastax.driver.core.PreparedStatement;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.service.ClientWarn;
|
||||
import org.assertj.core.api.Assertions;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class AlterNTSTest extends CQLTester
|
||||
{
|
||||
@Test
|
||||
public void testDropColumnAsPreparedStatement() throws Throwable
|
||||
{
|
||||
String table = createTable("CREATE TABLE %s (key int PRIMARY KEY, value int);");
|
||||
|
||||
PreparedStatement prepared = sessionNet().prepare("ALTER TABLE " + KEYSPACE + "." + table + " DROP value;");
|
||||
|
||||
executeNet("INSERT INTO %s (key, value) VALUES (1, 1)");
|
||||
assertRowsNet(executeNet("SELECT * FROM %s"), row(1, 1));
|
||||
|
||||
sessionNet().execute(prepared.bind());
|
||||
|
||||
executeNet("ALTER TABLE %s ADD value int");
|
||||
|
||||
assertRows(execute("SELECT * FROM %s"), row(1, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAlterKeyspacesRFWarnings() throws Throwable
|
||||
{
|
||||
requireNetwork();
|
||||
|
||||
// NTS
|
||||
ClientWarn.instance.captureWarnings();
|
||||
String ks = createKeyspace("CREATE KEYSPACE %s WITH replication = {'class' : 'NetworkTopologyStrategy', '" + DATA_CENTER + "' : 3 }");
|
||||
List<String> warnings = ClientWarn.instance.getWarnings();
|
||||
assertEquals(1, warnings.size());
|
||||
Assertions.assertThat(warnings.get(0)).contains("Your replication factor 3 for keyspace " + ks + " is higher than the number of nodes 1 for datacenter " + DATA_CENTER);
|
||||
|
||||
ClientWarn.instance.captureWarnings();
|
||||
execute("CREATE TABLE " + ks + ".t (k int PRIMARY KEY, v int)");
|
||||
warnings = ClientWarn.instance.getWarnings();
|
||||
assertNull(warnings);
|
||||
|
||||
ClientWarn.instance.captureWarnings();
|
||||
execute("ALTER KEYSPACE " + ks + " WITH replication = {'class' : 'NetworkTopologyStrategy', '" + DATA_CENTER + "' : 2 }");
|
||||
warnings = ClientWarn.instance.getWarnings();
|
||||
assertEquals(1, warnings.size());
|
||||
Assertions.assertThat(warnings.get(0)).contains("Your replication factor 2 for keyspace " + ks + " is higher than the number of nodes 1 for datacenter " + DATA_CENTER);
|
||||
|
||||
ClientWarn.instance.captureWarnings();
|
||||
execute("ALTER KEYSPACE " + ks + " WITH replication = {'class' : 'NetworkTopologyStrategy', '" + DATA_CENTER + "' : 1 }");
|
||||
warnings = ClientWarn.instance.getWarnings();
|
||||
assertNull(warnings);
|
||||
|
||||
// SimpleStrategy
|
||||
ClientWarn.instance.captureWarnings();
|
||||
ks = createKeyspace("CREATE KEYSPACE %s WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 }");
|
||||
warnings = ClientWarn.instance.getWarnings();
|
||||
assertEquals(1, warnings.size());
|
||||
Assertions.assertThat(warnings.get(0)).contains("Your replication factor 3 for keyspace " + ks + " is higher than the number of nodes 1");
|
||||
|
||||
ClientWarn.instance.captureWarnings();
|
||||
execute("CREATE TABLE " + ks + ".t (k int PRIMARY KEY, v int)");
|
||||
warnings = ClientWarn.instance.getWarnings();
|
||||
assertNull(warnings);
|
||||
|
||||
ClientWarn.instance.captureWarnings();
|
||||
execute("ALTER KEYSPACE " + ks + " WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 2 }");
|
||||
warnings = ClientWarn.instance.getWarnings();
|
||||
assertEquals(1, warnings.size());
|
||||
Assertions.assertThat(warnings.get(0)).contains("Your replication factor 2 for keyspace " + ks + " is higher than the number of nodes 1");
|
||||
|
||||
ClientWarn.instance.captureWarnings();
|
||||
execute("ALTER KEYSPACE " + ks + " WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }");
|
||||
warnings = ClientWarn.instance.getWarnings();
|
||||
assertNull(warnings);
|
||||
}
|
||||
}
|
||||
|
|
@ -17,14 +17,10 @@
|
|||
*/
|
||||
package org.apache.cassandra.cql3.validation.operations;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import com.datastax.driver.core.PreparedStatement;
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
|
|
@ -37,37 +33,16 @@ import org.apache.cassandra.locator.InetAddressAndPort;
|
|||
import org.apache.cassandra.locator.TokenMetadata;
|
||||
import org.apache.cassandra.schema.SchemaConstants;
|
||||
import org.apache.cassandra.schema.SchemaKeyspace;
|
||||
import org.apache.cassandra.service.ClientWarn;
|
||||
import org.apache.cassandra.service.StorageService;
|
||||
import org.apache.cassandra.utils.FBUtilities;
|
||||
import org.assertj.core.api.Assertions;
|
||||
|
||||
import static java.lang.String.format;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class AlterTest extends CQLTester
|
||||
{
|
||||
@Test
|
||||
public void testDropColumnAsPreparedStatement() throws Throwable
|
||||
{
|
||||
String table = createTable("CREATE TABLE %s (key int PRIMARY KEY, value int);");
|
||||
|
||||
PreparedStatement prepared = sessionNet().prepare("ALTER TABLE " + KEYSPACE + "." + table + " DROP value;");
|
||||
|
||||
executeNet("INSERT INTO %s (key, value) VALUES (1, 1)");
|
||||
assertRowsNet(executeNet("SELECT * FROM %s"), row(1, 1));
|
||||
|
||||
sessionNet().execute(prepared.bind());
|
||||
|
||||
executeNet("ALTER TABLE %s ADD value int");
|
||||
|
||||
assertRows(execute("SELECT * FROM %s"), row(1, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddList() throws Throwable
|
||||
{
|
||||
|
|
@ -278,58 +253,6 @@ public class AlterTest extends CQLTester
|
|||
"max_threshold", "32")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAlterKeyspacesRFWarnings() throws Throwable
|
||||
{
|
||||
requireNetwork();
|
||||
|
||||
// NTS
|
||||
ClientWarn.instance.captureWarnings();
|
||||
String ks = createKeyspace("CREATE KEYSPACE %s WITH replication = {'class' : 'NetworkTopologyStrategy', '" + DATA_CENTER + "' : 3 }");
|
||||
List<String> warnings = ClientWarn.instance.getWarnings();
|
||||
assertEquals(1, warnings.size());
|
||||
Assertions.assertThat(warnings.get(0)).contains("Your replication factor 3 for keyspace " + ks + " is higher than the number of nodes 1 for datacenter " + DATA_CENTER);
|
||||
|
||||
ClientWarn.instance.captureWarnings();
|
||||
execute("CREATE TABLE " + ks + ".t (k int PRIMARY KEY, v int)");
|
||||
warnings = ClientWarn.instance.getWarnings();
|
||||
assertNull(warnings);
|
||||
|
||||
ClientWarn.instance.captureWarnings();
|
||||
execute("ALTER KEYSPACE " + ks + " WITH replication = {'class' : 'NetworkTopologyStrategy', '" + DATA_CENTER + "' : 2 }");
|
||||
warnings = ClientWarn.instance.getWarnings();
|
||||
assertEquals(1, warnings.size());
|
||||
Assertions.assertThat(warnings.get(0)).contains("Your replication factor 2 for keyspace " + ks + " is higher than the number of nodes 1 for datacenter " + DATA_CENTER);
|
||||
|
||||
ClientWarn.instance.captureWarnings();
|
||||
execute("ALTER KEYSPACE " + ks + " WITH replication = {'class' : 'NetworkTopologyStrategy', '" + DATA_CENTER + "' : 1 }");
|
||||
warnings = ClientWarn.instance.getWarnings();
|
||||
assertNull(warnings);
|
||||
|
||||
// SimpleStrategy
|
||||
ClientWarn.instance.captureWarnings();
|
||||
ks = createKeyspace("CREATE KEYSPACE %s WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 }");
|
||||
warnings = ClientWarn.instance.getWarnings();
|
||||
assertEquals(1, warnings.size());
|
||||
Assertions.assertThat(warnings.get(0)).contains("Your replication factor 3 for keyspace " + ks + " is higher than the number of nodes 1");
|
||||
|
||||
ClientWarn.instance.captureWarnings();
|
||||
execute("CREATE TABLE " + ks + ".t (k int PRIMARY KEY, v int)");
|
||||
warnings = ClientWarn.instance.getWarnings();
|
||||
assertNull(warnings);
|
||||
|
||||
ClientWarn.instance.captureWarnings();
|
||||
execute("ALTER KEYSPACE " + ks + " WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 2 }");
|
||||
warnings = ClientWarn.instance.getWarnings();
|
||||
assertEquals(1, warnings.size());
|
||||
Assertions.assertThat(warnings.get(0)).contains("Your replication factor 2 for keyspace " + ks + " is higher than the number of nodes 1");
|
||||
|
||||
ClientWarn.instance.captureWarnings();
|
||||
execute("ALTER KEYSPACE " + ks + " WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }");
|
||||
warnings = ClientWarn.instance.getWarnings();
|
||||
assertNull(warnings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAlterNetworkTopologyWithDefaults() throws Throwable
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ import java.io.IOException;
|
|||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.config.Config;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.cql3.Attributes;
|
||||
|
|
@ -49,7 +47,6 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class TTLTest extends CQLTester
|
||||
{
|
||||
public static String NEGATIVE_LOCAL_EXPIRATION_TEST_DIR = "test/data/negative-local-expiration-test/%s";
|
||||
|
|
@ -214,15 +211,7 @@ public class TTLTest extends CQLTester
|
|||
baseTestRecoverOverflowedExpiration(false, false, false);
|
||||
baseTestRecoverOverflowedExpiration(true, false, false);
|
||||
baseTestRecoverOverflowedExpiration(true, false, true);
|
||||
// we reset the corrupted ts strategy after each test in @After above
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecoverOverflowedExpirationWithSSTableScrub() throws Throwable
|
||||
{
|
||||
// this tests writes corrupt tombstones on purpose, disable the strategy:
|
||||
DatabaseDescriptor.setCorruptedTombstoneStrategy(Config.CorruptedTombstoneStrategy.disabled);
|
||||
baseTestRecoverOverflowedExpiration(false, false, false);
|
||||
baseTestRecoverOverflowedExpiration(false, true, false);
|
||||
baseTestRecoverOverflowedExpiration(false, true, true);
|
||||
// we reset the corrupted ts strategy after each test in @After above
|
||||
|
|
@ -437,6 +426,7 @@ public class TTLTest extends CQLTester
|
|||
|
||||
try
|
||||
{
|
||||
cfs.truncateBlocking();
|
||||
dropTable("DROP TABLE %s");
|
||||
}
|
||||
catch (Throwable e)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import org.junit.Before;
|
|||
import org.junit.Assume;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.io.util.FileUtils;
|
||||
import org.apache.cassandra.schema.SchemaConstants;
|
||||
|
|
@ -61,7 +60,6 @@ import org.apache.cassandra.utils.FBUtilities;
|
|||
import org.apache.cassandra.utils.WrappedRunnable;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class ColumnFamilyStoreTest
|
||||
{
|
||||
public static final String KEYSPACE1 = "ColumnFamilyStoreTest1";
|
||||
|
|
@ -124,6 +122,7 @@ public class ColumnFamilyStoreTest
|
|||
{
|
||||
Keyspace keyspace = Keyspace.open(KEYSPACE1);
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF_STANDARD1);
|
||||
keyspace.getColumnFamilyStores().forEach(ColumnFamilyStore::truncateBlocking);
|
||||
|
||||
List<Mutation> rms = new LinkedList<>();
|
||||
rms.add(new RowUpdateBuilder(cfs.metadata(), 0, "key1")
|
||||
|
|
@ -556,5 +555,6 @@ public class ColumnFamilyStoreTest
|
|||
List<File> ssTableFiles = new Directories(cfs.metadata()).sstableLister(Directories.OnTxnErr.THROW).listFiles();
|
||||
assertNotNull(ssTableFiles);
|
||||
assertEquals(0, ssTableFiles.size());
|
||||
cfs.clearUnsafe();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,9 +42,7 @@ import org.junit.AfterClass;
|
|||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.UpdateBuilder;
|
||||
import org.apache.cassandra.Util;
|
||||
|
|
@ -84,11 +82,7 @@ import org.apache.cassandra.io.sstable.metadata.MetadataCollector;
|
|||
import org.apache.cassandra.io.util.FileUtils;
|
||||
import org.apache.cassandra.schema.KeyspaceParams;
|
||||
import org.apache.cassandra.schema.TableMetadataRef;
|
||||
import org.apache.cassandra.tools.StandaloneScrubber;
|
||||
import org.apache.cassandra.tools.ToolRunner;
|
||||
import org.apache.cassandra.tools.ToolRunner.ToolResult;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.assertj.core.api.Assertions;
|
||||
|
||||
import static org.apache.cassandra.SchemaLoader.counterCFMD;
|
||||
import static org.apache.cassandra.SchemaLoader.createKeyspace;
|
||||
|
|
@ -101,7 +95,6 @@ import static org.junit.Assert.assertTrue;
|
|||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class ScrubTest
|
||||
{
|
||||
public static final String INVALID_LEGACY_SSTABLE_ROOT_PROP = "invalid-legacy-sstable-root";
|
||||
|
|
@ -120,8 +113,8 @@ public class ScrubTest
|
|||
|
||||
private static final AtomicInteger seq = new AtomicInteger();
|
||||
|
||||
private String ksName;
|
||||
private Keyspace keyspace;
|
||||
String ksName;
|
||||
Keyspace keyspace;
|
||||
|
||||
@BeforeClass
|
||||
public static void defineSchema() throws ConfigurationException
|
||||
|
|
@ -179,7 +172,7 @@ public class ScrubTest
|
|||
|
||||
CompactionManager.instance.disableAutoCompaction();
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(COUNTER_CF);
|
||||
|
||||
cfs.truncateBlocking();
|
||||
fillCounterCF(cfs, numPartitions);
|
||||
|
||||
assertOrderedAll(cfs, numPartitions);
|
||||
|
|
@ -418,7 +411,7 @@ public class ScrubTest
|
|||
}
|
||||
}
|
||||
|
||||
private void overrideWithGarbage(SSTableReader sstable, ByteBuffer key1, ByteBuffer key2) throws IOException
|
||||
static void overrideWithGarbage(SSTableReader sstable, ByteBuffer key1, ByteBuffer key2) throws IOException
|
||||
{
|
||||
boolean compression = Boolean.parseBoolean(System.getProperty("cassandra.test.compression", "false"));
|
||||
long startPosition, endPosition;
|
||||
|
|
@ -448,7 +441,7 @@ public class ScrubTest
|
|||
overrideWithGarbage(sstable, startPosition, endPosition);
|
||||
}
|
||||
|
||||
private void overrideWithGarbage(SSTableReader sstable, long startPosition, long endPosition) throws IOException
|
||||
private static void overrideWithGarbage(SSTableReader sstable, long startPosition, long endPosition) throws IOException
|
||||
{
|
||||
try (RandomAccessFile file = new RandomAccessFile(sstable.getFilename(), "rw"))
|
||||
{
|
||||
|
|
@ -459,7 +452,7 @@ public class ScrubTest
|
|||
ChunkCache.instance.invalidateFile(sstable.getFilename());
|
||||
}
|
||||
|
||||
private static void assertOrderedAll(ColumnFamilyStore cfs, int expectedSize)
|
||||
static void assertOrderedAll(ColumnFamilyStore cfs, int expectedSize)
|
||||
{
|
||||
assertOrdered(Util.cmd(cfs).build(), expectedSize);
|
||||
}
|
||||
|
|
@ -478,7 +471,7 @@ public class ScrubTest
|
|||
assertEquals(expectedSize, size);
|
||||
}
|
||||
|
||||
protected void fillCF(ColumnFamilyStore cfs, int partitionsPerSSTable)
|
||||
protected static void fillCF(ColumnFamilyStore cfs, int partitionsPerSSTable)
|
||||
{
|
||||
for (int i = 0; i < partitionsPerSSTable; i++)
|
||||
{
|
||||
|
|
@ -517,7 +510,7 @@ public class ScrubTest
|
|||
cfs.forceBlockingFlush();
|
||||
}
|
||||
|
||||
protected void fillCounterCF(ColumnFamilyStore cfs, int partitionsPerSSTable) throws WriteTimeoutException
|
||||
protected static void fillCounterCF(ColumnFamilyStore cfs, int partitionsPerSSTable) throws WriteTimeoutException
|
||||
{
|
||||
for (int i = 0; i < partitionsPerSSTable; i++)
|
||||
{
|
||||
|
|
@ -709,193 +702,46 @@ public class ScrubTest
|
|||
@Test
|
||||
public void testFilterOutDuplicates() throws Exception
|
||||
{
|
||||
DatabaseDescriptor.setPartitionerUnsafe(Murmur3Partitioner.instance);
|
||||
QueryProcessor.process(String.format("CREATE TABLE \"%s\".cf_with_duplicates_3_0 (a int, b int, c int, PRIMARY KEY (a, b))", ksName), ConsistencyLevel.ONE);
|
||||
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore("cf_with_duplicates_3_0");
|
||||
|
||||
Path legacySSTableRoot = Paths.get(System.getProperty(INVALID_LEGACY_SSTABLE_ROOT_PROP),
|
||||
"Keyspace1",
|
||||
"cf_with_duplicates_3_0");
|
||||
|
||||
for (String filename : new String[]{ "mb-3-big-CompressionInfo.db",
|
||||
"mb-3-big-Digest.crc32",
|
||||
"mb-3-big-Index.db",
|
||||
"mb-3-big-Summary.db",
|
||||
"mb-3-big-Data.db",
|
||||
"mb-3-big-Filter.db",
|
||||
"mb-3-big-Statistics.db",
|
||||
"mb-3-big-TOC.txt" })
|
||||
{
|
||||
Files.copy(Paths.get(legacySSTableRoot.toString(), filename), cfs.getDirectories().getDirectoryForNewSSTables().toPath().resolve(filename));
|
||||
}
|
||||
|
||||
cfs.loadNewSSTables();
|
||||
|
||||
cfs.scrub(true, true, false, false, false, 1);
|
||||
|
||||
UntypedResultSet rs = QueryProcessor.executeInternal(String.format("SELECT * FROM \"%s\".cf_with_duplicates_3_0", ksName));
|
||||
assertNotNull(rs);
|
||||
assertEquals(1, rs.size());
|
||||
|
||||
QueryProcessor.executeInternal(String.format("DELETE FROM \"%s\".cf_with_duplicates_3_0 WHERE a=1 AND b =2", ksName));
|
||||
rs = QueryProcessor.executeInternal(String.format("SELECT * FROM \"%s\".cf_with_duplicates_3_0", ksName));
|
||||
assertNotNull(rs);
|
||||
assertEquals(0, rs.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScrubOnePartitionWithTool()
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
|
||||
|
||||
// insert data and verify we get it back w/ range query
|
||||
fillCF(cfs, 1);
|
||||
assertOrderedAll(cfs, 1);
|
||||
|
||||
ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, ksName, CF);
|
||||
Assertions.assertThat(tool.getStdout()).contains("Pre-scrub sstables snapshotted into");
|
||||
Assertions.assertThat(tool.getStdout()).contains("1 partitions in new sstable and 0 empty");
|
||||
tool.assertOnCleanExit();
|
||||
|
||||
// check data is still there
|
||||
assertOrderedAll(cfs, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSkipScrubCorruptedCounterPartitionWithTool() throws IOException, WriteTimeoutException
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(COUNTER_CF);
|
||||
int numPartitions = 1000;
|
||||
|
||||
fillCounterCF(cfs, numPartitions);
|
||||
assertOrderedAll(cfs, numPartitions);
|
||||
assertEquals(1, cfs.getLiveSSTables().size());
|
||||
SSTableReader sstable = cfs.getLiveSSTables().iterator().next();
|
||||
|
||||
overrideWithGarbage(sstable, ByteBufferUtil.bytes("0"), ByteBufferUtil.bytes("1"));
|
||||
|
||||
// with skipCorrupted == true, the corrupt rows will be skipped
|
||||
ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, "-s", ksName, COUNTER_CF);
|
||||
Assertions.assertThat(tool.getStdout()).contains("0 empty");
|
||||
Assertions.assertThat(tool.getStdout()).contains("partitions that were skipped");
|
||||
tool.assertOnCleanExit();
|
||||
|
||||
assertEquals(1, cfs.getLiveSSTables().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoSkipScrubCorruptedCounterPartitionWithTool() throws IOException, WriteTimeoutException
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(COUNTER_CF);
|
||||
int numPartitions = 1000;
|
||||
|
||||
fillCounterCF(cfs, numPartitions);
|
||||
assertOrderedAll(cfs, numPartitions);
|
||||
assertEquals(1, cfs.getLiveSSTables().size());
|
||||
SSTableReader sstable = cfs.getLiveSSTables().iterator().next();
|
||||
|
||||
overrideWithGarbage(sstable, ByteBufferUtil.bytes("0"), ByteBufferUtil.bytes("1"));
|
||||
|
||||
// with skipCorrupted == false, the scrub is expected to fail
|
||||
IPartitioner oldPart = DatabaseDescriptor.getPartitioner();
|
||||
try
|
||||
{
|
||||
ToolRunner.invokeClass(StandaloneScrubber.class, ksName, COUNTER_CF);
|
||||
fail("Expected a CorruptSSTableException to be thrown");
|
||||
DatabaseDescriptor.setPartitionerUnsafe(Murmur3Partitioner.instance);
|
||||
QueryProcessor.process(String.format("CREATE TABLE \"%s\".cf_with_duplicates_3_0 (a int, b int, c int, PRIMARY KEY (a, b))", ksName), ConsistencyLevel.ONE);
|
||||
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore("cf_with_duplicates_3_0");
|
||||
|
||||
Path legacySSTableRoot = Paths.get(System.getProperty(INVALID_LEGACY_SSTABLE_ROOT_PROP),
|
||||
"Keyspace1",
|
||||
"cf_with_duplicates_3_0");
|
||||
|
||||
for (String filename : new String[]{ "mb-3-big-CompressionInfo.db",
|
||||
"mb-3-big-Digest.crc32",
|
||||
"mb-3-big-Index.db",
|
||||
"mb-3-big-Summary.db",
|
||||
"mb-3-big-Data.db",
|
||||
"mb-3-big-Filter.db",
|
||||
"mb-3-big-Statistics.db",
|
||||
"mb-3-big-TOC.txt" })
|
||||
{
|
||||
Files.copy(Paths.get(legacySSTableRoot.toString(), filename), cfs.getDirectories().getDirectoryForNewSSTables().toPath().resolve(filename));
|
||||
}
|
||||
|
||||
cfs.loadNewSSTables();
|
||||
|
||||
cfs.scrub(true, true, false, false, false, 1);
|
||||
|
||||
UntypedResultSet rs = QueryProcessor.executeInternal(String.format("SELECT * FROM \"%s\".cf_with_duplicates_3_0", ksName));
|
||||
assertNotNull(rs);
|
||||
assertEquals(1, rs.size());
|
||||
|
||||
QueryProcessor.executeInternal(String.format("DELETE FROM \"%s\".cf_with_duplicates_3_0 WHERE a=1 AND b =2", ksName));
|
||||
rs = QueryProcessor.executeInternal(String.format("SELECT * FROM \"%s\".cf_with_duplicates_3_0", ksName));
|
||||
assertNotNull(rs);
|
||||
assertEquals(0, rs.size());
|
||||
}
|
||||
catch (IOError err) {
|
||||
assertTrue(err.getCause() instanceof CorruptSSTableException);
|
||||
finally
|
||||
{
|
||||
DatabaseDescriptor.setPartitionerUnsafe(oldPart);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoCheckScrubMultiPartitionWithTool()
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
|
||||
|
||||
// insert data and verify we get it back w/ range query
|
||||
fillCF(cfs, 10);
|
||||
assertOrderedAll(cfs, 10);
|
||||
|
||||
ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, "-n", ksName, CF);
|
||||
Assertions.assertThat(tool.getStdout()).contains("Pre-scrub sstables snapshotted into");
|
||||
Assertions.assertThat(tool.getStdout()).contains("10 partitions in new sstable and 0 empty");
|
||||
tool.assertOnCleanExit();
|
||||
|
||||
// check data is still there
|
||||
assertOrderedAll(cfs, 10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeaderFixValidateOnlyWithTool()
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
|
||||
|
||||
fillCF(cfs, 1);
|
||||
assertOrderedAll(cfs, 1);
|
||||
|
||||
ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, "-e", "validate_only", ksName, CF);
|
||||
Assertions.assertThat(tool.getStdout()).contains("Not continuing with scrub, since '--header-fix validate-only' was specified.");
|
||||
tool.assertOnCleanExit();
|
||||
assertOrderedAll(cfs, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeaderFixValidateWithTool()
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
|
||||
|
||||
fillCF(cfs, 1);
|
||||
assertOrderedAll(cfs, 1);
|
||||
|
||||
ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, "-e", "validate", ksName, CF);
|
||||
Assertions.assertThat(tool.getStdout()).contains("Pre-scrub sstables snapshotted into");
|
||||
Assertions.assertThat(tool.getStdout()).contains("1 partitions in new sstable and 0 empty");
|
||||
tool.assertOnCleanExit();
|
||||
assertOrderedAll(cfs, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeaderFixFixOnlyWithTool()
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
|
||||
|
||||
fillCF(cfs, 1);
|
||||
assertOrderedAll(cfs, 1);
|
||||
|
||||
ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, "-e", "fix-only", ksName, CF);
|
||||
Assertions.assertThat(tool.getStdout()).contains("Not continuing with scrub, since '--header-fix fix-only' was specified.");
|
||||
tool.assertOnCleanExit();
|
||||
assertOrderedAll(cfs, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeaderFixWithTool()
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
|
||||
|
||||
fillCF(cfs, 1);
|
||||
assertOrderedAll(cfs, 1);
|
||||
|
||||
ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, "-e", "fix", ksName, CF);
|
||||
Assertions.assertThat(tool.getStdout()).contains("Pre-scrub sstables snapshotted into");
|
||||
Assertions.assertThat(tool.getStdout()).contains("1 partitions in new sstable and 0 empty");
|
||||
tool.assertOnCleanExit();
|
||||
assertOrderedAll(cfs, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeaderFixNoChecksWithTool()
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
|
||||
|
||||
fillCF(cfs, 1);
|
||||
assertOrderedAll(cfs, 1);
|
||||
|
||||
ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, "-e", "off", ksName, CF);
|
||||
Assertions.assertThat(tool.getStdout()).contains("Pre-scrub sstables snapshotted into");
|
||||
Assertions.assertThat(tool.getStdout()).contains("1 partitions in new sstable and 0 empty");
|
||||
tool.assertOnCleanExit();
|
||||
assertOrderedAll(cfs, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,249 @@
|
|||
/*
|
||||
* 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.db;
|
||||
|
||||
import java.io.IOError;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.db.compaction.CompactionManager;
|
||||
import org.apache.cassandra.db.marshal.UUIDType;
|
||||
import org.apache.cassandra.dht.ByteOrderedPartitioner;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
import org.apache.cassandra.exceptions.WriteTimeoutException;
|
||||
import org.apache.cassandra.io.sstable.CorruptSSTableException;
|
||||
import org.apache.cassandra.io.sstable.format.SSTableReader;
|
||||
import org.apache.cassandra.schema.KeyspaceParams;
|
||||
import org.apache.cassandra.tools.StandaloneScrubber;
|
||||
import org.apache.cassandra.tools.ToolRunner;
|
||||
import org.apache.cassandra.utils.ByteBufferUtil;
|
||||
import org.assertj.core.api.Assertions;
|
||||
|
||||
import static org.apache.cassandra.SchemaLoader.counterCFMD;
|
||||
import static org.apache.cassandra.SchemaLoader.createKeyspace;
|
||||
import static org.apache.cassandra.SchemaLoader.getCompressionParameters;
|
||||
import static org.apache.cassandra.SchemaLoader.loadSchema;
|
||||
import static org.apache.cassandra.SchemaLoader.standardCFMD;
|
||||
import static org.apache.cassandra.db.ScrubTest.CF_INDEX1;
|
||||
import static org.apache.cassandra.db.ScrubTest.CF_INDEX1_BYTEORDERED;
|
||||
import static org.apache.cassandra.db.ScrubTest.CF_INDEX2;
|
||||
import static org.apache.cassandra.db.ScrubTest.CF_INDEX2_BYTEORDERED;
|
||||
import static org.apache.cassandra.db.ScrubTest.CF_UUID;
|
||||
import static org.apache.cassandra.db.ScrubTest.COMPRESSION_CHUNK_LENGTH;
|
||||
import static org.apache.cassandra.db.ScrubTest.COUNTER_CF;
|
||||
import static org.apache.cassandra.db.ScrubTest.assertOrderedAll;
|
||||
import static org.apache.cassandra.db.ScrubTest.fillCF;
|
||||
import static org.apache.cassandra.db.ScrubTest.fillCounterCF;
|
||||
import static org.apache.cassandra.db.ScrubTest.overrideWithGarbage;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class ScrubToolTest
|
||||
{
|
||||
private static final String CF = "scrub_tool_test";
|
||||
private static final AtomicInteger seq = new AtomicInteger();
|
||||
|
||||
String ksName;
|
||||
Keyspace keyspace;
|
||||
@BeforeClass
|
||||
public static void defineSchema() throws ConfigurationException
|
||||
{
|
||||
loadSchema();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup()
|
||||
{
|
||||
ksName = "scrub_test_" + seq.incrementAndGet();
|
||||
createKeyspace(ksName,
|
||||
KeyspaceParams.simple(1),
|
||||
standardCFMD(ksName, CF),
|
||||
counterCFMD(ksName, COUNTER_CF).compression(getCompressionParameters(COMPRESSION_CHUNK_LENGTH)),
|
||||
standardCFMD(ksName, CF_UUID, 0, UUIDType.instance),
|
||||
SchemaLoader.keysIndexCFMD(ksName, CF_INDEX1, true),
|
||||
SchemaLoader.compositeIndexCFMD(ksName, CF_INDEX2, true),
|
||||
SchemaLoader.keysIndexCFMD(ksName, CF_INDEX1_BYTEORDERED, true).partitioner(ByteOrderedPartitioner.instance),
|
||||
SchemaLoader.compositeIndexCFMD(ksName, CF_INDEX2_BYTEORDERED, true).partitioner(ByteOrderedPartitioner.instance));
|
||||
keyspace = Keyspace.open(ksName);
|
||||
|
||||
CompactionManager.instance.disableAutoCompaction();
|
||||
System.setProperty(org.apache.cassandra.tools.Util.ALLOW_TOOL_REINIT_FOR_TEST, "true"); // Necessary for testing
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScrubOnePartitionWithTool()
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
|
||||
|
||||
// insert data and verify we get it back w/ range query
|
||||
fillCF(cfs, 1);
|
||||
assertOrderedAll(cfs, 1);
|
||||
|
||||
ToolRunner.ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, ksName, CF);
|
||||
Assertions.assertThat(tool.getStdout()).contains("Pre-scrub sstables snapshotted into");
|
||||
Assertions.assertThat(tool.getStdout()).contains("1 partitions in new sstable and 0 empty");
|
||||
tool.assertOnCleanExit();
|
||||
|
||||
// check data is still there
|
||||
assertOrderedAll(cfs, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSkipScrubCorruptedCounterPartitionWithTool() throws IOException, WriteTimeoutException
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(COUNTER_CF);
|
||||
int numPartitions = 1000;
|
||||
|
||||
fillCounterCF(cfs, numPartitions);
|
||||
assertOrderedAll(cfs, numPartitions);
|
||||
assertEquals(1, cfs.getLiveSSTables().size());
|
||||
SSTableReader sstable = cfs.getLiveSSTables().iterator().next();
|
||||
|
||||
overrideWithGarbage(sstable, ByteBufferUtil.bytes("0"), ByteBufferUtil.bytes("1"));
|
||||
|
||||
// with skipCorrupted == true, the corrupt rows will be skipped
|
||||
ToolRunner.ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, "-s", ksName, COUNTER_CF);
|
||||
Assertions.assertThat(tool.getStdout()).contains("0 empty");
|
||||
Assertions.assertThat(tool.getStdout()).contains("partitions that were skipped");
|
||||
tool.assertOnCleanExit();
|
||||
|
||||
assertEquals(1, cfs.getLiveSSTables().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoSkipScrubCorruptedCounterPartitionWithTool() throws IOException, WriteTimeoutException
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(COUNTER_CF);
|
||||
int numPartitions = 1000;
|
||||
|
||||
fillCounterCF(cfs, numPartitions);
|
||||
assertOrderedAll(cfs, numPartitions);
|
||||
assertEquals(1, cfs.getLiveSSTables().size());
|
||||
SSTableReader sstable = cfs.getLiveSSTables().iterator().next();
|
||||
|
||||
overrideWithGarbage(sstable, ByteBufferUtil.bytes("0"), ByteBufferUtil.bytes("1"));
|
||||
|
||||
// with skipCorrupted == false, the scrub is expected to fail
|
||||
try
|
||||
{
|
||||
ToolRunner.invokeClass(StandaloneScrubber.class, ksName, COUNTER_CF);
|
||||
fail("Expected a CorruptSSTableException to be thrown");
|
||||
}
|
||||
catch (IOError err) {
|
||||
assertTrue(err.getCause() instanceof CorruptSSTableException);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoCheckScrubMultiPartitionWithTool()
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
|
||||
|
||||
// insert data and verify we get it back w/ range query
|
||||
fillCF(cfs, 10);
|
||||
assertOrderedAll(cfs, 10);
|
||||
|
||||
ToolRunner.ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, "-n", ksName, CF);
|
||||
Assertions.assertThat(tool.getStdout()).contains("Pre-scrub sstables snapshotted into");
|
||||
Assertions.assertThat(tool.getStdout()).contains("10 partitions in new sstable and 0 empty");
|
||||
tool.assertOnCleanExit();
|
||||
|
||||
// check data is still there
|
||||
assertOrderedAll(cfs, 10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeaderFixValidateOnlyWithTool()
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
|
||||
|
||||
fillCF(cfs, 1);
|
||||
assertOrderedAll(cfs, 1);
|
||||
|
||||
ToolRunner.ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, "-e", "validate_only", ksName, CF);
|
||||
Assertions.assertThat(tool.getStdout()).contains("Not continuing with scrub, since '--header-fix validate-only' was specified.");
|
||||
tool.assertOnCleanExit();
|
||||
assertOrderedAll(cfs, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeaderFixValidateWithTool()
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
|
||||
|
||||
fillCF(cfs, 1);
|
||||
assertOrderedAll(cfs, 1);
|
||||
|
||||
ToolRunner.ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, "-e", "validate", ksName, CF);
|
||||
Assertions.assertThat(tool.getStdout()).contains("Pre-scrub sstables snapshotted into");
|
||||
Assertions.assertThat(tool.getStdout()).contains("1 partitions in new sstable and 0 empty");
|
||||
tool.assertOnCleanExit();
|
||||
assertOrderedAll(cfs, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeaderFixFixOnlyWithTool()
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
|
||||
|
||||
fillCF(cfs, 1);
|
||||
assertOrderedAll(cfs, 1);
|
||||
|
||||
ToolRunner.ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, "-e", "fix-only", ksName, CF);
|
||||
Assertions.assertThat(tool.getStdout()).contains("Not continuing with scrub, since '--header-fix fix-only' was specified.");
|
||||
tool.assertOnCleanExit();
|
||||
assertOrderedAll(cfs, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeaderFixWithTool()
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
|
||||
|
||||
fillCF(cfs, 1);
|
||||
assertOrderedAll(cfs, 1);
|
||||
|
||||
ToolRunner.ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, "-e", "fix", ksName, CF);
|
||||
Assertions.assertThat(tool.getStdout()).contains("Pre-scrub sstables snapshotted into");
|
||||
Assertions.assertThat(tool.getStdout()).contains("1 partitions in new sstable and 0 empty");
|
||||
tool.assertOnCleanExit();
|
||||
assertOrderedAll(cfs, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeaderFixNoChecksWithTool()
|
||||
{
|
||||
ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF);
|
||||
|
||||
fillCF(cfs, 1);
|
||||
assertOrderedAll(cfs, 1);
|
||||
|
||||
ToolRunner.ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, "-e", "off", ksName, CF);
|
||||
Assertions.assertThat(tool.getStdout()).contains("Pre-scrub sstables snapshotted into");
|
||||
Assertions.assertThat(tool.getStdout()).contains("1 partitions in new sstable and 0 empty");
|
||||
tool.assertOnCleanExit();
|
||||
assertOrderedAll(cfs, 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -20,13 +20,11 @@ package org.apache.cassandra.db;
|
|||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.Util;
|
||||
import org.apache.cassandra.batchlog.Batch;
|
||||
import org.apache.cassandra.batchlog.BatchlogManager;
|
||||
import org.apache.cassandra.cache.ChunkCache;
|
||||
import org.apache.cassandra.UpdateBuilder;
|
||||
import org.apache.cassandra.db.compaction.AbstractCompactionStrategy;
|
||||
import org.apache.cassandra.db.compaction.CompactionManager;
|
||||
import org.apache.cassandra.db.compaction.Verifier;
|
||||
import org.apache.cassandra.db.marshal.UUIDType;
|
||||
|
|
@ -37,7 +35,6 @@ import org.apache.cassandra.dht.Token;
|
|||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
import org.apache.cassandra.exceptions.WriteTimeoutException;
|
||||
import org.apache.cassandra.io.FSWriteError;
|
||||
import org.apache.cassandra.io.compress.CorruptBlockException;
|
||||
import org.apache.cassandra.io.sstable.Component;
|
||||
import org.apache.cassandra.io.sstable.CorruptSSTableException;
|
||||
import org.apache.cassandra.io.sstable.format.SSTableReader;
|
||||
|
|
@ -51,10 +48,8 @@ import org.apache.cassandra.utils.ByteBufferUtil;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -74,7 +69,6 @@ import static org.junit.Assert.assertFalse;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class VerifyTest
|
||||
{
|
||||
public static final String KEYSPACE = "Keyspace1";
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.Util;
|
||||
import org.apache.cassandra.cql3.ColumnIdentifier;
|
||||
|
|
@ -77,10 +75,8 @@ import org.apache.cassandra.utils.FBUtilities;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class CompactionsTest
|
||||
{
|
||||
private static final String KEYSPACE1 = "Keyspace1";
|
||||
|
|
|
|||
|
|
@ -37,12 +37,10 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.Util;
|
||||
import org.apache.cassandra.UpdateBuilder;
|
||||
|
|
@ -72,7 +70,6 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class LeveledCompactionStrategyTest
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(LeveledCompactionStrategyTest.class);
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ import com.google.common.collect.Multimap;
|
|||
import com.google.common.collect.Sets;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.Util;
|
||||
import org.apache.cassandra.schema.TableMetadata;
|
||||
|
|
@ -49,7 +47,6 @@ import org.apache.cassandra.utils.ByteBufferUtil;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class TTLExpiryTest
|
||||
{
|
||||
public static final String KEYSPACE1 = "TTLExpiryTest";
|
||||
|
|
|
|||
|
|
@ -28,9 +28,7 @@ import com.google.common.collect.Multimap;
|
|||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.db.Keyspace;
|
||||
|
|
@ -49,7 +47,6 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class BootStrapperTest
|
||||
{
|
||||
static IPartitioner oldPartitioner;
|
||||
|
|
|
|||
|
|
@ -28,9 +28,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import org.junit.After;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -38,7 +36,6 @@ import static org.junit.Assert.assertFalse;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class DiagnosticEventServiceTest
|
||||
{
|
||||
|
||||
|
|
@ -240,5 +237,5 @@ public class DiagnosticEventServiceTest
|
|||
}
|
||||
}
|
||||
|
||||
public enum TestEventType { TEST1, TEST2, TEST3 };
|
||||
public enum TestEventType { TEST1, TEST2, TEST3 }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import java.util.*;
|
|||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.Sets;
|
||||
|
|
@ -31,18 +30,15 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.Util;
|
||||
import org.apache.cassandra.concurrent.NamedThreadFactory;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.db.Keyspace;
|
||||
import org.apache.cassandra.db.RowUpdateBuilder;
|
||||
import org.apache.cassandra.db.compaction.AntiCompactionTest;
|
||||
import org.apache.cassandra.db.compaction.CompactionInfo;
|
||||
import org.apache.cassandra.db.compaction.CompactionInterruptedException;
|
||||
import org.apache.cassandra.db.compaction.CompactionManager;
|
||||
|
|
@ -51,7 +47,6 @@ import org.apache.cassandra.db.compaction.OperationType;
|
|||
import org.apache.cassandra.db.lifecycle.LifecycleTransaction;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
import org.apache.cassandra.io.sstable.format.SSTableReader;
|
||||
import org.apache.cassandra.metrics.CompactionMetrics;
|
||||
import org.apache.cassandra.metrics.RestorableMeter;
|
||||
import org.apache.cassandra.schema.CachingParams;
|
||||
import org.apache.cassandra.schema.KeyspaceParams;
|
||||
|
|
@ -71,7 +66,6 @@ import static org.junit.Assert.assertNull;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class IndexSummaryManagerTest
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(IndexSummaryManagerTest.class);
|
||||
|
|
|
|||
|
|
@ -22,9 +22,7 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.cql3.UntypedResultSet;
|
||||
import org.apache.cassandra.metrics.CacheMetrics;
|
||||
|
|
@ -34,7 +32,6 @@ import org.apache.cassandra.service.CacheService;
|
|||
* Test intended to manually measure GC pressure to write and read partitions of different size
|
||||
* for CASSANDRA-11206.
|
||||
*/
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
@Ignore // all these tests take very, very long - so only run them manually
|
||||
public class LargePartitionsTest extends CQLTester
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,9 +31,7 @@ import com.google.common.collect.Multimap;
|
|||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.dht.Token;
|
||||
import org.apache.cassandra.service.StorageService;
|
||||
|
|
@ -46,7 +44,6 @@ import static org.junit.Assert.assertTrue;
|
|||
import static org.apache.cassandra.Util.token;
|
||||
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class TokenMetadataTest
|
||||
{
|
||||
public final static String ONE = "1";
|
||||
|
|
|
|||
|
|
@ -23,13 +23,11 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import com.datastax.driver.core.BatchStatement;
|
||||
import com.datastax.driver.core.Cluster;
|
||||
import com.datastax.driver.core.PreparedStatement;
|
||||
import com.datastax.driver.core.Session;
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
|
|
@ -44,7 +42,6 @@ import static org.quicktheories.QuickTheory.qt;
|
|||
import static org.quicktheories.generators.Generate.intArrays;
|
||||
import static org.quicktheories.generators.SourceDSL.integers;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class BatchMetricsTest extends SchemaLoader
|
||||
{
|
||||
private static final int MAX_ROUNDS_TO_PERFORM = 3;
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ import java.util.Random;
|
|||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
import org.apache.cassandra.io.compress.BufferType;
|
||||
|
|
@ -35,7 +33,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class BufferPoolMetricsTest
|
||||
{
|
||||
private BufferPool bufferPool;
|
||||
|
|
|
|||
|
|
@ -22,12 +22,10 @@ import java.io.IOException;
|
|||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import com.datastax.driver.core.Cluster;
|
||||
import com.datastax.driver.core.PreparedStatement;
|
||||
import com.datastax.driver.core.Session;
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.schema.Schema;
|
||||
|
|
@ -37,7 +35,6 @@ import org.apache.cassandra.service.EmbeddedCassandraService;
|
|||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class CQLMetricsTest extends SchemaLoader
|
||||
{
|
||||
private static EmbeddedCassandraService cassandra;
|
||||
|
|
|
|||
|
|
@ -23,16 +23,13 @@ import java.util.Iterator;
|
|||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.cache.CacheSize;
|
||||
import org.apache.cassandra.cache.ICache;
|
||||
import org.apache.cassandra.cache.InstrumentingCache;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class CacheMetricsTest
|
||||
{
|
||||
private static final long capacity = 65536;
|
||||
|
|
|
|||
|
|
@ -26,13 +26,11 @@ import java.util.stream.Stream;
|
|||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import com.datastax.driver.core.BatchStatement;
|
||||
import com.datastax.driver.core.Cluster;
|
||||
import com.datastax.driver.core.PreparedStatement;
|
||||
import com.datastax.driver.core.Session;
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
|
|
@ -43,7 +41,6 @@ import org.apache.cassandra.service.EmbeddedCassandraService;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class TableMetricsTest extends SchemaLoader
|
||||
{
|
||||
private static Session session;
|
||||
|
|
@ -261,7 +258,7 @@ public class TableMetricsTest extends SchemaLoader
|
|||
@Test
|
||||
public void testViewMetricsCleanupOnDrop()
|
||||
{
|
||||
String tableName = TABLE + "_metrics_cleanup";
|
||||
String tableName = TABLE + "_2_metrics_cleanup";
|
||||
String viewName = TABLE + "_materialized_view_cleanup";
|
||||
CassandraMetricsRegistry registry = CassandraMetricsRegistry.Metrics;
|
||||
Supplier<Stream<String>> metrics = () -> registry.getNames().stream().filter(m -> m.contains(viewName));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* 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.schema;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.cql3.QueryProcessor;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.db.Directories;
|
||||
import org.apache.cassandra.db.Keyspace;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class MigrationManagerDropKSTest
|
||||
{
|
||||
private static final String KEYSPACE1 = "keyspace1";
|
||||
private static final String TABLE1 = "standard1";
|
||||
private static final String TABLE2 = "standard2";
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@BeforeClass
|
||||
public static void defineSchema() throws ConfigurationException
|
||||
{
|
||||
SchemaLoader.prepareServer();
|
||||
SchemaLoader.startGossiper();
|
||||
SchemaLoader.createKeyspace(KEYSPACE1,
|
||||
KeyspaceParams.simple(1),
|
||||
SchemaLoader.standardCFMD(KEYSPACE1, TABLE1),
|
||||
SchemaLoader.standardCFMD(KEYSPACE1, TABLE2));
|
||||
}
|
||||
@Test
|
||||
public void dropKS() throws ConfigurationException
|
||||
{
|
||||
// sanity
|
||||
final KeyspaceMetadata ks = Schema.instance.getKeyspaceMetadata(KEYSPACE1);
|
||||
assertNotNull(ks);
|
||||
final TableMetadata cfm = ks.tables.getNullable(TABLE2);
|
||||
assertNotNull(cfm);
|
||||
|
||||
// write some data, force a flush, then verify that files exist on disk.
|
||||
for (int i = 0; i < 100; i++)
|
||||
QueryProcessor.executeInternal(String.format("INSERT INTO %s.%s (key, name, val) VALUES (?, ?, ?)",
|
||||
KEYSPACE1, TABLE2),
|
||||
"dropKs", "col" + i, "anyvalue");
|
||||
ColumnFamilyStore cfs = Keyspace.open(cfm.keyspace).getColumnFamilyStore(cfm.name);
|
||||
assertNotNull(cfs);
|
||||
cfs.forceBlockingFlush();
|
||||
assertTrue(!cfs.getDirectories().sstableLister(Directories.OnTxnErr.THROW).list().isEmpty());
|
||||
|
||||
MigrationManager.announceKeyspaceDrop(ks.name);
|
||||
|
||||
assertNull(Schema.instance.getKeyspaceMetadata(ks.name));
|
||||
|
||||
// write should fail.
|
||||
boolean success = true;
|
||||
try
|
||||
{
|
||||
QueryProcessor.executeInternal(String.format("INSERT INTO %s.%s (key, name, val) VALUES (?, ?, ?)",
|
||||
KEYSPACE1, TABLE2),
|
||||
"dropKs", "col0", "anyvalue");
|
||||
}
|
||||
catch (Throwable th)
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
assertFalse("This mutation should have failed since the KS no longer exists.", success);
|
||||
|
||||
// reads should fail too.
|
||||
boolean threw = false;
|
||||
try
|
||||
{
|
||||
Keyspace.open(ks.name);
|
||||
}
|
||||
catch (Throwable th)
|
||||
{
|
||||
threw = true;
|
||||
}
|
||||
assertTrue(threw);
|
||||
}
|
||||
}
|
||||
|
|
@ -30,9 +30,7 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.Util;
|
||||
import org.apache.cassandra.cql3.ColumnIdentifier;
|
||||
|
|
@ -63,7 +61,6 @@ import static org.junit.Assert.assertNull;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class MigrationManagerTest
|
||||
{
|
||||
private static final String KEYSPACE1 = "keyspace1";
|
||||
|
|
@ -260,56 +257,6 @@ public class MigrationManagerTest
|
|||
assertRows(rows, row("key0", "col0", "val0"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dropKS() throws ConfigurationException
|
||||
{
|
||||
// sanity
|
||||
final KeyspaceMetadata ks = Schema.instance.getKeyspaceMetadata(KEYSPACE1);
|
||||
assertNotNull(ks);
|
||||
final TableMetadata cfm = ks.tables.getNullable(TABLE2);
|
||||
assertNotNull(cfm);
|
||||
|
||||
// write some data, force a flush, then verify that files exist on disk.
|
||||
for (int i = 0; i < 100; i++)
|
||||
QueryProcessor.executeInternal(String.format("INSERT INTO %s.%s (key, name, val) VALUES (?, ?, ?)",
|
||||
KEYSPACE1, TABLE2),
|
||||
"dropKs", "col" + i, "anyvalue");
|
||||
ColumnFamilyStore cfs = Keyspace.open(cfm.keyspace).getColumnFamilyStore(cfm.name);
|
||||
assertNotNull(cfs);
|
||||
cfs.forceBlockingFlush();
|
||||
assertTrue(!cfs.getDirectories().sstableLister(Directories.OnTxnErr.THROW).list().isEmpty());
|
||||
|
||||
MigrationManager.announceKeyspaceDrop(ks.name);
|
||||
|
||||
assertNull(Schema.instance.getKeyspaceMetadata(ks.name));
|
||||
|
||||
// write should fail.
|
||||
boolean success = true;
|
||||
try
|
||||
{
|
||||
QueryProcessor.executeInternal(String.format("INSERT INTO %s.%s (key, name, val) VALUES (?, ?, ?)",
|
||||
KEYSPACE1, TABLE2),
|
||||
"dropKs", "col0", "anyvalue");
|
||||
}
|
||||
catch (Throwable th)
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
assertFalse("This mutation should have failed since the KS no longer exists.", success);
|
||||
|
||||
// reads should fail too.
|
||||
boolean threw = false;
|
||||
try
|
||||
{
|
||||
Keyspace.open(ks.name);
|
||||
}
|
||||
catch (Throwable th)
|
||||
{
|
||||
threw = true;
|
||||
}
|
||||
assertTrue(threw);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dropKSUnflushed() throws ConfigurationException
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,15 +17,12 @@
|
|||
*/
|
||||
package org.apache.cassandra.service;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class GCInspectorTest
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ import java.util.*;
|
|||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import org.apache.cassandra.*;
|
||||
import org.apache.cassandra.cql3.statements.schema.CreateTableStatement;
|
||||
|
|
@ -51,7 +49,6 @@ import static org.apache.cassandra.cql3.QueryProcessor.executeInternal;
|
|||
import static org.apache.cassandra.utils.ByteBufferUtil.bytes;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class QueryPagerTest
|
||||
{
|
||||
public static final String KEYSPACE1 = "QueryPagerTest";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* 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.service;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.db.Keyspace;
|
||||
import org.apache.cassandra.db.commitlog.CommitLog;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
import org.apache.cassandra.gms.Gossiper;
|
||||
import org.apache.cassandra.locator.IEndpointSnitch;
|
||||
import org.apache.cassandra.locator.PropertyFileSnitch;
|
||||
|
||||
import static org.apache.cassandra.ServerTestUtils.cleanup;
|
||||
import static org.apache.cassandra.ServerTestUtils.mkdirs;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class StorageServiceServerM3PTest
|
||||
{
|
||||
@BeforeClass
|
||||
public static void setUp() throws ConfigurationException
|
||||
{
|
||||
System.setProperty(Gossiper.Props.DISABLE_THREAD_VALIDATION, "true");
|
||||
DatabaseDescriptor.daemonInitialization();
|
||||
CommitLog.instance.start();
|
||||
IEndpointSnitch snitch = new PropertyFileSnitch();
|
||||
DatabaseDescriptor.setEndpointSnitch(snitch);
|
||||
Keyspace.setInitialized();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegularMode() throws ConfigurationException
|
||||
{
|
||||
mkdirs();
|
||||
cleanup();
|
||||
StorageService.instance.initServer(0);
|
||||
for (String path : DatabaseDescriptor.getAllDataFileLocations())
|
||||
{
|
||||
// verify that storage directories are there.
|
||||
assertTrue(new File(path).exists());
|
||||
}
|
||||
// a proper test would be to call decommission here, but decommission() mixes both shutdown and datatransfer
|
||||
// calls. This test is only interested in the shutdown-related items which a properly handled by just
|
||||
// stopping the client.
|
||||
//StorageService.instance.decommission();
|
||||
StorageService.instance.stopClient();
|
||||
}
|
||||
}
|
||||
|
|
@ -34,9 +34,7 @@ import org.apache.cassandra.db.SystemKeyspace;
|
|||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.audit.AuditLogManager;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.db.Keyspace;
|
||||
|
|
@ -59,13 +57,10 @@ import org.apache.cassandra.schema.*;
|
|||
import org.apache.cassandra.utils.FBUtilities;
|
||||
import org.assertj.core.api.Assertions;
|
||||
|
||||
import static org.apache.cassandra.ServerTestUtils.cleanup;
|
||||
import static org.apache.cassandra.ServerTestUtils.mkdirs;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class StorageServiceServerTest
|
||||
{
|
||||
@BeforeClass
|
||||
|
|
@ -79,24 +74,6 @@ public class StorageServiceServerTest
|
|||
Keyspace.setInitialized();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegularMode() throws ConfigurationException
|
||||
{
|
||||
mkdirs();
|
||||
cleanup();
|
||||
StorageService.instance.initServer(0);
|
||||
for (String path : DatabaseDescriptor.getAllDataFileLocations())
|
||||
{
|
||||
// verify that storage directories are there.
|
||||
assertTrue(new File(path).exists());
|
||||
}
|
||||
// a proper test would be to call decommission here, but decommission() mixes both shutdown and datatransfer
|
||||
// calls. This test is only interested in the shutdown-related items which a properly handled by just
|
||||
// stopping the client.
|
||||
//StorageService.instance.decommission();
|
||||
StorageService.instance.stopClient();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAllRangesEmpty()
|
||||
{
|
||||
|
|
@ -709,7 +686,7 @@ public class StorageServiceServerTest
|
|||
Assert.assertFalse(StorageService.instance.isReplacingSameHostAddressAndHostId(differentHostId));
|
||||
|
||||
final String hostAddress = FBUtilities.getBroadcastAddressAndPort().getHostAddress(false);
|
||||
UUID localHostId = SystemKeyspace.getLocalHostId();
|
||||
UUID localHostId = SystemKeyspace.getOrInitializeLocalHostId();
|
||||
Gossiper.instance.initializeNodeUnsafe(FBUtilities.getBroadcastAddressAndPort(), localHostId, 1);
|
||||
|
||||
// Check detects replacing the same host address with the same hostid
|
||||
|
|
|
|||
|
|
@ -29,12 +29,11 @@ import com.google.common.util.concurrent.MoreExecutors;
|
|||
import org.apache.cassandra.locator.RangesAtEndpoint;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.Util;
|
||||
import org.apache.cassandra.db.streaming.CassandraOutgoingFile;
|
||||
|
|
@ -63,7 +62,6 @@ import static org.apache.cassandra.SchemaLoader.standardCFMD;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class StreamingTransferTest
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(StreamingTransferTest.class);
|
||||
|
|
|
|||
|
|
@ -19,22 +19,18 @@
|
|||
package org.apache.cassandra.tools;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import com.datastax.driver.core.exceptions.NoHostAvailableException;
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.tools.ToolRunner.ToolResult;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class BulkLoaderTest extends OfflineToolUtils
|
||||
{
|
||||
@Test
|
||||
public void testBulkLoader_NoArgs() throws Exception
|
||||
public void testBulkLoader_NoArgs()
|
||||
{
|
||||
ToolResult tool = ToolRunner.invokeClass(BulkLoader.class);
|
||||
assertEquals(1, tool.getExitCode());
|
||||
|
|
|
|||
|
|
@ -21,12 +21,9 @@ package org.apache.cassandra.tools;
|
|||
import java.io.File;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.tools.ToolRunner.ToolResult;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class CompactionStressTest extends OfflineToolUtils
|
||||
{
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -19,12 +19,9 @@
|
|||
package org.apache.cassandra.tools;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.tools.ToolRunner.ToolResult;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class GetVersionTest extends OfflineToolUtils
|
||||
{
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
|
|||
|
|
@ -19,9 +19,7 @@
|
|||
package org.apache.cassandra.tools;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.tools.ToolRunner.ToolResult;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
|
|
@ -29,7 +27,6 @@ import org.hamcrest.CoreMatchers;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class SSTableExpiredBlockersTest extends OfflineToolUtils
|
||||
{
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -24,12 +24,10 @@ import java.util.Map;
|
|||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.tools.ToolRunner.ToolResult;
|
||||
import org.assertj.core.api.Assertions;
|
||||
|
||||
|
|
@ -43,7 +41,6 @@ import static org.junit.Assert.assertThat;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class) // tests calling assertSchemaNotLoaded should be the first ones
|
||||
public class SSTableExportTest extends OfflineToolUtils
|
||||
{
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
|
|
@ -246,7 +243,6 @@ public class SSTableExportTest extends OfflineToolUtils
|
|||
* {@code false} if the test shoudln't load the schema in any case. Note that a test not loading the schema can
|
||||
* still end with the schema loaded if a previous test already loaded it, so we should always run first the tests
|
||||
* that don't load the schema, and then the ones that may or may not load it. We also need to use the
|
||||
* {@link OrderedJUnit4ClassRunner} runner to guarantee the desired run order.
|
||||
*/
|
||||
private void assertPostTestEnv(boolean maybeLoadsSchema)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,9 +19,7 @@
|
|||
package org.apache.cassandra.tools;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.tools.ToolRunner.ToolResult;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
|
|
@ -29,7 +27,6 @@ import org.hamcrest.CoreMatchers;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class SSTableLevelResetterTest extends OfflineToolUtils
|
||||
{
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.tools.ToolRunner.ToolResult;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
|
|
@ -38,7 +36,6 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class SSTableMetadataViewerTest extends OfflineToolUtils
|
||||
{
|
||||
private static String sstable;
|
||||
|
|
|
|||
|
|
@ -19,9 +19,7 @@
|
|||
package org.apache.cassandra.tools;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.tools.ToolRunner.ToolResult;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
|
|
@ -29,7 +27,6 @@ import org.hamcrest.CoreMatchers;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class SSTableOfflineRelevelTest extends OfflineToolUtils
|
||||
{
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -21,12 +21,9 @@ package org.apache.cassandra.tools;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.io.util.FileUtils;
|
||||
import org.apache.cassandra.tools.ToolRunner.ToolResult;
|
||||
import org.assertj.core.api.Assertions;
|
||||
|
|
@ -35,7 +32,6 @@ import org.hamcrest.CoreMatchers;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class SSTableRepairedAtSetterTest extends OfflineToolUtils
|
||||
{
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ import java.util.Arrays;
|
|||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.tools.ToolRunner.ToolResult;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
|
|
@ -33,24 +31,8 @@ import org.hamcrest.CoreMatchers;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class StandaloneSSTableUtilTest extends OfflineToolUtils
|
||||
{
|
||||
@Test
|
||||
public void testNoArgsPrintsHelp()
|
||||
{
|
||||
ToolResult tool = ToolRunner.invokeClass(StandaloneSSTableUtil.class);
|
||||
assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("usage:"));
|
||||
assertThat(tool.getCleanedStderr(), CoreMatchers.containsStringIgnoringCase("Missing arguments"));
|
||||
assertEquals(1, tool.getExitCode());
|
||||
assertNoUnexpectedThreadsStarted(null, null);
|
||||
assertSchemaNotLoaded();
|
||||
assertCLSMNotLoaded();
|
||||
assertSystemKSNotLoaded();
|
||||
assertKeyspaceNotLoaded();
|
||||
assertServerNotLoaded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWrongArgFailsAndPrintsHelp()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ import java.util.Arrays;
|
|||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.tools.ToolRunner.ToolResult;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
|
|
@ -40,24 +38,8 @@ import static org.junit.Assert.assertTrue;
|
|||
* For TTL sstable scrubbing tests look at {@link TTLTest}
|
||||
*/
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class StandaloneScrubberTest extends OfflineToolUtils
|
||||
{
|
||||
@Test
|
||||
public void testNoArgsPrintsHelp()
|
||||
{
|
||||
ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class);
|
||||
assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("usage:"));
|
||||
assertThat(tool.getCleanedStderr(), CoreMatchers.containsStringIgnoringCase("Missing arguments"));
|
||||
assertEquals(1, tool.getExitCode());
|
||||
assertNoUnexpectedThreadsStarted(null, null);
|
||||
assertSchemaNotLoaded();
|
||||
assertCLSMNotLoaded();
|
||||
assertSystemKSNotLoaded();
|
||||
assertKeyspaceNotLoaded();
|
||||
assertServerNotLoaded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaybeChangeDocs()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,9 +24,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.tools.ToolRunner.ToolResult;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
|
|
@ -34,7 +32,6 @@ import org.hamcrest.CoreMatchers;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class StandaloneSplitterTest extends OfflineToolUtils
|
||||
{
|
||||
// Note: StandaloneSplitter modifies sstables
|
||||
|
|
@ -48,21 +45,6 @@ public class StandaloneSplitterTest extends OfflineToolUtils
|
|||
System.setProperty("cassandra.partitioner", "org.apache.cassandra.dht.ByteOrderedPartitioner");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoArgsPrintsHelp()
|
||||
{
|
||||
ToolResult tool = ToolRunner.invokeClass(StandaloneSplitter.class);
|
||||
assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("usage:"));
|
||||
assertThat(tool.getCleanedStderr(), CoreMatchers.containsStringIgnoringCase("No sstables to split"));
|
||||
assertEquals(1, tool.getExitCode());
|
||||
assertNoUnexpectedThreadsStarted(null, null);
|
||||
assertSchemaNotLoaded();
|
||||
assertCLSMNotLoaded();
|
||||
assertSystemKSNotLoaded();
|
||||
assertKeyspaceNotLoaded();
|
||||
assertServerNotLoaded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaybeChangeDocs()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,19 +19,15 @@
|
|||
package org.apache.cassandra.tools;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.io.sstable.format.SSTableReader;
|
||||
|
|
@ -41,32 +37,23 @@ import org.assertj.core.api.Assertions;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class StandaloneSplitterWithCQLTesterTest extends CQLTester
|
||||
{
|
||||
private static String sstableFileName;
|
||||
private static File sstablesDir;
|
||||
private static File sstablesBackupDir;
|
||||
private static List<File> origSstables;
|
||||
|
||||
// CQLTester post test method cleanup needs to be avoided by overriding as it'd clean all sstables, env, etc.
|
||||
@Override
|
||||
public void afterTest() throws Throwable
|
||||
@Before
|
||||
public void before() throws Throwable
|
||||
{
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setupEnv() throws Throwable
|
||||
{
|
||||
// Stop the server after setup as we're going to be changing things under it's feet
|
||||
setupTestSstables();
|
||||
tearDownClass();
|
||||
SSTableReader.resetTidying();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinFileSizeCheck() throws Throwable
|
||||
{
|
||||
restoreOrigSstables();
|
||||
ToolResult tool = ToolRunner.invokeClass(StandaloneSplitter.class, sstableFileName);
|
||||
Assertions.assertThat(tool.getStdout()).contains("is less than the split size");
|
||||
assertTrue(tool.getCleanedStderr(), tool.getCleanedStderr().isEmpty());
|
||||
|
|
@ -76,8 +63,6 @@ public class StandaloneSplitterWithCQLTesterTest extends CQLTester
|
|||
@Test
|
||||
public void testSplittingSSTable() throws Throwable
|
||||
{
|
||||
restoreOrigSstables();
|
||||
|
||||
ToolResult tool = ToolRunner.invokeClass(StandaloneSplitter.class, "-s", "1", sstableFileName);
|
||||
List<File> splitFiles = Arrays.asList(sstablesDir.listFiles());
|
||||
splitFiles.stream().forEach(f -> {
|
||||
|
|
@ -94,7 +79,6 @@ public class StandaloneSplitterWithCQLTesterTest extends CQLTester
|
|||
@Test
|
||||
public void testSplittingMultipleSSTables() throws Throwable
|
||||
{
|
||||
restoreOrigSstables();
|
||||
ArrayList<String> args = new ArrayList<>(Arrays.asList("-s", "1"));
|
||||
|
||||
args.addAll(Arrays.asList(sstablesDir.listFiles())
|
||||
|
|
@ -117,7 +101,6 @@ public class StandaloneSplitterWithCQLTesterTest extends CQLTester
|
|||
@Test
|
||||
public void testNoSnapshotOption() throws Throwable
|
||||
{
|
||||
restoreOrigSstables();
|
||||
ToolResult tool = ToolRunner.invokeClass(StandaloneSplitter.class, "-s", "1", "--no-snapshot", sstableFileName);
|
||||
assertTrue(origSstables.size() < Arrays.asList(sstablesDir.listFiles()).size());
|
||||
assertTrue(tool.getStdout(), tool.getStdout().isEmpty());
|
||||
|
|
@ -125,15 +108,9 @@ public class StandaloneSplitterWithCQLTesterTest extends CQLTester
|
|||
assertEquals(0, tool.getExitCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cleanEnv() throws Throwable
|
||||
{
|
||||
super.afterTest();
|
||||
System.clearProperty(Util.ALLOW_TOOL_REINIT_FOR_TEST);
|
||||
}
|
||||
|
||||
private void setupTestSstables() throws Throwable
|
||||
{
|
||||
SSTableReader.resetTidying();
|
||||
createTable("CREATE TABLE %s (id text primary key, val text)");
|
||||
for (int i = 0; i < 100000; i++)
|
||||
executeFormattedQuery(formatQuery("INSERT INTO %s (id, val) VALUES (?, ?)"), "mockData" + i, "mockData" + i);
|
||||
|
|
@ -145,44 +122,7 @@ public class StandaloneSplitterWithCQLTesterTest extends CQLTester
|
|||
sstableFileName = sstables.iterator().next().getFilename();
|
||||
assertTrue("Generated sstable must be at least 1MB", (new File(sstableFileName)).length() > 1024*1024);
|
||||
sstablesDir = new File(sstableFileName).getParentFile();
|
||||
sstablesBackupDir = new File(sstablesDir.getAbsolutePath() + "/testbackup");
|
||||
sstablesBackupDir.mkdir();
|
||||
origSstables = Arrays.asList(sstablesDir.listFiles());
|
||||
|
||||
// Back up orig sstables
|
||||
origSstables.stream().forEach(f -> {
|
||||
if (f.isFile())
|
||||
try
|
||||
{
|
||||
Files.copy(f, new File(sstablesBackupDir.getAbsolutePath() + "/" + f.getName()));
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
|
||||
System.setProperty(Util.ALLOW_TOOL_REINIT_FOR_TEST, "true"); // Necessary for testing
|
||||
}
|
||||
|
||||
private void restoreOrigSstables()
|
||||
{
|
||||
Arrays.asList(sstablesDir.listFiles()).stream().forEach(f -> {
|
||||
if (f.isFile())
|
||||
f.delete();
|
||||
});
|
||||
Arrays.asList(sstablesBackupDir.listFiles()).stream().forEach(f -> {
|
||||
if (f.isFile())
|
||||
try
|
||||
{
|
||||
Files.copy(f, new File(sstablesDir.getAbsolutePath() + "/" + f.getName()));
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
|
||||
SSTableReader.resetTidying();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,9 +28,7 @@ import java.util.stream.Collectors;
|
|||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.db.Keyspace;
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
|
|
@ -50,7 +48,6 @@ import static org.junit.Assert.assertEquals;
|
|||
*
|
||||
* Caution: heavy hacking ahead.
|
||||
*/
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class StandaloneUpgraderOnSStablesTest
|
||||
{
|
||||
String legacyId = LegacySSTableTest.legacyVersions[LegacySSTableTest.legacyVersions.length - 1];
|
||||
|
|
@ -87,6 +84,9 @@ public class StandaloneUpgraderOnSStablesTest
|
|||
List<String> newFiles = getSStableFiles("legacy_tables", "legacy_" + legacyId + "_simple");
|
||||
origFiles.removeAll(newFiles);
|
||||
assertEquals(0, origFiles.size()); // check previous version files are kept
|
||||
|
||||
// need to make sure the new sstables are live, so that they get truncated later
|
||||
Keyspace.open("legacy_tables").getColumnFamilyStore("legacy_" + legacyId + "_simple").loadNewSSTables();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -134,6 +134,8 @@ public class StandaloneUpgraderOnSStablesTest
|
|||
int origSize = origFiles.size();
|
||||
origFiles.removeAll(newFiles);
|
||||
assertEquals(origSize, origFiles.size()); // check previous version files are gone
|
||||
// need to make sure the new sstables are live, so that they get truncated later
|
||||
Keyspace.open("legacy_tables").getColumnFamilyStore("legacy_" + legacyId + "_simple").loadNewSSTables();
|
||||
}
|
||||
|
||||
private List<String> getSStableFiles(String ks, String table) throws StartupException
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@ package org.apache.cassandra.tools;
|
|||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.tools.ToolRunner.ToolResult;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
|
|
@ -31,24 +29,8 @@ import org.hamcrest.CoreMatchers;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class StandaloneUpgraderTest extends OfflineToolUtils
|
||||
{
|
||||
@Test
|
||||
public void testNoArgsPrintsHelp()
|
||||
{
|
||||
ToolResult tool = ToolRunner.invokeClass(StandaloneUpgrader.class);
|
||||
assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("usage:"));
|
||||
assertThat(tool.getCleanedStderr(), CoreMatchers.containsStringIgnoringCase("Missing arguments"));
|
||||
assertEquals(1, tool.getExitCode());
|
||||
assertNoUnexpectedThreadsStarted(null, null);
|
||||
assertSchemaNotLoaded();
|
||||
assertCLSMNotLoaded();
|
||||
assertSystemKSNotLoaded();
|
||||
assertKeyspaceNotLoaded();
|
||||
assertServerNotLoaded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaybeChangeDocs()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@ package org.apache.cassandra.tools;
|
|||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.tools.ToolRunner.ToolResult;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
|
|
@ -31,25 +29,8 @@ import org.hamcrest.CoreMatchers;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class StandaloneVerifierTest extends OfflineToolUtils
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testNoArgsPrintsHelp()
|
||||
{
|
||||
ToolResult tool = ToolRunner.invokeClass(StandaloneVerifier.class);
|
||||
assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("usage:"));
|
||||
assertThat(tool.getCleanedStderr(), CoreMatchers.containsStringIgnoringCase("Missing arguments"));
|
||||
assertEquals(1, tool.getExitCode());
|
||||
assertNoUnexpectedThreadsStarted(null, null);
|
||||
assertSchemaNotLoaded();
|
||||
assertCLSMNotLoaded();
|
||||
assertSystemKSNotLoaded();
|
||||
assertKeyspaceNotLoaded();
|
||||
assertServerNotLoaded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaybeChangeDocs()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* 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.tools;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hamcrest.CoreMatchers;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
public class ToolsSchemaLoadingTest extends OfflineToolUtils
|
||||
{
|
||||
@Test
|
||||
public void testNoArgsPrintsHelpStandaloneVerifier()
|
||||
{
|
||||
ToolRunner.ToolResult tool = ToolRunner.invokeClass(StandaloneVerifier.class);
|
||||
assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("usage:"));
|
||||
assertThat(tool.getCleanedStderr(), CoreMatchers.containsStringIgnoringCase("Missing arguments"));
|
||||
assertEquals(1, tool.getExitCode());
|
||||
assertNoUnexpectedThreadsStarted(null, null);
|
||||
assertSchemaNotLoaded();
|
||||
assertCLSMNotLoaded();
|
||||
assertSystemKSNotLoaded();
|
||||
assertKeyspaceNotLoaded();
|
||||
assertServerNotLoaded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoArgsPrintsHelpStandaloneScrubber()
|
||||
{
|
||||
ToolRunner.ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class);
|
||||
assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("usage:"));
|
||||
assertThat(tool.getCleanedStderr(), CoreMatchers.containsStringIgnoringCase("Missing arguments"));
|
||||
assertEquals(1, tool.getExitCode());
|
||||
assertNoUnexpectedThreadsStarted(null, null);
|
||||
assertSchemaNotLoaded();
|
||||
assertCLSMNotLoaded();
|
||||
assertSystemKSNotLoaded();
|
||||
assertKeyspaceNotLoaded();
|
||||
assertServerNotLoaded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoArgsPrintsHelpStandaloneSplitter()
|
||||
{
|
||||
ToolRunner.ToolResult tool = ToolRunner.invokeClass(StandaloneSplitter.class);
|
||||
assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("usage:"));
|
||||
assertThat(tool.getCleanedStderr(), CoreMatchers.containsStringIgnoringCase("No sstables to split"));
|
||||
assertEquals(1, tool.getExitCode());
|
||||
assertNoUnexpectedThreadsStarted(null, null);
|
||||
assertSchemaNotLoaded();
|
||||
assertCLSMNotLoaded();
|
||||
assertSystemKSNotLoaded();
|
||||
assertKeyspaceNotLoaded();
|
||||
assertServerNotLoaded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoArgsPrintsHelpStandaloneSSTableUtil()
|
||||
{
|
||||
ToolRunner.ToolResult tool = ToolRunner.invokeClass(StandaloneSSTableUtil.class);
|
||||
assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("usage:"));
|
||||
assertThat(tool.getCleanedStderr(), CoreMatchers.containsStringIgnoringCase("Missing arguments"));
|
||||
assertEquals(1, tool.getExitCode());
|
||||
assertNoUnexpectedThreadsStarted(null, null);
|
||||
assertSchemaNotLoaded();
|
||||
assertCLSMNotLoaded();
|
||||
assertSystemKSNotLoaded();
|
||||
assertKeyspaceNotLoaded();
|
||||
assertServerNotLoaded();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoArgsPrintsHelpStandaloneUpgrader()
|
||||
{
|
||||
ToolRunner.ToolResult tool = ToolRunner.invokeClass(StandaloneUpgrader.class);
|
||||
assertThat(tool.getStdout(), CoreMatchers.containsStringIgnoringCase("usage:"));
|
||||
assertThat(tool.getCleanedStderr(), CoreMatchers.containsStringIgnoringCase("Missing arguments"));
|
||||
assertEquals(1, tool.getExitCode());
|
||||
assertNoUnexpectedThreadsStarted(null, null);
|
||||
assertSchemaNotLoaded();
|
||||
assertCLSMNotLoaded();
|
||||
assertSystemKSNotLoaded();
|
||||
assertKeyspaceNotLoaded();
|
||||
assertServerNotLoaded();
|
||||
}
|
||||
}
|
||||
|
|
@ -25,16 +25,13 @@ import javax.management.openmbean.TabularData;
|
|||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.tools.NodeProbe;
|
||||
import org.apache.cassandra.tools.ToolRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class ClearSnapshotTest extends CQLTester
|
||||
{
|
||||
private static NodeProbe probe;
|
||||
|
|
|
|||
|
|
@ -21,15 +21,12 @@ package org.apache.cassandra.tools.nodetool;
|
|||
import org.junit.After;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.tools.ToolRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class GetAuditLogTest extends CQLTester
|
||||
{
|
||||
@BeforeClass
|
||||
|
|
|
|||
|
|
@ -23,16 +23,13 @@ import org.junit.BeforeClass;
|
|||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.fql.FullQueryLoggerOptions;
|
||||
import org.apache.cassandra.tools.ToolRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class GetFullQueryLogTest extends CQLTester
|
||||
{
|
||||
@ClassRule
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@ package org.apache.cassandra.tools.nodetool;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.net.Message;
|
||||
import org.apache.cassandra.net.MessagingService;
|
||||
|
|
@ -36,7 +34,6 @@ import org.assertj.core.api.Assertions;
|
|||
import static org.apache.cassandra.net.Verb.ECHO_REQ;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class GossipInfoTest extends CQLTester
|
||||
{
|
||||
private static String token;
|
||||
|
|
|
|||
|
|
@ -20,11 +20,9 @@ package org.apache.cassandra.tools.nodetool;
|
|||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import com.datastax.driver.core.EndPoint;
|
||||
import com.datastax.driver.core.PlainTextAuthProvider;
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.auth.AuthTestUtils;
|
||||
import org.apache.cassandra.auth.AuthenticatedUser;
|
||||
|
|
@ -38,7 +36,6 @@ import static org.apache.cassandra.auth.AuthTestUtils.ROLE_B;
|
|||
import static org.apache.cassandra.auth.AuthTestUtils.getRolesReadCount;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class InvalidateCredentialsCacheTest extends CQLTester
|
||||
{
|
||||
private static IAuthenticator.SaslNegotiator roleANegotiator;
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ import javax.security.auth.Subject;
|
|||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.auth.AuthTestUtils;
|
||||
import org.apache.cassandra.auth.AuthenticatedUser;
|
||||
|
|
@ -41,7 +39,6 @@ import static org.apache.cassandra.auth.AuthTestUtils.ROLE_B;
|
|||
import static org.apache.cassandra.auth.AuthTestUtils.getRolePermissionsReadCount;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class InvalidateJmxPermissionsCacheTest extends CQLTester
|
||||
{
|
||||
private static final AuthorizationProxy authorizationProxy = new NoAuthSetupAuthorizationProxy();
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@ package org.apache.cassandra.tools.nodetool;
|
|||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.auth.AuthTestUtils;
|
||||
import org.apache.cassandra.auth.AuthenticatedUser;
|
||||
|
|
@ -34,7 +32,6 @@ import static org.apache.cassandra.auth.AuthTestUtils.ROLE_B;
|
|||
import static org.apache.cassandra.auth.AuthTestUtils.getNetworkPermissionsReadCount;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class InvalidateNetworkPermissionsCacheTest extends CQLTester
|
||||
{
|
||||
@BeforeClass
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@ import java.util.Set;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.auth.AuthTestUtils;
|
||||
import org.apache.cassandra.auth.AuthenticatedUser;
|
||||
|
|
@ -49,7 +47,6 @@ import static org.apache.cassandra.auth.AuthTestUtils.ROLE_B;
|
|||
import static org.apache.cassandra.auth.AuthTestUtils.getRolePermissionsReadCount;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class InvalidatePermissionsCacheTest extends CQLTester
|
||||
{
|
||||
@BeforeClass
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@ package org.apache.cassandra.tools.nodetool;
|
|||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.SchemaLoader;
|
||||
import org.apache.cassandra.auth.AuthTestUtils;
|
||||
import org.apache.cassandra.auth.AuthenticatedUser;
|
||||
|
|
@ -34,7 +32,6 @@ import static org.apache.cassandra.auth.AuthTestUtils.ROLE_B;
|
|||
import static org.apache.cassandra.auth.AuthTestUtils.getRolesReadCount;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class InvalidateRolesCacheTest extends CQLTester
|
||||
{
|
||||
@BeforeClass
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@ import java.util.List;
|
|||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.locator.InetAddressAndPort;
|
||||
import org.apache.cassandra.net.Message;
|
||||
|
|
@ -45,7 +43,6 @@ import org.apache.cassandra.utils.FBUtilities;
|
|||
import static org.apache.cassandra.net.Verb.ECHO_REQ;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class NetStatsTest extends CQLTester
|
||||
{
|
||||
@BeforeClass
|
||||
|
|
|
|||
|
|
@ -22,9 +22,7 @@ import java.util.Arrays;
|
|||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.locator.SimpleSnitch;
|
||||
import org.apache.cassandra.service.StorageService;
|
||||
|
|
@ -33,7 +31,6 @@ import org.apache.cassandra.utils.FBUtilities;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class RingTest extends CQLTester
|
||||
{
|
||||
private static String token;
|
||||
|
|
|
|||
|
|
@ -22,9 +22,7 @@ import java.util.regex.Pattern;
|
|||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.locator.SimpleSnitch;
|
||||
import org.apache.cassandra.schema.SchemaConstants;
|
||||
|
|
@ -34,7 +32,6 @@ import org.apache.cassandra.utils.FBUtilities;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class StatusTest extends CQLTester
|
||||
{
|
||||
private static final Pattern PATTERN = Pattern.compile("\\R");
|
||||
|
|
|
|||
|
|
@ -27,15 +27,12 @@ import java.util.regex.Pattern;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.tools.ToolRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class TableStatsTest extends CQLTester
|
||||
{
|
||||
@BeforeClass
|
||||
|
|
|
|||
|
|
@ -28,10 +28,8 @@ import java.util.regex.Pattern;
|
|||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.net.Message;
|
||||
import org.apache.cassandra.net.MessagingService;
|
||||
|
|
@ -43,7 +41,6 @@ import org.yaml.snakeyaml.Yaml;
|
|||
import static org.apache.cassandra.net.Verb.ECHO_REQ;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class TpStatsTest extends CQLTester
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -34,13 +34,11 @@ import org.junit.After;
|
|||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import com.datastax.driver.core.Cluster;
|
||||
import com.datastax.driver.core.PreparedStatement;
|
||||
import com.datastax.driver.core.Session;
|
||||
import com.datastax.driver.core.exceptions.AuthenticationException;
|
||||
import org.apache.cassandra.OrderedJUnit4ClassRunner;
|
||||
import org.apache.cassandra.audit.AuditEvent;
|
||||
import org.apache.cassandra.audit.AuditLogEntryType;
|
||||
import org.apache.cassandra.audit.AuditLogManager;
|
||||
|
|
@ -56,7 +54,6 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
@RunWith(OrderedJUnit4ClassRunner.class)
|
||||
public class CQLUserAuditTest
|
||||
{
|
||||
private static EmbeddedCassandraService embedded;
|
||||
|
|
|
|||
Loading…
Reference in New Issue