Skip to content
Closed
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
18 changes: 17 additions & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Build
run: swift build -v

integration-test:
integration-test-linux:
runs-on: ubuntu-latest
services:
spark:
Expand All @@ -72,3 +72,19 @@ jobs:
swift-version: "6"
- name: Test
run: swift test --no-parallel

integration-test-mac:
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- uses: swift-actions/[email protected]
with:
swift-version: "6"
- name: Test
run: |
curl -LO https://dist.apache.org/repos/dist/dev/spark/v4.0.0-rc3-bin/spark-4.0.0-bin-hadoop3.tgz
tar xvfz spark-4.0.0-bin-hadoop3.tgz
cd spark-4.0.0-bin-hadoop3/sbin
./start-connect-server.sh
cd ../..
swift test --no-parallel
29 changes: 27 additions & 2 deletions Tests/SparkConnectTests/SQLTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,25 @@ struct SQLTests {

let regexID = /#\d+L?/
let regexPlanId = /plan_id=\d+/
let regexLocation = /file:[a-zA-Z0-9\.\-\/\\]+/
let regexOwner = /(runner|185)/

private func cleanUp(_ str: String) -> String {
return removeOwner(removeID(removeLocation(str)))
}

private func removeID(_ str: String) -> String {
return str.replacing(regexPlanId, with: "plan_id=").replacing(regexID, with: "#")
}

private func removeLocation(_ str: String) -> String {
return str.replacing(regexLocation, with: "*")
}

private func removeOwner(_ str: String) -> String {
return str.replacing(regexOwner, with: "*")
}

@Test
func testRemoveID() {
#expect(removeID("123") == "123")
Expand All @@ -44,6 +58,17 @@ struct SQLTests {
#expect(removeID("plan_id=123") == "plan_id=")
}

@Test
func removeLocation() {
#expect(removeLocation("file:/abc") == "*")
}

@Test
func removeOwner() {
#expect(removeOwner("runner") == "*")
#expect(removeOwner("185") == "*")
}

#if !os(Linux)
@Test
func runAll() async throws {
Expand All @@ -54,8 +79,8 @@ struct SQLTests {

let sql = try String(contentsOf: URL(fileURLWithPath: "\(path)/\(name)"), encoding: .utf8)
let jsonData = try encoder.encode(try await spark.sql(sql).collect())
let answer = removeID(String(data: jsonData, encoding: .utf8)!)
let expected = removeID(try String(contentsOf: URL(fileURLWithPath: "\(path)/\(name).json"), encoding: .utf8))
let answer = cleanUp(String(data: jsonData, encoding: .utf8)!)
let expected = cleanUp(try String(contentsOf: URL(fileURLWithPath: "\(path)/\(name).json"), encoding: .utf8))
#expect(answer == expected.trimmingCharacters(in: .whitespacesAndNewlines))
}
await spark.stop()
Expand Down
Loading