Skip to content

test(watcher): pin the single row after a fast resync replaces a container - #1648

Merged
scttbnsn merged 1 commit into
dev/v1.9from
fix/v1.9-1595-old-row
Nov 19, 2026
Merged

scttbnsn merged 1 commit into
dev/v1.9from
fix/v1.9-1595-old-row

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Adds the regression test asked for on #1595: after a UI or API update recreates a container (new ID, same name), the fast resync leaves exactly one row. The old ID is gone and the replacement is present, with WATCHEVENTS on and off.

No behavior change. The removal already happens in removeStaleContainerEntriesWithSameName when the replacement is first discovered; disabling that call fails both cases.

✨ Added

  • New test file: app/watchers/providers/docker/Docker.fast-resync-old-row.test.ts (+99 lines, new file).
  • Regression test for fast resync after a GUI/API update recreates a container with a new ID and the same name (ref #1595).
  • Test runs under describe.each([false, true]) with watchevents disabled and enabled.
  • Test setup: in-memory migrated database (createMigratedMemoryDatabase), mocked dockerApi (listContainers, getContainer, getImage), mocked ensureRemoteAuthHeaders, findNewVersion, registry.getState, event.emitContainerReport.
  • Assertions: old-id is undefined; new-id is defined; getContainers({ watcher: 'local' }) ids equal ['new-id'].

🔧 Changed

  • None. No production source files changed.

🐛 Fixed

  • None.

🗑️ Removed

  • None.

⚠️ Breaking

  • None.

🔒 Security

  • None.

Concerns

  • Test calls (docker as any).maybeFastResyncAfterUpdate('dashy'). Private method accessed via any; breaks silently on rename.
  • Test relies on removeStaleContainerEntriesWithSameName (docker-image-details-orchestration.ts:925, called at line 1026) for removal. Test does not isolate this path; removal logic is not changed in this PR.
  • PR objective states disabling removeStaleContainerEntriesWithSameName fails both cases. Not verified by this diff; no test run evidence available.
  • vi.mock('../../../log') and vi.restoreAllMocks() in afterEach: confirm vi is a global (no explicit import { vi } from 'vitest'). Other test files in the repo should be checked for the same convention.
  • as typeof docker.configuration and as unknown as Dockerode casts: weaken type checking; consider a typed fixture helper.
  • Mock getContainer ignores options.filters shape beyond id/name; summary() hardcodes ImageID: 'image-new' for both old and new containers.
  • Duplicated fixture-building logic (summary, inspection) could reuse existing test helpers if present in app/test/helpers.js.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6502488 and 723f380.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Adds a Docker watcher regression test using a migrated in-memory database and mocked dependencies. The test runs with watchevents enabled and disabled. After the container ID changes while its name stays the same, it checks that the old row is absent and exactly one row remains for the replacement container.

Possibly related PRs

  • CodesWhat/drydock#1632: Changes fast resync after a UI or API update, which is the behavior this test covers.
  • CodesWhat/drydock#1430: Adds test coverage for name refresh after an external container recreation, including replacement IDs and stale same-name entries.

Change: Other

Merge Risk: Minimal · previous review 65024

This change adds a test for fast resync after a container is recreated with a new ID and the same name. It does not change runtime behavior, and no merge-blocking risk was identified.

Pre-merge checks: Passed 2

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

The configuration directory could not be loaded. This review used the available YAML and UI settings; directory instructions and checks were not evaluated.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3be373d and 6502488.

Files selected for processing: 1

  • app/watchers/providers/docker/Docker.fast-resync-old-row.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttbnsn
scttbnsn force-pushed the fix/v1.9-1595-old-row branch from 6502488 to 723f380 Compare November 19, 2026 16:19
@scttbnsn
scttbnsn merged commit e5ae201 into dev/v1.9 Nov 19, 2026
33 checks passed
@scttbnsn
scttbnsn deleted the fix/v1.9-1595-old-row branch November 19, 2026 16:46
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