Skip to content

Fix tests to work with HANA#5

Open
schiwekM wants to merge 6 commits intomainfrom
fix/integration-tests
Open

Fix tests to work with HANA#5
schiwekM wants to merge 6 commits intomainfrom
fix/integration-tests

Conversation

@schiwekM
Copy link
Copy Markdown
Contributor

@schiwekM schiwekM commented Apr 10, 2026

  • Avoid data.reset() as else tests do no work on HANA
  • Add audit logging to hybrid tests
  • Fix issue that csn was not adjusted for privileges when using cds deploy

@schiwekM schiwekM requested a review from a team as a code owner April 10, 2026 15:45
@hyperspace-insights
Copy link
Copy Markdown

Summary

The following content is AI-generated and provides a summary of the pull request:


Fix Integration Tests for HANA Compatibility

Bug Fix

🐛 Refactored integration tests to work correctly with HANA by replacing the data.reset() approach with dynamically created, isolated test data. Additionally, audit logging support was added to the hybrid test setup in CI.

Changes

  • .github/actions/integration-tests/action.yml: Added steps to create and bind an Audit Logging BTP service instance (auditlog oauth2) as part of the integration test pipeline, enabling audit logging in hybrid test runs.

  • .gitignore: Added .cdsrc-private.json (generated by cds bind) to the ignore list to prevent it from being accidentally committed.

  • cds-plugin.js: Removed the explicit enhanceModelForDBRestrictions call from the loaded event handler; the function is now called inside the patched cds.compiler.to.hdi.migration function in hana-restrictions.js.

  • lib/build/hana-restrictions.js: Moved the enhanceModelForDBRestrictions call into the patched HDI migration function, fixing entity iteration to use csn.definitions directly instead of csn.collect() for better HANA compatibility.

  • package.json: Added Jest testTimeout configuration (40,000 ms) to accommodate slower HANA operations and avoid test timeouts.

  • tests/bookshop-app/db/undeploy.json: Added CSV and hdbtabledata patterns to the undeploy list to ensure test data artifacts are cleaned up during HANA deployments.

  • tests/retention/testDataProvider.js (new): Introduced a shared test data provider module that programmatically creates isolated, uniquely-IDed test fixtures for Customer, Employee, and all related sub-entities per test run, replacing the reliance on data.reset() with static seed data.

  • tests/retention/dataSubjectDeletion.test.js: Removed data.reset() and the local runWithPrivileged helper. Tests now use createCustomerTestData / createEmployeeTestData from testDataProvider.js. All hardcoded UUIDs replaced with dynamically generated IDs from test data, and queries scoped to per-test data for proper isolation.

  • tests/retention/ilmObjectName.test.js: Same pattern as dataSubjectDeletion.test.js — replaced data.reset() and hardcoded IDs with createCustomerTestData and dynamic IDs.

  • tests/retention/security.test.js: Removed data.reset() from the beforeEach hook since security tests do not depend on specific test data state.


  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.20.11 | 📖 Documentation | 🚨 Create Incident | 💬 Feedback

  • File Content Strategy: Full file content
  • Event Trigger: pull_request.opened
  • LLM: anthropic--claude-4.6-sonnet
  • Summary Prompt: Default Prompt
  • Output Template: Default Template
  • Correlation ID: 4c2761f0-34f4-11f1-8e19-6268d00b4fff

💌 Have ideas or want to contribute? Create an issue and share your thoughts with us!
📑 Check out the documentation for more information.
📬 Subscribe to the Hyperspace PR Bot DL to get the latest announcements and pilot features!

Made with ❤️ by Hyperspace.

Copy link
Copy Markdown

@hyperspace-insights hyperspace-insights bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

This PR replaces the data.reset() approach with isolated per-test data creation via a shared testDataProvider.js, and adds audit logging to the hybrid CI workflow. The overall direction is sound, but there are several substantive issues:

  1. HANA guard removed from enhanceModelForDBRestrictions (lib/build/hana-restrictions.js): The function is now called unconditionally inside the HDI migration hook, losing the db.kind === "hana" guard that existed in cds-plugin.js. This may cause HANA-specific CSN mutations in non-HANA builds.

  2. "eligible for deletion" tests still rely on seed data (dataSubjectDeletion.test.js): The hardcoded IDs in those assertions ("8e2f2640-6866-4dcf-8f4d-3027aa831cad", etc.) belong to the seed customer. With data.reset() gone, if any prior "deletion" test accidentally touches this seed customer, those assertions will silently break.

  3. Global DELETE … WHERE "1 = 1" breaks isolation (dataSubjectDeletion.test.js): Two tests delete all ILMObjectWithXPRBlockingEnabled rows, which wipes out records created by the outer beforeEach for employeeData, potentially causing subsequent tests in the same suite to fail.

  4. Stale data from the dual-role test: The inserted Employee and ILMObjectWithXPRBlockingEnabled record created in the "does not consider active records from different role" test are never cleaned up, which can affect subsequent test runs against a persistent DB.

PR Bot Information

Version: 1.20.11 | 📖 Documentation | 🚨 Create Incident | 💬 Feedback

  • LLM: anthropic--claude-4.6-sonnet
  • File Content Strategy: Full file content
  • Correlation ID: 4c2761f0-34f4-11f1-8e19-6268d00b4fff
  • Event Trigger: pull_request.opened

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant