@Override public void createCatalog(String catalogName, String connectorName, Map<String, String> properties) { long start = System.nanoTime(); Set<ConnectorId> connectorIds = new HashSet<>(); for (TestingPrestoServer server : servers) { connectorIds.add(server.createCatalog(catalogName, connectorName, properties)); } ConnectorId connectorId = getOnlyElement(connectorIds); log.info("Created catalog %s (%s) in %s", catalogName, connectorId, nanosSince(start)); // wait for all nodes to announce the new catalog start = System.nanoTime(); while (!isConnectionVisibleToAllNodes(connectorId)) { Assertions.assertLessThan(nanosSince(start), new Duration(100, SECONDS), "waiting for connector " + connectorId + " to be initialized in every node"); try { MILLISECONDS.sleep(10); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } } log.info("Announced catalog %s (%s) in %s", catalogName, connectorId, nanosSince(start)); }
@Test public void testReserved() { for (StandardErrorCode errorCode : StandardErrorCode.values()) { assertLessThan(code(errorCode), EXTERNAL_ERROR_START); } }
static void waitForNodeRefresh(TestingPrestoServer server) throws InterruptedException { long start = System.nanoTime(); while (server.refreshNodes().getActiveNodes().size() < 1) { assertLessThan(nanosSince(start), new Duration(10, SECONDS)); MILLISECONDS.sleep(10); } }
@Test(dataProvider = "provideStandardErrors") public void testMultiplePositions(double maxStandardError) { DescriptiveStatistics stats = new DescriptiveStatistics(); for (int i = 0; i < 500; ++i) { int uniques = ThreadLocalRandom.current().nextInt(getUniqueValuesCount()) + 1; List<Object> values = createRandomSample(uniques, (int) (uniques * 1.5)); long actual = estimateGroupByCount(values, maxStandardError); double error = (actual - uniques) * 1.0 / uniques; stats.addValue(error); } assertLessThan(stats.getMean(), 1.0e-2); assertLessThan(stats.getStandardDeviation(), 1.0e-2 + maxStandardError); }
private void waitForNodes(int numberOfNodes) throws InterruptedException { DistributedQueryRunner queryRunner = (DistributedQueryRunner) getQueryRunner(); long start = System.nanoTime(); while (queryRunner.getCoordinator().refreshNodes().getActiveNodes().size() < numberOfNodes) { assertLessThan(nanosSince(start), new Duration(10, SECONDS)); MILLISECONDS.sleep(10); } } }
Assertions.assertLessThan(nanosSince(start), new Duration(10, SECONDS)); MILLISECONDS.sleep(10);
public static void waitForGlobalResourceGroup(DistributedQueryRunner queryRunner) throws InterruptedException { long startTime = System.nanoTime(); while (true) { SECONDS.sleep(1); ResourceGroupInfo global = getResourceGroupManager(queryRunner).getResourceGroupInfo(new ResourceGroupId("global")); if (global.getSoftMemoryLimit().toBytes() > 0) { break; } assertLessThan(nanosSince(startTime).roundTo(SECONDS), 60L); } }
int lowerBound = binomial.inverseCumulativeProbability(0.000001); int upperBound = binomial.inverseCumulativeProbability(0.999999); assertLessThan(foo, upperBound); assertGreaterThan(foo, lowerBound); lowerBound = binomial.inverseCumulativeProbability(0.000001); upperBound = binomial.inverseCumulativeProbability(0.999999); assertLessThan(foo, upperBound); assertGreaterThan(foo, lowerBound);
@Test public void testSingleDictionaryColumnByteLimit() { int bytesPerEntry = 1024; int dictionaryEntries = 1024; TestDictionaryColumn column = dictionaryColumn(bytesPerEntry, dictionaryEntries); // construct a simulator that will hit the row limit first int stripeMaxBytes = megabytes(100); int bytesPerRow = estimateIndexBytesPerValue(dictionaryEntries); int expectedMaxRowCount = stripeMaxBytes / bytesPerRow; DataSimulator simulator = new DataSimulator(0, stripeMaxBytes, expectedMaxRowCount * 10, megabytes(16), 0, column); for (int loop = 0; loop < 3; loop++) { assertFalse(simulator.isDictionaryMemoryFull()); assertFalse(column.isDirect()); assertEquals(simulator.getRowCount(), 0); assertEquals(simulator.getBufferedBytes(), 0); simulator.advanceToNextStateChange(); // since there dictionary columns is only 1 MB, the simulator should advance until the strip is full assertFalse(simulator.isDictionaryMemoryFull()); assertFalse(column.isDirect()); assertGreaterThanOrEqual(simulator.getBufferedBytes(), (long) stripeMaxBytes); assertLessThan(simulator.getRowCount(), expectedMaxRowCount); simulator.finalOptimize(); assertFalse(simulator.isDictionaryMemoryFull()); assertFalse(column.isDirect()); assertGreaterThanOrEqual(simulator.getBufferedBytes(), (long) stripeMaxBytes); assertLessThan(simulator.getRowCount(), expectedMaxRowCount); simulator.reset(); } }
assertLessThan(simulator.getBufferedBytes(), (long) stripeMaxBytes); assertGreaterThanOrEqual(simulator.getRowCount(), expectedMaxRowCount); assertLessThan(simulator.getBufferedBytes(), (long) stripeMaxBytes); assertGreaterThanOrEqual(simulator.getRowCount(), expectedMaxRowCount);
assertLessThan(simulator.getBufferedBytes(), (long) stripeMaxBytes); assertGreaterThanOrEqual(simulator.getRowCount(), expectedMaxRowCount); assertLessThan(simulator.getBufferedBytes(), (long) stripeMaxBytes); assertGreaterThanOrEqual(simulator.getRowCount(), expectedMaxRowCount);
assertTrue(directColumn.isDirect()); assertFalse(dictionaryColumn.isDirect()); assertLessThan(simulator.getBufferedBytes(), (long) stripeMaxBytes); assertGreaterThanOrEqual(simulator.getRowCount(), expectedRowCountAtFlip);
assertLessThan(simulator.getBufferedBytes(), (long) stripeMaxBytes); assertGreaterThanOrEqual(simulator.getRowCount(), expectedRowCountAtFlip);
assertLessThan(simulator.getBufferedBytes(), (long) stripeMaxBytes); assertGreaterThanOrEqual(simulator.getRowCount(), expectedRowCountAtFlip);
assertLessThan(Duration.nanosSince(start), new Duration(5, TimeUnit.SECONDS)); sleepUninterruptibly(100, MILLISECONDS); assertLessThan(Duration.nanosSince(start), new Duration(5, TimeUnit.SECONDS)); sleepUninterruptibly(100, MILLISECONDS); assertLessThan(Duration.nanosSince(start), new Duration(5, TimeUnit.SECONDS)); sleepUninterruptibly(100, MILLISECONDS);
int lowerBound = binomial.inverseCumulativeProbability(0.000001); int upperBound = binomial.inverseCumulativeProbability(0.999999); assertLessThan(group2Ran, upperBound); assertGreaterThan(group2Ran, lowerBound);
assertLessThan(higherLevelTime, (lowerLevelTime * 2) + 10);
assertLessThan(additionalMemoryInBytes, 1L << 21, "additionalMemoryInBytes should be a relatively small number"); List<Page> result = new LinkedList<>(); assertLessThan(actualIncreasedMemory, additionalMemoryInBytes);
@SuppressWarnings({"unchecked", "rawtypes"}) public void passLessThan(Comparable actual, Comparable expected) { assertLessThan(actual, expected); assertLessThan(actual, expected, MESSAGE); }
static void waitForNodeRefresh(TestingPrestoServer server) throws InterruptedException { long start = System.nanoTime(); while (server.refreshNodes().getActiveNodes().size() < 1) { assertLessThan(nanosSince(start), new Duration(10, SECONDS)); MILLISECONDS.sleep(10); } }