private void checkHelpers(MethodInfo mi, Class<? extends Annotation> annClass) { // OK to have these annotation for @State objects if (BenchmarkGeneratorUtils.getAnnSuper(mi.getDeclaringClass(), State.class) == null) { if (!mi.getDeclaringClass().isAbstract()) { throw new GenerationException( "@" + TearDown.class.getSimpleName() + " annotation is placed within " + "the class not having @" + State.class.getSimpleName() + " annotation. " + "This has no behavioral effect, and prohibited.", mi); } } if (!mi.isPublic()) { throw new GenerationException( "@" + annClass.getSimpleName() + " method should be public.", mi); } if (!mi.getReturnType().equalsIgnoreCase("void")) { throw new GenerationException( "@" + annClass.getSimpleName() + " method should not return anything.", mi); } }
@TearDown(Level.Trial) public void tearDownLATEST() { // this name ensures this is the latest teardown to run Assert.assertEquals("Setup1 called once", 1, countSetupRun1.get()); Assert.assertEquals("Setup2 called once", 1, countSetupRun2.get()); Assert.assertEquals("Setup3 called twice", 2, countSetupIteration1.get()); Assert.assertEquals("Setup4 called twice", 2, countSetupIteration2.get()); // These asserts make no sense for Benchmark tests // Assert.assertEquals("Setup5 = invocation count", countInvocations.get(), countSetupInvocation1.get()); // Assert.assertEquals("Setup6 = invocation count", countInvocations.get(), countSetupInvocation2.get()); Assert.assertEquals("TearDown1 called once", 1, countTearDownRun1.get()); Assert.assertEquals("TearDown2 called once", 1, countTearDownRun2.get()); Assert.assertEquals("TearDown3 called twice", 2, countTearDownIteration1.get()); Assert.assertEquals("TearDown4 called twice", 2, countTearDownIteration2.get()); // These two asserts make no sense for Benchmark tests. // Assert.assertEquals("TearDown5 = invocation count", countInvocations.get(), countTearDownInvocation1.get()); // Assert.assertEquals("TearDown6 = invocation count", countInvocations.get(), countTearDownInvocation2.get()); }
@TearDown(Level.Invocation) public void afterInvocation() { if (invocation == 0) { // Only need to check the first invocation invocation++; for (int i = 0; i < nodes.length; i++) { if (nodes[i] != originalNodes[i]) { throw new InternalError(String.format("Benchmark method mutated node %d: original=%s, current=%s", i, originalNodes[i], nodes[i])); } } } }
/** * Ensures Accumulo and test are cleaned up. */ @TearDown(Level.Trial) public void teardownTrial() throws Exception { for (String table : tables) { AccumuloInstance.deleteTable(table); } AccumuloInstance.teardown(); }
@TearDown(Level.Iteration) public void tearDownIteration() { storage.write((NoResult.Quiet) storeProvider -> { storeProvider.getJobUpdateStore().deleteAllUpdatesAndEvents(); storeProvider.getLockStore().deleteLocks(); }); }
@TearDown public void dumpMetrics() throws Exception { // enable when using yourkit for single runs // if (controller != null) { // controller.captureSnapshot(Controller.SNAPSHOT_WITH_HEAP); // } final MetricRegistry metrics = injector.getInstance(MetricRegistry.class); // make the registry available to the profiler metricRegistry = metrics; final ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics) .outputTo(new PrintStream("/tmp/bench-" + directoryName + ".txt")) .build(); reporter.report(); }
@TearDown(Level.Trial) public void tearDown() { byteData.free(); byteCmpData.free(); shortData.free(); shortCmpData.free(); intData.free(); intCmpData.free(); longData.free(); longCmpData.free(); }
@TearDown(Level.Trial) public void cleanup() throws IOException { indexMemCache.close(); packMemCache.close(); System.gc(); FileUtils.deleteDirectory(workDir.toFile()); }
@TearDown public void detroyTestEnvironment() throws IOException, InterruptedException { clientTransport.close(); tcpAcceptor.close(); serverIOReactor.close(); clientIOReactor.close(); }
@TearDown public void detroyTestEnvironment() throws Exception { clientTransport.close(); serverTransport.close(); if (serverIOReactor != null) { serverIOReactor.close(); } if (clientIOReactor != null) { clientIOReactor.close(); } }
@TearDown public void detroyTestEnvironment() throws IOException, InterruptedException { clientTransport.close(); tcpAcceptor.close(); serverIOReactor.close(); if (clientIOReactor != null) { clientIOReactor.close(); } }
/** * We want to always start with an empty inbound. Iteration tear downs are synchronized. */ @TearDown(Level.Iteration) public void clear() { // SPSC -> consumer must clear the queue in.clear(); ping = in; pong = out; }
/** * We want to always start with an empty inbound. Iteration tear downs are synchronized. */ @TearDown(Level.Iteration) public void clear() { // SPSC -> consumer must clear the queue end.clear(); ping = start; pong = end; }
@TearDown(Level.Iteration) public void emptyQ() { if (marker.get() == null) return; // sadly the iteration tear down is performed from each participating thread, so we need to guess // which is which (can't have concurrent access to poll). while (q.poll() != null) ; }
@TearDown(Level.Iteration) public void validate() { for (String pattern : sample.getPattern()) { List<Integer> result = results.get(pattern); sample.validate(pattern, result); } }
@TearDown(Level.Invocation) public void tearDown() throws Exception { resolver.shutDownResolver(); assert results != null && results.size() == largeRound.numberOfTasks() : "Results should have size " + largeRound.numberOfTasks() + " but has " + results; }
/** * @throws Exception If failed. */ @TearDown public void tearDown() throws Exception { tree.destroy(); pageMem.stop(); }
@TearDown(Level.Trial) public void teardown() throws Exception { this.client.shutdown(false); for (TChannel server : servers) { server.shutdown(false); } }
@TearDown(Level.Trial) public void tearDown() { Assert.assertTrue("Trial(D) < Trial(1)", runD < run1); Assert.assertTrue("Trial(1) < Trial(2)", run1 < run2); Assert.assertTrue("Trial(2) < Trial(3)", run2 < run3); Assert.assertTrue("Iter(D) < Iter(1)", iterD < iter1); Assert.assertTrue("Iter(1) < Iter(2)", iter1 < iter2); Assert.assertTrue("Iter(2) < Iter(3)", iter2 < iter3); Assert.assertTrue("Invoc(D) < Invoc(1)", invocD < invoc1); Assert.assertTrue("Invoc(1) < Invoc(2)", invoc1 < invoc2); Assert.assertTrue("Invoc(2) < Invoc(3)", invoc2 < invoc3); }
@TearDown(Level.Trial) public void teardownZZZ() { // should perform last Assert.assertFalse("Test sanity", testInvocationThread.isEmpty()); Assert.assertTrue("test <: setupRun", testInvocationThread.containsAll(setupRunThread)); Assert.assertTrue("test <: setupIteration", testInvocationThread.containsAll(setupIterationThread)); Assert.assertTrue("test <: setupInvocation", testInvocationThread.containsAll(setupInvocationThread)); Assert.assertTrue("test <: teardownRun", testInvocationThread.containsAll(teardownRunThread)); Assert.assertTrue("test <: teardownIteration", testInvocationThread.containsAll(teardownIterationThread)); Assert.assertTrue("test <: teardownInvocation", testInvocationThread.containsAll(teardownInvocationThread)); }
/** * Stop the running calls then stop the server and client channels. */ @Override @TearDown(Level.Trial) public void teardown() throws Exception { completed.set(true); if (!latch.await(5, TimeUnit.SECONDS)) { logger.warning("Failed to shutdown all calls."); } super.teardown(); }
@TearDown(Level.Trial) public void tearDownRun() { if (teardownRunThread == null) { teardownRunThread = Thread.currentThread(); } Assert.assertEquals("teardownRun", teardownRunThread, Thread.currentThread()); }
@TearDown(Level.Iteration) public void tearDownIter() { if(isWarmup()) { Assert.assertEquals(WARMUP_BATCH + " batch size expected", WARMUP_BATCH, batchCount.get()); } else { Assert.assertEquals(MEASUREMENT_BATCH + " batch size expected", MEASUREMENT_BATCH, batchCount.get()); } }
/** * Stop the running calls then stop the server and client channels. */ @Override @TearDown(Level.Trial) public void teardown() throws Exception { completed.set(true); Thread.sleep(5000); super.teardown(); }
@TearDown(Level.Trial) public void tearDownInstance() { tickTearInstance = TICKER.incrementAndGet(); Assert.assertTrue("Setup/instance called before setup/iteration", tickSetInstance < tickSetIteration); Assert.assertTrue("Setup/iteration called before setup/invocation", tickSetIteration < tickSetInvocation); Assert.assertTrue("Setup/invocation called before run", tickSetInvocation < tickRun); Assert.assertTrue("Run called before tear/invocation", tickRun < tickTearInvocation); Assert.assertTrue("Tear/invocation called before tear/iteration", tickTearInvocation < tickTearIteration); Assert.assertTrue("Tear/iteration called before tear/instance", tickTearIteration < tickTearInstance); }
@TearDown(Level.Iteration) public void stop() { //We're NOT testing the time it take to process the log record, only how much //time an application spends submitting them. ((AsyncLogHandler) log.getHandlers()[0]).clearBacklog(); }
@TearDown public void tearDown() { System.setSecurityManager(null); }
@TearDown public synchronized void tearDown() { for (Counter c : all) { c.dispose(); } }
@TearDown(Level.Iteration) public void teardown() { validatorFactory.close(); }
@TearDown public void destroy() throws Exception { repo.close(); Util.deleteFileTree(repoDir); }
@TearDown public void tearDown() { nodes.forEach(n -> n.leaveAsync().join()); }
@TearDown(Level.Iteration) public void teardown() throws SQLException { connection.close(); }