#!/usr/bin/env bash set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" PROFILE="${RENDEZVOUS_CAPACITY_PROFILE:-quick}" OUTPUT="${RENDEZVOUS_CAPACITY_OUTPUT:-$ROOT/artifacts/capacity/rendezvous-capacity-v2.json}" CPUSET="${RENDEZVOUS_CAPACITY_CPUSET:-}" PROJECT="$ROOT/tests/FinalFactory.Rendezvous.Capacity/FinalFactory.Rendezvous.Capacity.csproj" TESTS="$ROOT/tests/FinalFactory.Rendezvous.Tests/FinalFactory.Rendezvous.Tests.csproj" if [[ "$PROFILE" != quick && "$PROFILE" != candidate ]]; then printf 'RENDEZVOUS_CAPACITY_PROFILE must be quick or candidate.\n' >&2 exit 2 fi command -v dotnet >/dev/null || { printf 'Missing required command: dotnet\n' >&2 exit 2 } if [[ -n "$CPUSET" ]]; then command -v taskset >/dev/null || { printf 'taskset is required when RENDEZVOUS_CAPACITY_CPUSET is set.\n' >&2 exit 2 } fi cd "$ROOT" dotnet restore "$ROOT/Rendezvous.slnx" --locked-mode dotnet build "$ROOT/Rendezvous.slnx" --configuration Release --no-restore filter='FullyQualifiedName~TrackerCapacityFailsClosedWithoutGrowingAndAWindowResetRecovers|FullyQualifiedName~OptionalTrafficCannotConsumeTheLeaseOperationReserve|FullyQualifiedName~ConcurrentAbusiveBurstStaysBoundedAndCannotBlockCriticalHttp|FullyQualifiedName~HttpOverloadIsTypedAndOversizedBodiesAreRejectedBeforeDispatch|FullyQualifiedName~WallClockMovementDoesNotExpireOrExtendLease|FullyQualifiedName~RepeatedMutableDeadlineRefreshesKeepOneScheduledEntryPerKey|FullyQualifiedName~RepeatedPrincipalRevocationCanExtendButCannotShortenProtection|FullyQualifiedName~RestartHasNewGenerationAndNoEphemeralState|FullyQualifiedName~RestartReturnsTypedUnavailabilityThenAllowsHostReregistration|FullyQualifiedName~DrainRejectsNewWorkAllowsInflightCompletionThenClearsState|FullyQualifiedName~UnavailableStoreFailsNewAuthorizationClosedAndErasesActiveState|FullyQualifiedName~KeyRotationHonorsOverlapAndRejectsRetiredKeys|FullyQualifiedName~OperatorSurfaceSeparatesAuthenticationConfirmsActionsAndRedactsInspection|FullyQualifiedName~SigtermDrainsThenReleasesHttpAndUdpSockets|FullyQualifiedName~ProductionTransportSoakKeepsHandlesMemoryAndSocketsBounded|FullyQualifiedName~NativeLiteNetLibRequestsIntroduceTheAuthorizedPair' dotnet test "$TESTS" --configuration Release --no-build --filter "$filter" \ --logger 'console;verbosity=minimal' mkdir -p "$(dirname "$OUTPUT")" arguments=( dotnet run --project "$PROJECT" --configuration Release --no-build -- --profile "$PROFILE" --output "$OUTPUT" ) export RENDEZVOUS_EVIDENCE_COMMIT="${RENDEZVOUS_EVIDENCE_COMMIT:-$(git rev-parse HEAD)}" if [[ -z "${RENDEZVOUS_EVIDENCE_TREE_STATE:-}" ]]; then if [[ -n "$(git status --porcelain)" ]]; then export RENDEZVOUS_EVIDENCE_TREE_STATE=dirty else export RENDEZVOUS_EVIDENCE_TREE_STATE=clean fi fi export RENDEZVOUS_EVIDENCE_CPUSET="${CPUSET:-unrestricted}" export RENDEZVOUS_EVIDENCE_COMMAND="RENDEZVOUS_CAPACITY_PROFILE=$PROFILE RENDEZVOUS_CAPACITY_CPUSET=${CPUSET:-unrestricted} ./scripts/run-capacity-gate.sh" if [[ -n "$CPUSET" ]]; then taskset -c "$CPUSET" "${arguments[@]}" else "${arguments[@]}" fi printf 'Capacity and resilience gate passed; evidence: %s\n' "$OUTPUT"