Skip to content
Merged
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
8 changes: 7 additions & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ jobs:
java-version: '17'
distribution: 'temurin'

# 'integrationTests' is not in root project, since we avoid running it via `./build/sbt test`,
# Here, we explicitly compile `integrationTests` to catch compilation issues early.
- name: Compile integration tests to verify compilation and checkstyle issues.
run: build/sbt integrationTests/test:compile

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the command to build the integrationTests which is included in the sbt's root .

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add this after the main tests have run?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively... why not add integrationTests to the root so that its always compiled like other modules?

@openinx openinx Nov 4, 2025 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively... why not add integrationTests to the root so that its always compiled like other modules?

Because we don't expect the integrationTests to be run if we do ./build/sbt test, rigtht ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats a good point. we dont want any one to run the integration test with the simple command of sbt test.
then i am okay with integration test being outside the root. please add a comment in the build file saying the reason why.

and then this github workflow can test the integration tests.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, let me add the context. I think it will better to have it in the first step, so that it won't waste resource to run all unit tests if there is any compliation error or checkstyle issue in integrationTests module.


- name: Run tests with coverage
run: build/sbt -J-Xmx2G +jacoco

- name: Run license check
run: build/sbt licenseCheck
run: build/sbt licenseCheck
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ lazy val integrationTests = (project in file("integration-tests"))
javaOptions ++= Seq(
"--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",
),
javafmtCheckSettings,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not add integrationTests to the root as well?
wouldnt that solve a lot of the problems?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

javaCheckstyleSettings("dev/checkstyle-config.xml"),
skipReleaseSettings,
libraryDependencies ++= Seq(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,85 +1,91 @@
package io.unitycatalog.integrationtests;

import lombok.Getter;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are just code reformat, to match the checkstyle rules.

import lombok.SneakyThrows;
import org.apache.spark.sql.SparkSession;
import org.junit.jupiter.api.BeforeAll;

import java.io.IOException;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import lombok.Getter;
import lombok.SneakyThrows;
import org.apache.spark.sql.SparkSession;
import org.junit.jupiter.api.BeforeAll;

public class BaseSparkTest {
// todo: parameterize such that catalogs can be specified per cloud provider if desired
private static final String ServerUrl = System.getenv().getOrDefault("CATALOG_URI", "http://localhost:8080");
private static final String AuthToken = System.getenv().getOrDefault("CATALOG_AUTH_TOKEN", "");
private static final String CatalogName = System.getenv().getOrDefault("CATALOG_NAME", "unity");
protected static SparkSession spark;
// todo: parameterize such that catalogs can be specified per cloud provider if desired
private static final String ServerUrl =
System.getenv().getOrDefault("CATALOG_URI", "http://localhost:8080");
private static final String AuthToken =
System.getenv().getOrDefault("CATALOG_AUTH_TOKEN", "");
private static final String CatalogName =
System.getenv().getOrDefault("CATALOG_NAME", "unity");
protected static SparkSession spark;

@BeforeAll
public static void setup() {
spark = createSparkSessionWithCatalogs(CatalogName);
}
@BeforeAll
public static void setup() {
spark = createSparkSessionWithCatalogs(CatalogName);
}

protected static SparkSession createSparkSessionWithCatalogs(String... catalogs) {
SparkSession.Builder builder =
SparkSession.builder()
.appName("test")
.master("local[*]")
.config("spark.sql.extensions", "io.delta.sql.DeltaSparkSessionExtension")
.config("spark.sql.catalog.spark_catalog", "org.apache.spark.sql.delta.catalog.DeltaCatalog")
// s3 conf
.config("spark.hadoop.fs.s3.impl", "org.apache.hadoop.fs.s3a.S3AFileSystem")
// GCS conf
.config("spark.hadoop.fs.AbstractFileSystem.gs.impl", "com.google.cloud.hadoop.fs.gcs.GoogleHadoopFS");
protected static SparkSession createSparkSessionWithCatalogs(String... catalogs) {
SparkSession.Builder builder =
SparkSession.builder()
.appName("test")
.master("local[*]")
.config("spark.sql.extensions", "io.delta.sql.DeltaSparkSessionExtension")
.config("spark.sql.catalog.spark_catalog",
"org.apache.spark.sql.delta.catalog.DeltaCatalog")
// s3 conf
.config("spark.hadoop.fs.s3.impl", "org.apache.hadoop.fs.s3a.S3AFileSystem")
// GCS conf
.config("spark.hadoop.fs.AbstractFileSystem.gs.impl",
"com.google.cloud.hadoop.fs.gcs.GoogleHadoopFS");

for (String catalog : catalogs) {
String catalogConf = "spark.sql.catalog." + catalog;
builder =
builder
.config(catalogConf, "io.unitycatalog.spark.UCSingleCatalog")
.config(catalogConf + ".uri", ServerUrl)
.config(catalogConf + ".token", AuthToken);
}
if (catalogs.length > 0) {
builder.config("spark.sql.defaultCatalog", catalogs[0]);
}
return builder.getOrCreate();
for (String catalog : catalogs) {
String catalogConf = "spark.sql.catalog." + catalog;
builder =
builder
.config(catalogConf, "io.unitycatalog.spark.UCSingleCatalog")
.config(catalogConf + ".uri", ServerUrl)
.config(catalogConf + ".token", AuthToken);
}

protected static String getBaseLocation(LocationType locationType) throws IOException {
return switch (locationType) {
// todo: add hook to clean up temp directory
case FILE -> Files.createTempDirectory("uc-test-table").toFile().getAbsolutePath();
case S3 -> System.getenv("S3_BASE_LOCATION");
case GS -> System.getenv("GS_BASE_LOCATION");
case ABFSS -> System.getenv("ABFSS_BASE_LOCATION");
};
if (catalogs.length > 0) {
builder.config("spark.sql.defaultCatalog", catalogs[0]);
}
return builder.getOrCreate();
}

@Getter
public enum LocationType {
FILE("file://"),
S3(System.getenv("S3_BASE_LOCATION")),
GS(System.getenv("GS_BASE_LOCATION")),
ABFSS(System.getenv("ABFSS_BASE_LOCATION"));
protected static String getBaseLocation(LocationType locationType) throws IOException {
return switch (locationType) {
// todo: add hook to clean up temp directory
case FILE -> Files.createTempDirectory("uc-test-table").toFile().getAbsolutePath();
case S3 -> System.getenv("S3_BASE_LOCATION");
case GS -> System.getenv("GS_BASE_LOCATION");
case ABFSS -> System.getenv("ABFSS_BASE_LOCATION");
};
}

private final String baseLocation;
@Getter
public enum LocationType {
FILE("file://"),
S3(System.getenv("S3_BASE_LOCATION")),
GS(System.getenv("GS_BASE_LOCATION")),
ABFSS(System.getenv("ABFSS_BASE_LOCATION"));

@SneakyThrows
LocationType(String baseLocation) {
this.baseLocation = Objects.equals(baseLocation, "file://") ? Files.createTempDirectory("uc-integration-tests").toFile().getAbsolutePath()
: baseLocation;
}
private final String baseLocation;

public boolean isEnabled() {
return this.baseLocation != null;
}
@SneakyThrows
LocationType(String baseLocation) {
this.baseLocation =
Objects.equals(baseLocation, "file://")
? Files.createTempDirectory("uc-integration-tests").toFile().getAbsolutePath()
: baseLocation;
}

static List<LocationType> locationTypes() {
return Arrays.stream(LocationType.values()).filter(LocationType::isEnabled).toList();
public boolean isEnabled() {
return this.baseLocation != null;
}
}

static List<LocationType> locationTypes() {
return Arrays.stream(LocationType.values()).filter(LocationType::isEnabled).toList();
}
}
Loading