Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1bdeb87
Move module definitions to separate file.
JoshRosen Jun 22, 2015
311c6a9
Move shell utility functions to own module.
JoshRosen Jun 22, 2015
32660fc
Initial cut at Python test runner refactoring
JoshRosen Jun 23, 2015
dcc9c09
Fix time division
JoshRosen Jun 23, 2015
4c97136
PYTHONPATH fixes
JoshRosen Jun 23, 2015
04015b9
First attempt at getting PySpark Kafka test to work in new runner script
JoshRosen Jun 24, 2015
aec0b8f
Actually get the Kafka stuff to run properly
JoshRosen Jun 24, 2015
def2d8a
Two minor fixes
JoshRosen Jun 24, 2015
d6a77d3
Fix the tests of dev/run-tests
JoshRosen Jun 24, 2015
caeb040
Fixes to PySpark test module definitions
JoshRosen Jun 24, 2015
b2ab027
Add command-line options for running individual suites in python/run-…
JoshRosen Jun 24, 2015
2efd594
Update dev/run-tests to use new Python test runner flags
JoshRosen Jun 24, 2015
fff4d09
Add dev/sparktestsupport to pep8 checks
JoshRosen Jun 24, 2015
f542ac5
Fix lint check for Python 3
JoshRosen Jun 24, 2015
8f3244c
Use universal_newlines to fix dev/run-tests doctest failures on Pytho…
JoshRosen Jun 25, 2015
4f8902c
Python lint fixes.
JoshRosen Jun 25, 2015
d33e525
Merge remote-tracking branch 'origin/master' into run-tests-python-mo…
JoshRosen Jun 25, 2015
9c80469
Fix passing of PYSPARK_PYTHON
JoshRosen Jun 25, 2015
f53db55
Remove python2 flag, since the test runner script also works fine und…
JoshRosen Jun 26, 2015
3b852ae
Fall back to PYSPARK_PYTHON when sys.executable is None (fixes a test)
JoshRosen Jun 26, 2015
568a3fd
Fix hashbang
JoshRosen Jun 26, 2015
c364ccf
Use which() to convert PYSPARK_PYTHON to an absolute path before shel…
JoshRosen Jun 26, 2015
27a389f
Skip MLLib tests for PyPy
JoshRosen Jun 26, 2015
37aff00
Python 3 fix
JoshRosen Jun 26, 2015
8f65ed0
Fix handling of module in python/run-tests
JoshRosen Jun 26, 2015
34c98d2
Fix universal_newlines for Python 3
JoshRosen Jun 27, 2015
8233d61
Add python/run-tests.py to Python lint checks
JoshRosen Jun 27, 2015
f578d6d
Fix print for Python 2.x
JoshRosen Jun 27, 2015
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
Prev Previous commit
Next Next commit
Move shell utility functions to own module.
  • Loading branch information
JoshRosen committed Jun 23, 2015
commit 311c6a99b313aa277cfc7d44be544a33c6550289
56 changes: 1 addition & 55 deletions dev/run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import os
import re
import sys
import shutil
import subprocess
from collections import namedtuple

from sparktestsupport.shellutils import exit_from_command_with_retcode, run_cmd, rm_r, which
import sparktestsupport.modules as modules

SPARK_HOME = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")
Expand Down Expand Up @@ -125,60 +125,6 @@ def get_error_codes(err_code_file):
ERROR_CODES = get_error_codes(os.path.join(SPARK_HOME, "dev/run-tests-codes.sh"))


def exit_from_command_with_retcode(cmd, retcode):
print "[error] running", ' '.join(cmd), "; received return code", retcode
sys.exit(int(os.environ.get("CURRENT_BLOCK", 255)))


def rm_r(path):
"""Given an arbitrary path properly remove it with the correct python
construct if it exists
- from: http://stackoverflow.com/a/9559881"""

if os.path.isdir(path):
shutil.rmtree(path)
elif os.path.exists(path):
os.remove(path)


def run_cmd(cmd):
"""Given a command as a list of arguments will attempt to execute the
command from the determined SPARK_HOME directory and, on failure, print
an error message"""

if not isinstance(cmd, list):
cmd = cmd.split()
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError as e:
exit_from_command_with_retcode(e.cmd, e.returncode)


def is_exe(path):
"""Check if a given path is an executable file
- from: http://stackoverflow.com/a/377028"""

return os.path.isfile(path) and os.access(path, os.X_OK)


def which(program):
"""Find and return the given program by its absolute path or 'None'
- from: http://stackoverflow.com/a/377028"""

fpath = os.path.split(program)[0]

if fpath:
if is_exe(program):
return program
else:
for path in os.environ.get("PATH").split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None


def determine_java_executable():
"""Will return the path of the java executable that will be used by Spark's
tests or `None`"""
Expand Down
81 changes: 81 additions & 0 deletions dev/sparktestsupport/shellutils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import os
import shutil
import subprocess
import sys


def exit_from_command_with_retcode(cmd, retcode):
print "[error] running", ' '.join(cmd), "; received return code", retcode
sys.exit(int(os.environ.get("CURRENT_BLOCK", 255)))


def rm_r(path):
"""
Given an arbitrary path, properly remove it with the correct Python construct if it exists.
From: http://stackoverflow.com/a/9559881
"""

if os.path.isdir(path):
shutil.rmtree(path)
elif os.path.exists(path):
os.remove(path)


def run_cmd(cmd):
"""
Given a command as a list of arguments will attempt to execute the command
and, on failure, print an error message
"""

if not isinstance(cmd, list):
cmd = cmd.split()
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError as e:
exit_from_command_with_retcode(e.cmd, e.returncode)


def is_exe(path):
"""
Check if a given path is an executable file.
From: http://stackoverflow.com/a/377028
"""

return os.path.isfile(path) and os.access(path, os.X_OK)


def which(program):
"""
Find and return the given program by its absolute path or 'None' if the program cannot be found.
From: http://stackoverflow.com/a/377028
"""

fpath = os.path.split(program)[0]

if fpath:
if is_exe(program):
return program
else:
for path in os.environ.get("PATH").split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None