登录 注册

spark-testing-base

去点 Star
开发者工具效率与办公工具内容创作与媒体工具
1,554
Stars
356
Forks
67
Watchers
97
Open Issues
Apache-2.0
许可证
Scala
语言
2015-01-30
创建时间
2026-10-31
最近更新

项目能做什么

spark-testing-base 是一个用于 Spark 应用程序测试的基础库。它解决了每次编写测试时都要手动搭建和销毁本地 Spark 运行环境的麻烦。核心功能是提供预设的测试基类,让开发者直接继承即可快速编写针对 Spark 的单元测试,支持 Scala 和 Python。
来源:AI 基于仓库事实生成 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
![build status](https://github.com/holdenk/spark-testing-base/actions/workflows/github-actions-basic.yml/badge.svg?branch=main)


# spark-testing-base

Base classes to use when writing tests with Spark.

## Why?

You've written an awesome program in Spark and now its time to write some tests. Only you find yourself writing the code to setup and tear down local mode Spark in between each suite and you say to your self:
This is not my beautiful code.

## How?

So you include com.holdenkarau.spark-testing-base [spark_version]_[spark_testing_base_version] (in thise case 2.1.2) and extend one of the classes and write some simple tests instead.  For example to include this in a project using Spark 4.0.0:

```scala
"com.holdenkarau" %% "spark-testing-base" % "4.0.0_2.1.2" % "test"
```

or

```
<dependency>
	<groupId>com.holdenkarau</groupId>
	<artifactId>spark-testing-base_2.13</artifactId>
	<version>${spark.version}_2.1.2</version>
	<scope>test</scope>
</dependency>
```

How to use it inside your code? have a look at the [wiki](https://github.com/holdenk/spark-testing-base/wiki) page.

The [Maven repositories page for spark-testing-base](https://mvnrepository.com/artifact/com.holdenkarau) lists the releases available.

The Python package of spark-testing-base is available via:
* PyPI: https://pypi.org/project/spark-testing-base/, e.g. `pip install spark-testing-base`
* Conda: https://anaconda.org/conda-forge/spark-testing-base, e.g. `conda install -c conda-forge spark-testing-base`

## Minimum Memory Requirements and OOMs

The default SBT testing java options are too small to support running many of the tests due to the need to launch Spark in local mode. To increase the amount of memory in a build.sbt file you can add:

```scala
fork in Test := true
javaOptions ++= Seq("-Xms8G", "-Xmx8G", "-XX:MaxPermSize=4048M", "-XX:+CMSClassUnloadingEnabled")
```

Note: if your running in JDK17+ PermSize and ClassnloadingEnabled have been removed so it becomes:

```scala
fork in Test := true
javaOptions ++= Seq("-Xms8G", "-Xmx8G"),
```

If using surefire you can add:

```
<argLine>-Xmx2048m -XX:MaxPermSize=2048m</argLine>
```

Note: the specific memory values are examples only (and the values used to run spark-testing-base's own tests).

## Special considerations

Make sure to disable parallel execution.

In sbt you can add:

```scala
parallelExecution in Test := false
```

In surefire make sure that forkCount is set to 1 and reuseForks is true.

If your testing Spark SQL CodeGen make sure to set SPARK_TESTING=true

### Codegen tests and Running Spark Testing Base's own tests

If you are testing codegen it's important to have SPARK_TESTING set to yes, as we do in our github actions.

`SPARK_TESTING=yes ./build/sbt clean +compile +test -DsparkVersion=$SPARK_VERSION`

## Where is this from?

Some of this code is a stripped down version of the test suite bases that are in Apache Spark but are not accessible. Other parts are also inspired by sscheck (scalacheck generat
阅读完整原文

项目深度分析 AI 生成

Spark 测试云端沙盒与 CI 加速插件

产品构想针对 README 中提到的测试需配置高内存(如 -Xmx8G)且必须禁用并行执行(parallelExecution := false)导致 CI 慢且易 OOM 的痛点,提供按需付费的云端高配测试沙盒或智能分片并行调度 CI 插件。
核心功能自动化的 JVM/Spark 测试内存调优、测试套件智能分片与隔离并行执行、OOM 根因分析报告。
目标用户中小型数据团队、受限于 CI Runner 内存和构建时长的 Spark 研发团队。
难度/周期中 · 2-4个月 · 成本:低至中(主要为初期云主机测试资源及开发时间成本,推测)
收费模式按构建时长/并发数订阅收费(SaaS 模式)。
竞争风险企业代码合规性要求高,可能不愿将测试代码放至第三方云端,需考虑支持私有化 Runner(推测)。
依据 已验证事实

Spark 版本升级与测试迁移辅助工具/咨询

产品构想利用项目紧跟 Spark 4.0.0 和 JDK17 的技术积累,为正在进行 Spark 2/3 向 Spark 4 或 JDK17 迁移的企业提供自动化测试兼容性扫描工具及定制迁移服务。
核心功能废弃 API 与 CodeGen 测试环境变量检查、自动生成适配新版本的测试基类脚手架、人工专家排错支持。
目标用户有历史 Spark 资产、面临技术栈升级压力的中大型企业数据团队。
难度/周期低(咨询/脚本工具) · 1-2个月 · 成本:极低(主要为人力与时间成本)
收费模式项目制技术咨询收费或迁移工具按席位/代码库授权收费。
竞争风险Spark 4.0 生态尚在演进中,企业实际全面升级的节奏可能较慢,需求释放存在滞后性(尚需验证的假设)。
依据 AI推测

基于 Apache-2.0 的企业级 Spark 数据测试与质量平台(Open Core)

产品构想基于现有开源测试基类,向下延伸封装面向企业的数据测试高级特性(如脱敏测试数据自动生成、DataFrame 差异可视化报告、血缘与测试覆盖率看板),以商业版形式交付。
核心功能可视化测试报告、生产数据脱敏采样生成器、与现有调度系统(如 Airflow)集成的自动化回归测试门禁。
目标用户对数据质量、合规性有强需求的大型金融、互联网企业数据中台团队。
难度/周期高 · 6个月以上 · 成本:中至高(需持续研发投入及企业级销售支持,推测)
收费模式企业版私有化部署授权(License)+ 年度维保服务。
竞争风险商业化路径较重,不适合单人长期独立推进;且需面对现有开源数据质量工具(如 Great Expectations 等)的间接竞争(AI推测)。
依据 AI推测
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

项目中文简介Stars语言
zeotap/spark-property-tests 中文介绍暂未生成
Write property based tests easily on spark dataframes
21 Scala
mohsenasm/spark-on-yarn-cluster 中文介绍暂未生成
A Procedure To Create A Yarn Cluster Based on Docker, Run Sp
16 C
aws-samples/aws-glue-apache-spark-unittesting-using-localstack 中文介绍暂未生成
This codebase covers a use-case that describes how to setup
11 Python
jafeerr/spark-data-test 中文介绍暂未生成
Spark Data Test - A PySpark-based automation testing utility
7 Python
以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。

项目优势与风险

技术成熟度创建于 2015-01-30,近 30 天仍在推送,发布过 4 个 Release
社区活跃Star 1,554 / Fork 356 / Issue 97(数据支持,可自行核实)
许可证Apache-2.0
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

此项目未提供 Docker 镜像,安装步骤以原仓库 README 为准(涉及依赖安装与环境配置,对新手门槛较高)。