This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTestExample.ps1
71 lines (58 loc) · 3.22 KB
/
TestExample.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
param(
[Parameter(Mandatory = $True)][string]$Path,
[Parameter(Mandatory = $True)][string]$BuildConfig,
[Parameter(Mandatory = $True)][string]$ReportDir,
[Parameter(Mandatory = $True)][string]$EnvironmentPath,
[Parameter(Mandatory = $True)][string]$StackName,
[Parameter(Mandatory = $True)][string]$ResourceGroupName,
[Parameter(Mandatory = $True)][string]$Location)
$WorkingDirectory = "$Path\Examples\Eklee.Azure.Functions.GraphQl.Example\bin\$BuildConfig\netstandard2.1"
Compress-Archive -Path "$WorkingDirectory\*" -DestinationPath "$WorkingDirectory\Deploy.zip"
Write-Host "Configure app settings"
$content = Get-Content -Path "$Path\Examples\Eklee.Azure.Functions.GraphQl.Example\local.settings.json" | ConvertFrom-Json
$documentUrl = $content.DocumentDb.Url
$documentKey = $content.DocumentDb.Key
$searchName = $content.Search.ServiceName
$searchApiKey = $content.Search.ApiKey
$tableStorageConnectionString = $content.TableStorage.ConnectionString
$audience = $content.Security.Audience
$issuers = $content.Security.Issuers
$issuer1 = $content.Tenants[0].Issuer
$issuer2 = $content.Tenants[1].Issuer
az functionapp config appsettings set -n $StackName -g $ResourceGroupName --settings "GraphQl:EnableMetrics=true" "GraphQl:ExposeExceptions=true" `
"DocumentDb:Url=$documentUrl" `
"DocumentDb:Key=$documentKey" `
"DocumentDb:RequestUnits=400" `
"Search:ServiceName=$searchName" `
"Search:ApiKey=$searchApiKey" `
"TableStorage:ConnectionString=$tableStorageConnectionString" `
"Security:Audience=$audience" `
"Security:Issuers=$issuers" `
"Tenants:0:Issuer=$issuer1" `
"Tenants:0:DocumentDb:Url=$documentUrl" `
"Tenants:0:DocumentDb:Key=$documentKey" `
"Tenants:0:DocumentDb:RequestUnits=400" `
"Tenants:0:Search:ServiceName=$searchName" `
"Tenants:0:Search:ApiKey=$searchApiKey" `
"Tenants:0:TableStorage:ConnectionString=$tableStorageConnectionString" `
"Tenants:1:Issuer=$issuer2" `
"Tenants:1:DocumentDb:Url=$documentUrl" `
"Tenants:1:DocumentDb:Key=$documentKey" `
"Tenants:1:DocumentDb:RequestUnits=400" `
"Tenants:1:Search:ServiceName=$searchName" `
"Tenants:1:Search:ApiKey=$searchApiKey" `
"Tenants:1:TableStorage:ConnectionString=$tableStorageConnectionString" `
"ApiBaseUrl=https://$StackName.azurewebsites.net/api/" | Out-Null
Write-Host "Deploying code"
az functionapp deployment source config-zip -g $ResourceGroupName -n $StackName --src "$WorkingDirectory\Deploy.zip" | Out-Null
Write-Host "Installing newman"
Push-Location $WorkingDirectory
npm install --save-dev newman
Pop-Location
$content = (Get-Content -Path "$Path\Tests\Eklee.Azure.Functions.GraphQl.Local.postman_environment.json").Replace("http://localhost:7071", "https://$StackName.azurewebsites.net")
$content | Out-File "$Path\Tests\Eklee.Azure.Functions.GraphQl.Local.postman_environment.json" -Encoding ASCII
Write-Host "Running postman"
$reportFilePath = "$ReportDir/report.xml"
Push-Location $Path\Examples\Eklee.Azure.Functions.GraphQl.Example\bin\$BuildConfig\netstandard2.1
node_modules\.bin\newman run ..\..\..\..\..\tests\Eklee.Azure.Functions.GraphQl.postman_collection.json -e "$EnvironmentPath\Tests\Eklee.Azure.Functions.GraphQl.Local.postman_environment.json" --reporters 'cli,junit' --reporter-junit-export $reportFilePath --delay-request 100
Pop-Location