kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | c0a7681387c1814cd19ab91c03ead5ac125dd609c106eaf883ca843b39569f4f |
|---|---|
| Author | Andrew Tolbert <andrew.tolbert@datastax.com> · 2015-11-04 08:30 -06:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-11-05 18:37 +01:00 |
| Parents | baf47da1c074 |
1 file changed
modified driver-core/src/test/java/com/datastax/driver/core/CCMBridge.java +15 −4
| @@ -506,19 +506,30 @@ | ||
| 506 | 506 | |
| 507 | 507 | private void clearSimpleKeyspace() { |
| 508 | 508 | if(keyspace != null) { |
| 509 | - // Temporarily extend read timeout to 1 minute to accommodate keyspaces with many tables. | |
| 510 | - // This should be more than enough although some tests create many tables, so dropping a keyspace | |
| 511 | - // could take as long as 12 seconds on restricted hardware. | |
| 509 | + logger.debug("Removing keyspace {}.", keyspace); | |
| 510 | + // Temporarily extend read timeout to 1 minute to accommodate dropping keyspaces and | |
| 511 | + // tables being slow, particularly in a CI environment. | |
| 512 | 512 | int currentTimeout = cluster.getConfiguration().getSocketOptions().getReadTimeoutMillis(); |
| 513 | 513 | cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(60000); |
| 514 | 514 | try { |
| 515 | + KeyspaceMetadata ksm = cluster.getMetadata().getKeyspace(keyspace); | |
| 516 | + if (ksm != null) { | |
| 517 | + // drop each table individually as this seems to be more dependable than dropping | |
| 518 | + // the entire keyspace at once if it has many tables. | |
| 519 | + if(ksm.getTables().size() > 10) { | |
| 520 | + for (TableMetadata table : ksm.getTables()) { | |
| 521 | + logger.debug("Dropping table {}.{}.", keyspace, table.getName()); | |
| 522 | + session.execute("DROP TABLE " + keyspace + "." + table.getName()); | |
| 523 | + } | |
| 524 | + } | |
| 525 | + } | |
| 526 | + logger.debug("Dropping keyspace {}.", keyspace); | |
| 515 | 527 | session.execute("DROP KEYSPACE " + keyspace); |
| 516 | 528 | } finally { |
| 517 | 529 | cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(currentTimeout); |
| 518 | 530 | } |
| 519 | 531 | } |
| 520 | 532 | } |
| 521 | - | |
| 522 | 533 | } |
| 523 | 534 | |
| 524 | 535 | public static class CCMCluster { |