SparkTest.NET 1.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package SparkTest.NET --version 1.2.1                
NuGet\Install-Package SparkTest.NET -Version 1.2.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SparkTest.NET" Version="1.2.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SparkTest.NET --version 1.2.1                
#r "nuget: SparkTest.NET, 1.2.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SparkTest.NET as a Cake Addin
#addin nuget:?package=SparkTest.NET&version=1.2.1

// Install SparkTest.NET as a Cake Tool
#tool nuget:?package=SparkTest.NET&version=1.2.1                

SparkTest.NET SparkTest.NET

Nuget

Support for testing Spark dotnet applications

Features

  • Test framework agnostic
  • Zero dependencies (except spark dotnet!)
  • Easy to use
  • Stable and fast spark debug usage tailored to testing
// import the factory
using static SparkTest.NET.SparkSessionFactory;

...

// Then you can use a spark session within a test
[Fact]
public static void SomeTest()
{
    var result = UseSession(session =>
    {
        // session is safe to use here
        ...
        // return something to assert against
        return ...
    });
    ...
}

Getting Started

To use this library, simply include SparkTest.NET.dll in your project or grab it from NuGet, and add this to the top of each test .cs file that needs it:

using static SparkTest.NET.SparkSessionFactory;

Why?

There is no documented/supported way to write tests for Spark dotnet applications.

There are a number of foot guns and this aims to disarm them.

  • spark-debug needs to run from the executing location of the tests assembly, this starts spark-debug in the correct location, and ensures that it is stopped after all the tests are complete
    • If spark-debug is already running, it will not be started, good for CI
  • spark-debug without any tuning is not optimized for short running tests, this,
    • Sets the log level to Error (default is super chatty)
    • Disables the Spark UI settings
    • Stops Spark from spreading out and localizes work
    • Disables shuffling for Spark SQL
    • Enables all cores on the spark submit job
  • SparkSession is not thread safe, its backed by a single SparkContext, this enforces that all operations that need a SparkSession run sequentially

The following settings configure the spark-submit process,

They can be set via the environment or from the test csproj file,

AssemblyMetadata Key Environment Variable Name Required? Description
SparkTest.NET.SparkHome SPARK_HOME Yes Location of spark on the system, used to start spark-submit
SparkTest.NET.SparkDotnetJarName SPARK_DOTNET_JAR_NAME Yes Name of the microsoft-spark jar file to use for example 'microsoft-spark-3-2_2.12-2.1.1.jar'
SparkTest.NET.ExtraJars SPARK_DEBUG_EXTRA_JARS No Optional extra jar files to include from the executing test location, for example 'azure-storage-3.1.0.jar,spark-xml-assembly-0.14.0.jar'

eg.


<ItemGroup>
    <AssemblyMetadata Include="SparkTest.NET.ExtraJars"
                      Value="azure-storage-3.1.0.jar,spark-xml-assembly-0.14.0.jar"/>
</ItemGroup>

or

export SPARK_DEBUG_EXTRA_JARS=azure-storage-3.1.0.jar,spark-xml-assembly-0.14.0.jar

For more details/information have a look the test projects or create an issue.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.2 476 6/7/2023
1.2.1 188 6/2/2023
1.2.0 279 4/29/2023
1.1.1 237 4/25/2023
1.1.0 243 4/23/2023
1.0.0 245 4/9/2023