@Test public void testCreateSchema() { assertEquals(metadata.listSchemaNames(SESSION), ImmutableList.of("default")); metadata.createSchema(SESSION, "test", ImmutableMap.of()); assertEquals(metadata.listSchemaNames(SESSION), ImmutableList.of("default", "test")); }
result.setEnabled(test.enabled()); result.setGroups(join(test.groups(), findInheritedStringArray(cls, Test.class, "groups"))); result.setParameters(test.parameters()); result.setDependsOnGroups(join(test.dependsOnGroups(), findInheritedStringArray(cls, Test.class, "dependsOnGroups"))); result.setDependsOnMethods(join(test.dependsOnMethods(), findInheritedStringArray(cls, Test.class, "dependsOnMethods"))); result.setTimeOut(test.timeOut()); result.setInvocationTimeOut(test.invocationTimeOut()); result.setInvocationCount(test.invocationCount()); result.setThreadPoolSize(test.threadPoolSize()); result.setSuccessPercentage(test.successPercentage()); result.setDataProvider(test.dataProvider()); findInherited(test.dataProviderClass(), cls, Test.class, "dataProviderClass", DEFAULT_CLASS)); result.setAlwaysRun(test.alwaysRun()); result.setDescription( findInherited(test.description(), cls, Test.class, "description", DEFAULT_STRING)); result.setExpectedExceptions(test.expectedExceptions()); result.setExpectedExceptionsMessageRegExp(test.expectedExceptionsMessageRegExp()); result.setSuiteName(test.suiteName()); result.setTestName(test.testName()); result.setSequential(test.sequential()); result.setSingleThreaded(test.singleThreaded()); result.setRetryAnalyzer(test.retryAnalyzer()); result.setSkipFailedInvocations(test.skipFailedInvocations()); result.setIgnoreMissingDependencies(test.ignoreMissingDependencies()); result.setPriority(test.priority());
@Test public void testIntersectsWithEquiClause() { assertPlan("SELECT b.name, a.name " + "FROM (VALUES ('POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))', 'a')) AS a (wkt, name), (VALUES ('POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))', 'a')) AS b (wkt, name) " + "WHERE a.name = b.name AND ST_Intersects(ST_GeometryFromText(a.wkt), ST_GeometryFromText(b.wkt))", anyTree( join(JoinNode.Type.INNER, ImmutableList.of(equiJoinClause("name_a", "name_b")), Optional.of("ST_Intersects(ST_GeometryFromText(cast(wkt_a as varchar)), ST_GeometryFromText(cast(wkt_B as varchar)))"), anyTree(values(ImmutableMap.of("wkt_a", 0, "name_a", 1))), anyTree(values(ImmutableMap.of("wkt_b", 0, "name_b", 1)))))); }
@Test public void testProjectNoColumns() { PageProcessor pageProcessor = new PageProcessor(Optional.empty(), ImmutableList.of(), OptionalInt.of(MAX_BATCH_SIZE)); Page inputPage = new Page(createLongSequenceBlock(0, 100)); Iterator<Optional<Page>> output = processAndAssertRetainedPageSize(pageProcessor, inputPage); List<Optional<Page>> outputPages = ImmutableList.copyOf(output); assertEquals(outputPages.size(), 1); Page outputPage = outputPages.get(0).orElse(null); assertEquals(outputPage.getChannelCount(), 0); assertEquals(outputPage.getPositionCount(), inputPage.getPositionCount()); }
@Test public void testGroupingOperationSomeBitsSet() { List<Integer> groupingOrdinals = ImmutableList.of(7, 2, 9, 3, 5); List<Set<Integer>> groupingSetOrdinals = ImmutableList.of(ImmutableSet.of(4, 2), ImmutableSet.of(9, 7, 14), ImmutableSet.of(5, 2, 7), ImmutableSet.of(3)); List<Long> expectedResults = ImmutableList.of(23L, 11L, 6L, 29L); for (int groupId = 0; groupId < groupingSetOrdinals.size(); groupId++) { Set<Integer> groupingSet = groupingSetOrdinals.get(groupId); assertEquals(Long.valueOf(calculateGrouping(groupingSet, groupingOrdinals)), expectedResults.get(groupId)); } }
@Test public void testGetAllTable() { assertEquals(mockClient.getAccessCount(), 0); assertEquals(metastore.getAllTables(TEST_DATABASE).get(), ImmutableList.of(TEST_TABLE)); assertEquals(mockClient.getAccessCount(), 1); assertEquals(metastore.getAllTables(TEST_DATABASE).get(), ImmutableList.of(TEST_TABLE)); assertEquals(mockClient.getAccessCount(), 1); metastore.flushCache(); assertEquals(metastore.getAllTables(TEST_DATABASE).get(), ImmutableList.of(TEST_TABLE)); assertEquals(mockClient.getAccessCount(), 2); }
@Test public void testNoCaching() { ImmutableList.Builder<RowExpression> projectionsBuilder = ImmutableList.builder(); ArrayType arrayType = new ArrayType(VARCHAR); Signature signature = new Signature("concat", SCALAR, arrayType.getTypeSignature(), arrayType.getTypeSignature(), arrayType.getTypeSignature()); projectionsBuilder.add(new CallExpression(signature, arrayType, ImmutableList.of(field(0, arrayType), field(1, arrayType)))); ImmutableList<RowExpression> projections = projectionsBuilder.build(); PageProcessor pageProcessor = compiler.compilePageProcessor(Optional.empty(), projections).get(); PageProcessor pageProcessor2 = compiler.compilePageProcessor(Optional.empty(), projections).get(); assertTrue(pageProcessor != pageProcessor2); }
@Test public void testNullWithDescription() { CreateSnapshotOptions options = new CreateSnapshotOptions(); assertEquals(options.buildFormParameters().get("Description"), ImmutableList.of()); }
@Test(timeOut = 60 * 1000) public void testTopologyAwareScheduling() throws Exception InMemoryNodeManager nodeManager = new InMemoryNodeManager(); ImmutableList.Builder<Node> nodeBuilder = ImmutableList.builder(); nodeBuilder.add(new PrestoNode("node1", URI.create("http://host1.rack1:11"), NodeVersion.UNKNOWN, false)); nodeBuilder.add(new PrestoNode("node2", URI.create("http://host2.rack1:12"), NodeVersion.UNKNOWN, false)); ImmutableSet.Builder<Split> nonRackLocalBuilder = ImmutableSet.builder(); for (int i = 0; i < (25 + 11) * 3; i++) { nonRackLocalBuilder.add(new Split(CONNECTOR_ID, transactionHandle, new TestSplitRemote(HostAddress.fromParts("data.other_rack", 1)))); nonRackLocalSplits = Sets.difference(nonRackLocalSplits, new HashSet<>(assignments.values())); assertEquals(nonRackLocalSplits.size(), 3); ImmutableSet.Builder<Split> rackLocalSplits = ImmutableSet.builder(); HostAddress dataHost1 = HostAddress.fromParts("data.rack1", 1); HostAddress dataHost2 = HostAddress.fromParts("data.rack2", 1); assertEquals(unassigned.size(), 3); int rack1 = 0; int rack2 = 0;
@Test public void testMaxSplitsPerNodePerTask() nodeManager.addNode(CONNECTOR_ID, newNode); ImmutableList.Builder<Split> initialSplits = ImmutableList.builder(); for (int i = 0; i < 20; i++) { initialSplits.add(new Split(CONNECTOR_ID, transactionHandle, new TestSplitRemote())); splits.add(new Split(CONNECTOR_ID, transactionHandle, new TestSplitRemote())); Multimap<Node, Split> assignments = nodeSelector.computeAssignments(splits, ImmutableList.copyOf(taskMap.values())).getAssignments(); assertEquals(assignments.keySet().size(), 3); // Splits should be scheduled on the other three nodes assertFalse(assignments.keySet().contains(newNode)); // No splits scheduled on the maxed out node assertEquals(nodeTaskMap.getPartitionedSplitsOnNode(newNode), 0);
@Test public void testTableSampleBernoulli() { DescriptiveStatistics stats = new DescriptiveStatistics(); int total = computeExpected("SELECT orderkey FROM orders", ImmutableList.of(BIGINT)).getMaterializedRows().size(); for (int i = 0; i < 100; i++) { List<MaterializedRow> values = computeActual("SELECT orderkey FROM orders TABLESAMPLE BERNOULLI (50)").getMaterializedRows(); assertEquals(values.size(), ImmutableSet.copyOf(values).size(), "TABLESAMPLE produced duplicate rows"); stats.addValue(values.size() * 1.0 / total); } double mean = stats.getGeometricMean(); assertTrue(mean > 0.45 && mean < 0.55, format("Expected mean sampling rate to be ~0.5, but was %s", mean)); }
@Test public void testScheduleLocal() { Split split = new Split(CONNECTOR_ID, TestingTransactionHandle.create(), new TestSplitLocal()); Set<Split> splits = ImmutableSet.of(split); Map.Entry<Node, Split> assignment = Iterables.getOnlyElement(nodeSelector.computeAssignments(splits, ImmutableList.copyOf(taskMap.values())).getAssignments().entries()); assertEquals(assignment.getKey().getHostAndPort(), split.getAddresses().get(0)); assertEquals(assignment.getValue(), split); }
@Test(dataProvider = "owningModeAndReadMethod") public void testReadsAfterMods(boolean isOwner, ReadMethod method) throws Exception { Object KEY = getKey(isOwner, DIST); cache(0, DIST).put(KEY, "a"); tm.begin(); assertEquals("a", rw.eval(KEY, append("b")).join()); assertEquals("ab", rw.evalMany(Collections.singleton(KEY), append("c")).findAny().get()); assertEquals(null, rw.eval("otherKey", append("d")).join()); assertEquals("abc", method.eval(KEY, ro, MarshallableFunctions.returnReadOnlyFindOrNull())); tm.commit(); }
@Test public void testBasicAssignment() { // One split for each node Set<Split> splits = new HashSet<>(); for (int i = 0; i < 3; i++) { splits.add(new Split(CONNECTOR_ID, TestingTransactionHandle.create(), new TestSplitRemote())); } Multimap<Node, Split> assignments = nodeSelector.computeAssignments(splits, ImmutableList.copyOf(taskMap.values())).getAssignments(); assertEquals(assignments.entries().size(), 3); for (Node node : nodeManager.getActiveConnectorNodes(CONNECTOR_ID)) { assertTrue(assignments.keySet().contains(node)); } }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Final aggregation with default value not separated from partial aggregation by remote hash exchange") public void testGloballyDistributedFinalAggregationInTheSameStageAsPartialAggregation() { PlanNode root = builder.aggregation( af -> af.step(FINAL) .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) .source(builder.aggregation(ap -> ap .step(PARTIAL) .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) .source(tableScanNode)))); validatePlan(root, false); }
@Test public void testExtensionShort() throws Exception { Session session = getFactory().openSession(); QName valueName = new QName(NS_P, "shortType"); ItemDefinition def = getDefinition(GenericObjectType.class, ItemPath.create(ObjectType.F_EXTENSION, valueName)); AssertJUnit.assertNotNull(def); Element value = DOMUtil.createElement(DOMUtil.getDocument(), valueName); value.setTextContent("123"); Object realValue = RAnyConverter.getRealRepoValue(def, value, prismContext); AssertJUnit.assertEquals(123L, realValue); session.close(); }
@Test public void testScheduleRemote() { Set<Split> splits = new HashSet<>(); splits.add(new Split(CONNECTOR_ID, TestingTransactionHandle.create(), new TestSplitRemote())); Multimap<Node, Split> assignments = nodeSelector.computeAssignments(splits, ImmutableList.copyOf(taskMap.values())).getAssignments(); assertEquals(assignments.size(), 1); }
@Test public void testSkipEncoding() throws SecurityException, NoSuchMethodException { Invokable<?, ?> method = method(TestEncoding.class, "twoPaths", String.class, String.class); GeneratedHttpRequest request = processor.apply(Invocation.create(method, ImmutableList.<Object> of("1", "localhost"))); assertEquals(request.getEndpoint().getPath(), "/1/localhost"); assertEquals(request.getMethod(), HttpMethod.GET); assertEquals(request.getHeaders().size(), 0); }
@Test @Transactional(propagation = Propagation.NOT_SUPPORTED) void autowiringFromConfigClass() { assertNotNull(employee, "The employee should have been autowired."); assertEquals(employee.getName(), "John Smith"); assertNotNull(pet, "The pet should have been autowired."); assertEquals(pet.getName(), "Fido"); }
@Test public void testMultivaluedExtensionPropertySubstringUnqualified() throws SchemaException { ObjectQuery query = prismContext.queryFor(GenericObjectType.class) .item(ObjectType.F_EXTENSION, new QName("multivalued")).contains("slava") .build(); OperationResult result = new OperationResult("search"); List<PrismObject<GenericObjectType>> resources = repositoryService.searchObjects(GenericObjectType.class, query, null, result); result.recomputeStatus(); assertTrue(result.isSuccess()); assertEquals("Should find one object", 1, resources.size()); }