From 72b4de4d688c80b71a60ffb5b18457bd7915fca0 Mon Sep 17 00:00:00 2001 From: Dongjoon Hyun Date: Wed, 9 Apr 2025 10:27:01 +0900 Subject: [PATCH] [SPARK-51749] Add `MacOS` integration test with Apache Spark 4.0.0 RC3 --- .github/workflows/build_and_test.yml | 18 +++++++++++++++- Tests/SparkConnectTests/SQLTests.swift | 29 ++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 76f740a..0c37870 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -55,7 +55,7 @@ jobs: - name: Build run: swift build -v - integration-test: + integration-test-linux: runs-on: ubuntu-latest services: spark: @@ -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/setup-swift@v2.2.0 + 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 diff --git a/Tests/SparkConnectTests/SQLTests.swift b/Tests/SparkConnectTests/SQLTests.swift index c875a80..997e888 100644 --- a/Tests/SparkConnectTests/SQLTests.swift +++ b/Tests/SparkConnectTests/SQLTests.swift @@ -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") @@ -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 { @@ -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()