Skip to content

Fix sporadic test failures in S3BackupService specs by mocking tar compression#235

Merged
stefan-burke merged 2 commits intomainfrom
terragon/fix-s3backupservice-sporadic-failure
Aug 22, 2025
Merged

Fix sporadic test failures in S3BackupService specs by mocking tar compression#235
stefan-burke merged 2 commits intomainfrom
terragon/fix-s3backupservice-sporadic-failure

Conversation

@stefan-burke
Copy link
Copy Markdown
Member

Summary

  • Addresses sporadic failures in S3BackupService specs related to tar compression mocking
  • Enhances test reliability by simulating creation of compressed files during tar command mocks

Changes

Test Suite Improvements

  • Updated s3_backup_service_spec.rb to mock the tar -czf system call more realistically:
    • Instead of just returning true, the mock now creates a compressed file with dummy content at the expected path
    • This simulates the actual side effect of the tar command, preventing downstream errors in tests
  • Added default stubs for system calls related to database backup creation and tar compression
  • Removed redundant manual file creation in tests, relying on the improved mocks instead

Test plan

  • Run S3BackupService specs multiple times to confirm elimination of sporadic failures
  • Verify that all tests involving tar compression and S3 upload pass consistently
  • Ensure no regressions in backup creation and upload logic coverage

🌿 Generated by Terry


ℹ️ Tag @terragon-labs to ask questions and address PR feedback

📎 Task: https://www.terragonlabs.com/task/18b0a700-56cd-4652-ae1c-c1fb89869257

stefan-burke and others added 2 commits August 22, 2025 13:05
…king

- Mock tar compression to create a compressed file during tests
- Replace simple return true with file creation to simulate tar output
- Add detailed stubs for system calls related to backup and compression
- Improve test reliability by simulating actual file creation in mocks

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
…ompression mocking

Refactored the S3BackupService spec to introduce a helper method `mock_tar_compression` that mocks the tar compression system call and creates a compressed file. This reduces duplication and improves readability by replacing repeated mocking code with a single reusable method.

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
@stefan-burke stefan-burke marked this pull request as ready for review August 22, 2025 17:15
@stefan-burke stefan-burke merged commit 7074a51 into main Aug 22, 2025
16 of 17 checks passed
@stefan-burke stefan-burke deleted the terragon/fix-s3backupservice-sporadic-failure branch August 22, 2025 18:23
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.

1 participant