Repository navigation
Fix the integration tests checkstyles. #1149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a0ba51b
9948ca1
70c3b78
8e4f644
6fde6f1
8491099
a292f8c
2599909
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -629,6 +629,7 @@ lazy val integrationTests = (project in file("integration-tests")) | |
| javaOptions ++= Seq( | ||
| "--add-exports=java.base/sun.nio.ch=ALL-UNNAMED", | ||
| ), | ||
| javafmtCheckSettings, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not add integrationTests to the root as well?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| javaCheckstyleSettings("dev/checkstyle-config.xml"), | ||
| skipReleaseSettings, | ||
| libraryDependencies ++= Seq( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,85 +1,91 @@ | ||
| package io.unitycatalog.integrationtests; | ||
|
|
||
| import lombok.Getter; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
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
integrationTestswhich is included in the sbt's root .There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we don't expect the integrationTests to be run if we do
./build/sbt test, rigtht ?There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
integrationTestsmodule.