keith-turner commented on code in PR #4051:
URL: https://github.com/apache/accumulo/pull/4051#discussion_r1422814477
##########
test/src/main/java/org/apache/accumulo/test/ScanConsistencyIT.java:
##########
@@ -104,69 +150,97 @@ public void testConcurrentScanConsistency() throws
Exception {
// getClusterControl().stopAllServers(ServerType.GARBAGE_COLLECTOR);
var executor = Executors.newCachedThreadPool();
- try (AccumuloClient client =
Accumulo.newClient().from(getClientProps()).build()) {
- client.tableOperations().create(table);
+ client.tableOperations().create(table);
- TestContext testContext = new TestContext(client, table,
getCluster().getFileSystem(),
- getCluster().getTemporaryPath().toString());
+ TestContext testContext = new TestContext(client, table, fileSystem,
tmpDir);
- List<Future<WriteStats>> writeTasks = new ArrayList<>();
- List<Future<ScanStats>> scanTasks = new ArrayList<>();
+ List<Future<WriteStats>> writeTasks = new ArrayList<>();
+ List<Future<ScanStats>> scanTasks = new ArrayList<>();
- Random random = new Random();
+ Random random = new Random();
- int numWriteTask = random.nextInt(10) + 1;
- int numsScanTask = random.nextInt(10) + 1;
+ int numWriteTask = random.nextInt(10) + 1;
+ int numsScanTask = random.nextInt(10) + 1;
- for (int i = 0; i < numWriteTask; i++) {
- writeTasks.add(executor.submit(new WriteTask(testContext)));
- }
+ for (int i = 0; i < numWriteTask; i++) {
+ writeTasks.add(executor.submit(new WriteTask(testContext)));
+ }
- for (int i = 0; i < numsScanTask; i++) {
- scanTasks.add(executor.submit(new ScanTask(testContext)));
- }
+ for (int i = 0; i < numsScanTask; i++) {
+ scanTasks.add(executor.submit(new ScanTask(testContext)));
+ }
- var tableOpsTask = executor.submit(new TableOpsTask(testContext));
+ var tableOpsTask = executor.submit(new TableOpsTask(testContext));
- // let the concurrent mayhem run for a bit
- Thread.sleep(60000);
+ // let the concurrent mayhem run for a bit
+ Thread.sleep(60000);
- // let the threads know to exit
- testContext.keepRunning.set(false);
+ // let the threads know to exit
+ testContext.keepRunning.set(false);
- for (Future<WriteStats> writeTask : writeTasks) {
- var stats = writeTask.get();
- log.debug(String.format("Wrote:%,d Bulk imported:%,d Deleted:%,d Bulk
deleted:%,d",
- stats.written, stats.bulkImported, stats.deleted,
stats.bulkDeleted));
- assertTrue(stats.written + stats.bulkImported > 0);
- assertTrue(stats.deleted + stats.bulkDeleted > 0);
- }
+ for (Future<WriteStats> writeTask : writeTasks) {
+ var stats = writeTask.get();
+ log.debug(String.format("Wrote:%,d Bulk imported:%,d Deleted:%,d Bulk
deleted:%,d",
+ stats.written, stats.bulkImported, stats.deleted,
stats.bulkDeleted));
+ checkTrue(stats.written + stats.bulkImported > 0);
+ checkTrue(stats.deleted + stats.bulkDeleted > 0);
+ }
- for (Future<ScanStats> scanTask : scanTasks) {
- var stats = scanTask.get();
- log.debug(String.format("Scanned:%,d verified:%,d", stats.scanned,
stats.verified));
- assertTrue(stats.verified > 0);
- // These scans were running concurrently with writes, so a scan will
see more data than what
- // was written before the scan started.
- assertTrue(stats.scanned > stats.verified);
- }
+ for (Future<ScanStats> scanTask : scanTasks) {
+ var stats = scanTask.get();
+ log.debug(String.format("Scanned:%,d verified:%,d", stats.scanned,
stats.verified));
+ checkTrue(stats.verified > 0);
+ // These scans were running concurrently with writes, so a scan will see
more data than what
+ // was written before the scan started.
+ checkTrue(stats.scanned > stats.verified);
+ }
+
+ log.debug(tableOpsTask.get());
+
+ var stats1 = scanData(testContext, random, new Range(), false);
+ var stats2 = scanData(testContext, random, new Range(), true);
+ var stats3 = batchScanData(testContext, new Range());
+ log.debug(
+ String.format("Final scan, scanned:%,d verified:%,d", stats1.scanned,
stats1.verified));
+ checkTrue(stats1.verified > 0);
+ // Should see all expected data now that there are no concurrent writes
happening
+ checkEquals(stats1.scanned, stats1.verified);
+ checkEquals(stats2.scanned, stats1.scanned);
+ checkEquals(stats2.verified, stats1.verified);
+ checkEquals(stats3.scanned, stats1.scanned);
+ checkEquals(stats3.verified, stats1.verified);
+
+ executor.shutdownNow();
Review Comment:
Would be good to shutdown this executor in a finally block still.
##########
test/src/main/java/org/apache/accumulo/test/ScanConsistencyIT.java:
##########
@@ -104,69 +150,97 @@ public void testConcurrentScanConsistency() throws
Exception {
// getClusterControl().stopAllServers(ServerType.GARBAGE_COLLECTOR);
var executor = Executors.newCachedThreadPool();
- try (AccumuloClient client =
Accumulo.newClient().from(getClientProps()).build()) {
- client.tableOperations().create(table);
+ client.tableOperations().create(table);
- TestContext testContext = new TestContext(client, table,
getCluster().getFileSystem(),
- getCluster().getTemporaryPath().toString());
+ TestContext testContext = new TestContext(client, table, fileSystem,
tmpDir);
- List<Future<WriteStats>> writeTasks = new ArrayList<>();
- List<Future<ScanStats>> scanTasks = new ArrayList<>();
+ List<Future<WriteStats>> writeTasks = new ArrayList<>();
+ List<Future<ScanStats>> scanTasks = new ArrayList<>();
- Random random = new Random();
+ Random random = new Random();
- int numWriteTask = random.nextInt(10) + 1;
- int numsScanTask = random.nextInt(10) + 1;
+ int numWriteTask = random.nextInt(10) + 1;
+ int numsScanTask = random.nextInt(10) + 1;
- for (int i = 0; i < numWriteTask; i++) {
- writeTasks.add(executor.submit(new WriteTask(testContext)));
- }
+ for (int i = 0; i < numWriteTask; i++) {
+ writeTasks.add(executor.submit(new WriteTask(testContext)));
+ }
- for (int i = 0; i < numsScanTask; i++) {
- scanTasks.add(executor.submit(new ScanTask(testContext)));
- }
+ for (int i = 0; i < numsScanTask; i++) {
+ scanTasks.add(executor.submit(new ScanTask(testContext)));
+ }
- var tableOpsTask = executor.submit(new TableOpsTask(testContext));
+ var tableOpsTask = executor.submit(new TableOpsTask(testContext));
- // let the concurrent mayhem run for a bit
- Thread.sleep(60000);
+ // let the concurrent mayhem run for a bit
+ Thread.sleep(60000);
- // let the threads know to exit
- testContext.keepRunning.set(false);
+ // let the threads know to exit
+ testContext.keepRunning.set(false);
- for (Future<WriteStats> writeTask : writeTasks) {
- var stats = writeTask.get();
- log.debug(String.format("Wrote:%,d Bulk imported:%,d Deleted:%,d Bulk
deleted:%,d",
- stats.written, stats.bulkImported, stats.deleted,
stats.bulkDeleted));
- assertTrue(stats.written + stats.bulkImported > 0);
- assertTrue(stats.deleted + stats.bulkDeleted > 0);
- }
+ for (Future<WriteStats> writeTask : writeTasks) {
+ var stats = writeTask.get();
+ log.debug(String.format("Wrote:%,d Bulk imported:%,d Deleted:%,d Bulk
deleted:%,d",
+ stats.written, stats.bulkImported, stats.deleted,
stats.bulkDeleted));
+ checkTrue(stats.written + stats.bulkImported > 0);
Review Comment:
Do you know what happens if assertTrue is called outside of a junit test?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]