Search in sources :

Example 21 with NodeToolResult

use of org.apache.cassandra.distributed.api.NodeToolResult in project cassandra by apache.

the class NodeToolTest method testCaptureConsoleOutput.

@Test
public void testCaptureConsoleOutput() {
    NodeToolResult ringResult = NODE.nodetoolResult("ring");
    ringResult.asserts().stdoutContains("Datacenter: datacenter0");
    ringResult.asserts().stdoutContains("127.0.0.1       rack0       Up     Normal");
    assertEquals("Non-empty error output", "", ringResult.getStderr());
}
Also used : NodeToolResult(org.apache.cassandra.distributed.api.NodeToolResult) Test(org.junit.Test)

Example 22 with NodeToolResult

use of org.apache.cassandra.distributed.api.NodeToolResult in project cassandra by apache.

the class NodeToolTest method testSetCacheCapacityWhenDisabled.

@Test
public void testSetCacheCapacityWhenDisabled() throws Throwable {
    try (ICluster cluster = init(builder().withNodes(1).withConfig(c -> c.set("row_cache_size", "0MiB")).start())) {
        NodeToolResult ringResult = cluster.get(1).nodetoolResult("setcachecapacity", "1", "1", "1");
        ringResult.asserts().stderrContains("is not permitted as this cache is disabled");
    }
}
Also used : ICluster(org.apache.cassandra.distributed.api.ICluster) NodeToolResult(org.apache.cassandra.distributed.api.NodeToolResult) Test(org.junit.Test)

Example 23 with NodeToolResult

use of org.apache.cassandra.distributed.api.NodeToolResult in project cassandra by apache.

the class RepairCoordinatorFast method missingKeyspace.

@Test
public void missingKeyspace() {
    assertTimeoutPreemptively(Duration.ofMinutes(1), () -> {
        // as of this moment the check is done in nodetool so the JMX notifications are not imporant
        // nor is the history stored
        long repairExceptions = getRepairExceptions(CLUSTER, 2);
        NodeToolResult result = repair(2, "doesnotexist");
        result.asserts().failure().errorContains("Keyspace [doesnotexist] does not exist.");
        Assert.assertEquals(repairExceptions, getRepairExceptions(CLUSTER, 2));
        assertParentRepairNotExist(CLUSTER, "doesnotexist");
    });
}
Also used : NodeToolResult(org.apache.cassandra.distributed.api.NodeToolResult) Test(org.junit.Test)

Example 24 with NodeToolResult

use of org.apache.cassandra.distributed.api.NodeToolResult in project cassandra by apache.

the class RepairCoordinatorFast method unknownHost.

@Test
public void unknownHost() {
    String table = tableName("unknownhost");
    assertTimeoutPreemptively(Duration.ofMinutes(1), () -> {
        CLUSTER.schemaChange(format("CREATE TABLE %s.%s (key text, value text, PRIMARY KEY (key))", KEYSPACE, table));
        long repairExceptions = getRepairExceptions(CLUSTER, 2);
        NodeToolResult result = repair(2, KEYSPACE, table, "--in-hosts", "thisreally.should.not.exist.apache.org");
        result.asserts().failure().errorContains("Unknown host specified thisreally.should.not.exist.apache.org");
        if (withNotifications) {
            result.asserts().notificationContains(ProgressEventType.START, "Starting repair command").notificationContains(ProgressEventType.START, "repairing keyspace " + KEYSPACE + " with repair options").notificationContains(ProgressEventType.ERROR, "Unknown host specified thisreally.should.not.exist.apache.org").notificationContains(ProgressEventType.COMPLETE, "finished with error");
        }
        assertParentRepairNotExist(CLUSTER, KEYSPACE, table);
        Assert.assertEquals(repairExceptions + 1, getRepairExceptions(CLUSTER, 2));
    });
}
Also used : NodeToolResult(org.apache.cassandra.distributed.api.NodeToolResult) Test(org.junit.Test)

Example 25 with NodeToolResult

use of org.apache.cassandra.distributed.api.NodeToolResult in project cassandra by apache.

the class RepairCoordinatorFast method noTablesToRepair.

@Test
public void noTablesToRepair() {
    // index CF currently don't support repair, so they get dropped when listed
    // this is done in this test to cause the keyspace to have 0 tables to repair, which causes repair to no-op
    // early and skip.
    String table = tableName("withindex");
    assertTimeoutPreemptively(Duration.ofMinutes(1), () -> {
        CLUSTER.schemaChange(format("CREATE TABLE %s.%s (key text, value text, PRIMARY KEY (key))", KEYSPACE, table));
        CLUSTER.schemaChange(format("CREATE INDEX value_%s ON %s.%s (value)", postfix(), KEYSPACE, table));
        long repairExceptions = getRepairExceptions(CLUSTER, 2);
        // if CF has a . in it, it is assumed to be a 2i which rejects repairs
        NodeToolResult result = repair(2, KEYSPACE, table + ".value");
        result.asserts().success();
        if (withNotifications) {
            result.asserts().notificationContains("Empty keyspace").notificationContains("skipping repair: " + KEYSPACE).notificationContains(ProgressEventType.SUCCESS, // will fail since success isn't returned; only complete
            "Empty keyspace").notificationContains(ProgressEventType.COMPLETE, // will fail since it doesn't do this
            "finished");
        }
        assertParentRepairNotExist(CLUSTER, KEYSPACE, table + ".value");
        // this is actually a SKIP and not a FAILURE, so shouldn't increment
        Assert.assertEquals(repairExceptions, getRepairExceptions(CLUSTER, 2));
    });
}
Also used : NodeToolResult(org.apache.cassandra.distributed.api.NodeToolResult) Test(org.junit.Test)

Aggregations

NodeToolResult (org.apache.cassandra.distributed.api.NodeToolResult)29 Test (org.junit.Test)24 Cluster (org.apache.cassandra.distributed.Cluster)6 IMessageFilters (org.apache.cassandra.distributed.api.IMessageFilters)5 UnknownHostException (java.net.UnknownHostException)2 ExecutorService (java.util.concurrent.ExecutorService)2 Token (org.apache.cassandra.dht.Token)2 IInvokableInstance (org.apache.cassandra.distributed.api.IInvokableInstance)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Random (java.util.Random)1 UUID (java.util.UUID)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Future (java.util.concurrent.Future)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 CassandraRelevantProperties (org.apache.cassandra.config.CassandraRelevantProperties)1 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)1 Range (org.apache.cassandra.dht.Range)1 ConsistencyLevel (org.apache.cassandra.distributed.api.ConsistencyLevel)1