Skip to content

Commit 37a236c

Browse files
committed
Add MacOS integration test with Apache Spark 4.0.0 RC3
1 parent 2c91276 commit 37a236c

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

.github/workflows/build_and_test.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
- name: Build
5656
run: swift build -v
5757

58-
integration-test:
58+
integration-test-linux:
5959
runs-on: ubuntu-latest
6060
services:
6161
spark:
@@ -72,3 +72,19 @@ jobs:
7272
swift-version: "6"
7373
- name: Test
7474
run: swift test --no-parallel
75+
76+
integration-test-mac:
77+
runs-on: macos-15
78+
steps:
79+
- uses: actions/checkout@v4
80+
- uses: swift-actions/[email protected]
81+
with:
82+
swift-version: "6"
83+
- name: Test
84+
run: |
85+
curl -LO https://dist.apache.org/repos/dist/dev/spark/v4.0.0-rc3-bin/spark-4.0.0-bin-hadoop3.tgz
86+
tar xvfz spark-4.0.0-bin-hadoop3.tgz
87+
cd spark-4.0.0-bin-hadoop3/sbin
88+
./start-connect-server.sh
89+
cd ../..
90+
swift test --no-parallel

Tests/SparkConnectTests/SQLTests.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,20 @@ struct SQLTests {
3030

3131
let regexID = /#\d+L?/
3232
let regexPlanId = /plan_id=\d+/
33+
let regexLocation = /file:\S+/
34+
35+
private func cleanUp(_ str: String) -> String {
36+
return removeID(removeLocation(str))
37+
}
3338

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

43+
private func removeLocation(_ str: String) -> String {
44+
return str.replacing(regexLocation, with: "*")
45+
}
46+
3847
@Test
3948
func testRemoveID() {
4049
#expect(removeID("123") == "123")
@@ -44,6 +53,11 @@ struct SQLTests {
4453
#expect(removeID("plan_id=123") == "plan_id=")
4554
}
4655

56+
@Test
57+
func removeLocation() {
58+
#expect(removeLocation("file:/abc") == "*")
59+
}
60+
4761
#if !os(Linux)
4862
@Test
4963
func runAll() async throws {
@@ -54,8 +68,8 @@ struct SQLTests {
5468

5569
let sql = try String(contentsOf: URL(fileURLWithPath: "\(path)/\(name)"), encoding: .utf8)
5670
let jsonData = try encoder.encode(try await spark.sql(sql).collect())
57-
let answer = removeID(String(data: jsonData, encoding: .utf8)!)
58-
let expected = removeID(try String(contentsOf: URL(fileURLWithPath: "\(path)/\(name).json"), encoding: .utf8))
71+
let answer = cleanUp(String(data: jsonData, encoding: .utf8)!)
72+
let expected = cleanUp(try String(contentsOf: URL(fileURLWithPath: "\(path)/\(name).json"), encoding: .utf8))
5973
#expect(answer == expected.trimmingCharacters(in: .whitespacesAndNewlines))
6074
}
6175
await spark.stop()

0 commit comments

Comments
 (0)