Skip to content

Extract dummy CPI from bosh-director into integration_support#2756

Merged
aramprice merged 8 commits into
mainfrom
extract-dummy-cpi
Jun 27, 2026
Merged

Extract dummy CPI from bosh-director into integration_support#2756
aramprice merged 8 commits into
mainfrom
extract-dummy-cpi

Conversation

@aramprice

@aramprice aramprice commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary

  • The dummy CPI (`Bosh::Clouds::Dummy`, `DummyV2`, and the `dummy_cpi` binary) is only used by integration specs — it has no role in production `bosh-director` code
  • Moves all three files from `src/bosh-director/` to `src/spec/integration_support/` where they belong alongside other integration test support code
  • Updates `sandbox.rb` to reference the new locations
  • Adds comprehensive unit specs for the dummy CPI under `spec/integration_support/spec/clouds/dummy_spec.rb`
  • Makes `dummy.rb` and `dummy_v2.rb` self-contained by explicitly declaring all their dependencies

Changes

Old location New location
`src/bosh-director/bin/dummy_cpi` `src/spec/integration_support/bin/dummy_cpi`
`src/bosh-director/lib/clouds/dummy.rb` `src/spec/integration_support/clouds/dummy.rb`
`src/bosh-director/lib/clouds/dummy_v2.rb` `src/spec/integration_support/clouds/dummy_v2.rb`

`clouds/errors.rb` stays in `src/bosh-director/lib/clouds/` — it is production code used by `external_cpi.rb` and loaded by the director at runtime.

Unit spec coverage

`spec/integration_support/spec/clouds/dummy_spec.rb` covers:

  • Initialization (dir validation, api_version storage, context formats)
  • Stemcell lifecycle (`create_stemcell`, `delete_stemcell`, `all_stemcells`)
  • VM lifecycle (`create_vm`, `has_vm`, `delete_vm`, static IP allocation, IP collision detection)
  • Disk lifecycle (`create_disk`, `has_disk`, `delete_disk`, `disk_cids`)
  • Disk attachment (`attach_disk`, `detach_disk`, attachment verification in agent settings)
  • Disk resize/update (`resize_disk`, `update_disk`)
  • Snapshot lifecycle (`snapshot_disk`, `delete_snapshot`, `all_snapshots`)
  • Network lifecycle (`create_network`, `delete_network`)
  • Metadata (`set_vm_metadata`, `set_disk_metadata`)
  • Cloud properties (`calculate_vm_cloud_properties`)
  • Invocation recording (`invocations`, `invocations_for_method`)
  • Helper methods (`kill_agents`, `reset`)
  • CommandTransport (create_vm failure/success, dynamic IP configuration, vmnotfound, attach/detach not-implemented)
  • `DummyV2`: `create_vm` returns tuple, `attach_disk` returns path, `info` returns api_version 2

Test plan

  • All existing integration tests pass (file renames only, logic unchanged)
  • Unit tests for `bosh-director` pass (they never referenced the dummy CPI lib files)
  • New `dummy_spec.rb` unit tests pass as part of the integration test run

The dummy CPI (Bosh::Clouds::Dummy, DummyV2, and the dummy_cpi binary) is
only used by integration specs, not by the bosh-director production code.

Move these files out of src/bosh-director/ into src/spec/integration_support/
where they belong:

  src/bosh-director/bin/dummy_cpi
    → src/spec/integration_support/bin/dummy_cpi
      (update BUNDLE_GEMFILE path: ../../ → ../../../)
      (update require_relative: ../lib/clouds/ → ../clouds/)

  src/bosh-director/lib/clouds/dummy.rb
    → src/spec/integration_support/clouds/dummy.rb
      (update require_relative '../clouds/errors' → require 'clouds/errors'
       since errors.rb stays in bosh-director as production code)

  src/bosh-director/lib/clouds/dummy_v2.rb
    → src/spec/integration_support/clouds/dummy_v2.rb
      (same errors.rb require update)

Update sandbox.rb to reflect the new locations:
- require 'clouds/dummy' → require 'integration_support/clouds/dummy'
- exec_path: now points to spec/integration_support/bin/dummy_cpi
Copilot AI review requested due to automatic review settings June 26, 2026 22:50

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • ✅ Review completed - (🔄 Check again to review again)

Walkthrough

The dummy CPI script now uses the integration support Gemfile and loads dummy implementations from src/spec/integration_support/clouds. The dummy cloud files load clouds/errors through the load path and use instance-specific logger names. The sandbox now requires integration_support/clouds/dummy, updates its initialization comment, and points the external CPI executable at src/spec/integration_support/bin/dummy_cpi. A new spec file adds coverage for the dummy CPI and dummy v2 implementations.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change of extracting the dummy CPI into integration_support.
Description check ✅ Passed The description is detailed and covers summary, changes, spec coverage, and test plan, though some template sections are not filled out.
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)
  • Create PR with unit tests
  • Commit unit tests in branch extract-dummy-cpi

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.

@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/spec/integration_support/bin/dummy_cpi`:
- Line 3: The dummy CPI boot path is missing the dependency needed for require
'cloud', so update the bundle setup in dummy_cpi to point at the correct bundle
root and ensure the cloud load-path is available, either by adding the missing
local dependency to the Gemfile used here or by changing the require to a
provided module. Use the dummy_cpi entry point and the Gemfile/bundle
initialization as the place to fix it.
🪄 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: 4d60d802-e0bb-4af2-93d7-e83b945071f7

📥 Commits

Reviewing files that changed from the base of the PR and between 244b3e3 and e1975fd.

📒 Files selected for processing (4)
  • src/spec/integration_support/bin/dummy_cpi
  • src/spec/integration_support/clouds/dummy.rb
  • src/spec/integration_support/clouds/dummy_v2.rb
  • src/spec/integration_support/sandbox.rb

Comment thread src/spec/integration_support/bin/dummy_cpi
- Add comprehensive unit specs for Bosh::Clouds::Dummy and DummyV2
  covering: initialization, VM/stemcell/disk/snapshot/network lifecycles,
  metadata operations, CommandTransport, invocation recording, and error
  scenarios (IP collision, configured failures, NotImplemented variants)

- dummy.rb: add explicit requires for all standard-library and gem
  dependencies (ipaddr, json, logging, membrane, securerandom, socket,
  yaml) so the file is self-contained and loadable without first requiring
  sandbox.rb or bosh-director

- dummy_v2.rb: replace redundant top-level requires with a single
  require_relative 'dummy', since DummyV2 depends entirely on Dummy
Comment thread src/spec/integration_support/spec/clouds/dummy_spec.rb Fixed
Comment thread src/spec/integration_support/spec/clouds/dummy_spec.rb Fixed

@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/spec/integration_support/spec/clouds/dummy_spec.rb`:
- Around line 238-243: The `#reboot_vm` spec is asserting the wrong exception
type; update it to expect the shared `Bosh::Clouds::NotImplemented` error
instead of `Bosh::Clouds::Dummy::NotImplemented` so it matches the contract in
`errors.rb`. Use the `dummy.reboot_vm` example in `dummy_spec.rb` and keep the
existing message match, but change the raised class reference to the shared
error namespace.
🪄 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: 79da7e3d-a6b7-4cb1-8ac0-968baa1dcbfd

📥 Commits

Reviewing files that changed from the base of the PR and between e1975fd and 9fa5ffd.

📒 Files selected for processing (3)
  • src/spec/integration_support/clouds/dummy.rb
  • src/spec/integration_support/clouds/dummy_v2.rb
  • src/spec/integration_support/spec/clouds/dummy_spec.rb

Comment thread src/spec/integration_support/spec/clouds/dummy_spec.rb
- dummy.rb: remove require 'logging' — the real logging gem overrides
  the hand-rolled Logging module in the dummy_cpi subprocess, breaking
  subprocess execution; logging is always available via bosh/director
  in the test context

- dummy_spec.rb: three correctness fixes
  1. invocations tests: CPI method names are stored and returned as
     Strings after JSON round-trip, not Symbols — update assertions
     to compare against strings ('create_disk', not :create_disk)
  2. vm_cids test: stub spawn_agent_process with distinct return values
     (10001, 10002) so each VM gets a unique cid; a shared stub value
     of 99999 caused the second VM to overwrite the first in the VMRepo
  3. Add require 'stringio' and require 'logging' at top of spec for
     explicit documentation of dependencies
The real logging gem (used in the test process) maintains a global
registry of appenders by name. Multiple Bosh::Clouds::Dummy instances
created within the same process (e.g. across spec examples) all tried
to register an IO appender named 'DummyCPIIO' and a logger named
'DummyCPI', causing a registration conflict from the second instance
onward.

Use object_id to make each instance's logger and appender names unique:
  "DummyCPI_#{object_id}"  /  "DummyCPIIO_#{object_id}"

This has no effect in the dummy_cpi subprocess context — the custom
Logging module defined there does not maintain a global registry, so
unique vs. shared names are irrelevant.
reboot_vm was calling validate_and_record_inputs(__method__, vm_cid) but
the method signature is (schema, the_method, *args). Without the schema,
the_method received the vm_cid string, causing Kernel#method to be called
with the CID value instead of a method name, raising NameError.
- Remove two useless local variable assignments in dummy_spec.rb that
  were flagged by github-code-quality (vm_cid and snapshot_id were
  assigned but never read)
- Make reboot_vm raise Bosh::Clouds::NotImplemented for consistency
  with all other unimplemented CPI methods (attach_disk, detach_disk,
  resize_disk, update_disk); update the spec to match
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 26, 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 Jun 26, 2026
ystros
ystros previously approved these changes Jun 26, 2026
@aramprice
aramprice dismissed stale reviews from ystros and coderabbitai[bot] via 8caba05 June 26, 2026 23:44
@aramprice
aramprice merged commit 2de4571 into main Jun 27, 2026
24 checks passed
@aramprice
aramprice deleted the extract-dummy-cpi branch June 27, 2026 00:06
@github-project-automation github-project-automation Bot moved this from Pending Merge | Prioritized to Done in Foundational Infrastructure Working Group Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants