Search in sources :

Example 1 with QueryResult

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

the class DistributedRepairUtils method assertParentRepairNotExist.

public static void assertParentRepairNotExist(ICluster<IInvokableInstance> cluster, int coordinator, String ks, String table) {
    QueryResult rs = queryParentRepairHistory(cluster, coordinator, ks, table);
    Assert.assertFalse("No repairs should be found but at least one found", rs.hasNext());
}
Also used : QueryResult(org.apache.cassandra.distributed.api.QueryResult)

Example 2 with QueryResult

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

the class TableEstimatesTest method refreshSizeEstimatesClearsInvalidEntries.

/**
 * Replaces Python Dtest: nodetool_test.py#test_refresh_size_estimates_clears_invalid_entries
 */
@Test
public void refreshSizeEstimatesClearsInvalidEntries() {
    String size_estimatesInsert = "INSERT INTO system.size_estimates (keyspace_name, table_name, range_start, range_end, mean_partition_size, partitions_count) VALUES (?, ?, ?, ?, ?, ?)";
    IInstance node = CLUSTER.get(1);
    node.executeInternal(size_estimatesInsert, "system_auth", "bad_table", "-5", "5", 0L, 0L);
    node.executeInternal(size_estimatesInsert, "bad_keyspace", "bad_table", "-5", "5", 0L, 0L);
    node.nodetoolResult("refreshsizeestimates").asserts().success();
    QueryResult qr = CLUSTER.coordinator(1).executeWithResult("SELECT * FROM system.size_estimates WHERE keyspace_name=? AND table_name=?", ConsistencyLevel.ONE, "system_auth", "bad_table");
    Assertions.assertThat(qr).isExhausted();
    qr = CLUSTER.coordinator(1).executeWithResult("SELECT * FROM system.size_estimates WHERE keyspace_name=?", ConsistencyLevel.ONE, "bad_keyspace");
    Assertions.assertThat(qr).isExhausted();
}
Also used : QueryResult(org.apache.cassandra.distributed.api.QueryResult) IInstance(org.apache.cassandra.distributed.api.IInstance) Test(org.junit.Test)

Example 3 with QueryResult

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

the class TableEstimatesTest method refreshTableEstimatesClearsInvalidEntries.

/**
 * Replaces Python Dtest: nodetool_test.py#test_refresh_size_estimates_clears_invalid_entries
 */
@Test
public void refreshTableEstimatesClearsInvalidEntries() {
    String table_estimatesInsert = "INSERT INTO system.table_estimates (keyspace_name, table_name, range_type, range_start, range_end, mean_partition_size, partitions_count) VALUES (?, ?, ?, ?, ?, ?, ?)";
    IInstance node = CLUSTER.get(1);
    try {
        node.executeInternal(table_estimatesInsert, "system_auth", "bad_table", "local_primary", "-5", "5", 0L, 0L);
        node.executeInternal(table_estimatesInsert, "bad_keyspace", "bad_table", "local_primary", "-5", "5", 0L, 0L);
    } catch (Exception e) {
        // to make this test portable (with the intent to extract out), handle the case where the table_estimates isn't defined
        Assertions.assertThat(e.getClass().getCanonicalName()).isEqualTo("org.apache.cassandra.exceptions.InvalidRequestException");
        Assertions.assertThat(e).hasMessageContaining("does not exist");
        Assume.assumeTrue("system.table_estimates not present", false);
    }
    node.nodetoolResult("refreshsizeestimates").asserts().success();
    QueryResult qr = CLUSTER.coordinator(1).executeWithResult("SELECT * FROM system.table_estimates WHERE keyspace_name=? AND table_name=?", ConsistencyLevel.ONE, "system_auth", "bad_table");
    Assertions.assertThat(qr).isExhausted();
    qr = CLUSTER.coordinator(1).executeWithResult("SELECT * FROM system.table_estimates WHERE keyspace_name=?", ConsistencyLevel.ONE, "bad_keyspace");
    Assertions.assertThat(qr).isExhausted();
}
Also used : QueryResult(org.apache.cassandra.distributed.api.QueryResult) IInstance(org.apache.cassandra.distributed.api.IInstance) IOException(java.io.IOException) Test(org.junit.Test)

Example 4 with QueryResult

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

the class DistributedRepairUtils method assertParentRepairFailedWithMessageContains.

public static void assertParentRepairFailedWithMessageContains(ICluster<IInvokableInstance> cluster, int coordinator, String ks, String table, String message) {
    QueryResult rs = queryParentRepairHistory(cluster, coordinator, ks, table);
    validateExistingParentRepair(rs, row -> {
        // check completed
        Assert.assertNotNull("finished_at not found, the repair is not complete?", row.getTimestamp("finished_at"));
        // check failed
        Assert.assertNotNull("Exception not found", row.getString("exception_stacktrace"));
        String exceptionMessage = row.getString("exception_message");
        Assert.assertNotNull("Exception not found", exceptionMessage);
        Assert.assertTrue("Unable to locate message '" + message + "' in repair error message: " + exceptionMessage, exceptionMessage.contains(message));
    });
}
Also used : QueryResult(org.apache.cassandra.distributed.api.QueryResult)

Example 5 with QueryResult

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

the class DistributedRepairUtils method assertParentRepairSuccess.

public static void assertParentRepairSuccess(ICluster<IInvokableInstance> cluster, int coordinator, String ks, String table, Consumer<Row> moreSuccessCriteria) {
    Assert.assertNotNull("Invalid null value for moreSuccessCriteria", moreSuccessCriteria);
    QueryResult rs = queryParentRepairHistory(cluster, coordinator, ks, table);
    validateExistingParentRepair(rs, row -> {
        // check completed
        Assert.assertNotNull("finished_at not found, the repair is not complete?", row.getTimestamp("finished_at"));
        // check not failed (aka success)
        Assert.assertNull("Exception found", row.getString("exception_stacktrace"));
        Assert.assertNull("Exception found", row.getString("exception_message"));
        moreSuccessCriteria.accept(row);
    });
}
Also used : QueryResult(org.apache.cassandra.distributed.api.QueryResult)

Aggregations

QueryResult (org.apache.cassandra.distributed.api.QueryResult)6 IInstance (org.apache.cassandra.distributed.api.IInstance)2 Test (org.junit.Test)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 IOException (java.io.IOException)1 Collections (java.util.Collections)1 Set (java.util.Set)1 Consumer (java.util.function.Consumer)1 ConsistencyLevel (org.apache.cassandra.distributed.api.ConsistencyLevel)1 ICluster (org.apache.cassandra.distributed.api.ICluster)1 IInvokableInstance (org.apache.cassandra.distributed.api.IInvokableInstance)1 NodeToolResult (org.apache.cassandra.distributed.api.NodeToolResult)1 Row (org.apache.cassandra.distributed.api.Row)1 AbstractCluster (org.apache.cassandra.distributed.impl.AbstractCluster)1 StorageMetrics (org.apache.cassandra.metrics.StorageMetrics)1 Retry.retryWithBackoffBlocking (org.apache.cassandra.utils.Retry.retryWithBackoffBlocking)1 ArrayUtils (org.apache.commons.lang3.ArrayUtils)1 Assert (org.junit.Assert)1