Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions amoro-common/pom.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -159,6 +159,12 @@
<classifier>core</classifier>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.amoro.shade.zookeeper3.org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.amoro.shade.zookeeper3.org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.curator.test.TestingServer;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.Random;
Expand Down Expand Up @@ -64,7 +64,7 @@ private static void init() throws Exception {
}

@Test
public void testFoobar() throws Exception {
void testFoobar() throws Exception {
System.out.println("client: " + client);
getClient().create().forPath("/test", "test-data".getBytes());

Expand Down
5 changes: 1 addition & 4 deletions amoro-common/src/test/java/org/apache/amoro/TestAms.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@

package org.apache.amoro;

import org.junit.rules.ExternalResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TestAms extends ExternalResource {
public class TestAms {
private static final Logger LOG = LoggerFactory.getLogger(TestAms.class);
private static MockAmoroManagementServer SINGLETON;

Expand Down Expand Up @@ -54,7 +53,6 @@ public MockAmoroManagementServer.OptimizerManagerHandler getOptimizerHandler() {
return mockAms.optimizerHandler();
}

@Override
public void before() throws Exception {
if (SingletonResourceUtil.isUseSingletonResource()) {
if (!mockAms.isStarted()) {
Expand All @@ -74,7 +72,6 @@ public void before() throws Exception {
}
}

@Override
public void after() {
if (!SingletonResourceUtil.isUseSingletonResource()) {
mockAms.stopAndCleanUp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,40 @@

package org.apache.amoro.client;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class TestPoolConfig {

@Test
public void testConstructFromUrl() {
void testConstructFromUrl() {
String url =
"thrift://127.0.0.1:1261?connectTimeout=5000&socketTimeout=6000&maxMessageSize=100&autoReconnect=false"
+ "&maxReconnects=3&minIdle=10&maxIdle=10&maxWaitMillis=500";
PoolConfig<?> poolConfig = PoolConfig.forUrl(url);

Assert.assertEquals(5000, poolConfig.getConnectTimeout());
Assert.assertEquals(6000, poolConfig.getSocketTimeout());
Assert.assertEquals(100, poolConfig.getMaxMessageSize());
Assert.assertFalse(poolConfig.isAutoReconnect());
Assert.assertEquals(3, poolConfig.getMaxReconnects());
Assert.assertEquals(10, poolConfig.getMinIdle());
Assert.assertEquals(10, poolConfig.getMaxIdle());
Assert.assertEquals(500, poolConfig.getMaxWaitMillis());
Assertions.assertEquals(5000, poolConfig.getConnectTimeout());
Assertions.assertEquals(6000, poolConfig.getSocketTimeout());
Assertions.assertEquals(100, poolConfig.getMaxMessageSize());
Assertions.assertFalse(poolConfig.isAutoReconnect());
Assertions.assertEquals(3, poolConfig.getMaxReconnects());
Assertions.assertEquals(10, poolConfig.getMinIdle());
Assertions.assertEquals(10, poolConfig.getMaxIdle());
Assertions.assertEquals(500, poolConfig.getMaxWaitMillis());
}

@Test
public void tetUrlParameterNameError() {
void tetUrlParameterNameError() {
// We will ignore parameters with unknown name
String url = "thrift://127.0.0.1:1261?connectTimeouts=300";
PoolConfig<?> poolConfig = PoolConfig.forUrl(url);
Assert.assertEquals(0, poolConfig.getConnectTimeout());
Assertions.assertEquals(0, poolConfig.getConnectTimeout());
}

@Test
public void testUrlFormatError() {
void testUrlFormatError() {
String url = "thrift://127.0.0.1:1261?connectTimeout=5000& ";
Assert.assertThrows(
Assertions.assertThrows(
IllegalArgumentException.class,
() -> {
PoolConfig.forUrl(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,54 @@
package org.apache.amoro.formats;

import org.apache.amoro.AmoroCatalog;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.io.TempDir;

import java.io.IOException;
import java.nio.file.Path;

public abstract class AmoroCatalogTestBase {

@Rule public TemporaryFolder temp = new TemporaryFolder();
@TempDir Path tempDir;

protected AmoroCatalogTestHelper<?> catalogTestHelper;

protected AmoroCatalog amoroCatalog;

protected Object originalCatalog;

public AmoroCatalogTestBase() {
this.catalogTestHelper = null;
}

public AmoroCatalogTestBase(AmoroCatalogTestHelper<?> catalogTestHelper) {
this.catalogTestHelper = catalogTestHelper;
}

@Before
public void setupCatalog() throws IOException {
String path = temp.newFolder().getPath();
protected AmoroCatalogTestHelper<?> createHelper() {
return null;
}

@BeforeEach
protected void setupCatalog() throws IOException {
if (catalogTestHelper == null) {
catalogTestHelper = createHelper();
if (catalogTestHelper == null) {
throw new IllegalStateException(
"catalogTestHelper must be set either via constructor or createHelper() method");
}
}
String path = tempDir.toFile().getAbsolutePath();
catalogTestHelper.initWarehouse(path);
this.amoroCatalog = catalogTestHelper.amoroCatalog();
this.originalCatalog = catalogTestHelper.originalCatalog();
}

@After
public void cleanCatalog() {
catalogTestHelper.clean();
@AfterEach
void cleanCatalog() {
if (catalogTestHelper != null) {
catalogTestHelper.clean();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import org.apache.amoro.AmoroTable;
import org.apache.amoro.shade.guava32.com.google.common.collect.Sets;
import org.apache.amoro.table.TableIdentifier;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -37,6 +37,10 @@ public abstract class TestAmoroCatalogBase extends AmoroCatalogTestBase {

private static final String TABLE = "table";

public TestAmoroCatalogBase() {
super();
}

public TestAmoroCatalogBase(AmoroCatalogTestHelper<?> catalogTestHelper) {
super(catalogTestHelper);
}
Expand All @@ -54,36 +58,36 @@ public void testListDatabases() {
createDatabase(DB2);
createDatabase(DB3);
HashSet<String> databases = Sets.newHashSet(amoroCatalog.listDatabases());
Assert.assertTrue(databases.contains(DB1));
Assert.assertTrue(databases.contains(DB2));
Assert.assertTrue(databases.contains(DB3));
Assertions.assertTrue(databases.contains(DB1));
Assertions.assertTrue(databases.contains(DB2));
Assertions.assertTrue(databases.contains(DB3));
}

@Test
public void testDropDatabases() {
createDatabase(DB1);
amoroCatalog.dropDatabase(DB1);

Assert.assertFalse(amoroCatalog.listDatabases().contains(DB1));
Assertions.assertFalse(amoroCatalog.listDatabases().contains(DB1));
}

@Test
public void testCreateDatabases() {
amoroCatalog.createDatabase(DB1);
Assert.assertTrue(listDatabases().contains(DB1));
Assertions.assertTrue(listDatabases().contains(DB1));
}

@Test
public void testExistsDatabase() {
createDatabase(DB1);
Assert.assertTrue(amoroCatalog.databaseExists(DB1));
Assertions.assertTrue(amoroCatalog.databaseExists(DB1));
}

@Test
public void testExistsTable() {
createDatabase(DB1);
createTable(DB1, TABLE, new HashMap<>());
Assert.assertTrue(amoroCatalog.tableExists(DB1, TABLE));
Assertions.assertTrue(amoroCatalog.tableExists(DB1, TABLE));
}

@Test
Expand All @@ -93,10 +97,10 @@ public void testLoadTable() {
properties.put("key1", "value1");
createTable(DB1, TABLE, properties);
AmoroTable<?> amoroTable = amoroCatalog.loadTable(DB1, TABLE);
Assert.assertEquals(amoroTable.properties().get("key1"), "value1");
Assert.assertEquals(
amoroTable.name(), catalogTestHelper.catalogName() + "." + DB1 + "." + TABLE);
Assert.assertEquals(
amoroTable.id(), TableIdentifier.of(catalogTestHelper.catalogName(), DB1, TABLE));
Assertions.assertEquals("value1", amoroTable.properties().get("key1"));
Assertions.assertEquals(
catalogTestHelper.catalogName() + "." + DB1 + "." + TABLE, amoroTable.name());
Assertions.assertEquals(
TableIdentifier.of(catalogTestHelper.catalogName(), DB1, TABLE), amoroTable.id());
}
}
Loading
Loading