forked from apache/polaris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add initial integration tests * Add gradle workflow in github * Fixed Dockerfile to create default-realm dir for sqlite * Add docker-compose and Dockerfile for regtest * Docker build in ci * Fix context in docker-compose file * Update regtest to work locally and in docker * Fix dockerfile to run gradle build * Add .keep file for output directory
- Loading branch information
1 parent
820ffd8
commit e92da9b
Showing
14 changed files
with
389 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | ||
|
||
name: Java CI with Gradle | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '21' | ||
distribution: 'temurin' | ||
|
||
# Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies. | ||
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | ||
|
||
- name: Build with Gradle Wrapper | ||
working-directory: iceberg-rest-server | ||
run: ./gradlew test | ||
|
||
# NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html). | ||
# If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version. | ||
# | ||
# - name: Setup Gradle | ||
# uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | ||
# with: | ||
# gradle-version: '8.6' | ||
# | ||
# - name: Build with Gradle 8.6 | ||
# run: gradle build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Regression Tests | ||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Regression Test | ||
run: docker compose up --exit-code-from regtest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
services: | ||
pinnacle: | ||
build: | ||
context: ./iceberg-rest-server | ||
ports: | ||
- "8181:8181" | ||
regtest: | ||
build: | ||
context: ./regtests | ||
args: | ||
PINNACLE_HOST: pinnacle | ||
depends_on: | ||
- pinnacle | ||
volumes: | ||
- local_output:/tmp/pinnacle-regtests/ | ||
volumes: | ||
local_output: | ||
driver: local | ||
driver_opts: | ||
o: bind | ||
type: none | ||
device: ./regtests/output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
...t-server/src/test/java/org/apache/iceberg/rest/IcebergRestApplicationIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
package org.apache.iceberg.rest; | ||
|
||
import io.dropwizard.testing.ResourceHelpers; | ||
import io.dropwizard.testing.junit5.DropwizardAppExtension; | ||
import io.dropwizard.testing.junit5.DropwizardExtensionsSupport; | ||
import org.apache.iceberg.catalog.Namespace; | ||
import org.apache.iceberg.catalog.SessionCatalog; | ||
import org.apache.iceberg.exceptions.NoSuchNamespaceException; | ||
import org.apache.iceberg.rest.config.IcebergRestApplicationConfig; | ||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.fail; | ||
|
||
@ExtendWith(DropwizardExtensionsSupport.class) | ||
public class IcebergRestApplicationIntegrationTest { | ||
private static DropwizardAppExtension<IcebergRestApplicationConfig> EXT = | ||
new DropwizardAppExtension<>( | ||
IcebergRestApplication.class, | ||
ResourceHelpers.resourceFilePath("iceberg-rest-server-integrationtest.yml") | ||
); | ||
|
||
@BeforeAll | ||
public static void setup() throws IOException { | ||
Path testDir = Path.of("build/test_data/iceberg/default-realm"); | ||
if (Files.exists(testDir)) { | ||
if (Files.isDirectory(testDir)) { | ||
Files.walk(testDir) | ||
.sorted(Comparator.reverseOrder()) | ||
.forEach(path -> { | ||
try { | ||
Files.delete(path); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
}); | ||
|
||
} else { | ||
Files.delete(testDir); | ||
} | ||
} | ||
Files.createDirectories(testDir); | ||
} | ||
|
||
private static RESTSessionCatalog newSessionCatalog(String catalog) { | ||
RESTSessionCatalog sessionCatalog = new RESTSessionCatalog(); | ||
sessionCatalog.initialize("snowflake", Map.of( | ||
"uri", "http://localhost:" + EXT.getLocalPort() + "/api/catalog", | ||
"prefix", catalog | ||
)); | ||
return sessionCatalog; | ||
} | ||
|
||
@Test | ||
public void testIcebergListNamespaces() throws IOException { | ||
try (RESTSessionCatalog sessionCatalog = newSessionCatalog("testIcebergListNamespaces")) { | ||
SessionCatalog.SessionContext sessionContext = SessionCatalog.SessionContext.createEmpty(); | ||
List<Namespace> namespaces = sessionCatalog.listNamespaces(sessionContext); | ||
assertThat(namespaces) | ||
.isNotNull() | ||
.isEmpty(); | ||
} | ||
} | ||
|
||
@Test | ||
public void testIcebergListNamespacesNotFound() throws IOException { | ||
try (RESTSessionCatalog sessionCatalog = newSessionCatalog("testIcebergListNamespacesNotFound")) { | ||
SessionCatalog.SessionContext sessionContext = SessionCatalog.SessionContext.createEmpty(); | ||
try { | ||
sessionCatalog.listNamespaces(sessionContext, Namespace.of("whoops")); | ||
fail("Expected exception to be thrown"); | ||
} catch (NoSuchNamespaceException e) { | ||
// we expect this! | ||
Assertions.assertThat(e).isNotNull(); | ||
} catch (Exception e) { | ||
fail("Unexpected exception", e); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void testIcebergListNamespacesNestedNotFound() throws IOException { | ||
try (RESTSessionCatalog sessionCatalog = newSessionCatalog("testIcebergListNamespacesNestedNotFound")) { | ||
SessionCatalog.SessionContext sessionContext = SessionCatalog.SessionContext.createEmpty(); | ||
Namespace topLevelNamespace = Namespace.of("top_level"); | ||
sessionCatalog.createNamespace(sessionContext, topLevelNamespace); | ||
sessionCatalog.loadNamespaceMetadata(sessionContext, Namespace.of("top_level")); | ||
try { | ||
sessionCatalog.listNamespaces(sessionContext, Namespace.of("top_level", "whoops")); | ||
fail("Expected exception to be thrown"); | ||
} catch (NoSuchNamespaceException e) { | ||
// we expect this! | ||
Assertions.assertThat(e).isNotNull(); | ||
} catch (Exception e) { | ||
fail("Unexpected exception", e); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void testIcebergListTablesNamespaceNotFound() throws IOException { | ||
try (RESTSessionCatalog sessionCatalog = newSessionCatalog("testIcebergListTablesNamespaceNotFound")) { | ||
SessionCatalog.SessionContext sessionContext = SessionCatalog.SessionContext.createEmpty(); | ||
try { | ||
sessionCatalog.listTables(sessionContext, Namespace.of("whoops")); | ||
fail("Expected exception to be thrown"); | ||
} catch (NoSuchNamespaceException e) { | ||
// we expect this! | ||
Assertions.assertThat(e).isNotNull(); | ||
} catch (Exception e) { | ||
fail("Unexpected exception", e); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
public void testIcebergCreateNamespace() throws IOException { | ||
try (RESTSessionCatalog sessionCatalog = newSessionCatalog("testIcebergCreateNamespace")) { | ||
SessionCatalog.SessionContext sessionContext = SessionCatalog.SessionContext.createEmpty(); | ||
Namespace topLevelNamespace = Namespace.of("top_level"); | ||
sessionCatalog.createNamespace(sessionContext, topLevelNamespace); | ||
List<Namespace> namespaces = sessionCatalog.listNamespaces(sessionContext); | ||
assertThat(namespaces) | ||
.isNotNull() | ||
.hasSize(1) | ||
.containsExactly(topLevelNamespace); | ||
Namespace nestedNamespace = Namespace.of("top_level", "second_level"); | ||
sessionCatalog.createNamespace(sessionContext, nestedNamespace); | ||
namespaces = sessionCatalog.listNamespaces(sessionContext, topLevelNamespace); | ||
assertThat(namespaces) | ||
.isNotNull() | ||
.hasSize(1) | ||
.containsExactly(nestedNamespace); | ||
} | ||
} | ||
} |
Oops, something went wrong.