-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci/tests: Send test results to Azure DevOps for reporting
- Loading branch information
Showing
3 changed files
with
206 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
#*************************************************************************** | ||
# _ _ ____ _ | ||
# Project ___| | | | _ \| | | ||
# / __| | | | |_) | | | ||
# | (__| |_| | _ <| |___ | ||
# \___|\___/|_| \_\_____| | ||
# | ||
# Copyright (C) 2020, Daniel Stenberg, <daniel@haxx.se>, et al. | ||
# Copyright (C) 2020, Marc Hoersken, <info@marc-hoersken.de> | ||
# | ||
# This software is licensed as described in the file COPYING, which | ||
# you should have received as part of this distribution. The terms | ||
# are also available at https://curl.haxx.se/docs/copyright.html. | ||
# | ||
# You may opt to use, copy, modify, merge, publish, distribute and/or sell | ||
# copies of the Software, and permit persons to whom the Software is | ||
# furnished to do so, under the terms of the COPYING file. | ||
# | ||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
# KIND, either express or implied. | ||
# | ||
########################################################################### | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use POSIX qw(strftime); | ||
|
||
sub azure_check_environment { | ||
if(defined $ENV{'AZURE_ACCESS_TOKEN'} && | ||
defined $ENV{'AGENT_JOBNAME'} && $ENV{'BUILD_BUILDID'} && | ||
defined $ENV{'SYSTEM_TEAMFOUNDATIONCOLLECTIONURI'} && | ||
defined $ENV{'SYSTEM_TEAMPROJECTID'}) { | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
|
||
sub azure_create_test_run { | ||
my $azure_baseurl="$ENV{'SYSTEM_TEAMFOUNDATIONCOLLECTIONURI'}$ENV{'SYSTEM_TEAMPROJECTID'}"; | ||
my $azure_run=`curl --silent \\ | ||
--header "Authorization: Bearer $ENV{'AZURE_ACCESS_TOKEN'}" \\ | ||
--header "Content-Type: application/json" \\ | ||
--data " | ||
{ | ||
'name': '$ENV{'AGENT_JOBNAME'}', | ||
'automated': true, | ||
'build': {'id': '$ENV{'BUILD_BUILDID'}'} | ||
} | ||
" \\ | ||
"$azure_baseurl/_apis/test/runs?api-version=5.0"`; | ||
if($azure_run =~ /"id":(\d+)/) { | ||
return $1; | ||
} | ||
return ""; | ||
} | ||
|
||
sub azure_create_test_result { | ||
my ($azure_run_id, $testnum, $testname)=@_; | ||
my $azure_baseurl="$ENV{'SYSTEM_TEAMFOUNDATIONCOLLECTIONURI'}$ENV{'SYSTEM_TEAMPROJECTID'}"; | ||
my $azure_result=`curl --silent \\ | ||
--header "Authorization: Bearer $ENV{'AZURE_ACCESS_TOKEN'}" \\ | ||
--header "Content-Type: application/json" \\ | ||
--data " | ||
[ | ||
{ | ||
'build': {'id': '$ENV{'BUILD_BUILDID'}'}, | ||
'testCase': {'id': $testnum}, | ||
'testCaseTitle': '$testname', | ||
'automatedTestName': 'curl.tests.$testnum', | ||
'outcome': 'InProgress' | ||
} | ||
] | ||
" \\ | ||
"$azure_baseurl/_apis/test/runs/$azure_run_id/results?api-version=5.0"`; | ||
if($azure_result =~ /\[\{"id":(\d+)/) { | ||
return $1; | ||
} | ||
return ""; | ||
} | ||
|
||
sub azure_update_test_result { | ||
my ($azure_run_id, $azure_result_id, $testnum, $error, $start, $stop)=@_; | ||
if(!defined $stop) { | ||
$stop = $start; | ||
} | ||
my $azure_start = strftime "%Y-%m-%dT%H:%M:%SZ", gmtime $start; | ||
my $azure_complete = strftime "%Y-%m-%dT%H:%M:%SZ", gmtime $stop; | ||
my $azure_duration = sprintf("%.0f", ($stop-$start)*1000); | ||
my $azure_outcome; | ||
if($error < 0) { | ||
$azure_outcome = 'Not executed'; | ||
} | ||
elsif(!$error) { | ||
$azure_outcome = 'Passed'; | ||
} | ||
else { | ||
$azure_outcome = 'Failed'; | ||
} | ||
my $azure_baseurl="$ENV{'SYSTEM_TEAMFOUNDATIONCOLLECTIONURI'}$ENV{'SYSTEM_TEAMPROJECTID'}"; | ||
my $azure_result=`curl --silent --request PATCH \\ | ||
--header "Authorization: Bearer $ENV{'AZURE_ACCESS_TOKEN'}" \\ | ||
--header "Content-Type: application/json" \\ | ||
--data " | ||
[ | ||
{ | ||
'id': $azure_result_id, | ||
'outcome': '$azure_outcome', | ||
'startedDate': '$azure_start', | ||
'completedDate': '$azure_complete', | ||
'durationInMs': $azure_duration | ||
} | ||
] | ||
" \\ | ||
"$azure_baseurl/_apis/test/runs/$azure_run_id/results?api-version=5.0"`; | ||
if($azure_result =~ /\[\{"id":(\d+)/) { | ||
return $1; | ||
} | ||
return ""; | ||
} | ||
|
||
sub azure_update_test_run { | ||
my ($azure_run_id)=@_; | ||
my $azure_baseurl="$ENV{'SYSTEM_TEAMFOUNDATIONCOLLECTIONURI'}$ENV{'SYSTEM_TEAMPROJECTID'}"; | ||
my $azure_run=`curl --silent --request PATCH \\ | ||
--header "Authorization: Bearer $ENV{'AZURE_ACCESS_TOKEN'}" \\ | ||
--header "Content-Type: application/json" \\ | ||
--data " | ||
{ | ||
'state': 'Completed' | ||
} | ||
" \\ | ||
"$azure_baseurl/_apis/test/runs/$azure_run_id?api-version=5.0"`; | ||
if($azure_run =~ /"id":(\d+)/) { | ||
return $1; | ||
} | ||
return ""; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ada581f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this broke running the tests from the nightly source tarballs:
https://curl.haxx.se/dev/log.cgi?id=20200301051843-27018#prob1
ada581f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, that new pm isn't included in the dist... I'll fix!
ada581f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=> c537b00