-
Notifications
You must be signed in to change notification settings - Fork 0
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
SBT publish... and add tests to main itself #4
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2c9b7a0
Add "sbt publish"
arielshaqed 6888772
Add unit test
arielshaqed 3f4d370
Add Scala CI workflow
arielshaqed a5d463c
Use correct Java version
arielshaqed 63a9c2f
Run CI on any PR not just to main
arielshaqed 675617d
[bug] Remove dependency graph plugin
arielshaqed a2ccb7d
[CR] Bug: Remove debug print
arielshaqed f25f6b2
Merge pull request #1 from treeverse/feature/add-unit-test
arielshaqed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,26 @@ | ||
name: Scala CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: {} | ||
workflow_dispatch: {} | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
cache: 'sbt' | ||
- name: Run tests | ||
run: sbt test |
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 @@ | ||
sbt.version=1.9.3 |
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,6 @@ | ||
credentials += Credentials( | ||
"GnuPG Key ID", | ||
"gpg", | ||
"F638279A7281EE8EAE58C4B98D3CFE7E7D0262DA", // key identifier | ||
"ignored" // this field is ignored; passwords are supplied by pinentry | ||
) |
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,2 @@ | ||
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.0") | ||
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") |
36 changes: 36 additions & 0 deletions
36
src/test/scala/io/lakefs/iceberg/extension/ExtensionSpec.scala
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,36 @@ | ||
package io.lakefs.iceberg.extension | ||
|
||
import org.scalatest.funspec.AnyFunSpec | ||
import org.scalatest.matchers.should | ||
|
||
import org.apache.spark.sql.Row | ||
|
||
class ExtensionSpec extends AnyFunSpec | ||
with SparkSessionWithExtensionSetup[LakeFSSparkSessionExtensions] | ||
with should.Matchers { | ||
|
||
val _ = new LakeFSSparkSessionExtensions() | ||
|
||
describe("Extension") { | ||
it("should SELECT") { | ||
withSparkSession(spark => { | ||
import spark.implicits._ | ||
|
||
spark.sql("CREATE DATABASE first") | ||
val df = Seq(("a", 1), ("b", 2), ("c", 3)).toDF | ||
df.writeTo("spark_catalog.first.table").create() | ||
|
||
spark.sql("CREATE DATABASE second") | ||
val df2 = Seq(("a", 1), ("xyzzy", 2), ("c", 3), ("d", 4)).toDF | ||
df2.writeTo("spark_catalog.second.table").create() | ||
|
||
val diff = spark.sql("SELECT * FROM schema_diff('spark_catalog', 'first', 'second', 'table')") | ||
.collect() | ||
.toSet | ||
diff should equal(Set(Row("-", "b", 2), Row("+", "xyzzy", 2), Row("+", "d", 4))) | ||
}) | ||
} | ||
|
||
// TODO(ariels): Test SQL identifier quotation. | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/test/scala/io/lakefs/iceberg/extension/SparkSessionSetup.scala
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,34 @@ | ||
package io.lakefs.iceberg.extension | ||
|
||
import java.nio.file.Files | ||
import org.apache.commons.io.FileUtils | ||
import scala.reflect.ClassTag | ||
|
||
import org.apache.spark.sql.SparkSession | ||
import org.apache.spark.SparkConf | ||
|
||
trait SparkSessionWithExtensionSetup[E] { | ||
def withSparkSession(testMethod: (SparkSession) => Any)(implicit tag: ClassTag[E]) { | ||
val tmpDir = Files.createTempDirectory("sparktest").toString | ||
val conf = new SparkConf() | ||
.setMaster("local") | ||
.setAppName("Spark test") | ||
.set("spark.sql.extensions", tag.runtimeClass.getCanonicalName) | ||
.set("spark.sql.warehouse.dir", tmpDir) | ||
val spark = new SparkSession.Builder() | ||
.appName("extension-test") | ||
.config(conf) | ||
.enableHiveSupport() | ||
.getOrCreate | ||
try { | ||
testMethod(spark) | ||
} finally { | ||
// Clean up catalog dir | ||
FileUtils.deleteDirectory(new java.io.File(tmpDir)) | ||
// local metastore_db always created in current working directory, and | ||
// current working directory cannot be changed in Java. | ||
FileUtils.deleteDirectory(new java.io.File("./metastore_db")) | ||
spark.close() | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is this supposed to be public?
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.
Yeah, it's confusing and scary!
https://keyserver.ubuntu.com/pks/lookup?search=F638279A7281EE8EAE58C4B98D3CFE7E7D0262DA&fingerprint=on&op=index
It's the public key for lakeFS signing. We do the same in lakeFSFS.