Skip to content

[GLUTEN-11550][UT] Add GlutenTestSetWithSystemPropertyTrait, enable 6 suites, remove 7 TestHiveSingleton suites, fix JobTagging flaky test#11847

Merged
baibaichen merged 3 commits intoapache:mainfrom
baibaichen:fix/11550-system-property-trait
Apr 10, 2026
Merged

[GLUTEN-11550][UT] Add GlutenTestSetWithSystemPropertyTrait, enable 6 suites, remove 7 TestHiveSingleton suites, fix JobTagging flaky test#11847
baibaichen merged 3 commits intoapache:mainfrom
baibaichen:fix/11550-system-property-trait

Conversation

@baibaichen
Copy link
Copy Markdown
Contributor

@baibaichen baibaichen commented Mar 30, 2026

What changes were proposed in this pull request?

1. Add GlutenTestSetWithSystemPropertyTrait — a reusable trait for test suites whose Spark parent creates per-test SparkContext/SparkSession (via LocalSparkContext, LocalSparkSession, or direct new SparkContext). It injects GlutenPlugin config via system properties so per-test sessions inherit it.

2. Enable 6 suites by switching to this trait:

  • GlutenSQLExecutionSuite
  • GlutenSQLJsonProtocolSuite
  • GlutenShufflePartitionsUtilSuite
  • GlutenExternalAppendOnlyUnsafeRowArraySuite
  • GlutenUnsafeRowSerializerSuite
  • GlutenSparkSessionJobTaggingAndCancellationSuite

3. Remove 7 TestHiveSingleton suites that cannot load GlutenPlugin due to trait conflict (TestHiveSingleton.spark (protected val) vs Gluten trait spark (implicit protected def)). The non-Hive variants are already enabled. Updated excluded-spark-uts.md.

4. Fix JobTagging flaky test — The original "Tags set from session are prefixed with session UUID" test uses ExecutionContext.global whose ForkJoinPool reuses threads created before addTag(). InheritableThreadLocal (used by managedJobTags) only copies values at thread creation time, so reused threads see an empty tag map. This causes withSessionTagsApplied to not attach the user tag to the job, making cancelJobsWithTagWithFuture return empty.

Root cause confirmed via CI debug logging: Future thread (id=17689) had managedJobTags=Map() while main thread had the correct tag. The fix creates a fresh SingleThreadExecutor after addTag() so the new thread inherits InheritableThreadLocal values.

How was this patch tested?

  • All 6 enabled suites verified on spark41 and spark40 via run-scala-test.sh
  • JobTagging testGluten verified locally (5/5 passed) and on CI (spark40 + spark41 all green)
  • CI run: all 59 checks passed (2026-04-09)

Related issue: #11550

@github-actions github-actions Bot added the CORE works for Gluten Core label Mar 30, 2026
@github-actions
Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@baibaichen baibaichen force-pushed the fix/11550-system-property-trait branch from 619c5dd to 6662b97 Compare March 30, 2026 15:04
@github-actions
Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@baibaichen baibaichen force-pushed the fix/11550-system-property-trait branch from 6662b97 to b303883 Compare April 2, 2026 07:45
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 2, 2026

Run Gluten Clickhouse CI on x86

@baibaichen baibaichen force-pushed the fix/11550-system-property-trait branch from b600264 to 4987bcb Compare April 9, 2026 01:52
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 9, 2026

Run Gluten Clickhouse CI on x86

@baibaichen baibaichen force-pushed the fix/11550-system-property-trait branch from 4987bcb to e9e760f Compare April 9, 2026 07:46
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 9, 2026

Run Gluten Clickhouse CI on x86

baibaichen and others added 3 commits April 9, 2026 16:08
…e 6 suites

Add a reusable trait for test suites whose parent creates per-test
SparkContext/SparkSession (via LocalSparkContext/LocalSparkSession).
It injects GlutenPlugin config via system properties so per-test
sessions inherit it, avoiding shared session conflicts.

Enable 6 suites by switching to this trait:
- GlutenSQLExecutionSuite (SQLExecutionSuite: new SparkContext internally)
- GlutenSQLJsonProtocolSuite (SQLJsonProtocolSuite with LocalSparkSession)
- GlutenShufflePartitionsUtilSuite (ShufflePartitionsUtilSuite with LocalSparkContext)
- GlutenExternalAppendOnlyUnsafeRowArraySuite (with LocalSparkContext)
- GlutenUnsafeRowSerializerSuite (UnsafeRowSerializerSuite with LocalSparkSession)
- GlutenSparkSessionJobTaggingAndCancellationSuite (with LocalSparkContext)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…lutenPlugin

Remove 7 test suites (spark40 + spark41) that extend TestHiveSingleton.
TestHiveSingleton.spark (protected val) conflicts with Gluten test traits'
spark (implicit protected def), making it impossible to load GlutenPlugin.

The non-Hive variants (e.g. GlutenBucketedReadWithoutHiveSupportSuite)
are already enabled and cover the same functionality.

Removed suites:
- GlutenBucketedReadWithHiveSupportSuite
- GlutenBucketedWriteWithHiveSupportSuite
- GlutenDisableUnnecessaryBucketedScanWithHiveSupportSuite
- GlutenCommitFailureTestRelationSuite
- GlutenJsonHadoopFsRelationSuite
- GlutenParquetHadoopFsRelationSuite
- GlutenSimpleTextHadoopFsRelationSuite

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The original test uses ExecutionContext.global whose ForkJoinPool reuses
threads created long before addTag(). InheritableThreadLocal (used by
managedJobTags) only copies values at thread creation time, so reused
threads see an empty tag map. This causes withSessionTagsApplied to not
attach the user tag to the job, making cancelJobsWithTagWithFuture
return empty.

Fix: testGluten override that creates a fresh SingleThreadExecutor AFTER
addTag(), ensuring the new thread inherits InheritableThreadLocal values.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@baibaichen baibaichen force-pushed the fix/11550-system-property-trait branch from e9e760f to f75e867 Compare April 9, 2026 16:08
@baibaichen baibaichen changed the title [GLUTEN-11550][UT] Add GlutenTestSetWithSystemPropertyTrait, enable 6 suites, remove 7 TestHiveSingleton suites [GLUTEN-11550][UT] Add GlutenTestSetWithSystemPropertyTrait, enable 6 suites, remove 7 TestHiveSingleton suites, fix JobTagging flaky test Apr 9, 2026
@baibaichen baibaichen marked this pull request as ready for review April 9, 2026 16:09
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 9, 2026

Run Gluten Clickhouse CI on x86

@baibaichen baibaichen merged commit 0fbec92 into apache:main Apr 10, 2026
107 of 108 checks passed
@baibaichen baibaichen deleted the fix/11550-system-property-trait branch April 10, 2026 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE works for Gluten Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants