Skip to content

UFAL/Failing BE tests#1301

Open
Kasinhou wants to merge 8 commits intodtq-devfrom
ufal/fix-be-tests
Open

UFAL/Failing BE tests#1301
Kasinhou wants to merge 8 commits intodtq-devfrom
ufal/fix-be-tests

Conversation

@Kasinhou
Copy link
Copy Markdown

@Kasinhou Kasinhou commented Apr 7, 2026

Problem description

Issue: https://github.com/dataquest-dev/dspace-customers/issues/524

Manual Testing (if applicable)

Copilot review

  • Requested review from Copilot

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses failing backend tests (Issue: dataquest-dev/dspace-customers#524) by making integration tests less brittle and aligning Spring Boot cache configuration with DSpace kernel-managed caching.

Changes:

  • Update MetadataBitstreamControllerIT to validate the ZIP response by parsing/extracting it instead of byte-for-byte ZIP generation.
  • Make BitstreamFormatRestRepositoryIT compute the baseline number of bitstream formats dynamically rather than relying on a hardcoded constant.
  • Adjust Spring Boot configuration to avoid creating a competing CacheManager (cache is managed by the DSpace kernel).

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
dspace-server-webapp/src/test/java/org/dspace/app/rest/MetadataBitstreamControllerIT.java Switches ZIP verification to extract-and-compare approach.
dspace-server-webapp/src/test/java/org/dspace/app/rest/BitstreamFormatRestRepositoryIT.java Removes hardcoded baseline count; initializes it from the DB per test.
dspace-server-webapp/src/main/resources/application.properties Disables Boot cache autoconfig to prevent competing CacheManager vs kernel cache.
dspace-api/src/test/java/org/dspace/ctask/general/CreateMissingIdentifiersIT.java Restores modified config after test to avoid cross-test pollution.
dspace-api/src/test/java/org/dspace/builder/ItemBuilder.java Fixes indentation in test builder cleanup.

Comment on lines +90 to +94
try (ZipArchiveInputStream zipIn = new ZipArchiveInputStream(new ByteArrayInputStream(responseBytes))) {
ZipArchiveEntry entry = zipIn.getNextZipEntry();
// Verify entry name matches bitstream name
assertEquals(bts.getName(), entry.getName());
// Verify uncompressed content matches the original bitstream content
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

After calling getNextZipEntry(), the test assumes an entry exists. If the response is not a valid ZIP or is empty, entry will be null and the test will NPE on entry.getName(), which makes failures harder to diagnose. Add an assertion that the entry is non-null (and optionally assert there are no unexpected additional entries).

Copilot uses AI. Check for mistakes.
Comment on lines +81 to 82
String bitstreamContent = "ThisIsSomeDummyText";

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

bitstreamContent is hardcoded again in this test method, duplicating the value used when creating the Bitstream in setUp(). To avoid future divergence (e.g., setUp changes but the assertion doesn’t), store the content in a shared constant/field or derive expected bytes by retrieving the bitstream content from bts.

Copilot uses AI. Check for mistakes.
Comment on lines +61 to +66
private int DEFAULT_AMOUNT_FORMATS;

@Before
public void init() throws SQLException {
DEFAULT_AMOUNT_FORMATS = bitstreamFormatService.findAll(context).size();
}
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

DEFAULT_AMOUNT_FORMATS is no longer a constant (it’s assigned in @before), but it’s still named like a constant (ALL_CAPS). Rename it to a regular field name (e.g., defaultAmountFormats/initialAmountFormats) to match Java conventions and reduce confusion.

Copilot generated this review using guidance from organization custom instructions.
@Kasinhou
Copy link
Copy Markdown
Author

Kasinhou commented Apr 8, 2026

Current state:

Error:  Failures: 
Error:    IIIFControllerIT.findOneWithCacheEvictionAfterBitstreamUpdate:1278 JSON path "$.sequences[0].canvases[1].label"
Expected: is "Test label"
     but: was "Original label"
Error:    IIIFControllerIT.findOneWithCacheEvictionAfterItemUpdate:1400 JSON path "$.metadata[0].value"
Expected: is "Public item (revised)"
     but: was "Public item 1"
[INFO] 
Error:  Tests run: 3278, Failures: 2, Errors: 0, Skipped: 55

@kuchtiak-ufal
Copy link
Copy Markdown

See the fixes made in ufal/clarin-dspace repository, particularly:
ufal#1353

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants