Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion ScheduledTasks/DailySupportCheck/Invoke-DailySupportCheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,28 @@ function Test-SubscriptionService {
$subscriptions = @(& $provider $uri $timeoutSeconds)
$subscriptionIdValue = if ($subscriptions.Count -eq 1 -and $subscriptions[0].PSObject.Properties['subscriptionId']) { $subscriptions[0].subscriptionId }
$isSubscriptionCollection = $subscriptionIdValue -is [System.Collections.IEnumerable] -and $subscriptionIdValue -isnot [string]
if ($subscriptions.Count -eq 1 -and $subscriptions[0].PSObject.Properties['subscriptionId'] -and $isSubscriptionCollection) {
$flattenedSubscriptionIds = if ($subscriptionIdValue -is [string]) {
@([regex]::Split($subscriptionIdValue.Trim(), '(?=\$idx-)') | Where-Object { -not [string]::IsNullOrWhiteSpace([string] $_) })
}
$flattenedSubscriptionIds = @($flattenedSubscriptionIds)
if ($subscriptions.Count -eq 1 -and $flattenedSubscriptionIds.Count -gt 1) {
$flattenedResponse = $subscriptions[0]
$flattenedTags = if ($flattenedResponse.PSObject.Properties['tag']) { @(([string] $flattenedResponse.tag).Trim() -split '\s+') } else { @() }
$flattenedHealth = if ($flattenedResponse.PSObject.Properties['health']) { @(([string] $flattenedResponse.health).Trim() -split '\s+') } else { @() }
$subscriptions = for ($index = 0; $index -lt $flattenedSubscriptionIds.Count; $index++) {
$subscriptionId = ([string] $flattenedSubscriptionIds[$index]).Trim()
[pscustomobject]@{
subscriptionId = $subscriptionId
tag = if ($flattenedTags.Count -eq $flattenedSubscriptionIds.Count) { $flattenedTags[$index] } else { ($subscriptionId -split '_')[-1] }
isRunning = $flattenedResponse.isRunning
health = if ($flattenedHealth.Count -eq $flattenedSubscriptionIds.Count) { $flattenedHealth[$index] } else { $flattenedResponse.health }
parkedEventCount = $flattenedResponse.parkedEventCount
operationalReason = if ($flattenedResponse.PSObject.Properties['operationalReason']) { $flattenedResponse.operationalReason } else { $null }
runtimeFailureReason = if ($flattenedResponse.PSObject.Properties['runtimeFailureReason']) { $flattenedResponse.runtimeFailureReason } else { $null }
}
}
}
elseif ($subscriptions.Count -eq 1 -and $subscriptions[0].PSObject.Properties['subscriptionId'] -and $isSubscriptionCollection) {
$wrappedSubscriptions = $subscriptions[0]
$subscriptionCount = @($wrappedSubscriptions.subscriptionId).Count
$subscriptions = for ($index = 0; $index -lt $subscriptionCount; $index++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,37 @@ Describe 'Daily support check' {
$result.Details[1].SubscriptionId | Should -Be 'subscription-2'
}

It 'expands the flattened subscription response emitted by the status endpoint' {
$context = [pscustomobject]@{
Configuration = [pscustomobject]@{
SubscriptionService = [pscustomobject]@{
Enabled = $true
BaseUrl = 'http://subscription-service'
StatusPath = '/subscriptions/status'
TimeoutSeconds = 10
}
}
SubscriptionServiceProvider = {
[pscustomobject]@{
subscriptionId = '$idx-ce-TransactionAggregate_Transaction Processor_Main $idx-ce-SettlementAggregate_Transaction Processor_Ordered'
tag = 'Main Ordered'
isRunning = $true
health = 'Healthy Healthy'
parkedEventCount = 0
}
}
}

$result = Test-SubscriptionService -Context $context

$result.Status | Should -Be 'Passed'
$result.Details.Count | Should -Be 2
$result.Details[0].SubscriptionId | Should -Be '$idx-ce-TransactionAggregate_Transaction Processor_Main'
$result.Details[0].Tag | Should -Be 'Main'
$result.Details[1].SubscriptionId | Should -Be '$idx-ce-SettlementAggregate_Transaction Processor_Ordered'
$result.Details[1].Tag | Should -Be 'Ordered'
}

It 'fails when a subscription is stopped and warns when parked messages exist' {
$configuration = [pscustomobject]@{
SubscriptionService = [pscustomobject]@{
Expand Down
Loading