VSTS - 测试 -> 运行 -> 查询端点未根据参数进行过滤
VSTS - Test -> Runs -> Query endpoint is not filtering based on parameters
我正在尝试使用测试 -> 运行 -> 查询端点来 return 特定版本的测试 运行 列表,详见 here
不幸的是,无论我输入什么作为查询参数($top
除外,它似乎会过滤),我似乎都得到了针对 运行 returned 的每个测试项目。
例如,我知道有 14 个针对特定版本的测试 运行。
我可以通过以下查询获取我的发布 ID...
https://smartassessor.vsrm.visualstudio.com/Smart End Point Assessment/_apis/release/releases?searchText=Release-103
如果我然后像这样在测试 运行 查询中使用该 ID...
https://smartassessor.visualstudio.com/Smart End Point Assessment/_apis/test/runs?releaseIds=1678&api-version=5.0-preview.2
我得到 529 个结果,这看起来像大多数 运行 对项目的测试。
过滤器是否针对此端点起作用?如果是这样,我应该如何调整我的请求以使用 releaseIds
参数。
谢谢
我可以重现这个问题。似乎 API 暂时不可用。
有 an issue submitted here 用于跟踪。您还可以跟踪它的更新。
作为解决方法,您可以使用下面的 PowerShell 脚本按版本 ID 过滤测试运行:(或者您可以将结果导出到 *.CSV 文件)
Param(
[string]$collectionurl = "https://{account}.visualstudio.com",
[string]$project = "ProjectName",
[string]$releaseid = "1",
[string]$user = "username",
[string]$token = "password"
)
#Set the path and name for the output csv file
$path = "D:\temp"
$filename = "ReleaseTestRun" + "-" + $releaseid
# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
$baseUrl = "$collectionurl/$project/_apis/test/runs"
$response = Invoke-RestMethod -Uri $baseUrl -Method Get -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
$testruns = $response.value
Write-Host $results
$Releaseruns = @()
foreach ($testrun in $testruns)
{
$testrunID = $testrun.id
$runbaseUrl = "$collectionurl/$project/_apis/test/runs/$testrunID"
$runresponse = Invoke-RestMethod -Uri $runbaseUrl -Method Get -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} | Where {$_.release.id -eq $releaseid} #| Filter the test run by Release ID
$customObject = new-object PSObject -property @{
"id" = $runresponse.id
"name" = $runresponse.name
"url" = $runresponse.url
"isAutomated" = $runresponse.isAutomated
"state" = $runresponse.state
"totalTests" = $runresponse.totalTests
"incompleteTests" = $runresponse.incompleteTests
"notApplicableTests" = $runresponse.notApplicableTests
"passedTests" = $runresponse.passedTests
"unanalyzedTests" = $runresponse.unanalyzedTests
"revision" = $runresponse.revision
"webAccessUrl" = $runresponse.webAccessUrl
}
$Releaseruns += $customObject
}
$Releaseruns | Select `
id,
name,
url,
isAutomated,
state,
totalTests,
incompleteTests,
notApplicableTests,
passedTests,
unanalyzedTests,
revision,
webAccessUrl | where {$_.id -ne $Null} #|export-csv -Path $path$filename.csv -NoTypeInformation # Filter non-empty values and export to csv file.
我正在尝试使用测试 -> 运行 -> 查询端点来 return 特定版本的测试 运行 列表,详见 here
不幸的是,无论我输入什么作为查询参数($top
除外,它似乎会过滤),我似乎都得到了针对 运行 returned 的每个测试项目。
例如,我知道有 14 个针对特定版本的测试 运行。
我可以通过以下查询获取我的发布 ID...
https://smartassessor.vsrm.visualstudio.com/Smart End Point Assessment/_apis/release/releases?searchText=Release-103
如果我然后像这样在测试 运行 查询中使用该 ID...
https://smartassessor.visualstudio.com/Smart End Point Assessment/_apis/test/runs?releaseIds=1678&api-version=5.0-preview.2
我得到 529 个结果,这看起来像大多数 运行 对项目的测试。
过滤器是否针对此端点起作用?如果是这样,我应该如何调整我的请求以使用 releaseIds
参数。
谢谢
我可以重现这个问题。似乎 API 暂时不可用。
有 an issue submitted here 用于跟踪。您还可以跟踪它的更新。
作为解决方法,您可以使用下面的 PowerShell 脚本按版本 ID 过滤测试运行:(或者您可以将结果导出到 *.CSV 文件)
Param(
[string]$collectionurl = "https://{account}.visualstudio.com",
[string]$project = "ProjectName",
[string]$releaseid = "1",
[string]$user = "username",
[string]$token = "password"
)
#Set the path and name for the output csv file
$path = "D:\temp"
$filename = "ReleaseTestRun" + "-" + $releaseid
# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
$baseUrl = "$collectionurl/$project/_apis/test/runs"
$response = Invoke-RestMethod -Uri $baseUrl -Method Get -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
$testruns = $response.value
Write-Host $results
$Releaseruns = @()
foreach ($testrun in $testruns)
{
$testrunID = $testrun.id
$runbaseUrl = "$collectionurl/$project/_apis/test/runs/$testrunID"
$runresponse = Invoke-RestMethod -Uri $runbaseUrl -Method Get -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} | Where {$_.release.id -eq $releaseid} #| Filter the test run by Release ID
$customObject = new-object PSObject -property @{
"id" = $runresponse.id
"name" = $runresponse.name
"url" = $runresponse.url
"isAutomated" = $runresponse.isAutomated
"state" = $runresponse.state
"totalTests" = $runresponse.totalTests
"incompleteTests" = $runresponse.incompleteTests
"notApplicableTests" = $runresponse.notApplicableTests
"passedTests" = $runresponse.passedTests
"unanalyzedTests" = $runresponse.unanalyzedTests
"revision" = $runresponse.revision
"webAccessUrl" = $runresponse.webAccessUrl
}
$Releaseruns += $customObject
}
$Releaseruns | Select `
id,
name,
url,
isAutomated,
state,
totalTests,
incompleteTests,
notApplicableTests,
passedTests,
unanalyzedTests,
revision,
webAccessUrl | where {$_.id -ne $Null} #|export-csv -Path $path$filename.csv -NoTypeInformation # Filter non-empty values and export to csv file.