-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from engelhardtnick-at-TW/specify-java-setup-c…
…onstraints Specify java setup constraints
- Loading branch information
Showing
7 changed files
with
52 additions
and
15 deletions.
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
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 |
---|---|---|
@@ -1,3 +0,0 @@ | ||
from pyspark.sql import SparkSession | ||
|
||
SPARK = SparkSession.builder.appName("IntegrationTests").getOrCreate() | ||
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,7 @@ | ||
import pytest | ||
from pyspark.sql import SparkSession | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def SPARK(): | ||
return SparkSession.builder.appName("IntegrationTests").getOrCreate() |
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
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,33 @@ | ||
import os | ||
import re | ||
import subprocess | ||
|
||
import pytest | ||
|
||
|
||
def test_java_home_is_set(): | ||
java_home = os.environ.get("JAVA_HOME") | ||
assert java_home is not None, "Environment variable 'JAVA_HOME' is not set but is required by pySpark to work." | ||
|
||
|
||
def test_java_version_is_greater_or_equal_11(): | ||
version_regex = re.compile(r'(?P<major>\d+)\.(?P<minor>\d+)\.\w+') | ||
|
||
java_version_output = subprocess.check_output(['java', '-version'], stderr=subprocess.STDOUT).decode("utf-8") | ||
print(f"\n`java -version` returned\n{java_version_output}") | ||
|
||
version_number = java_version_output.splitlines()[0].split('"')[1].strip('"') | ||
print(f"Assuming {version_number=} is the version to check.") | ||
|
||
regex_match = version_regex.search(version_number) | ||
if not regex_match: | ||
pytest.fail(f"Couldn't parse Java version from {version_number=} using {version_regex=}.") | ||
if regex_match["major"] == "1": | ||
# we need to jump this hoop due to Java version naming conventions - it's fun: | ||
# https://softwareengineering.stackexchange.com/questions/175075/why-is-java-version-1-x-referred-to-as-java-x | ||
actual_major_version = int(regex_match["minor"]) | ||
else: | ||
actual_major_version = int(regex_match["major"]) | ||
expected_major_version = 11 | ||
assert actual_major_version >= expected_major_version, (f"Major version {actual_major_version} is not recent " | ||
f"enough, we need at least version {expected_major_version}.") |
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