Skip to content

Remove fakefs gem from bosh-director#2767

Open
aramprice wants to merge 1 commit into
mainfrom
remove-fake-fs
Open

Remove fakefs gem from bosh-director#2767
aramprice wants to merge 1 commit into
mainfrom
remove-fake-fs

Conversation

@aramprice

Copy link
Copy Markdown
Member

Replace all FakeFS usage in unit specs with Dir.mktmpdir-based real filesystem isolation and allow(File).to receive stubs, so the gem can be dropped entirely.

Changes per file:

  • spec/support/file_helpers.rb: replace FakeFS::FileSystem.clone and fake-file creation with allow(File).to receive(:read) stubs for the three NATS cert paths referenced in test-director-config.yml
  • external_cpi_spec.rb, external_cpi_response_wrapper_spec.rb: use a real tmpdir for the CPI task log directory; remove FileUtils.mkdir_p on the fake /var/vcap path
  • config_spec.rb, instance_spec.rb, snapshot_manager_spec.rb: remove FakeFS::SpecHelpers (configure_fake_config_files now uses stubs)
  • rendered_templates_writer_spec.rb: write rendered templates into a real Dir.mktmpdir instead of the hardcoded /out path
  • compressed_rendered_job_templates_spec.rb: scope Dir.mktmpdir-backed tmpdir to the #contents and #sha1 contexts; #write uses a static path since all filesystem operations are mocked there
  • task_remover_spec.rb: create task output dirs under a real tmpdir; update Dir[] assertions accordingly; remove FakeFS.deactivate!/activate!
  • ssh_spec.rb: remove FakeFS entirely (Jobs::Ssh performs no filesystem I/O - it writes results via TaskDBWriter to the DB)
  • Gemfile, bosh-director.gemspec: drop fakefs dependency
  • Gemfile.lock: updated by bundle install

@aramprice aramprice requested a review from Copilot July 11, 2026 00:06
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 39f897fe-0564-42c6-ac9e-6053a5827340

📥 Commits

Reviewing files that changed from the base of the PR and between 95dfbec and 923ea79.

⛔ Files ignored due to path filters (1)
  • src/Gemfile.lock is excluded by !**/*.lock
📒 Files selected for processing (13)
  • src/Gemfile
  • src/bosh-director/bosh-director.gemspec
  • src/bosh-director/spec/support/file_helpers.rb
  • src/bosh-director/spec/unit/bosh/director/api/snapshot_manager_spec.rb
  • src/bosh-director/spec/unit/bosh/director/api/task_remover_spec.rb
  • src/bosh-director/spec/unit/bosh/director/config_spec.rb
  • src/bosh-director/spec/unit/bosh/director/core/templates/compressed_rendered_job_templates_spec.rb
  • src/bosh-director/spec/unit/bosh/director/core/templates/rendered_templates_writer_spec.rb
  • src/bosh-director/spec/unit/bosh/director/deployment_plan/instance_spec.rb
  • src/bosh-director/spec/unit/bosh/director/jobs/ssh_spec.rb
  • src/bosh-director/spec/unit/clouds/external_cpi_response_wrapper_spec.rb
  • src/bosh-director/spec/unit/clouds/external_cpi_spec.rb
  • src/vendor/cache/fakefs-3.2.1.gem
💤 Files with no reviewable changes (4)
  • src/bosh-director/bosh-director.gemspec
  • src/Gemfile
  • src/vendor/cache/fakefs-3.2.1.gem
  • src/bosh-director/spec/unit/bosh/director/jobs/ssh_spec.rb

Walkthrough

Removed FakeFS from development and test dependencies. Updated shared helpers to stub configuration reads, and refactored affected specs to use temporary real filesystem paths for task outputs, rendered templates, and CPI logs.

Suggested reviewers: ystros, mkocher, selzoc, Alphasite

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change, but it misses most required template sections like context, tests, release notes, breaking change, and tags. Add the template sections with testing performed, release-note wording, breaking-change status, contextual links, team tags, and AI review feedback.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately states the main change: removing the fakefs gem from bosh-director.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch remove-fake-fs

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

Comment @coderabbitai help to get the list of available commands.

@aramprice aramprice requested review from a team, ay901246 and ramonskie and removed request for a team July 11, 2026 00:07
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Removes the fakefs dependency from bosh-director by migrating unit specs from FakeFS-based isolation to real temporary directories (Dir.mktmpdir) and targeted File stubs.

Changes:

  • Dropped fakefs from development/test dependencies (Gemfile, gemspec, lockfile) and removed the vendored gem.
  • Updated specs to use real tmpdirs for filesystem interactions (CPI task logs, rendered templates output, task outputs, etc.).
  • Replaced FakeFS file cloning/creation with File.read stubs for NATS certificate paths used by the test director config fixture.

Reviewed changes

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

Show a summary per file
File Description
src/vendor/cache/fakefs-3.2.1.gem Removes the vendored FakeFS gem artifact.
src/Gemfile Drops fakefs from the development/test group.
src/Gemfile.lock Removes fakefs from locked dependencies.
src/bosh-director/bosh-director.gemspec Drops fakefs as a development dependency.
src/bosh-director/spec/support/file_helpers.rb Replaces FakeFS cloning/file creation with File.read stubbing for cert paths.
src/bosh-director/spec/unit/clouds/external_cpi_spec.rb Uses tmpdir-backed log path instead of FakeFS /var/vcap/....
src/bosh-director/spec/unit/clouds/external_cpi_response_wrapper_spec.rb Uses tmpdir-backed log path instead of FakeFS /var/vcap/....
src/bosh-director/spec/unit/bosh/director/jobs/ssh_spec.rb Removes FakeFS usage from SSH job specs.
src/bosh-director/spec/unit/bosh/director/deployment_plan/instance_spec.rb Removes FakeFS helpers; relies on stubbed config file reads.
src/bosh-director/spec/unit/bosh/director/core/templates/rendered_templates_writer_spec.rb Writes rendered templates into a real tmpdir instead of /out.
src/bosh-director/spec/unit/bosh/director/core/templates/compressed_rendered_job_templates_spec.rb Uses tmpdir for #contents/#sha1; adjusts #write expectation without FakeFS.
src/bosh-director/spec/unit/bosh/director/config_spec.rb Removes FakeFS helpers; relies on stubbed config file reads.
src/bosh-director/spec/unit/bosh/director/api/task_remover_spec.rb Uses tmpdir-backed task output dirs and removes FakeFS activation toggling.
src/bosh-director/spec/unit/bosh/director/api/snapshot_manager_spec.rb Removes FakeFS helpers; relies on stubbed config file reads.

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

Comment thread src/bosh-director/spec/support/file_helpers.rb Outdated
Comment thread src/bosh-director/spec/unit/bosh/director/api/task_remover_spec.rb Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 14 changed files in this pull request and generated 1 comment.

Comment thread src/bosh-director/spec/unit/bosh/director/config_spec.rb

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/bosh-director/spec/support/file_helpers.rb`:
- Around line 24-30: Rename configure_fake_config_files to a name reflecting its
behavior, such as stub_nats_config_file_reads, and update every call site
accordingly; keep the existing File.read stubs unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 636540da-c157-4955-9ec1-ffd809ccf43b

📥 Commits

Reviewing files that changed from the base of the PR and between a473d2e and 2851866.

⛔ Files ignored due to path filters (1)
  • src/Gemfile.lock is excluded by !**/*.lock
📒 Files selected for processing (13)
  • src/Gemfile
  • src/bosh-director/bosh-director.gemspec
  • src/bosh-director/spec/support/file_helpers.rb
  • src/bosh-director/spec/unit/bosh/director/api/snapshot_manager_spec.rb
  • src/bosh-director/spec/unit/bosh/director/api/task_remover_spec.rb
  • src/bosh-director/spec/unit/bosh/director/config_spec.rb
  • src/bosh-director/spec/unit/bosh/director/core/templates/compressed_rendered_job_templates_spec.rb
  • src/bosh-director/spec/unit/bosh/director/core/templates/rendered_templates_writer_spec.rb
  • src/bosh-director/spec/unit/bosh/director/deployment_plan/instance_spec.rb
  • src/bosh-director/spec/unit/bosh/director/jobs/ssh_spec.rb
  • src/bosh-director/spec/unit/clouds/external_cpi_response_wrapper_spec.rb
  • src/bosh-director/spec/unit/clouds/external_cpi_spec.rb
  • src/vendor/cache/fakefs-3.2.1.gem
💤 Files with no reviewable changes (6)
  • src/bosh-director/spec/unit/bosh/director/jobs/ssh_spec.rb
  • src/Gemfile
  • src/bosh-director/bosh-director.gemspec
  • src/vendor/cache/fakefs-3.2.1.gem
  • src/bosh-director/spec/unit/bosh/director/api/snapshot_manager_spec.rb
  • src/bosh-director/spec/unit/bosh/director/deployment_plan/instance_spec.rb

Comment thread src/bosh-director/spec/support/file_helpers.rb Outdated
@github-project-automation github-project-automation Bot moved this from Inbox to Waiting for Changes | Open for Contribution in Foundational Infrastructure Working Group Jul 11, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 11, 2026
@github-project-automation github-project-automation Bot moved this from Waiting for Changes | Open for Contribution to Pending Merge | Prioritized in Foundational Infrastructure Working Group Jul 11, 2026
@aramprice aramprice requested a review from Copilot July 11, 2026 00:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comments suppressed due to low confidence (1)

src/bosh-director/spec/unit/bosh/director/core/templates/compressed_rendered_job_templates_spec.rb:50

  • subject.contents returns an open file handle (File.open). This example reads from it but never closes it, which can leak file descriptors across the test suite (more noticeable now that the real filesystem is used). Close the IO in an ensure block after reading.
        it 'returns IO object for given path' do
          expect(subject.contents.readlines).to eq(['fake-content'])
        end

Comment thread src/bosh-director/spec/unit/bosh/director/api/task_remover_spec.rb Outdated
Comment thread src/bosh-director/spec/unit/bosh/director/config_spec.rb

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 14 changed files in this pull request and generated no new comments.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/bosh-director/spec/unit/bosh/director/config_spec.rb`:
- Around line 29-33: Remove the nested after hook near the identity_provider
examples that calls FileUtils.rm_rf(temp_dir), since the top-level cleanup hook
already covers all tests in the Bosh::Director::Config spec. Retain the
top-level after hook and ensure cleanup behavior remains unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 92d6e34f-a0c1-4e94-aa86-cc28147b3201

📥 Commits

Reviewing files that changed from the base of the PR and between 95dfbec and a700968.

⛔ Files ignored due to path filters (1)
  • src/Gemfile.lock is excluded by !**/*.lock
📒 Files selected for processing (13)
  • src/Gemfile
  • src/bosh-director/bosh-director.gemspec
  • src/bosh-director/spec/support/file_helpers.rb
  • src/bosh-director/spec/unit/bosh/director/api/snapshot_manager_spec.rb
  • src/bosh-director/spec/unit/bosh/director/api/task_remover_spec.rb
  • src/bosh-director/spec/unit/bosh/director/config_spec.rb
  • src/bosh-director/spec/unit/bosh/director/core/templates/compressed_rendered_job_templates_spec.rb
  • src/bosh-director/spec/unit/bosh/director/core/templates/rendered_templates_writer_spec.rb
  • src/bosh-director/spec/unit/bosh/director/deployment_plan/instance_spec.rb
  • src/bosh-director/spec/unit/bosh/director/jobs/ssh_spec.rb
  • src/bosh-director/spec/unit/clouds/external_cpi_response_wrapper_spec.rb
  • src/bosh-director/spec/unit/clouds/external_cpi_spec.rb
  • src/vendor/cache/fakefs-3.2.1.gem
💤 Files with no reviewable changes (4)
  • src/vendor/cache/fakefs-3.2.1.gem
  • src/Gemfile
  • src/bosh-director/spec/unit/bosh/director/jobs/ssh_spec.rb
  • src/bosh-director/bosh-director.gemspec

Comment thread src/bosh-director/spec/unit/bosh/director/config_spec.rb
@github-project-automation github-project-automation Bot moved this from Pending Merge | Prioritized to Waiting for Changes | Open for Contribution in Foundational Infrastructure Working Group Jul 11, 2026
Replace all FakeFS usage in unit specs with Dir.mktmpdir-based real
filesystem isolation and allow(File).to receive stubs, so the gem can be
dropped entirely.

Changes per file:
- spec/support/file_helpers.rb: replace FakeFS::FileSystem.clone and
  fake-file creation with allow(File).to receive(:read) stubs for cert
  paths read from the YAML fixture (so stubs stay aligned if fixture changes)
- external_cpi_spec.rb, external_cpi_response_wrapper_spec.rb: use a
  real tmpdir for the CPI task log directory; remove FileUtils.mkdir_p
  on the fake /var/vcap path
- config_spec.rb, instance_spec.rb, snapshot_manager_spec.rb: remove
  FakeFS::SpecHelpers (configure_fake_config_files now uses stubs)
- rendered_templates_writer_spec.rb: write rendered templates into a
  real Dir.mktmpdir instead of the hardcoded /out path
- compressed_rendered_job_templates_spec.rb: scope Dir.mktmpdir-backed
  tmpdir to the #contents and #sha1 contexts; #write uses a static path
  since all filesystem operations are mocked there
- task_remover_spec.rb: create task output dirs under a real tmpdir;
  update Dir[] assertions accordingly; use File.exist? instead of
  Dir[...].to_not be_nil (Dir[] returns Array, never nil); remove
  FakeFS.deactivate!/activate!
- ssh_spec.rb: remove FakeFS entirely (Jobs::Ssh performs no filesystem
  I/O - it writes results via TaskDBWriter to the DB)
- Gemfile, bosh-director.gemspec: drop fakefs dependency
- Gemfile.lock: updated by bundle install
@github-project-automation github-project-automation Bot moved this from Waiting for Changes | Open for Contribution to Pending Merge | Prioritized in Foundational Infrastructure Working Group Jul 11, 2026

@Alphasite Alphasite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

left a couple comments but it seems ok...

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

Labels

None yet

Projects

Status: Pending Merge | Prioritized

Development

Successfully merging this pull request may close these issues.

3 participants