Skip to content

tests: fix flaky test in entity_store_compaction#4256

Merged
Bravo555 merged 1 commit into
thin-edge:mainfrom
Bravo555:test/entity-store-compaction
Jul 15, 2026
Merged

tests: fix flaky test in entity_store_compaction#4256
Bravo555 merged 1 commit into
thin-edge:mainfrom
Bravo555:test/entity-store-compaction

Conversation

@Bravo555

@Bravo555 Bravo555 commented Jul 14, 2026

Copy link
Copy Markdown
Member

Proposed changes

The test's check could run before compaction process is completed, failing it. I've observed in the test report, that after failure, entity store was 4 entities (and only 1 was the compaction_count device), so the compaction completed, just a little later.

To fix this, do the comparison using test in bash so it's subject to the retry policy. To confirm that it worked, I see the following in the report of some test runs after the fix:

cmd: ['/bin/sh', '-c', 'bash -c \'[ $(grep -c "compaction_count" /etc/tedge/.agent/entity_store.jsonl) -lt 10 ]\''], exit code: 1
...
cmd: ['/bin/sh', '-c', 'bash -c \'[ $(grep -c "compaction_count" /etc/tedge/.agent/entity_store.jsonl) -lt 10 ]\''], exit code: 0

The retry is applied once, the compaction completes, and the test succeeds.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue


Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s. You can activate automatic signing by running just prepare-dev once)
  • I ran just format as mentioned in CODING_GUIDELINES
  • I used just check as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

The test's check could run before compaction process is completed,
failing it. I've observed in the test report, that after failure, entity
store was 4 entities (and only 1 was the compaction_count device), so
the compaction completed, just a little later.

To fix this, do the comparison using test in bash so it's subject to the
retry policy. To confirm that it worked, I see the following in the
report of some test runs after the fix:

```
cmd: ['/bin/sh', '-c', 'bash -c \'[ $(grep -c "compaction_count" /etc/tedge/.agent/entity_store.jsonl) -lt 10 ]\''], exit code: 1
...
cmd: ['/bin/sh', '-c', 'bash -c \'[ $(grep -c "compaction_count" /etc/tedge/.agent/entity_store.jsonl) -lt 10 ]\''], exit code: 0
```

The retry is applied once, the compaction completes, and the test
succeeds.

Signed-off-by: Marcel Guzik <marcel.guzik@cumulocity.com>
@Bravo555 Bravo555 requested a review from a team as a code owner July 14, 2026 18:57
@Bravo555 Bravo555 added the theme:testing Theme: Testing label Jul 14, 2026
@Bravo555 Bravo555 deployed to Test Pull Request July 14, 2026 18:57 — with GitHub Actions Active
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
Contributor

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
953 0 7 953 100 2h50m55.760073s

@reubenmiller reubenmiller added the skip-release-notes Don't include the ticket in the auto generated release notes label Jul 14, 2026
@Bravo555 Bravo555 added this pull request to the merge queue Jul 15, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 15, 2026
@Bravo555 Bravo555 added this pull request to the merge queue Jul 15, 2026
Merged via the queue into thin-edge:main with commit 2c470ee Jul 15, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-release-notes Don't include the ticket in the auto generated release notes theme:testing Theme: Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants