-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.ps1
77 lines (59 loc) · 2.12 KB
/
run.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
##########################################################################
# This is build bootstrapper script for PowerShell.
##########################################################################
<#
.SYNOPSIS
This is a Powershell script to run newman with collections for EHR Store.
.DESCRIPTION
This Powershell script will execute newman with the parameters you provide.
.PARAMETER Url
Base url for ehr store server
.PARAMETER Iterations
Number of iterations to run
.PARAMETER Help
Prints script synoposis, description, parameters and link
.LINK
http://www.github.com/DIPSAS/EhrStore.Postman
.EXAMPLE
./run.ps1
Default
.EXAMPLE
./run.ps1 -Url "http://localhost:9000"
Set url
.EXAMPLE
./run.ps1 -Url "http://localhost:9000" -Iterations 10
Set url and iterations
#>
[CmdletBinding()]
Param(
[string]$Url = "http://localhost:9000",
[int]$Iterations = 1,
[switch]$Help
)
###########################################################################
# PRINT HELP
###########################################################################
if ($Help) {
Get-Help .\run.ps1 -full
exit 0
}
$ErrorActionPreference = 'Stop'
function Exec([scriptblock]$cmd, [string]$errorMessage = "Error executing command: " + $cmd) {
& $cmd
if ($LastExitCode -ne 0) {
throw $errorMessage
}
}
exec { & npm install -g newman newman-reporter-teamcity }
$uri = [System.Uri]$Url
$serverPort = $uri.Port
$serverHostname = $uri.Host
$serverProtocol = $uri.Scheme
$message = "Running API test against $serverProtocol" + "://$serverHostname" + ":$serverPort"
Write-Host $message
# Run newman tests for all json files named *collection.json in the src/ folder
exec { & Get-ChildItem -Path "src\*collection.json" -Recurse | Sort-Object Length -Descending | ForEach-Object {
newman run $_.FullName --global-var "Protocol=$serverProtocol" --global-var "ServerHostname=$serverHostname" --global-var "ServerPort=$serverPort" --global-var "BasePath=openehr" -k -n $iterations -r 'teamcity,cli'
}
}
Write-Output "##teamcity[message text='$serverHostname']"