Skip to content

test(amqp): use pinned CFSClean broker - #5023

Open
Johnathan W (j7nw4r) wants to merge 14 commits into
mainfrom
j7nw4r/amqp-cfsclean-broker
Open

test(amqp): use pinned CFSClean broker#5023
Johnathan W (j7nw4r) wants to merge 14 commits into
mainfrom
j7nw4r/amqp-cfsclean-broker

Conversation

@j7nw4r

@j7nw4r Johnathan W (j7nw4r) commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary

Restores the broker backed azure_core_amqp tests, and makes a missing broker fail the build instead of passing it.

Motivation

Work item 39130334 requires the Rust AMQP tests to run without changing any file in the broker clone.

The setup script exited at its first line, so the broker never started. The tests then took a skip branch and still passed, and the suite reported the same counts with the broker and without it. Nothing turned red, so the loss stayed invisible.

Changes

  • Adds nuget.cfsclean.config to this repository and restores the broker through it. The feed policy is this pipeline's requirement, so the configuration that satisfies it lives with the pipeline and not in the broker clone.
  • Runs the restore and the build from the clone root, because the .NET SDK reads global.json from the current directory and not from the project directory.
  • Adds src/test_broker.rs. TEST_BROKER_REQUIRED makes an absent broker an error instead of a skip, and the CI template sets it for every job except macOS, where the setup script never starts a broker.
  • Stops the broker from a finally block behind a success flag. Invoke-LoggedCommand calls exit from inside itself, so the earlier inline calls left a broker on port 25672 on some failure paths.
  • Bounds each readiness attempt. The blocking Connect method takes no timeout, so a dropped SYN made the probe run far past its own budget.
  • Adds TEST_BROKER_COMMIT to retarget the broker, and a GitHub compare API check that warns when the pin is not reachable from master. TEST_BROKER_REQUIRE_MERGED makes that an error. A check that cannot run always continues.

Validation

  • cargo test -p azure_core_amqp --all-features with no broker and no flag: the suite passes and the broker tests skip. With TEST_BROKER_REQUIRED set and no broker: the suite fails and names the setup script. cargo fmt and cargo clippy -D warnings are clean.
  • Restore and build from a clean broker clone using this repository's config, from an empty package cache. The clone stayed unchanged.
  • The pin check answers correctly for a reachable commit, an unreachable commit, and a squash commit. A 404, a timeout, an empty answer, and a non-numeric field all report that the check did not run, and none fails the build.
  • The readiness probe returns inside its budget against an address that drops the SYN. The earlier code ran for 75 seconds against a 5 second budget.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions github-actions Bot added the Azure.Core The azure_core crate label Aug 7, 2026
@j7nw4r
Johnathan W (j7nw4r) marked this pull request as ready for review August 10, 2026 20:59
Copilot AI balanced review requested due to automatic review settings August 10, 2026 20:59
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

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

Restores broker-backed AMQP tests using a pinned CFSClean-compatible broker and prevents silent CI skips.

Changes:

  • Pins, restores, starts, probes, and cleans up the AMQP test broker.
  • Requires broker availability in non-macOS CI jobs.
  • Centralizes broker-test gating and updates documentation.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Test-Setup.ps1 Implements broker provisioning and readiness checks.
Test-Cleanup.ps1 Cleans up active broker jobs.
src/test_broker.rs Centralizes broker-test gating.
src/lib.rs Registers the test helper module.
src/connection.rs Migrates connection tests to the helper.
README.md Documents broker setup and pinning.
nuget.cfsclean.config Pins the permitted NuGet feed.
ci.tests.yml Requires the broker in non-macOS CI.
Suppressed comments (1)

sdk/core/azure_core_amqp/README.md:80

  • The manual CFSClean restore points at azure-amqp\nuget.cfsclean.config, but that file does not exist in the pinned clone; this PR intentionally adds the config beside Test-Setup.ps1. After cd azure-amqp, this command therefore fails before restoring. Resolve and pass the config from the azure-sdk-for-rust checkout instead.
dotnet restore .\test\TestAmqpBroker\TestAmqpBroker.csproj --configfile .\nuget.cfsclean.config

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread sdk/core/azure_core_amqp/README.md Outdated
Comment thread sdk/core/azure_core_amqp/Test-Setup.ps1 Outdated
Comment thread sdk/core/azure_core_amqp/src/test_broker.rs
@j7nw4r
Johnathan W (j7nw4r) force-pushed the j7nw4r/amqp-cfsclean-broker branch from dd9f08b to 4816284 Compare August 10, 2026 21:37
Comment thread eng/pipelines/templates/jobs/ci.tests.yml Outdated
Comment thread sdk/core/azure_core_amqp/Test-Setup.ps1
Comment thread sdk/core/azure_core_amqp/README.md Outdated

@heaths Heath Stewart (heaths) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should just rely on the root nuget.config or it may cause conflicts otherwise.

Comment thread sdk/core/azure_core_amqp/README.md Outdated
Comment thread sdk/core/azure_core_amqp/Test-Setup.ps1 Outdated
Johnathan Walker and others added 12 commits August 11, 2026 09:14
Pin broker setup to the azure-amqp commit that owns the CFSClean
NuGet config. Restore through that config, build net10.0, and fail
with broker output when readiness does not arrive.

Check that the clone stays clean, re-enable cleanup, and document the
pin plus the external developer and CFSClean build paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Teach cspell the broker config file and option names used by the
CFSClean setup path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The broker tests skipped when TEST_BROKER_ADDRESS was absent, and they
still passed. The suite therefore stayed green when the broker did not
run at all. Add a test_broker helper. TEST_BROKER_REQUIRED makes a
missing broker an error, and the pipeline sets it for every job except
macOS, where setup never starts a broker.

Run the restore and the build from the clone root. The dotnet command
reads global.json from the current directory and not from the project
directory, so the earlier absolute paths lost the SDK pin of the clone.

Stop the broker from the finally block behind a success flag.
Invoke-LoggedCommand calls exit from inside itself, so the earlier
inline calls did not run on every failure path and left the broker on
port 25672.

Bound each readiness attempt. The blocking Connect method takes no
timeout, so a dropped SYN made the probe run far past its own budget.

Add TEST_BROKER_COMMIT to override the pinned commit without a code
change, and test whether the pin is reachable from master through the
GitHub compare API. An unreachable pin warns, and
TEST_BROKER_REQUIRE_MERGED turns that warning into an error. A check
that cannot run always continues, because the anonymous rate limit is
shared and says nothing about the pin.
A non-numeric ahead_by read as "not reachable" before. A build that sets
TEST_BROKER_REQUIRE_MERGED could then fail because of a malformed answer
and not because of a bad pin. Count that case as "the check did not run"
instead.

Coerce after the absence test and never instead of it, because
$null -as [int] gives 0. A coercion on its own would turn a missing
ahead_by field into 0 and report an unreachable pin as reachable.

Correct the comment above the pin. The SHA is now an ancestor of
refs/pull/318/head and not the head itself, because that pull request
has moved on.
The previous commit wrapped the rev-parse call in "$( ... )" to take the
last output line. That broke the argument. The outer double-quoted
string consumes the escaped quotes first, so the command split into
three arguments. The second one bound to -ExecutePath, and git ran with
a bare -C.

CI showed the result:
  > git -C
  Push-Location: Cannot find path '.../TestArtifacts/azure-amqp rev-parse
  HEAD' because it does not exist.

Use two statements instead, so no outer string can consume the quotes.
The last-line behavior stays the same, and the result is still a string.
REMOVE BEFORE MERGE.

Report the package sources that the pipeline agent resolves from inside
the broker clone. No local test can answer whether the agent turns off
the source named nuget.org, which feeds the agent allows, or whether the
explicit config narrows the list on a real agent.

The block prints and does nothing else. It restores the error preference
around itself, so it cannot fail the run.
The restricted feed policy is this pipeline's requirement, and not a
requirement of Azure/azure-amqp. The configuration that satisfies a
policy belongs with the code that enforces the policy, so this
repository now carries its own nuget.cfsclean.config next to the setup
script, and the restore passes that file.

Drop the check for a restore config inside the broker clone, and check
the copy in this repository instead. The pinned commit no longer has to
contain a restore config, so the pin can move to any commit that builds
the broker.
Azure/azure-amqp pull request 318 closed without a merge, so its head
commit is not on any branch and can disappear. This repository now owns
the restore config, so the pin no longer has to reach a commit that
carries one, and any commit that builds the broker works.

Pin the head of master. The reachability check stays quiet, because that
commit is reachable from master.
The cspell step failed on nuget.cfsclean.config with "Unknown word
(configfile)". Say the same thing in plain words instead of adding a
dictionary entry.
The helper had one test, and it covered an absent variable that no rule
depends on. The behavior that keeps a silent skip from returning was
untested.

Move the rule into resolve_broker_address, which reads no environment
variable, and test every branch: a present address comes back, an absent
address skips, and an absent address panics when the run requires a
broker. Cover the documented flag values too.

Correct the pin update steps and the README. They said the pinned commit
must contain nuget.cfsclean.config. This package owns that file now, so
any commit that builds the broker works.
TEST_BROKER_REQUIRED sat in eng/pipelines/templates/jobs/ci.tests.yml,
which every package uses for its tests. The flag belongs to this
package, so the template no longer carries it and this change leaves
that file untouched.

Test-Setup.ps1 sets the flag instead, right after the macOS guard. That
placement gives the macOS behavior for free, because the script exits
before this line on macOS and the flag never gets set there. The script
sets the process variable and also emits the pipeline logging command,
so the value reaches a later step as well.

Move the spelling words into .cspell.json for this package, and drop the
inline cspell directives from the README and the two scripts.
The package carried its own nuget.cfsclean.config, and that file was a
copy of eng/templates/NuGet.config.template, which the pipeline already
uses through eng/pipelines/templates/steps/nuget-config.yml. Two files
with the same contents drift apart. Delete the copy and name the
template on the restore.

The restore still has to name a configuration. The broker clone carries
its own nuget.config that adds NuGet.org, and a directory level file
wins over the user level one that the pipeline writes.

Keep the pinned commit in Test-Setup.ps1 alone. README.md repeated the
SHA, so an update needed two edits and could leave the two out of step.
The README now points at the script.
@j7nw4r
Johnathan W (j7nw4r) force-pushed the j7nw4r/amqp-cfsclean-broker branch from ab7742c to 44ce2b2 Compare August 11, 2026 13:14
@j7nw4r
Johnathan W (j7nw4r) enabled auto-merge (squash) August 11, 2026 13:33
The pin update steps still told the reader to write the SHA into
README.md. Test-Setup.ps1 is the only place that holds the pin now, and
the paragraph below the steps already says so. The two statements
disagreed.
# adds NuGet.org, and a directory level file wins over the user level one, so the restore
# has to name a configuration explicitly. Pass an absolute path, because the dotnet calls
# run from the clone root.
$nugetConfig = [System.IO.Path]::Combine($RepoRoot, "eng", "templates", "NuGet.config.template")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This needs to wait until Daniel Jurek (@danieljurek) gets his in. Daniel, can you make sure the feed here is in that nuget.confg as well?

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

Labels

Azure.Core The azure_core crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants