xiaobaicai66695 commented on PR #1555:
URL: https://github.com/apache/dubbo-admin/pull/1555#issuecomment-6880831742

   # Admin 前端路由端到端测试留痕
   ## 测试拓扑
   
   ```mermaid
   flowchart LR
       PS[PowerShell 请求脚本] --> F[shop-frontend]
       F -->|GET /login: UserService/login| U[shop-user]
       F -->|GET /login: DetailService/getItem| D[shop-detail]
       D -->|CommentService/getComment:亲和路由被测调用| C[shop-comment]
       F -->|POST /order: OrderService/submitOrder:脚本路由被测调用| O[shop-order]
   ```
   
   | 场景 | 请求入口 | 被测 Dubbo 调用 | 消费者 | 提供者 | 验证内容 |
   | --- | --- | --- | --- | --- | --- |
   | 亲和路由 | `GET /login` | `CommentService/getComment` | `shop-detail` Pod | 
`shop-comment` Pod | 比较这两个 Pod 的 `region`。前端到 `shop-detail` 的 
`DetailService/getItem` 只负责进入该调用链。 |
   | 脚本路由 | `POST /order` | `OrderService/submitOrder` | `shop-frontend` Pod | 
`shop-order` Pod | 核对脚本筛选后实际命中的 Order Pod。 |
   
   `/login` 还会调用 `shop-user` 完成登录,但 `shop-user` 不参与本次亲和判断。校验脚本通过 Jaeger span 
的父子关系确认同一条 `shop-detail → shop-comment` 调用,再读取对应 Pod 的区域配置。Admin 前端负责保存 
YAML;PowerShell 负责发出 HTTP 请求并保存 trace ID;Jaeger 提供实际 Dubbo 调用链和命中的实例。
   
   端到端测试的主要思路和代码如下;
   在admin前端分别写入亲和性路由或脚本路由的规则,
   通过对应的ps脚本发送请求,然后拿到jaeger中的对应的链路,判断路由是否生效
   亲和性路由的测试接口是/login,
   使用的yaml配置如下:
   ``` yaml
   configVersion: v3.1
   scope: service
   key: "org.apache.dubbo.samples.CommentService::"
   runtime: true
   enabled: true
   affinityAware:
     key: region
     ratio: 1
   ```
   亲和性路由的脚本如下:
   ``` powershell
   param(
       [int]$Count = 20,
       [string]$BaseUrl = 'http://127.0.0.1:18082',
       [string]$OutputDir = (Join-Path $PSScriptRoot 'runs')
   )
   
   $ErrorActionPreference = 'Stop'
   if ($Count -lt 1) { throw 'Count must be positive.' }
   if (-not (Test-Path -LiteralPath $OutputDir -PathType Container)) { New-Item 
-ItemType Directory -Path $OutputDir | Out-Null }
   
   $runId = [guid]::NewGuid().ToString('N').Substring(0, 8)
   $stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
   $outputFile = Join-Path $OutputDir "pr1547-login-run-$stamp-$runId.json"
   $base = $BaseUrl.TrimEnd('/')
   $requests = [System.Collections.Generic.List[object]]::new()
   
   for ($i = 1; $i -le $Count; $i++) {
       $traceId = [guid]::NewGuid().ToString('N')
       $parentId = [guid]::NewGuid().ToString('N').Substring(0, 16)
       $username = 'pr1547-' + $runId + '-' + $i.ToString('00')
       $url = $base + '/login?username=' + [uri]::EscapeDataString($username) + 
'&password=pr1547-test'
       $status = 0
       $errorText = ''
       try {
           $response = Invoke-WebRequest -Uri $url -Method Get -Headers @{ 
traceparent = "00-$traceId-$parentId-01" } -UseBasicParsing -TimeoutSec 20
           $status = [int]$response.StatusCode
       } catch {
           if ($_.Exception.Response) { $status = 
[int]$_.Exception.Response.StatusCode }
           $errorText = $_.Exception.Message
       }
       $requests.Add([pscustomobject]@{ index = $i; traceId = $traceId; 
username = $username; httpStatus = $status; error = $errorText })
       Write-Host ("{0,2}/{1}  HTTP {2}  trace={3}" -f $i, $Count, $status, 
$traceId)
   }
   
   [pscustomobject]@{
       kind = 'login'
       createdAt = (Get-Date).ToString('o')
       baseUrl = $base
       requests = $requests
   } | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath $outputFile -Encoding 
utf8
   
   Write-Output "Run file: $outputFile"
   Write-Host "Next: & '$PSScriptRoot\pr1547-check-login-20.ps1' -RunFile 
'$outputFile'"
   ```
   使用的校验脚本如下:
   ``` powershell
   param(
       [string]$RunFile,
       [string]$JaegerUrl = 'http://127.0.0.1:16687',
       [string]$KubeConfig = 'C:\Users\57512\.kube\dubbo-admin-rke2.yaml',
       [string]$Namespace = 'dubbo-samples-shop',
       [int]$WaitSeconds = 45
   )
   
   $ErrorActionPreference = 'Stop'
   if (-not $RunFile) {
       $latest = Get-ChildItem -LiteralPath (Join-Path $PSScriptRoot 'runs') 
-Filter 'pr1547-login-run-*.json' -File -ErrorAction SilentlyContinue |
           Sort-Object LastWriteTime -Descending | Select-Object -First 1
       if (-not $latest) { throw 'No login run file found. Run 
pr1547-login-20.ps1 first.' }
       $RunFile = $latest.FullName
   }
   $run = Get-Content -LiteralPath $RunFile -Raw | ConvertFrom-Json
   if ($run.kind -ne 'login') { throw "Not a login run file: $RunFile" }
   $requests = @($run.requests)
   $jaeger = $JaegerUrl.TrimEnd('/')
   $null = Invoke-RestMethod -Uri ($jaeger + '/api/services') -TimeoutSec 10
   $podJson = & kubectl --kubeconfig $KubeConfig -n $Namespace get pods -o json
   if ($LASTEXITCODE -ne 0) { throw "Cannot read Pods in namespace $Namespace" }
   $pods = ($podJson -join "`n") | ConvertFrom-Json
   $regionByPod = @{}
   foreach ($pod in $pods.items) {
       $labels = $pod.spec.containers[0].env | Where-Object { $_.name -eq 
'DUBBO_LABELS' } | Select-Object -First 1
       $region = [regex]::Match([string]$labels.value, 
'(?:^|;)\s*region\s*=\s*([^;\s]+)')
       $regionByPod[[string]$pod.metadata.name] = if ($region.Success) { 
$region.Groups[1].Value } else { 'UNSET' }
   }
   
   function Get-PodRegion([string]$PodName) {
       if ($regionByPod.ContainsKey($PodName)) { return $regionByPod[$PodName] }
       return 'NOT_FOUND'
   }
   
   function Find-Spans($trace, [string]$service, [string]$operation) {
       foreach ($span in $trace.spans) {
           $process = $trace.processes.($span.processID)
           if ($process.serviceName -eq $service -and $span.operationName -eq 
$operation) { $span }
       }
   }
   function Get-PodName($trace, $span) {
       if (-not $span) { return '' }
       $process = $trace.processes.($span.processID)
       $tag = $process.tags | Where-Object { $_.key -eq 'k8s.pod.name' } | 
Select-Object -First 1
       if ($tag) { return [string]$tag.value }
       return ''
   }
   function Has-Parent($child, $parent) {
       if (-not $child -or -not $parent) { return $false }
       foreach ($reference in $child.references) {
           if ($reference.spanID -eq $parent.spanID) { return $true }
       }
       return $false
   }
   function Test-Complete($trace) {
       $root = $trace.spans | Where-Object { $_.operationName -eq 'http get 
/login' } | Select-Object -First 1
       $detail = @(Find-Spans $trace 'shop-detail' 
'org.apache.dubbo.samples.DetailService/getItem')
       $client = @(Find-Spans $trace 'shop-detail' 
'org.apache.dubbo.samples.CommentService/getComment')
       $comment = @(Find-Spans $trace 'shop-comment' 
'org.apache.dubbo.samples.CommentService/getComment')
       return [bool]($root -and $detail.Count -gt 0 -and $client.Count -gt 0 
-and $comment.Count -gt 0)
   }
   
   $traces = @{}
   $pending = @{}
   $lastCount = @{}
   $stableCount = @{}
   foreach ($request in $requests) {
       if ($request.httpStatus -ge 200 -and $request.httpStatus -lt 300) { 
$pending[$request.traceId] = $true }
   }
   $runAgeSeconds = ([datetimeoffset]::Now - 
[datetimeoffset]::Parse($run.createdAt)).TotalSeconds
   if ($runAgeSeconds -lt 8) { Start-Sleep -Seconds ([math]::Ceiling(8 - 
$runAgeSeconds)) }
   $deadline = (Get-Date).AddSeconds($WaitSeconds)
   do {
       foreach ($traceId in @($pending.Keys)) {
           try {
               $response = Invoke-RestMethod -Uri ($jaeger + '/api/traces/' + 
$traceId) -TimeoutSec 10
               if (@($response.data).Count -gt 0) {
                   $trace = $response.data[0]
                   $traces[$traceId] = $trace
                   $count = @($trace.spans).Count
                   if ($lastCount.ContainsKey($traceId) -and 
$lastCount[$traceId] -eq $count) {
                       $stableCount[$traceId] = [int]$stableCount[$traceId] + 1
                   } else { $stableCount[$traceId] = 0 }
                   $lastCount[$traceId] = $count
                   if ((Test-Complete $trace) -and $stableCount[$traceId] -ge 
2) {
                       [void]$pending.Remove($traceId)
                   }
               }
           } catch { }
       }
       if ($pending.Count -gt 0 -and (Get-Date) -lt $deadline) { Start-Sleep 
-Seconds 2 }
   } while ($pending.Count -gt 0 -and (Get-Date) -lt $deadline)
   
   $rows = foreach ($request in $requests) {
       $trace = $traces[$request.traceId]
       $details = if ($trace) { @(Find-Spans $trace 'shop-detail' 
'org.apache.dubbo.samples.DetailService/getItem') } else { @() }
       $clients = if ($trace) { @(Find-Spans $trace 'shop-detail' 
'org.apache.dubbo.samples.CommentService/getComment') } else { @() }
       $comments = if ($trace) { @(Find-Spans $trace 'shop-comment' 
'org.apache.dubbo.samples.CommentService/getComment') } else { @() }
       $pairs = foreach ($comment in $comments) {
           $client = $clients | Where-Object { Has-Parent $comment $_ } | 
Select-Object -First 1
           $detail = $details | Where-Object { Has-Parent $client $_ } | 
Select-Object -First 1
           if (-not $client -or -not $detail) { continue }
           $detailPod = Get-PodName $trace $detail
           $commentPod = Get-PodName $trace $comment
           $detailRegion = Get-PodRegion $detailPod
           $commentRegion = Get-PodRegion $commentPod
           $pairStatus = 'MATCH'
           $isGray = ($detailPod -match '-gray-' -or $commentPod -match 
'-gray-')
           $inferred = ($detailRegion -in @('UNSET', 'NOT_FOUND') -or 
$commentRegion -in @('UNSET', 'NOT_FOUND'))
           if (-not $inferred) {
               if ($detailRegion -ne $commentRegion) { $pairStatus = 'MISMATCH' 
}
           } elseif ($detailPod -notmatch '^shop-detail-(v[12])-' -or 
$commentPod -notmatch '^shop-comment-(v[12])-') {
               $pairStatus = 'UNKNOWN_POD'
           } else {
               # In this shop fixture, v1 maps to beijing and v2 to hangzhou, 
including v1-gray Pods.
               $detailVersion = [regex]::Match($detailPod, 
'^shop-detail-(v[12])-').Groups[1].Value
               $commentVersion = [regex]::Match($commentPod, 
'^shop-comment-(v[12])-').Groups[1].Value
               if ($detailVersion -ne $commentVersion) { $pairStatus = 
'MISMATCH' }
           }
           [pscustomobject]@{
               DetailPod = $detailPod
               DetailRegion = $detailRegion
               CommentPod = $commentPod
               CommentRegion = $commentRegion
               Gray = $isGray
               Inferred = $inferred
               Result = $pairStatus
           }
       }
       $pairs = @($pairs)
       $status = 'MATCH'
       if ($request.httpStatus -lt 200 -or $request.httpStatus -ge 300) { 
$status = 'HTTP_ERROR' }
       elseif (-not $trace) { $status = 'NO_TRACE' }
       elseif ($details.Count -eq 0 -or $clients.Count -eq 0 -or 
$comments.Count -eq 0) { $status = 'INCOMPLETE' }
       elseif ($pairs.Count -eq 0) { $status = 'UNLINKED' }
       elseif (@($pairs | Where-Object { $_.Result -eq 'MISMATCH' }).Count -gt 
0) { $status = 'MISMATCH' }
       elseif (@($pairs | Where-Object { $_.Result -eq 'UNKNOWN_POD' }).Count 
-gt 0) { $status = 'UNKNOWN_POD' }
       [pscustomobject]@{
           No = $request.index
           HTTP = $request.httpStatus
           DetailPod = (($pairs | ForEach-Object { $_.DetailPod }) -join ',')
           DetailRegion = (($pairs | ForEach-Object { $_.DetailRegion }) -join 
',')
           CommentPod = (($pairs | ForEach-Object { $_.CommentPod }) -join ',')
           CommentRegion = (($pairs | ForEach-Object { $_.CommentRegion }) 
-join ',')
           Pairs = $pairs.Count
           GrayPairs = @($pairs | Where-Object { $_.Gray }).Count
           InferredPairs = @($pairs | Where-Object { $_.Inferred }).Count
           Result = $status
           TraceId = $request.traceId
       }
   }
   
   Write-Host "Run file: $RunFile"
   $rows | Select-Object No, HTTP, DetailRegion, CommentRegion, InferredPairs, 
Result, TraceId |
       Format-Table -AutoSize | Out-String -Width 170 | Write-Host
   $rows | Select-Object No, DetailPod, CommentPod |
       Format-Table -AutoSize | Out-String -Width 170 | Write-Host
   $rows | Group-Object Result | Sort-Object Name | ForEach-Object { Write-Host 
("{0}: {1}" -f $_.Name, $_.Count) }
   $grayRows = @($rows | Where-Object { $_.GrayPairs -gt 0 })
   $normalRows = @($rows | Where-Object { $_.GrayPairs -eq 0 })
   Write-Host ("Gray matched: {0}/{1}; UNSET means no region in DUBBO_LABELS." 
-f @($grayRows | Where-Object { $_.Result -eq 'MATCH' }).Count, $grayRows.Count)
   Write-Host ("Pairs inferred from Pod names because region is unavailable: 
{0}" -f @($rows | Measure-Object -Property InferredPairs -Sum).Sum)
   Write-Host ("Non-gray matched: {0}/{1}" -f @($normalRows | Where-Object { 
$_.Result -eq 'MATCH' }).Count, $normalRows.Count)
   Write-Host ("Matched: {0}/{1}" -f @($rows | Where-Object { $_.Result -eq 
'MATCH' }).Count, $requests.Count)
   Write-Host "Open a trace: $jaeger/trace/<TraceId>"
   $bad = @($rows | Where-Object { $_.Result -ne 'MATCH' })
   $normal = @($rows | Where-Object { $_.Result -eq 'MATCH' })
   if ($bad.Count -gt 0 -or $normal.Count -eq 0) { exit 1 }
   ```
   
   ## 脚本路由
   
   脚本路由的测试接口是 POST /order。规则由人工在 Admin 前端页面保存到 Nacos;请求脚本向商城前端发送订单请求,并为每次请求生成 
trace ID。校验脚本按 trace ID 查询 Jaeger 中的 OrderService/submitOrder 提供者 span,核对实际命中的 
Pod 和重试次数。
   
   Nacos group 为 dubbo,DataID 为 shop-order.script-router。v1 和 v2 是同一条规则的两次内容:先在 
Admin 中创建 v1,再编辑为 v2;不应创建两条并存的脚本规则。
   
   ### 选择 shop-order-v1 的 YAML
   
   ```yaml
   configVersion: v3.0
   scope: application
   key: shop-order
   enabled: true
   type: javascript
   script: |
     (function route(invokers, invocation, context) {
       var result = new java.util.ArrayList(invokers.size());
       for (var i = 0; i < invokers.size(); i++) {
         if (invokers.get(i).getUrl().getPort() == 20882) {
           result.add(invokers.get(i));
         }
       }
       return result.isEmpty() ? invokers : result;
     })(invokers, invocation, context);
   ```
   
   端口 20882 对应 shop-order-v1。
   
   ### 编辑为选择 shop-order-v2 的 YAML
   
   ```yaml
   configVersion: v3.0
   scope: application
   key: shop-order
   enabled: true
   type: javascript
   script: |
     (function route(invokers, invocation, context) {
       var result = new java.util.ArrayList(invokers.size());
       for (var i = 0; i < invokers.size(); i++) {
         if (invokers.get(i).getUrl().getPort() == 20883) {
           result.add(invokers.get(i));
         }
       }
       return result.isEmpty() ? invokers : result;
     })(invokers, invocation, context);
   ```
   
   端口 20883 对应 shop-order-v2。两份脚本在目标端口不存在时都会回退到全部候选实例,因此“只命中目标实例”的结论以目标实例在线为前提。
   
   ### 发送请求的 PowerShell 脚本
   
   文件名:pr1547-order-20.ps1。脚本提交测试订单,并将每次请求的 HTTP 状态和 trace ID 保存到 runs 目录中的 
JSON。
   
   ```powershell
   param(
       [int]$Count = 20,
       [string]$BaseUrl = 'http://127.0.0.1:18082',
       [string]$OutputDir = (Join-Path $PSScriptRoot 'runs')
   )
   
   $ErrorActionPreference = 'Stop'
   if ($Count -lt 1) { throw 'Count must be positive.' }
   if (-not (Test-Path -LiteralPath $OutputDir -PathType Container)) { New-Item 
-ItemType Directory -Path $OutputDir | Out-Null }
   
   $runId = [guid]::NewGuid().ToString('N').Substring(0, 8)
   $stamp = Get-Date -Format 'yyyyMMdd-HHmmss'
   $outputFile = Join-Path $OutputDir "pr1547-order-run-$stamp-$runId.json"
   $base = $BaseUrl.TrimEnd('/')
   $requests = [System.Collections.Generic.List[object]]::new()
   
   for ($i = 1; $i -le $Count; $i++) {
       $traceId = [guid]::NewGuid().ToString('N')
       $parentId = [guid]::NewGuid().ToString('N').Substring(0, 16)
       $username = 'pr1547-' + $runId + '-' + $i.ToString('00')
       $status = 0
       $errorText = ''
       try {
           # This matches the shop page's Buy Now request: POST 
/order?username= with form fields username and sku.
           $response = Invoke-WebRequest -Uri ($base + '/order?username=') 
-Method Post `
               -Body @{ username = $username; sku = '1' } -ContentType 
'application/x-www-form-urlencoded' `
               -Headers @{ traceparent = "00-$traceId-$parentId-01" } 
-UseBasicParsing -TimeoutSec 20
           $status = [int]$response.StatusCode
       } catch {
           if ($_.Exception.Response) { $status = 
[int]$_.Exception.Response.StatusCode }
           $errorText = $_.Exception.Message
       }
       $requests.Add([pscustomobject]@{ index = $i; traceId = $traceId; 
username = $username; httpStatus = $status; error = $errorText })
       Write-Host ("{0,2}/{1}  HTTP {2}  trace={3}" -f $i, $Count, $status, 
$traceId)
   }
   
   [pscustomobject]@{
       kind = 'order'
       createdAt = (Get-Date).ToString('o')
       baseUrl = $base
       requests = $requests
   } | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath $outputFile -Encoding 
utf8
   
   Write-Output "Run file: $outputFile"
   Write-Host "Next: & '$PSScriptRoot\pr1547-check-order-20.ps1' -RunFile 
'$outputFile'"
   ```
   
   ### Jaeger 校验 PowerShell 脚本
   
   文件名:pr1547-check-order-20.ps1。ExpectedVersion=any 用于观察无规则阶段的落点;v1 或 v2 
用于判断所有提供者调用是否命中指定版本。还需检查 Attempts 是否为 1,以排除同版本重试。
   
   ```powershell
   param(
       [string]$RunFile,
       [string]$JaegerUrl = 'http://127.0.0.1:16687',
       [ValidateSet('any', 'v1', 'v2')][string]$ExpectedVersion = 'any',
       [int]$WaitSeconds = 45
   )
   
   $ErrorActionPreference = 'Stop'
   if (-not $RunFile) {
       $latest = Get-ChildItem -LiteralPath (Join-Path $PSScriptRoot 'runs') 
-Filter 'pr1547-order-run-*.json' -File -ErrorAction SilentlyContinue |
           Sort-Object LastWriteTime -Descending | Select-Object -First 1
       if (-not $latest) { throw 'No order run file found. Run 
pr1547-order-20.ps1 first.' }
       $RunFile = $latest.FullName
   }
   $run = Get-Content -LiteralPath $RunFile -Raw | ConvertFrom-Json
   if ($run.kind -ne 'order') { throw "Not an order run file: $RunFile" }
   $requests = @($run.requests)
   $jaeger = $JaegerUrl.TrimEnd('/')
   $null = Invoke-RestMethod -Uri ($jaeger + '/api/services') -TimeoutSec 10
   
   function Find-OrderSpans($trace) {
       foreach ($span in $trace.spans) {
           $process = $trace.processes.($span.processID)
           if ($process.serviceName -eq 'shop-order' -and
               $span.operationName -eq 
'org.apache.dubbo.samples.OrderService/submitOrder') { $span }
       }
   }
   function Get-PodName($trace, $span) {
       if (-not $span) { return '' }
       $process = $trace.processes.($span.processID)
       $tag = $process.tags | Where-Object { $_.key -eq 'k8s.pod.name' } | 
Select-Object -First 1
       if ($tag) { return [string]$tag.value }
       return ''
   }
   
   $traces = @{}
   $pending = @{}
   $lastCount = @{}
   $stableCount = @{}
   foreach ($request in $requests) {
       if ($request.httpStatus -ge 200 -and $request.httpStatus -lt 300) { 
$pending[$request.traceId] = $true }
   }
   $runAgeSeconds = ([datetimeoffset]::Now - 
[datetimeoffset]::Parse($run.createdAt)).TotalSeconds
   if ($runAgeSeconds -lt 8) { Start-Sleep -Seconds ([math]::Ceiling(8 - 
$runAgeSeconds)) }
   $deadline = (Get-Date).AddSeconds($WaitSeconds)
   do {
       foreach ($traceId in @($pending.Keys)) {
           try {
               $response = Invoke-RestMethod -Uri ($jaeger + '/api/traces/' + 
$traceId) -TimeoutSec 10
               if (@($response.data).Count -gt 0) {
                   $trace = $response.data[0]
                   $traces[$traceId] = $trace
                   $count = @($trace.spans).Count
                   if ($lastCount.ContainsKey($traceId) -and 
$lastCount[$traceId] -eq $count) {
                       $stableCount[$traceId] = [int]$stableCount[$traceId] + 1
                   } else { $stableCount[$traceId] = 0 }
                   $lastCount[$traceId] = $count
                   $root = $trace.spans | Where-Object { $_.operationName -eq 
'http post /order' } | Select-Object -First 1
                   if ($root -and @(Find-OrderSpans $trace).Count -gt 0 -and 
$stableCount[$traceId] -ge 2) {
                       [void]$pending.Remove($traceId)
                   }
               }
           } catch { }
       }
       if ($pending.Count -gt 0 -and (Get-Date) -lt $deadline) { Start-Sleep 
-Seconds 2 }
   } while ($pending.Count -gt 0 -and (Get-Date) -lt $deadline)
   
   $rows = foreach ($request in $requests) {
       $trace = $traces[$request.traceId]
       $spans = if ($trace) { @(Find-OrderSpans $trace | Sort-Object startTime) 
} else { @() }
       $pods = @($spans | ForEach-Object { Get-PodName $trace $_ })
       $pod = if ($pods.Count -gt 0) { $pods[-1] } else { '' }
       $versions = @($pods | ForEach-Object {
           if ($_ -match '-gray-') { 'gray' }
           elseif ($_ -match '^shop-order-(v[12])-') { [regex]::Match($_, 
'^shop-order-(v[12])-').Groups[1].Value }
           else { 'unknown' }
       })
       $status = 'OBSERVED'
       if ($request.httpStatus -lt 200 -or $request.httpStatus -ge 300) { 
$status = 'HTTP_ERROR' }
       elseif (-not $trace) { $status = 'NO_TRACE' }
       elseif ($spans.Count -eq 0 -or -not $pod) { $status = 'INCOMPLETE' }
       elseif ($ExpectedVersion -ne 'any' -and @($versions | Where-Object { $_ 
-ne $ExpectedVersion }).Count -eq 0) { $status = 'MATCH' }
       elseif ($ExpectedVersion -ne 'any') { $status = 'WRONG_POD' }
       elseif ($pods.Count -gt 1) { $status = 'MULTI_POD' }
       [pscustomobject]@{
           No = $request.index
           HTTP = $request.httpStatus
           LastPod = $pod
           AllPods = ($pods -join ' -> ')
           Attempts = $pods.Count
           Result = $status
           TraceId = $request.traceId
       }
   }
   
   Write-Host "Run file: $RunFile"
   Write-Host "Expected version: $ExpectedVersion"
   $rows | Format-Table No, HTTP, LastPod, Attempts, Result, TraceId -AutoSize 
| Out-String -Width 220 | Write-Host
   $rows | Where-Object { $_.Attempts -gt 1 } | ForEach-Object { Write-Host 
("Request {0} all order pods: {1}" -f $_.No, $_.AllPods) }
   $rows | Group-Object Result | Sort-Object Name | ForEach-Object { Write-Host 
("{0}: {1}" -f $_.Name, $_.Count) }
   Write-Host "Open a trace: $jaeger/trace/<TraceId>"
   if ($ExpectedVersion -eq 'any') {
       if (@($rows | Where-Object { $_.Result -in @('HTTP_ERROR', 'NO_TRACE', 
'INCOMPLETE') }).Count -gt 0) { exit 1 }
   } elseif (@($rows | Where-Object { $_.Result -ne 'MATCH' }).Count -gt 0) {
       exit 1
   }


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to