Skip to content

Conversation

@akrem-chabchoub
Copy link
Contributor

@akrem-chabchoub akrem-chabchoub commented Oct 29, 2025

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

Add synctest in joiner tests.

Open API Spec Version Changes (if applicable)

Motivation and Context (Optional)

Related Issue (Optional)

#5232

Screenshots (if appropriate):

@akrem-chabchoub akrem-chabchoub self-assigned this Oct 29, 2025
@akrem-chabchoub akrem-chabchoub marked this pull request as ready for review October 29, 2025 15:39
Copilot AI review requested due to automatic review settings October 29, 2025 15:39
@akrem-chabchoub akrem-chabchoub added this to the v2.7.0 milestone Oct 29, 2025
Copy link
Contributor

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 refactors test cases in pkg/file/joiner/joiner_test.go to use Go 1.24+'s testing/synctest package for better time-based test control and deterministic timing. The changes update four test functions to wrap their logic in synctest.Test() calls and replace context.Background() with t.Context() throughout the test file. Additionally, the Makefile has been temporarily modified to run only the joiner tests during CI.

  • Wrapped four test functions (TestJoinerReadAt, TestJoinerOneLevel, TestJoinerTwoLevelsAcrossChunk, TestJoinerIterateChunkAddresses) in synctest.Test()
  • Replaced context.Background() with t.Context() across all modified tests
  • Refactored TestJoinerRedundancyMultilevel to extract a helper function and use synctest.Test()
  • Temporarily limited CI test scope to ./pkg/file/joiner in Makefile

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/file/joiner/joiner_test.go Wrapped selected test functions in synctest.Test() and replaced context.Background() with t.Context() for improved time control and test determinism
Makefile Temporarily narrowed CI test scope from ./... to ./pkg/file/joiner to focus on joiner package tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}
if c != swarm.ChunkSize {
t.Fatalf("chunk %d expected read %d bytes; got %d", i, swarm.ChunkSize, c)
if c != 42 {
Copy link
Contributor

Choose a reason for hiding this comment

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

why 42?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It showed that I changed the line to 42, but in reality it didn’t change at all.

Image

Copy link
Contributor

@acud acud left a comment

Choose a reason for hiding this comment

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

It would really be easier to review and approve if the change would be just about adding the synctest helpers. I'm not sure if all the other changes are a result of some vscode auto-linter/formatter or a refactor extension, in which case I would disable it at least for these sort of changes. Mind you that these are delicate components. Every tiny change to tests and production code have to be thoroughly understood before being approved.

@akrem-chabchoub akrem-chabchoub force-pushed the migrate-to-synctest-joiner branch from 9f89af3 to 8aa1b5f Compare November 22, 2025 15:20
@akrem-chabchoub
Copy link
Contributor Author

It would really be easier to review and approve if the change would be just about adding the synctest helpers. I'm not sure if all the other changes are a result of some vscode auto-linter/formatter or a refactor extension, in which case I would disable it at least for these sort of changes. Mind you that these are delicate components. Every tiny change to tests and production code have to be thoroughly understood before being approved.

Yes, I completely agree.
If you're using VSCode, these extensions can help avoid noisy diffs and make reviews much clearer:

GitHub Pull Requests:
https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github

SemanticDiff:
https://marketplace.visualstudio.com/items?itemName=semanticdiff.semanticdiff

@akrem-chabchoub akrem-chabchoub force-pushed the migrate-to-synctest-joiner branch from 50ab377 to a75c2ba Compare November 23, 2025 12:26
})

// First sanity check and recover a range
t.Log("Starting test sequence")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this log intentional or it was used for debugging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its used for debugging, I removed it

})
// Helper function to test reading with different strategies
canReadRange := func(s getter.Strategy, fallback bool, canRead bool, description string) {
t.Logf("Testing: %s", description)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this log intentional or it was used for debugging?

Copy link
Contributor Author

@akrem-chabchoub akrem-chabchoub Nov 29, 2025

Choose a reason for hiding this comment

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

Yes its intentioanl.
Previously we were using t.Run() and passing the description in it. But since synctest doesn't allow using t.Run() inside it so I passed the description to the canReadRange function.

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.

4 participants