Search in sources :

Example 11 with EmbeddedCassandraService

use of org.apache.cassandra.service.EmbeddedCassandraService in project cassandra by apache.

the class DebuggableScheduledThreadPoolExecutorTest method startup.

@BeforeClass
public static void startup() throws IOException {
    // The DSTPE checks for if we are in the service shutdown hook so
    // to test it we need to start C* internally.
    service = new EmbeddedCassandraService();
    service.start();
}
Also used : EmbeddedCassandraService(org.apache.cassandra.service.EmbeddedCassandraService) BeforeClass(org.junit.BeforeClass)

Example 12 with EmbeddedCassandraService

use of org.apache.cassandra.service.EmbeddedCassandraService in project cassandra by apache.

the class PagingTest method setup.

@BeforeClass
public static void setup() throws Exception {
    System.setProperty("cassandra.config", "cassandra-murmur.yaml");
    EmbeddedCassandraService cassandra = new EmbeddedCassandraService();
    cassandra.start();
    // Currently the native server start method return before the server is fully binded to the socket, so we need
    // to wait slightly before trying to connect to it. We should fix this but in the meantime using a sleep.
    Thread.sleep(500);
    cluster = Cluster.builder().addContactPoint("127.0.0.1").withPort(DatabaseDescriptor.getNativeTransportPort()).build();
    session = cluster.connect();
    session.execute(dropKsStatement);
    session.execute(createKsStatement);
}
Also used : EmbeddedCassandraService(org.apache.cassandra.service.EmbeddedCassandraService) BeforeClass(org.junit.BeforeClass)

Example 13 with EmbeddedCassandraService

use of org.apache.cassandra.service.EmbeddedCassandraService in project cassandra by apache.

the class TableMetricsTest method setup.

@BeforeClass
public static void setup() throws ConfigurationException, IOException {
    Schema.instance.clear();
    EmbeddedCassandraService cassandra = new EmbeddedCassandraService();
    cassandra.start();
    Cluster cluster = Cluster.builder().addContactPoint("127.0.0.1").withPort(DatabaseDescriptor.getNativeTransportPort()).build();
    session = cluster.connect();
    session.execute(String.format("CREATE KEYSPACE IF NOT EXISTS %s WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };", KEYSPACE));
    session.execute(String.format("CREATE TABLE IF NOT EXISTS %s.%s (id_c counter, id int, val text, PRIMARY KEY(id, val));", KEYSPACE, COUNTER_TABLE));
}
Also used : Cluster(com.datastax.driver.core.Cluster) EmbeddedCassandraService(org.apache.cassandra.service.EmbeddedCassandraService) BeforeClass(org.junit.BeforeClass)

Example 14 with EmbeddedCassandraService

use of org.apache.cassandra.service.EmbeddedCassandraService in project cassandra by apache.

the class KeyspaceMetricsTest method setup.

@BeforeClass
public static void setup() throws ConfigurationException, IOException {
    Schema.instance.clear();
    EmbeddedCassandraService cassandra = new EmbeddedCassandraService();
    cassandra.start();
    Cluster cluster = Cluster.builder().addContactPoint("127.0.0.1").withPort(DatabaseDescriptor.getNativeTransportPort()).build();
    session = cluster.connect();
}
Also used : Cluster(com.datastax.driver.core.Cluster) EmbeddedCassandraService(org.apache.cassandra.service.EmbeddedCassandraService) BeforeClass(org.junit.BeforeClass)

Example 15 with EmbeddedCassandraService

use of org.apache.cassandra.service.EmbeddedCassandraService in project cassandra by apache.

the class CQLUserAuditTest method setup.

@BeforeClass
public static void setup() throws Exception {
    OverrideConfigurationLoader.override((config) -> {
        config.authenticator = "PasswordAuthenticator";
        config.role_manager = "CassandraRoleManager";
        config.diagnostic_events_enabled = true;
        config.audit_logging_options.enabled = true;
        config.audit_logging_options.logger = new ParameterizedClass("DiagnosticEventAuditLogger", null);
    });
    CQLTester.prepareServer();
    System.setProperty("cassandra.superuser_setup_delay_ms", "0");
    embedded = new EmbeddedCassandraService();
    embedded.start();
    executeAs(Arrays.asList("CREATE ROLE testuser WITH LOGIN = true AND SUPERUSER = false AND PASSWORD = 'foo'", "CREATE ROLE testuser_nologin WITH LOGIN = false AND SUPERUSER = false AND PASSWORD = 'foo'", "CREATE KEYSPACE testks WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}", "CREATE TABLE testks.table1 (a text, b int, c int, PRIMARY KEY (a, b))", "CREATE TABLE testks.table2 (a text, b int, c int, PRIMARY KEY (a, b))"), "cassandra", "cassandra", null);
    DiagnosticEventService.instance().subscribe(AuditEvent.class, auditEvents::add);
    AuditLogManager.instance.initialize();
}
Also used : ParameterizedClass(org.apache.cassandra.config.ParameterizedClass) EmbeddedCassandraService(org.apache.cassandra.service.EmbeddedCassandraService) BeforeClass(org.junit.BeforeClass)

Aggregations

EmbeddedCassandraService (org.apache.cassandra.service.EmbeddedCassandraService)15 BeforeClass (org.junit.BeforeClass)13 Cluster (com.datastax.driver.core.Cluster)2 ParameterizedClass (org.apache.cassandra.config.ParameterizedClass)2 LoggingRetryPolicy (com.datastax.driver.core.policies.LoggingRetryPolicy)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 HashMap (java.util.HashMap)1 ConfigurationException (org.apache.cassandra.config.ConfigurationException)1 TException (org.apache.thrift.TException)1 TTransportException (org.apache.thrift.transport.TTransportException)1 Test (org.junit.Test)1