public class TestUtils
extends Object
TODO: See if we can move this to the test codebase by specifying test dependencies between projects.
| Constructor and Description |
|---|
TestUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <E extends Throwable> |
assertExceptionMsg(Throwable exception,
String msg,
boolean ignoreCase,
scala.reflect.ClassTag<E> evidence$1)
Asserts that exception message contains the message.
|
static void |
assertNotSpilled(SparkContext sc,
String identifier,
scala.Function0<scala.runtime.BoxedUnit> body)
Run some code involving jobs submitted to the given context and assert that the jobs
did not spill.
|
static void |
assertSpilled(SparkContext sc,
String identifier,
scala.Function0<scala.runtime.BoxedUnit> body)
Run some code involving jobs submitted to the given context and assert that the jobs spilled.
|
static void |
configTestLog4j2(String level)
config a log4j2 properties used for testsuite
|
static java.io.File |
createCompiledClass(String className,
java.io.File destDir,
String toStringValue,
String baseClass,
scala.collection.Seq<java.net.URL> classpathUrls,
scala.collection.Seq<String> implementsClasses,
String extraCodeBody,
scala.Option<String> packageName)
Creates a compiled class with the given name.
|
static java.io.File |
createCompiledClass(String className,
java.io.File destDir,
org.apache.spark.TestUtils.JavaSourceFromString sourceFile,
scala.collection.Seq<java.net.URL> classpathUrls)
Creates a compiled class with the source file.
|
static java.net.URL |
createJar(scala.collection.Seq<java.io.File> files,
java.io.File jarFile,
scala.Option<String> directoryPrefix,
scala.Option<String> mainClass)
Create a jar file that contains this set of files.
|
static java.net.URL |
createJarWithClasses(scala.collection.Seq<String> classNames,
String toStringValue,
scala.collection.Seq<scala.Tuple2<String,String>> classNamesWithBase,
scala.collection.Seq<java.net.URL> classpathUrls)
Create a jar that defines classes with the given names.
|
static java.net.URL |
createJarWithFiles(scala.collection.immutable.Map<String,String> files,
java.io.File dir)
Create a jar file containing multiple files.
|
static String |
createTempJsonFile(java.io.File dir,
String prefix,
org.json4s.JsonAST.JValue jsonValue)
Creates a temp JSON file that contains the input JSON record.
|
static String |
createTempScriptWithExpectedOutput(java.io.File dir,
String prefix,
String output)
Creates a temp bash script that prints the given output.
|
static scala.Option<String> |
getAbsolutePathFromExecutable(String executable)
Get the absolute path from the executable.
|
static int |
httpResponseCode(java.net.URL url,
String method,
scala.collection.Seq<scala.Tuple2<String,String>> headers)
Returns the response code from an HTTP(S) URL.
|
static String |
httpResponseMessage(java.net.URL url,
String method,
scala.collection.Seq<scala.Tuple2<String,String>> headers)
Returns the response message from an HTTP(S) URL.
|
static boolean |
isPythonVersionAvailable() |
static String[] |
listDirectory(java.io.File path)
Returns the list of files at 'path' recursively.
|
static String |
minimumPythonSupportedVersion() |
static java.io.File[] |
recursiveList(java.io.File f)
Lists files recursively.
|
static boolean |
testCommandAvailable(String command)
Test if a command is available.
|
static <T> T |
withHttpConnection(java.net.URL url,
String method,
scala.collection.Seq<scala.Tuple2<String,String>> headers,
scala.Function1<java.net.HttpURLConnection,T> fn) |
static void |
withHttpServer(String resBaseDir,
scala.Function1<java.net.URL,scala.runtime.BoxedUnit> body) |
static <L extends SparkListener> |
withListener(SparkContext sc,
L listener,
scala.Function1<L,scala.runtime.BoxedUnit> body)
Runs some code with the given listener installed in the SparkContext.
|
public static java.net.URL createJarWithClasses(scala.collection.Seq<String> classNames,
String toStringValue,
scala.collection.Seq<scala.Tuple2<String,String>> classNamesWithBase,
scala.collection.Seq<java.net.URL> classpathUrls)
Note: if this is used during class loader tests, class names should be unique in order to avoid interference between tests.
classNames - (undocumented)toStringValue - (undocumented)classNamesWithBase - (undocumented)classpathUrls - (undocumented)public static java.net.URL createJarWithFiles(scala.collection.immutable.Map<String,String> files,
java.io.File dir)
files map contains a mapping of
file names in the jar file to their contents.files - (undocumented)dir - (undocumented)public static java.net.URL createJar(scala.collection.Seq<java.io.File> files,
java.io.File jarFile,
scala.Option<String> directoryPrefix,
scala.Option<String> mainClass)
files - (undocumented)jarFile - (undocumented)directoryPrefix - (undocumented)mainClass - (undocumented)public static java.io.File createCompiledClass(String className,
java.io.File destDir,
org.apache.spark.TestUtils.JavaSourceFromString sourceFile,
scala.collection.Seq<java.net.URL> classpathUrls)
public static java.io.File createCompiledClass(String className,
java.io.File destDir,
String toStringValue,
String baseClass,
scala.collection.Seq<java.net.URL> classpathUrls,
scala.collection.Seq<String> implementsClasses,
String extraCodeBody,
scala.Option<String> packageName)
public static void assertSpilled(SparkContext sc, String identifier, scala.Function0<scala.runtime.BoxedUnit> body)
sc - (undocumented)identifier - (undocumented)body - (undocumented)public static void assertNotSpilled(SparkContext sc, String identifier, scala.Function0<scala.runtime.BoxedUnit> body)
sc - (undocumented)identifier - (undocumented)body - (undocumented)public static <E extends Throwable> void assertExceptionMsg(Throwable exception,
String msg,
boolean ignoreCase,
scala.reflect.ClassTag<E> evidence$1)
E is supplied, this will additionally confirm
that the exception is a subtype of the exception provided in the type parameter.exception - (undocumented)msg - (undocumented)ignoreCase - (undocumented)evidence$1 - (undocumented)public static boolean testCommandAvailable(String command)
command - (undocumented)public static String minimumPythonSupportedVersion()
public static boolean isPythonVersionAvailable()
public static scala.Option<String> getAbsolutePathFromExecutable(String executable)
spark/dev/sparktestsupport/shellutils.py.executable - (undocumented)public static int httpResponseCode(java.net.URL url,
String method,
scala.collection.Seq<scala.Tuple2<String,String>> headers)
url - (undocumented)method - (undocumented)headers - (undocumented)public static String httpResponseMessage(java.net.URL url,
String method,
scala.collection.Seq<scala.Tuple2<String,String>> headers)
url - (undocumented)method - (undocumented)headers - (undocumented)public static <T> T withHttpConnection(java.net.URL url,
String method,
scala.collection.Seq<scala.Tuple2<String,String>> headers,
scala.Function1<java.net.HttpURLConnection,T> fn)
public static <L extends SparkListener> void withListener(SparkContext sc, L listener, scala.Function1<L,scala.runtime.BoxedUnit> body)
sc - (undocumented)listener - (undocumented)body - (undocumented)public static void withHttpServer(String resBaseDir,
scala.Function1<java.net.URL,scala.runtime.BoxedUnit> body)
public static void configTestLog4j2(String level)
level - (undocumented)public static java.io.File[] recursiveList(java.io.File f)
f - (undocumented)public static String[] listDirectory(java.io.File path)
path - (undocumented)public static String createTempJsonFile(java.io.File dir,
String prefix,
org.json4s.JsonAST.JValue jsonValue)
public static String createTempScriptWithExpectedOutput(java.io.File dir,
String prefix,
String output)