Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test: User callback #1648

Closed
buhtz opened this issue Feb 20, 2024 · 4 comments · Fixed by #1658
Closed

Unit test: User callback #1648

buhtz opened this issue Feb 20, 2024 · 4 comments · Fixed by #1658

Comments

@buhtz
Copy link
Member

buhtz commented Feb 20, 2024

This issue need to be solved before working on PR #1269 .

To my knowledge user-callback behavior is not covered by any of the current tests. Of course the code is executed in some tests (and covered in a technical way) but not tested.

IMHO the behavior to test would be if the callback reasons/steps are called on the right position on the timeline after/before some other specific steps of the taking a snapshot process.

Problem: My assumption is that this is nearly impossible in the current state of the productive code. The code is not isolated enough. And especially in testing user-callback behavior to many elements of code are involved. I see no way doing this with "unit tests" or "integration tests" in the near time.

Solution: A "dirty" approach could be to do a full snapshot run in an "system test" and then parsing the log output for the expected messages (or their patterns) and if they appear in the correct order. We still have tests doing full backups. They do use some helper code from test/generic.py.

@buhtz buhtz added the HELP-WANTED Used by 24pullrequests.com to suggest issues label Feb 20, 2024
@buhtz buhtz added this to the Upcoming release (1.5.0) milestone Feb 20, 2024
@aryoda aryoda self-assigned this Feb 20, 2024
@aryoda
Copy link
Contributor

aryoda commented Feb 20, 2024

I think I (or someone else) could solve most of the testing requirements via an instrumented user-callback script that produces the required output (while checking if the call corresponds to current snapshot or mount state).

A good basis for that is my "logging-only" user-callback script...

@aryoda aryoda removed their assignment Feb 20, 2024
@buhtz buhtz self-assigned this Feb 21, 2024
@buhtz buhtz removed the HELP-WANTED Used by 24pullrequests.com to suggest issues label Feb 21, 2024
@buhtz
Copy link
Member Author

buhtz commented Feb 21, 2024

Thanks for that script. I am working on it....

@buhtz
Copy link
Member Author

buhtz commented Feb 24, 2024

I never really used user-callback. So I played around. To me this is seems to be a valid and expected combination and order of user-callback "reasons" for a local snapshot profile. Do you agree? Is this the order of Reason I should test for?

INFO: user-callback returned 'Profile: "Main profile" (1)  Reason: 7'
INFO: user-callback returned 'Profile: "Main profile" (1)  Reason: 1'
INFO: Take a new snapshot. Profile: 1 Main profile
INFO: Call rsync to take the snapshot
INFO: Save config file
INFO: Save permissions
INFO: Create info file
INFO: user-callback returned 'Profile: "Main profile" (1)  Reason: 3
sys.argv[4:]=['20240224-222022-131', '/tmp/bit.oz71hdju/snapshotdestination/backintime/test-host/test-user/1/20240224-222022-131']'
INFO: user-callback returned 'Profile: "Main profile" (1)  Reason: 2'
INFO: user-callback returned 'Profile: "Main profile" (1)  Reason: 8'
  • 7 - "Mount drives"
  • 1 - "Backup process begins"
  • 3 - "A new snapshot was taken" incl. id and path of the snapshot
  • 2 - "Backup process ends"
  • 8 - "Unmount the drives"

buhtz added a commit that referenced this issue Mar 9, 2024
@buhtz
Copy link
Member Author

buhtz commented Mar 9, 2024

Microsoft GitHub closed the accidentally closed the issue. Feel free to reopen if you think there should be more user callback related tests.

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

Successfully merging a pull request may close this issue.

2 participants