fix(test): disable scheduling in passport test for CDS v10#448
Conversation
CDS v10 enables cds.requires.scheduling by default. Its Scheduler runs periodic outbox reads (SELECT cds.outbox.Messages) in their own database transactions that overlap with request timing. On HANA those extra transactions each trigger the passport plugin's BEGIN reset and per-SELECT passport set, producing spurious SAP_PASSPORT set/reset pairs on the connection. The test's deterministic count assertions (_count === 2 for simple GET, _count === 3 for prepared statements) were written for the CDS v9 behavior where a single request produced exactly one transaction, and now fail non-deterministically depending on scheduler tick timing. Turning off scheduling for this test is sufficient: it only exercises that SAP_PASSPORT is set at the expected points during a user request, which does not require the scheduler.
There was a problem hiding this comment.
The change is correct and well-scoped. The environment variable name cds_requires_scheduling follows the standard CDS flat-key convention (underscore-delimited path of cds.requires.scheduling), it is set before cds is required so it takes effect at bootstrap time, and the comment accurately describes the root cause. No issues to flag.
The PR is a clean, minimal fix — a single targeted environment-variable override with a clear explanatory comment that prevents non-deterministic scheduler transactions from corrupting the _count assertions, without altering any production code.
PR Bot Information
Version: 1.26.14
- Correlation ID:
97eee740-76c4-11f1-9d9c-a2df1c241ad2 - File Content Strategy: Full file content
- LLM:
anthropic--claude-4.6-sonnet - Event Trigger:
pull_request.opened
SummaryThe following content is AI-generated and provides a summary of the pull request: fix(test): Disable Scheduling in Passport Test for CDS v10 CompatibilityBug Fix🐛 Fixed a flaky test failure in In CDS v9, each user request ran in a single transaction, so a simple query would produce exactly 2 passport operations (1 reset + 1 set). In CDS v10, the background scheduler introduces additional transactions that overlap with request timing, inflating the count to 4 and causing the assertion Changes
ContextThis is the same class of issue addressed in PR #435 for queue metrics. The passport test was overlooked during that fix. The scheduler's
PR Bot InformationVersion:
|
Problem
The HANA workflow's
passport.test.js › gets set once for simple queriesfails oncds-10-9— see run 28586742752:Root cause
CDS v10 sets
cds.requires.scheduling = trueby default. Its Scheduler pollscds.outbox.Messagesin its own database transactions. Those extra transactions overlap request timing and each triggers this plugin'sBEGINreset (lib/tracing/index.js:141-143) + per-SELECT passport set (lib/tracing/trace.js:351).Reproduced locally on
cds-10-9with@sap/cds@10.0.3+@cap-js/hana@3.0.1. Instrumented the plugin'sdbc.set()and captured the exact sequence:2 transactions × (1 reset + 1 passport) =
_count = 4. The test's assertion of2was correct for CDS v9's single-transaction-per-request behavior — cds v10 broke that invariant.The queue-metrics plugin already needed adjusting for the same scheduling shift — see #435 ("adapt queue metrics to CDS v10 scheduling changes"). Passport was overlooked.
Fix
Disable
schedulingfor this test only. The test's purpose is to verify SAP_PASSPORT stamping during a user request; the scheduler is irrelevant to that check and its background transactions just produce non-deterministic extra sets.Verification
Ran the CI-scoped subset (
CI=true HANA_DRIVER=hdb HANA_PROM=true npm test) locally against the same HDI container / driver stack the workflow uses:Follow-up (out of scope for this PR)
There's an underlying semantic issue: the passport plugin currently stamps SAP_PASSPORT on every database call, including scheduler/outbox internal transactions that have no user request to correlate to. That pollutes DSR passport traces on production HANA — worth a separate PR that skips
dbc.setwhencds.context?.user?.id === 'privileged'at both sites.