@BeforeMethod(groups = {"short", "long"}) @AfterMethod(groups = {"short", "long"}) public void resetClients() { activityClient.clearAllRecordedActivity(); primingClient.clearAllPrimes(); currentClient.enableListener(); }
public BatchExecution executeBatch( Session session, String statement, ConsistencyLevel level, ConsistencyLevel serialLevel) { BatchStatement batch = new BatchStatement(); batch.add(new SimpleStatement(statement)); if (level != null) { batch.setConsistencyLevel(level); } if (serialLevel != null) { batch.setSerialConsistencyLevel(serialLevel); } session.execute(batch); List<BatchExecution> batches = sCluster.node(1).activityClient().retrieveBatches(); assertEquals(batches.size(), 1); return batches.get(0); }
public PreparedStatementExecution executePrepared( Session session, String statement, ConsistencyLevel level, ConsistencyLevel serialLevel) { PreparedStatement ps = session.prepare(statement); BoundStatement bound = ps.bind(); if (level != null) { bound.setConsistencyLevel(level); } if (serialLevel != null) { bound.setSerialConsistencyLevel(serialLevel); } session.execute(bound); List<PreparedStatementExecution> pses = sCluster.node(1).activityClient().retrievePreparedStatementExecutions(); PreparedStatementExecution pse = pses.get(0); assertTrue(pse.getPreparedStatementText().equals(statement)); return pse; }
/** * Deletes the recorded prepared statement executions, recorded batch executions, recorded queries and recorded connections. */ public void clearAllRecordedActivity() { clearConnections(); clearQueries(); clearPreparedStatementExecutions(); clearBatchExecutions(); clearPreparedStatementPreparations(); }
scassandra.node(1).activityClient().retrievePreparedStatementPreparations(); scassandra.node(1).activityClient().clearAllRecordedActivity(); scassandra.node(1).stop(); assertThat(cluster).host(1).goesDownWithin(10, TimeUnit.SECONDS); assertThat(cluster).host(1).comesUpWithin(60, TimeUnit.SECONDS); preparationOne = scassandra.node(1).activityClient().retrievePreparedStatementPreparations(); if (expectReprepare) { if (i == maxTries) throw e; scassandra.node(1).activityClient().clearAllRecordedActivity();
protected void assertQueried(int hostNumber, int times) { assertThat(scassandras.node(hostNumber).activityClient().retrieveQueries()).hasSize(times); }
public void validatePrepared(boolean expectAll) { // Prepare the statement String query = "select sansa_stark from the_known_world"; PreparedStatement statement = session.prepare(query); assertThat(cluster.manager.preparedQueries).containsValue(statement); // Ensure prepared properly based on expectation. List<PreparedStatementPreparation> preparationOne = scassandra.node(1).activityClient().retrievePreparedStatementPreparations(); List<PreparedStatementPreparation> preparationTwo = scassandra.node(2).activityClient().retrievePreparedStatementPreparations(); List<PreparedStatementPreparation> preparationThree = scassandra.node(3).activityClient().retrievePreparedStatementPreparations(); assertThat(preparationOne).hasSize(1); assertThat(preparationOne.get(0).getPreparedStatementText()).isEqualTo(query); if (expectAll) { assertThat(preparationTwo).hasSize(1); assertThat(preparationTwo.get(0).getPreparedStatementText()).isEqualTo(query); assertThat(preparationThree).hasSize(1); assertThat(preparationThree.get(0).getPreparedStatementText()).isEqualTo(query); } else { assertThat(preparationTwo).isEmpty(); assertThat(preparationThree).isEmpty(); } }
public ActivityClient build() { return new ActivityClient(this.host, this.port, this.socketTimeout); } }
ScassandraRunner(String binaryListenAddress, int binaryPort, String adminListenAddress, int adminPort, long startupTimeout) { this.binaryPort = binaryPort; this.adminPort = adminPort; this.serverStubRunner = new ServerStubRunner(binaryListenAddress, binaryPort, adminListenAddress, adminPort, startupTimeout); this.primingClient = PrimingClient.builder().withHost(adminListenAddress).withPort(adminPort).build(); this.activityClient = ActivityClient.builder().withHost(adminListenAddress).withPort(adminPort).build(); this.currentClient = CurrentClient.builder().withHost(adminListenAddress).withPort(adminPort).build(); this.versionUrl = "http://" + binaryListenAddress + ":" + adminPort + "/version"; }
@BeforeMethod(groups = "short") public void beforeMethod() { scassandra = ScassandraCluster.builder().withNodes(3).build(); scassandra.init(); queryOptions = new QueryOptions(); loadBalancingPolicy = new SortingLoadBalancingPolicy(); cluster = Cluster.builder() .addContactPoints(scassandra.address(2).getAddress()) .withPort(scassandra.getBinaryPort()) .withLoadBalancingPolicy(loadBalancingPolicy) .withQueryOptions(queryOptions) .withNettyOptions(nonQuietClusterCloseOptions) .build(); session = cluster.connect(); host1 = TestUtils.findHost(cluster, 1); host2 = TestUtils.findHost(cluster, 2); host3 = TestUtils.findHost(cluster, 3); // Make sure there are no prepares for (int host : Lists.newArrayList(1, 2, 3)) { assertThat(scassandra.node(host).activityClient().retrievePreparedStatementPreparations()) .hasSize(0); scassandra.node(host).activityClient().clearAllRecordedActivity(); } }
public Query executeSimple( Session session, String statement, ConsistencyLevel level, ConsistencyLevel serialLevel) { SimpleStatement simpleStatement = new SimpleStatement(statement); if (level != null) { simpleStatement.setConsistencyLevel(level); } if (serialLevel != null) { simpleStatement.setSerialConsistencyLevel(serialLevel); } session.execute(simpleStatement); // Find the unique query in the activity log. List<Query> queries = sCluster.node(1).activityClient().retrieveQueries(); for (Query query : queries) { if (query.getQuery().equals(statement)) return query; } return null; }
public void validatePrepared(boolean expectAll) { // Prepare the statement String query = "select sansa_stark from the_known_world"; PreparedStatement statement = session.prepare(query); assertThat(cluster.manager.preparedQueries).containsValue(statement); // Ensure prepared properly based on expectation. List<PreparedStatementPreparation> preparationOne = scassandra.node(1).activityClient().retrievePreparedStatementPreparations(); List<PreparedStatementPreparation> preparationTwo = scassandra.node(2).activityClient().retrievePreparedStatementPreparations(); List<PreparedStatementPreparation> preparationThree = scassandra.node(3).activityClient().retrievePreparedStatementPreparations(); assertThat(preparationOne).hasSize(1); assertThat(preparationOne.get(0).getPreparedStatementText()).isEqualTo(query); if (expectAll) { assertThat(preparationTwo).hasSize(1); assertThat(preparationTwo.get(0).getPreparedStatementText()).isEqualTo(query); assertThat(preparationThree).hasSize(1); assertThat(preparationThree.get(0).getPreparedStatementText()).isEqualTo(query); } else { assertThat(preparationTwo).isEmpty(); assertThat(preparationThree).isEmpty(); } }
public void clearActivityLog() { for (Scassandra node : sCluster.nodes()) { node.activityClient().clearAllRecordedActivity(); } }
scassandra.node(1).activityClient().retrievePreparedStatementPreparations(); scassandra.node(1).activityClient().clearAllRecordedActivity(); scassandra.node(1).stop(); assertThat(cluster).host(1).goesDownWithin(10, TimeUnit.SECONDS); assertThat(cluster).host(1).comesUpWithin(60, TimeUnit.SECONDS); preparationOne = scassandra.node(1).activityClient().retrievePreparedStatementPreparations(); if (expectReprepare) { if (i == maxTries) throw e; scassandra.node(1).activityClient().clearAllRecordedActivity();
assertThat(activityClient.retrieveQueries()) .extractingResultOf("getQuery") .containsOnlyOnce("USE \"newkeyspace\"");
public BatchExecution executeBatch( Session session, String statement, ConsistencyLevel level, ConsistencyLevel serialLevel) { BatchStatement batch = new BatchStatement(); batch.add(new SimpleStatement(statement)); if (level != null) { batch.setConsistencyLevel(level); } if (serialLevel != null) { batch.setSerialConsistencyLevel(serialLevel); } session.execute(batch); List<BatchExecution> batches = sCluster.node(1).activityClient().retrieveBatches(); assertEquals(batches.size(), 1); return batches.get(0); }
public PreparedStatementExecution executePrepared( Session session, String statement, ConsistencyLevel level, ConsistencyLevel serialLevel) { PreparedStatement ps = session.prepare(statement); BoundStatement bound = ps.bind(); if (level != null) { bound.setConsistencyLevel(level); } if (serialLevel != null) { bound.setSerialConsistencyLevel(serialLevel); } session.execute(bound); List<PreparedStatementExecution> pses = sCluster.node(1).activityClient().retrievePreparedStatementExecutions(); PreparedStatementExecution pse = pses.get(0); assertTrue(pse.getPreparedStatementText().equals(statement)); return pse; }
public void clearActivityLog() { for (Scassandra node : sCluster.nodes()) { node.activityClient().clearAllRecordedActivity(); } }
@BeforeMethod(groups = "short") public void beforeMethod() { scassandra = ScassandraCluster.builder().withNodes(3).build(); scassandra.init(); queryOptions = new QueryOptions(); loadBalancingPolicy = new SortingLoadBalancingPolicy(); cluster = Cluster.builder() .addContactPoints(scassandra.address(2).getAddress()) .withPort(scassandra.getBinaryPort()) .withLoadBalancingPolicy(loadBalancingPolicy) .withQueryOptions(queryOptions) .withNettyOptions(nonQuietClusterCloseOptions) .build(); session = cluster.connect(); host1 = TestUtils.findHost(cluster, 1); host2 = TestUtils.findHost(cluster, 2); host3 = TestUtils.findHost(cluster, 3); // Make sure there are no prepares for (int host : Lists.newArrayList(1, 2, 3)) { assertThat(scassandra.node(host).activityClient().retrievePreparedStatementPreparations()) .hasSize(0); scassandra.node(host).activityClient().clearAllRecordedActivity(); } }
protected void assertQueried(int hostNumber, int times) { assertThat(scassandras.node(hostNumber).activityClient().retrieveQueries()).hasSize(times); }