Skip to content

Commit 88fbb9a

Browse files
collado-mikejdanielmyersannafilsfc-gh-mcolladosfc-gh-aixu
committed
Merge Polaris catalog code (apache#1)
* Initial commit Co-authored-by: Aihua Xu <[email protected]> Co-authored-by: Alvin Chen <[email protected]> Co-authored-by: Benoit Dageville <[email protected]> Co-authored-by: Dennis Huo <[email protected]> Co-authored-by: Evan Gilbert <[email protected]> Co-authored-by: Evgeny Zubatov <[email protected]> Co-authored-by: Jonas-Taha El Sesiy <[email protected]> Co-authored-by: Maninder Parmar <[email protected]> Co-authored-by: Michael Collado <[email protected]> Co-authored-by: Sean Lee <[email protected]> Co-authored-by: Shannon Chen <[email protected]> Co-authored-by: Tyler Jones <[email protected]> Co-authored-by: Vivo Xu <[email protected]> * Add brief description to README * Update package naming to separate snowflake code and oss core, extensions, and service impl * Set up new gradle project structure * Add gradle wrapper * Moved docker files to project root and renamed files and classes to Polaris * Update CI scripts to use new layout * Add missing gradlew file * Updates to READMEs and move manual* scripts to snowflake repository root * Fix SparkIntegrationTest after merge * Fix regtest in polaris application Fix json error messages to return clearer validation causes (apache#272) Extended gradle format in root project to apply to oss (apache#273) Improve error message for invalid json and distinguish from invalid values (apache#274) Update repository references to managed-polaris Removed references and made aws resources configurable Fix references to snowflake reg test resources Update README with instructions on running cloud-specific regtests Copy recommended gradle .gitignore contents Update github actions Add @polaris-catalog/polaris team to codeowners * Merge branch 'managed-polaris' into mcollado-polaris-import Co-authored-by: Dennis Huo <[email protected]> * Merged changes into polaris-catalog/polaris-dev Co-authored-by: Dennis Huo <[email protected]> Co-authored-by: Evgeny Zubatov <[email protected]> * Squashed commit of the following: Co-authored-by: Benoit Dageville <[email protected]> Co-authored-by: Dennis Huo <[email protected]> Co-authored-by: Eric Maynard <[email protected]> Co-authored-by: Evgeny Zubatov <[email protected]> Co-authored-by: Michael Collado <[email protected]> Co-authored-by: Shannon Chen <[email protected]> commit bd256f544c069ff15a7a96ab7f2abc650a2e9812 Author: Shannon Chen <[email protected]> Date: Tue Jul 23 23:43:38 2024 +0000 Remove s3gov s3china enums and validate roleArn. Removing the enums because the iceberg spec does not have s3gov or s3china prefix for the url, those are snowflake style supported prefix. commit 855dbb702bdc4fc80ca852b8bf563979e08d63d2 Author: Michael Collado <[email protected]> Date: Tue Jul 23 10:02:35 2024 -0700 Fix credential vending for view creation (apache#19) Correctly sets vended credentials for view creation commit 0429e6356cd71b3908600b6c5c17f82493f1d37d Author: Eric Maynard <[email protected]> Date: Tue Jul 23 09:49:20 2024 -0700 This PR implements a basic CLI for Polaris, supporting simple commands like: ``` polaris catalogs list polaris catalogs create --type --storage-type s3 --default-base-location s3://my-bucket --role-arn ${ARN} polaris principals update emaynard --property foo=bar --property e=mc2 polaris privileges --catalog my_cat --catalog-role my_role namespace grant --namespace a.b.c TABLE_READ_DATA polaris privileges --catalog my_cat --catalog-role my_role table revoke --namespace a.b.c --table t1 TABLE_READ_DATA ``` commit 01d4c294e6f8b3e77bf205af00ea2e1dbef0d362 Author: Evgeny Zubatov <[email protected]> Date: Mon Jul 22 11:12:29 2024 -0700 Service Bootstrap (Part 2): we are removing bootstrap code in init methods and updates to In-Memory store (apache#8) Changing bootstrap logic, moving bootstrap code to a separate method and only use it during service bootstrapping and first time initialization. So moving forward we will not call bootstrap during SessionManager init code as it used to be, as this will be destructive if service gets restarted. For InMemory Store we have special handling and doing bootstrap on a very first initialization of SessionManager for a given realm. And it makes sense as we can't use our custom dropwizard Bootstrap command for bootstrapping in-memory store (as in-memory store is only valid and available during server process lifetime) commit 2c7f3c43c557e521d7177a4d7dd44157147f0a0c Author: Dennis Huo <[email protected]> Date: Fri Jul 19 23:33:05 2024 +0000 Defense-in-depth - make FileIO impl come from StorageConfigurationInfo (apache#15) Description Rather than specifying ResolvingFileIO, we can be more explicit about the FileIO impl we're allowing. Also only allow custom specification of FileIO in test environments using a feature config flag. Even if there are valid FileIO customizations customers could specify, we have only really vetted the enumerated list of impls, so for example we don't want a customer to be able to force Polaris to try to use Hadoop's S3AFileSystem for S3 files even if it "might" work. This in conjunction with omitting `FILE` from SUPPORTED_CATALOG_STORAGE_TYPES for managed environments (https://github.com/snowflakedb/polaris-k8-config/pull/116/files) ensures we won't have a FileIO impl that's capable of reading unexpected files. commit 498861114994b0508efdbdd2167918be5517f4cb Merge: cf07ac0 c100175 Author: Michael Collado <[email protected]> Date: Fri Jul 19 13:41:02 2024 -0700 Merge branch 'main' into mcollado-update-aws-region commit cf07ac099644b96f93026b209c9938243c1cce18 Author: Michael Collado <[email protected]> Date: Fri Jul 19 13:38:22 2024 -0700 Stop setting AWS_REGION env and use client.region spark config in tests commit c10017521145e138ae5cdd903d7d51b4bee9e82c Merge: b1de84a d2df00f Author: Eric Maynard <[email protected]> Date: Fri Jul 19 12:43:15 2024 -0700 Merge pull request apache#12 from snowflakedb/confirm-warehouse-non-null commit b1de84ad47f6bdf5be4318d4664767dfc33bb5a0 Merge: 504dcc0 1f79e19 Author: Michael Collado <[email protected]> Date: Fri Jul 19 09:25:07 2024 -0700 Merge branch 'main' into mcollado-view-tests commit d4c58a6a19756078309229c1de4dbf5f737dbdd0 Author: Shannon Chen <[email protected]> Date: Thu Jul 18 02:58:52 2024 -0700 cross region support commit 504dcc05bb33e686f5765e5b2d91aa4dcfe2e5d1 Author: Michael Collado <[email protected]> Date: Fri Jul 19 00:00:57 2024 -0700 fix regtest failures commit b7ed5d27e2d71708977cc6fe7eac3ab10e8d9836 Author: Michael Collado <[email protected]> Date: Thu Jul 18 21:52:46 2024 -0700 Add reg tests to verify view support * Squashed commit of the following: commit 4fb3b6c19a8a8a4961b777ad32dbe1b87d5efe94 Author: Evgeny Zubatov <[email protected]> Date: Thu Jul 25 14:02:30 2024 -0700 Adding annotation and enforcing size limits for Principal, Role, Catalog and Catalog Role names. Also blocking "SYSTEM$" prefix from being used in names. Adding case-insensitive regex rule to block "SYSTEM$" commit 2fcc2898ea038c074fed075cdc7ff62e4884e76a Author: Alvin Chen <[email protected]> Date: Thu Jul 25 11:28:00 2024 -0700 Replace Dropwizard Metrics with Micrometer (apache#18) <!-- Please describe your change here and remove this comment --> Since the current Dropwizard Metric library 4.x doesn't support adding custom labels to metrics, we cannot define per-account metrics in order As a result, we're migrating to Micrometer metrics to support custom tagging and align with the metric implementations Major changes by component - `PolarisMetricRegistry` - defines caching for timers and error counters as well as abstracts away the creation of two separate metrics, one with and one without the `account` tag - `TimedApplicationEventListener` - an implementation of the Jersey ApplicationEventListener to listen on requests invoking methods with `@TimedApi` annotation, and handles logic of timing resource/counting errors on success/failure cases respectively - `IcebergMappedException` - removed the original logic for counting errors since the code is now centralized in the above two classes ## Test Manual tested by calling the /metrics endpoint. Following is the result of one successful and one failure invoke of the /oauth endpoint. Note that the timer produces a `summary` and a `gauge`, and doesn't get incremented on failure cases. ``` % curl http://localhost:8182/metrics # HELP polaris_OAuth2Api_getToken_error_total # TYPE polaris_OAuth2Api_getToken_error_total counter polaris_OAuth2Api_getToken_error_total{HTTP_RESPONSE_CODE="401"} 1.0 # HELP polaris_OAuth2Api_getToken_error_realm_total # TYPE polaris_OAuth2Api_getToken_error_realm_total counter polaris_OAuth2Api_getToken_error_realm_total{HTTP_RESPONSE_CODE="401",REALM_ID="testpolaris"} 1.0 # HELP polaris_OAuth2Api_getToken_realm_seconds # TYPE polaris_OAuth2Api_getToken_realm_seconds summary polaris_OAuth2Api_getToken_realm_seconds_count{REALM_ID="testpolaris"} 1 polaris_OAuth2Api_getToken_realm_seconds_sum{REALM_ID="testpolaris"} 0.384 # HELP polaris_OAuth2Api_getToken_realm_seconds_max # TYPE polaris_OAuth2Api_getToken_realm_seconds_max gauge polaris_OAuth2Api_getToken_realm_seconds_max{REALM_ID="testpolaris"} 0.384 # HELP polaris_OAuth2Api_getToken_seconds # TYPE polaris_OAuth2Api_getToken_seconds summary polaris_OAuth2Api_getToken_seconds_count 1 polaris_OAuth2Api_getToken_seconds_sum 0.384 # HELP polaris_OAuth2Api_getToken_seconds_max # TYPE polaris_OAuth2Api_getToken_seconds_max gauge polaris_OAuth2Api_getToken_seconds_max 0.384 # HELP polaris_persistence_loadEntity_realm_seconds # TYPE polaris_persistence_loadEntity_realm_seconds summary polaris_persistence_loadEntity_realm_seconds_count{REALM_ID="testpolaris"} 1 polaris_persistence_loadEntity_realm_seconds_sum{REALM_ID="testpolaris"} 0.041 # HELP polaris_persistence_loadEntity_realm_seconds_max # TYPE polaris_persistence_loadEntity_realm_seconds_max gauge polaris_persistence_loadEntity_realm_seconds_max{REALM_ID="testpolaris"} 0.041 # HELP polaris_persistence_loadEntity_seconds # TYPE polaris_persistence_loadEntity_seconds summary polaris_persistence_loadEntity_seconds_count 1 polaris_persistence_loadEntity_seconds_sum 0.041 # HELP polaris_persistence_loadEntity_seconds_max # TYPE polaris_persistence_loadEntity_seconds_max gauge polaris_persistence_loadEntity_seconds_max 0.041 ``` commit 5abee21b07be00f5f3b18faabe61fb88ecec37e0 Author: Shannon Chen <[email protected]> Date: Thu Jul 25 17:14:09 2024 +0000 select view hangs in remote polaris because iceberg SDK could not initialize the s3client since it is missing credentials. It works locally because the SDK S3client initialization work if your local environment have AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY set, and our dev environment does have these two variables set, so it was not using vending scopedcreds. This PR does below things: 1. add scoped creds to the fileIO when select view 2. stops retry for more cases, the `select view` hangs because it keeps retying commit 85d41bcbab30c9fc3fad56dea83f80e8146ee79c Author: Eric Maynard <[email protected]> Date: Wed Jul 24 16:33:57 2024 -0700 In this PR, I've regenerated the Python clients from the spec by following the steps [here](https://github.com/snowflakedb/managed-polaris/tree/main/polaris/regtests#python-tests). I ran: ``` docker run --rm \ -v ${PWD}:/local openapitools/openapi-generator-cli generate \ -i /local/spec/polaris-management-service.yml \ -g python \ -o /local/regtests/client/python --additional-properties=packageName=polaris.management --additional-properties=apiNamePrefix=polaris docker run --rm \ -v ${PWD}:/local openapitools/openapi-generator-cli generate \ -i /local/spec/rest-catalog-open-api.yaml \ -g python \ -o /local/regtests/client/python --additional-properties=packageName=polaris.catalog --additional-properties=apiNameSuffix="" --additional-properties=apiNamePrefix=Iceberg ``` commit 485d99c89abd7b7c3690f45d96a5043a47032ba3 Author: Eric Maynard <[email protected]> Date: Wed Jul 24 11:27:21 2024 -0700 This PR introduces quickstart documentation and adds a basic structure for OSS docs. commit 4310980aecf81cc23bbf583cfb6c360ca738a788 Author: Shannon Chen <[email protected]> Date: Wed Jul 24 17:38:14 2024 +0000 Stop retry 403 Access Denied error (apache#22) commit 95acd5b3e7983b89d47a915c62ac5bb247730313 Author: Benoit Dageville <[email protected]> Date: Tue Jul 23 22:15:34 2024 -0700 * Fix readme statement and snowflake reference in PolarisDefaultDiagServiceImpl --------- Co-authored-by: Daniel Myers <[email protected]> Co-authored-by: Anna Filippova <[email protected]> Co-authored-by: Michael Collado <[email protected]> Co-authored-by: Aihua Xu <[email protected]> Co-authored-by: Alvin Chen <[email protected]> Co-authored-by: Benoit Dageville <[email protected]> Co-authored-by: Dennis Huo <[email protected]> Co-authored-by: Evan Gilbert <[email protected]> Co-authored-by: Evgeny Zubatov <[email protected]> Co-authored-by: Jonas-Taha El Sesiy <[email protected]> Co-authored-by: Maninder Parmar <[email protected]> Co-authored-by: Sean Lee <[email protected]> Co-authored-by: Shannon Chen <[email protected]> Co-authored-by: Tyler Jones <[email protected]> Co-authored-by: Vivo Xu <[email protected]>
1 parent dbcbb79 commit 88fbb9a

File tree

792 files changed

+115301
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

792 files changed

+115301
-2
lines changed

.dockerignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
polaris-service/logs
2+
polaris-service/build
3+
polaris-core/build
4+
build
5+
.idea

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@polaris-catalog/polaris

.github/dependabot.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"

.github/pull_request_template.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!-- Please describe your change here and remove this comment -->

.github/workflows/gradle.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
6+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
7+
8+
name: Java CI with Gradle
9+
10+
on:
11+
push:
12+
branches: [ "main" ]
13+
pull_request:
14+
branches: [ "main" ]
15+
16+
jobs:
17+
build:
18+
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Set up JDK 21
26+
uses: actions/setup-java@v4
27+
with:
28+
java-version: '21'
29+
distribution: 'temurin'
30+
31+
# Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies.
32+
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
33+
- name: Setup Gradle
34+
uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda # v3.4.2
35+
36+
- name: Check formatting
37+
run: ./gradlew check
38+
39+
- name: Build with Gradle Wrapper
40+
run: ./gradlew test
41+
42+
- name: Archive test results
43+
uses: actions/upload-artifact@v4
44+
if: always()
45+
with:
46+
name: upload-test-artifacts
47+
path: |
48+
polaris-core/build/test-results/test
49+
polaris-service/build/test-results/test
50+
51+
# NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html).
52+
# If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version.
53+
#
54+
# - name: Setup Gradle
55+
# uses: gradle/actions/setup-gradle@dbbdc275be76ac10734476cc723d82dfe7ec6eda # v3.4.2
56+
# with:
57+
# gradle-version: '8.6'
58+
#
59+
# - name: Build with Gradle 8.6
60+
# run: gradle build

.github/workflows/regtest.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Regression Tests
2+
on:
3+
push:
4+
branches: [ "main" ]
5+
pull_request:
6+
branches: [ "main" ]
7+
8+
jobs:
9+
regtest:
10+
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: fix permissions
18+
run: mkdir -p regtests/output && chmod 777 regtests/output && chmod 777 regtests/t_*/ref/*
19+
- name: Regression Test
20+
env:
21+
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
22+
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
23+
run: docker compose up --build --exit-code-from regtest

.github/workflows/semgrep.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: Run semgrep checks
3+
on:
4+
pull_request:
5+
branches: [main]
6+
permissions:
7+
contents: read
8+
jobs:
9+
run-semgrep-reusable-workflow:
10+
uses: snowflakedb/reusable-workflows/.github/workflows/semgrep-v2.yml@main
11+
secrets:
12+
token: ${{ secrets.SEMGREP_APP_TOKEN }}

.github/workflows/stale.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
jobs:
3+
stale:
4+
runs-on: ubuntu-22.04
5+
steps:
6+
- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e
7+
with:
8+
days-before-close: 5
9+
days-before-stale: 30
10+
stale-issue-message: "This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days."
11+
stale-pr-message: "This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days."
12+
name: "Close stale issues and PRs"
13+
on:
14+
schedule:
15+
- cron: "30 1 * * *"
16+
permissions:
17+
issues: read
18+
pull-requests: write

.gitignore

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
polaris-service/logs/
2+
regtests/derby.log
3+
regtests/metastore_db
4+
regtests/output/
5+
notebooks/.ipynb_checkpoints/
6+
.gradle
7+
**/build/
8+
!src/**/build/
9+
10+
# Ignore Gradle GUI config
11+
gradle-app.setting
12+
13+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
14+
!gradle-wrapper.jar
15+
16+
# Avoid ignore Gradle wrappper properties
17+
!gradle-wrapper.properties
18+
19+
# Cache of project
20+
.gradletasknamecache
21+
22+
# Eclipse Gradle plugin generated files
23+
# Eclipse Core
24+
.project
25+
# JDT-specific (Eclipse Java Development Tools)
26+
.classpath
27+
.env
28+
.java-version
29+
**/*.iml

.openapi-generator-ignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
src/main/webapp/**
2+
build.gradle
3+
pom.xml
4+
README.md
5+
settings.gradle
6+
.openapi-generator-ignore
7+
src/main/java/org/**

Dockerfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Base Image
2+
FROM gradle:8.6-jdk21 as build
3+
4+
# Copy the REST catalog into the container
5+
COPY . /app
6+
7+
# Set the working directory in the container, nuke any existing builds
8+
WORKDIR /app
9+
RUN rm -rf build
10+
11+
# Build the rest catalog
12+
RUN gradle --no-daemon --info shadowJar
13+
14+
FROM openjdk:21
15+
WORKDIR /app
16+
COPY --from=build /app/polaris-service/build/libs/polaris-service-1.0.0-all.jar /app
17+
COPY --from=build /app/polaris-server.yml /app
18+
19+
EXPOSE 8181
20+
21+
# Run the resulting java binary
22+
CMD ["java", "-jar", "/app/polaris-service-1.0.0-all.jar", "server", "polaris-server.yml"]

README.md

+152-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,158 @@
66

77
## Status
88

9-
Polaris Catalog will be open sourced under an Apache 2.0 license in the next 90 days. In the meantime:
9+
Polaris Catalog is open source under an Apache 2.0 license.
1010

11-
- 👀 Watch this repo if you would like to be notified when the Polaris code goes live.
1211
- ⭐ Star this repo if you’d like to bookmark and come back to it!
1312
- 📖 Read the <a href="https://snowflake.com/blog/introducing-polaris-catalog/" target="_blank">announcement blog post<a/> for more details!
13+
14+
## API Docs
15+
16+
API docs are hosted via Github Pages at https://polaris-catalog.github.io/polaris. All updates to the main branch
17+
update the hosted docs.
18+
19+
The Polaris management API docs are found [here](docs%2Fpolaris-management%2Findex.html)
20+
21+
The open source Iceberg REST API docs are at [index.html](docs%2Ficeberg-rest%2Findex.html)
22+
23+
Docs are generated using Redocly. They can be regenerated by running the following commands
24+
from the project root directory
25+
26+
```bash
27+
docker run -p 8080:80 -v ${PWD}:/spec redocly/cli build-docs spec/polaris-management-service.yml --output=docs/polaris-management/index.html
28+
docker run -p 8080:80 -v ${PWD}:/spec redocly/cli build-docs spec/rest-catalog-open-api.yaml --output=docs/iceberg-rest/index.html
29+
```
30+
31+
# Setup
32+
33+
## Requirements / Setup
34+
35+
- Java JDK >= 21 . If on a Mac you can use [jenv](https://www.jenv.be/) to set the appropriate SDK.
36+
- Gradle 8.6 - This is included in the project and can be run using `./gradlew` in the project root.
37+
- Docker - If you want to run the project in a containerized environment.
38+
39+
Command-Line getting started
40+
-------------------
41+
Polaris is a multi-module project with three modules:
42+
43+
- `polaris-core` - The main Polaris entity definitions and core business logic
44+
- `polaris-server` - The Polaris REST API server
45+
- `polaris-eclipselink` - The Eclipselink implementation of the MetaStoreManager interface
46+
47+
Build the binary (first time may require installing new JDK version). This build will run IntegrationTests by default.
48+
49+
```
50+
./gradlew build
51+
```
52+
53+
Run the Polaris server locally on localhost:8181
54+
55+
```
56+
./gradlew runApp
57+
```
58+
59+
While the Polaris server is running, run regression tests, or end-to-end tests in another terminal
60+
61+
```
62+
./regtests/run.sh
63+
```
64+
65+
Docker Instructions
66+
-------------------
67+
68+
Build the image:
69+
70+
```
71+
docker build -t localhost:5001/polaris:latest .
72+
```
73+
74+
Run it in a standalone mode. This runs a single container that binds the container's port `8181` to localhosts `8181`:
75+
76+
```
77+
docker run -p 8181:8181 localhost:5001/polaris:latest
78+
```
79+
80+
# Running the tests
81+
82+
## Unit and Integration tests
83+
84+
Unit and integration tests are run using gradle. To run all tests, use the following command:
85+
86+
```bash
87+
./gradlew test
88+
```
89+
90+
## Regression tests
91+
92+
Regression tests, or functional tests, are stored in the `regtests` directory. They can be executed in a docker
93+
environment by using the `docker-compose.yml` file in the project root.
94+
95+
```bash
96+
docker compose up --build --exit-code-from regtest
97+
```
98+
99+
They can also be executed outside of docker by following the setup instructions in
100+
the [README](regtests/README.md)
101+
102+
# Kubernetes Instructions
103+
-----------------------
104+
105+
You can run Polaris as a mini-deployment locally. This will create two pods that bind themselves to port `8181`:
106+
107+
```
108+
./setup.sh
109+
```
110+
111+
You can check the pod and deployment status like so:
112+
113+
```
114+
kubectl get pods
115+
kubectl get deployment
116+
```
117+
118+
If things aren't working as expected you can troubleshoot like so:
119+
120+
```
121+
kubectl describe deployment polaris-deployment
122+
```
123+
124+
## Creating a Catalog manually
125+
126+
Before connecting with Spark, you'll need to create a catalog. To create a catalog, generate a token for the root
127+
principal:
128+
129+
```bash
130+
curl -i -X POST \
131+
http://localhost:8181/api/catalog/v1/oauth/tokens \
132+
-d 'grant_type=client_credentials&client_id=<principalClientId>=&client_secret=<mainSecret>=&scope=PRINCIPAL_ROLE:ALL'
133+
```
134+
135+
The response output will contain an access token:
136+
137+
```json
138+
{
139+
"access_token": "ver:1-hint:1036-ETMsDgAAAY/GPANareallyverylongstringthatissecret",
140+
"token_type": "bearer",
141+
"expires_in": 3600
142+
}
143+
```
144+
145+
Set the contents of the `access_token` field as the `PRINCIPAL_TOKEN` variable. Then use curl to invoke the
146+
createCatalog
147+
api:
148+
149+
```bash
150+
$ export PRINCIPAL_TOKEN=ver:1-hint:1036-ETMsDgAAAY/GPANareallyverylongstringthatissecret
151+
152+
$ curl -i -X PUT -H "Authorization: Bearer $PRINCIPAL_TOKEN" -H 'Accept: application/json' -H 'Content-Type: application/json' \
153+
http://${POLARIS_HOST:-localhost}:8181/api/v1/catalogs \
154+
-d '{"name": "snowflake", "id": 100, "type": "INTERNAL", "readOnly": false}'
155+
```
156+
157+
This creates a catalog called `snowflake`. From here, you can use Spark to create namespaces, tables, etc.
158+
159+
You must run the following as the first query in your spark-sql shell to actually use Polaris:
160+
161+
```
162+
use polaris;
163+
```

0 commit comments

Comments
 (0)