Skip to content

Add --dry-run preview to throughput write subcommands - #166

Merged
Mike Krüger (mkrueger) merged 3 commits into
mainfrom
dev/mkrueger/throughput-dry-run
Jul 9, 2026
Merged

Mike Krüger (mkrueger) merged 3 commits into
mainfrom
dev/mkrueger/throughput-dry-run

Conversation

@mkrueger

@mkrueger Mike Krüger (mkrueger) commented Jul 7, 2026 •

Copy link
Copy Markdown
Collaborator

What

Adds a --dry-run option to the throughput write subcommands (set / manual / autoscale). With --dry-run, the command reads the current provisioned throughput and reports the current vs. planned mode and RU/s — then stops, performing no write and requiring no confirmation.

This is a first, contained slice of dry-run mode (item G1, #156), scoped to throughput. It also addresses the "preview before a billable change" gap called out in C1 (#164).

Part of #156
Part of #164

Why

Throughput changes are billable. Today the only safety net is an interactive confirmation prompt, which is skipped in non-interactive contexts (MCP, scripts, piped input). --dry-run lets agents and automation preview the exact effect of a scaling change before committing to it.

Behavior

throughput autoscale 10000 --dry-run
  • Reads current throughput; computes the intended new state.
  • Emits structured JSON with dryRun: true plus current and planned blocks (mode, throughput, autoscaleMaxThroughput, minThroughput).
  • Prints a friendly table interactively, with a "Dry run: no change was applied." note.
  • Honors output redirection (... --dry-run > out.json) like throughput show.
  • Still validates RU/s arguments up front, so an invalid preview fails cleanly instead of implying a valid plan.
  • No confirmation prompt (nothing is applied).

Scope / non-goals

Tests

  • New offline unit tests in ThroughputCommandTests covering: --dry-run still enforces missing-RU and below-minimum validation across set/manual/autoscale, and dry-run on a disconnected shell throws NotConnectedException.
  • Existing throughput tests unchanged and passing.

Docs

  • docs/commands.md — documents the --dry-run option, behavior, and an example.
  • CHANGELOG.md — Unreleased entry.

Validation

  • dotnet build CosmosDBShell/CosmosDBShell.csproj ✅
  • dotnet build CosmosDBShell.Tests/CosmosDBShell.Tests.csproj ✅
  • Throughput + help-verification + localization-audit tests pass ✅

throughput set/manual/autoscale now accept --dry-run to preview the current vs. planned mode and RU/s without applying the change or prompting for confirmation. Structured JSON (current/planned) plus an interactive table. First slice of dry-run mode (G1).

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

Adds a --dry-run preview mode to the throughput write subcommands so automation and users can see the current vs. intended throughput configuration before making a billable change. This fits the CosmosDBShell CLI’s pattern of providing structured JSON results (for MCP/automation) while keeping interactive output human-friendly.

Changes:

  • Adds --dry-run handling to throughput set|manual|autoscale to compute and return a “current vs. planned” preview without performing writes or prompting.
  • Extends localization strings and command documentation to describe the new option and its output.
  • Adds unit tests ensuring --dry-run still enforces RU validation and fails cleanly when disconnected.

Reviewed changes

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

Show a summary per file
File Description
docs/commands.md Documents --dry-run for throughput write subcommands and adds an example.
CosmosDBShell/lang/en.ftl Adds localized option/help text and labels for the dry-run preview table.
CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/ThroughputCommand.cs Implements --dry-run plan generation and interactive preview output for throughput writes.
CosmosDBShell.Tests/CommandTests/ThroughputCommandTests.cs Adds coverage for dry-run RU validation and disconnected behavior.
CHANGELOG.md Adds an Unreleased entry describing the new --dry-run feature.

Comment thread CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/ThroughputCommand.cs
@github-code-quality

github-code-quality Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: C#

C# / code-coverage/dotnet

The overall coverage in the dev/mkrueger/through... branch remains at 61%, unchanged from the main branch.

Show a code coverage summary of the most impacted files.
File main 324e232 dev/mkrueger/through... a54cb9f +/-
D:\a\CosmosDBSh...ghputCommand.cs 35% 25% -10%

Updated July 09, 2026 14:16 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

Mike Krüger (mkrueger) added a commit that referenced this pull request Jul 9, 2026
…, delete) (#167)

## Summary

Adds `--dry-run` preview support to the destructive delete commands,
extending the dry-run pattern already used by `import` (and, in #166,
`throughput`). This is a scoped slice of the broader dry-run work
tracked in #156.

When `--dry-run` is supplied, the command reports what it *would* delete
and makes no changes:

- **`rm --dry-run`** — runs the same pattern match/pipe evaluation but
issues no `DeleteItemAsync` calls, then reports how many items matched.
- **`rmcon --dry-run`** — locates the target container and reports it
without confirming or deleting.
- **`rmdb --dry-run`** — locates the target database and reports it
without confirming or deleting.
- **`delete <type> ... --dry-run`** — forwards the flag to the routed
`rm` / `rmcon` / `rmdb` command.

No confirmation prompt is shown in dry-run mode and no writes occur.

## Changes

- `RmCommand`, `RmContainerCommand`, `RmDbCommand`, `DeleteCommand`: new
`--dry-run` option and preview branches (`delete` forwards the flag).
- `lang/en.ftl`: new `command-*-description-dry-run` and
`command-*-dry-run-plan` strings (the `rm` plan honours the existing `{
$count }` plural form).
- `docs/commands.md`: documented `--dry-run` for `rm`, `rmcon`, `rmdb`,
and `delete`.
- `CHANGELOG.md`: added an Unreleased entry.
- Tests: offline dry-run tests for `rm`, `rmdb`, and `delete`
(validation still applies, disconnected still throws, dry-run
localization keys resolve).

## Validation

- `dotnet build` — both projects build clean.
- `dotnet test` — 38 affected tests pass (RmCommand, RmDbCommand,
DeleteCommand, HelpCommandVerification, LocalizationKeyAudit).

## Notes

- Cost-delta ($) estimation is out of scope; deletes have no throughput
contract to preview.
- Relates to #156. Companion to #166 (throughput `--dry-run`).
Copilot AI review requested due to automatic review settings July 9, 2026 13:48

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 5 out of 5 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 9, 2026 14:12

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 5 out of 5 changed files in this pull request and generated no new comments.

@mkrueger
Mike Krüger (mkrueger) merged commit 8338954 into main Jul 9, 2026
15 checks passed
@mkrueger
Mike Krüger (mkrueger) deleted the dev/mkrueger/throughput-dry-run branch July 9, 2026 14:36
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.

3 participants