forked from microsoft/azure-maven-archetypes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe2etest.ps1
52 lines (45 loc) · 2.11 KB
/
e2etest.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
# Define the functions
Function RemoveFileIfExist($fileName) {
if (Test-Path $fileName) {
Remove-Item -Force $fileName
}
}
Function RemoveFolderIfExist($folderName) {
if (Test-Path $folderName) {
Remove-Item -Recurse -Force $folderName
}
}
Function DownloadFileFromUrl($url, $destination) {
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($Env:FUNCTIONCLI_URL, $functionCLIZipPath)
}
#Scripts
$base = pwd
$functionCLIPath = "$base\Azure.Functions.Cli"
$functionCLIZipPath = "$base\Azure.Functions.Cli.zip"
# Download Functions Core Tools
RemoveFileIfExist $functionCLIZipPath
RemoveFolderIfExist $functionCLIPath
DownloadFileFromUrl $Env:FUNCTIONCLI_URL $functionCLIZipPath
Expand-Archive $functionCLIZipPath -DestinationPath $functionCLIPath
$Env:Path = $Env:Path + ";$functionCLIPath"
# Install maven plguin archetype
mvn clean install
# Generate function project through archetype
$testProjectBaseFolder = ".\testprojects"
# Get the version of archetype and set archetypeVersion in following steps
$archetypeVersion = ([xml](gc ".\azure-functions-archetype\pom.xml")).project.version
RemoveFolderIfExist $testProjectBaseFolder
mkdir $testProjectBaseFolder
cd $testProjectBaseFolder
mvn archetype:generate -DarchetypeCatalog="local" -DarchetypeGroupId="com.microsoft.azure" -DarchetypeArtifactId="azure-functions-archetype" -DarchetypeVersion="$archetypeVersion" -DgroupId="com.microsoft" -DartifactId="e2etestproject" -Dversion="1.0-SNAPSHOT" -Dpackage="com.microsoft" -B
$testFunctionAppName = ([xml](gc ".\e2etestproject\pom.xml")).project.properties.functionAppName
mvn -f ".\e2etestproject\pom.xml" clean package
cd ..
# Run function host
$Env:FUNCTIONS_WORKER_RUNTIME = "java"
$Env:AZURE_FUNCTIONS_ENVIRONMENT = "development"
$Env:AzureWebJobsScriptRoot = "$base\$testProjectBaseFolder\e2etestproject\target\azure-functions\$testFunctionAppName"
$proc = start-process -filepath "$functionCLIPath\func.exe" -WorkingDirectory "$Env:AzureWebJobsScriptRoot" -ArgumentList "host start" -RedirectStandardOutput "output.txt" -RedirectStandardError "error.txt" -PassThru
Start-Sleep -s 30
return $proc