-
Notifications
You must be signed in to change notification settings - Fork 7
[PERF-338] Install applications on Azure VM for performance testing #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
josejuancm
wants to merge
8
commits into
main
Choose a base branch
from
PERF-338
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
88fc045
prerequisites updated
josejuancm 40c2bd3
action to download the installation packages and scripts creation
josejuancm c1d3a14
fixes on references and versions
josejuancm fd989ef
feat: added missing secrets
c68cb1f
swagger and sandbox installation scripts
josejuancm 40a287e
Get package versions based on ODS version to install
simpat-jesus e57ce1f
Update action version
simpat-jesus 1e2f631
Remove action environments
simpat-jesus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,99 @@ | ||
| #Requires -Version 5 | ||
| param( | ||
| [Parameter(mandatory=$true)] | ||
| [string] | ||
| $PackageVersion | ||
| ) | ||
|
|
||
| function Invoke-SemanticSort { | ||
| param( | ||
| [Parameter(Mandatory=$true)] | ||
| [string[]] | ||
| $Versions | ||
| ) | ||
|
|
||
| $major = @{label="major";expression={[int]$_.Split(".")[0]}} | ||
| $minor = @{label="minor";expression={[int]$_.Split(".")[1]}} | ||
| $patch = @{label="patch";expression={[int]$_.Split(".")[2]}} | ||
|
|
||
| $Versions ` | ||
| | Select-Object $major, $minor, $patch ` | ||
| | Sort-Object major, minor, patch -Descending ` | ||
| | ForEach-Object { "$($_.major).$($_.minor).$($_.patch)" } | ||
| } | ||
|
|
||
| function Get-NugetPackageVersion { | ||
| [CmdletBinding()] | ||
| param( | ||
| [Parameter(Mandatory=$true)] | ||
| [string] | ||
| $PackageName, | ||
|
|
||
| [Parameter(Mandatory=$true)] | ||
| [string] | ||
| $PackageVersion, | ||
|
|
||
| # URL for the release package feed | ||
| [string] | ||
| $ReleaseServiceIndex = "https://pkgs.dev.azure.com/ed-fi-alliance/Ed-Fi-Alliance-OSS/_packaging/EdFi%40Release/nuget/v3/index.json" | ||
| ) | ||
|
|
||
| $nugetServicesURL = $ReleaseServiceIndex | ||
|
|
||
| # The first URL just contains metadata for looking up more useful services | ||
| $nugetServices = Invoke-RestMethod $nugetServicesURL | ||
|
|
||
| $packageService = $nugetServices.resources ` | ||
| | Where-Object { $_."@type" -like "PackageBaseAddress*" } ` | ||
| | Select-Object -Property "@id" -ExpandProperty "@id" | ||
|
|
||
| # Pad the package version out to three part semver | ||
| switch ($PackageVersion.split(".").length) { | ||
| 1 { $versionSearch = "$PackageVersion.*.*"} | ||
| 2 { $versionSearch = "$PackageVersion.*" } | ||
| 3 { $versionSearch = $PackageVersion } | ||
| default: { throw "Invalid version string ``$($PackageVersion)``. Should be one, two, or three components from a Semantic Version.".Trim() } | ||
| } | ||
| $lowerId = $PackageName.ToLower() | ||
|
|
||
| # Lookup available packages | ||
| $package = Invoke-RestMethod "$($packageService)$($lowerId)/index.json" | ||
|
|
||
| # Sort by SemVer | ||
| $versions = Invoke-SemanticSort $package.versions | ||
|
|
||
| # Find the first available version that matches the requested version | ||
| $version = $versions | Where-Object { $_ -like $versionSearch } | Select-Object -First 1 | ||
|
|
||
| if ($null -eq $version) { | ||
| throw "Version ``$($PackageVersion)`` does not exist yet for ``$($PackageName)``." | ||
| } | ||
|
|
||
| $version | ||
| } | ||
| Write-Host $PackageVersion | ||
| switch -Exact ($PackageVersion) | ||
| { | ||
| '7.3' { $StandardVersion = "5.2.0" } | ||
| '7.2' { $StandardVersion = "5.1.0" } | ||
| '7.1' { $StandardVersion = "5.0.0" } | ||
| } | ||
|
|
||
| $env:WEBAPI_INSTALLLER_VERSION = "$(Get-NugetPackageVersion -PackageName EdFi.Suite3.Installer.WebApi -PackageVersion $PackageVersion)".Trim() | ||
| $env:SWAGGER_INSTALLER_VERSION = "$(Get-NugetPackageVersion -PackageName EdFi.Suite3.Installer.SwaggerUI -PackageVersion $PackageVersion)".Trim() | ||
| $env:SANDBOXADMIN_INSTALLER_VERSION = "$(Get-NugetPackageVersion -PackageName EdFi.Suite3.Installer.SandboxAdmin -PackageVersion $PackageVersion)".Trim() | ||
|
|
||
| $env:SWAGGER_VERSION = "$(Get-NugetPackageVersion -PackageName EdFi.Suite3.Ods.SwaggerUI -PackageVersion $PackageVersion)".Trim() | ||
| $env:SANDBOXADMIN_VERSION = "$(Get-NugetPackageVersion -PackageName EdFi.Suite3.Ods.SandboxAdmin -PackageVersion $PackageVersion)".Trim() | ||
|
|
||
| if ($null -eq $StandardVersion) { | ||
| $env:DATABASE_INSTALLER_VERSION = "$(Get-NugetPackageVersion -PackageName EdFi.Suite3.RestApi.Databases -PackageVersion $PackageVersion)".Trim() | ||
| $env:DATABASE_INSTALLER = "EdFi.Suite3.RestApi.Databases" | ||
| $env:WEBAPI_VERSION = "$(Get-NugetPackageVersion -PackageName EdFi.Suite3.Ods.WebApi -PackageVersion $PackageVersion)".Trim() | ||
| $env:WEBAPI = "EdFi.Suite3.Ods.WebApi" | ||
| }else { | ||
| $env:DATABASE_INSTALLER_VERSION = "$(Get-NugetPackageVersion -PackageName EdFi.Suite3.RestApi.Databases.Standard.$StandardVersion -PackageVersion $PackageVersion)".Trim() | ||
| $env:DATABASE_INSTALLER = "EdFi.Suite3.RestApi.Databases.Standard.$StandardVersion" | ||
| $env:WEBAPI_VERSION = "$(Get-NugetPackageVersion -PackageName EdFi.Suite3.Ods.WebApi.Standard.$StandardVersion -PackageVersion $PackageVersion)".Trim() | ||
| $env:WEBAPI = "EdFi.Suite3.Ods.WebApi.Standard.$StandardVersion" | ||
| } |
This file contains hidden or 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,193 @@ | ||
| name: Download packages and create installation scripts | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| resource_group: | ||
| description: "The resource group of the VM" | ||
| required: true | ||
| web_api_vm_name: | ||
| description: "The name of the WEB API VM" | ||
| required: true | ||
| sql_vm_name: | ||
| description: "The name of the SQL VM" | ||
| required: true | ||
| ods_api_version: | ||
| description: "The version of EdFi ODS / API to install" | ||
| required: true | ||
| default: "7.3" | ||
| type: choice | ||
| options: | ||
| - 7.3 | ||
| - 7.2 | ||
| - 7.1 | ||
| - 6.2 | ||
| - 5.4 | ||
| db_server: | ||
| description: "Database server IP address" | ||
| required: true | ||
|
|
||
| env: | ||
| ARM_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }} | ||
| ARM_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} | ||
| ARM_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }} | ||
| ARM_TENANT_ID: ${{ vars.AZURE_TENANT_ID }} | ||
|
|
||
| jobs: | ||
| run-command: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
|
|
||
| - name: Checkout | ||
| uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
|
||
| - name: Get Package Versions | ||
| working-directory: ./.github/workflows | ||
| run: | | ||
| .\get-versions.ps1 -PackageVersion ${{ github.event.inputs.ods_api_version }} | ||
| shell: pwsh | ||
|
|
||
| - name: Azure Login | ||
| uses: azure/login@v1 | ||
| with: | ||
| creds: '{"clientId":"${{ env.ARM_CLIENT_ID }}","clientSecret":"${{ env.ARM_CLIENT_SECRET }}","subscriptionId":"${{ env.ARM_SUBSCRIPTION_ID }}","tenantId":"${{ env.ARM_TENANT_ID }}"}' | ||
|
|
||
| - name: Download Components on Web Server VM | ||
| run: | | ||
|
simpat-jesus marked this conversation as resolved.
|
||
| az vm run-command invoke \ | ||
| --command-id RunPowerShellScript \ | ||
| --name "${{ github.event.inputs.web_api_vm_name }}" \ | ||
| --resource-group "${{ github.event.inputs.resource_group }}" \ | ||
| --scripts ' | ||
| # Download and extract WebApi Installer | ||
| Invoke-WebRequest -Uri "https://pkgs.dev.azure.com/ed-fi-alliance/Ed-Fi-Alliance-OSS/_apis/packaging/feeds/EdFi@Release/nuget/packages/EdFi.Suite3.Installer.WebApi/versions/${{ $env:WEBAPI_INSTALLLER_VERSION }}/content" -OutFile "C:/ODS/${{ github.event.inputs.ods_api_version }}/EdFi.Suite3.Installer.WebApi.${{ $env:WEBAPI_INSTALLLER_VERSION }}.nupkg" | ||
| Rename-Item -Path "C:/ODS/${{ github.event.inputs.ods_api_version }}/EdFi.Suite3.Installer.WebApi.${{ $env:WEBAPI_INSTALLLER_VERSION }}.nupkg" -NewName "EdFi.Suite3.Installer.WebApi.zip" | ||
| Expand-Archive -Path "C:/ODS/${{ github.event.inputs.ods_api_version }}/EdFi.Suite3.Installer.WebApi.zip" -DestinationPath "C:/ODS/${{ github.event.inputs.ods_api_version }}/EdFi.Suite3.Installer.WebApi" -Force | ||
|
|
||
| # Download and extract SwaggerUI | ||
| Invoke-WebRequest -Uri "https://pkgs.dev.azure.com/ed-fi-alliance/Ed-Fi-Alliance-OSS/_apis/packaging/feeds/EdFi@Release/nuget/packages/EdFi.Suite3.Installer.SwaggerUI/versions/${{ $env:SWAGGER_INSTALLER_VERSION }}/content" -OutFile "C:/ODS/${{ github.event.inputs.ods_api_version }}/EdFi.Suite3.Installer.SwaggerUI.${{ $env:SWAGGER_INSTALLER_VERSION }}.nupkg" | ||
| Rename-Item -Path "C:/ODS/${{ github.event.inputs.ods_api_version }}/EdFi.Suite3.Installer.SwaggerUI.${{ $env:SWAGGER_INSTALLER_VERSION }}.nupkg" -NewName "EdFi.Suite3.Installer.SwaggerUI.zip" | ||
| Expand-Archive -Path "C:/ODS/${{ github.event.inputs.ods_api_version }}/EdFi.Suite3.Installer.SwaggerUI.zip" -DestinationPath "C:/ODS/${{ github.event.inputs.ods_api_version }}/EdFi.Suite3.Installer.SwaggerUI" -Force | ||
|
|
||
| # Download and extract SandboxAdmin | ||
| Invoke-WebRequest -Uri "https://pkgs.dev.azure.com/ed-fi-alliance/Ed-Fi-Alliance-OSS/_apis/packaging/feeds/EdFi@Release/nuget/packages/EdFi.Suite3.Installer.SandboxAdmin/versions/${{ $env:SANDBOXADMIN_INSTALLER_VERSION }}/content" -OutFile "C:/ODS/${{ github.event.inputs.ods_api_version }}/EdFi.Suite3.Installer.SandboxAdmin.${{ $env:SANDBOXADMIN_INSTALLER_VERSION }}.nupkg" | ||
| Rename-Item -Path "C:/ODS/${{ github.event.inputs.ods_api_version }}/EdFi.Suite3.Installer.SandboxAdmin.${{ $env:SANDBOXADMIN_INSTALLER_VERSION }}.nupkg" -NewName "EdFi.Suite3.Installer.SandboxAdmin.zip" | ||
| Expand-Archive -Path "C:/ODS/${{ github.event.inputs.ods_api_version }}/EdFi.Suite3.Installer.SandboxAdmin.zip" -DestinationPath "C:/ODS/${{ github.event.inputs.ods_api_version }}/EdFi.Suite3.Installer.SandboxAdmin" -Force' | ||
|
|
||
| - name: Download RestApi Databases on SQL Server VM | ||
| run: | | ||
| az vm run-command invoke \ | ||
| --command-id RunPowerShellScript \ | ||
| --name "${{ github.event.inputs.sql_vm_name }}" \ | ||
| --resource-group "${{ github.event.inputs.resource_group }}" \ | ||
| --scripts ' | ||
| # Download and extract RestApi Databases | ||
| Invoke-WebRequest -Uri "https://pkgs.dev.azure.com/ed-fi-alliance/Ed-Fi-Alliance-OSS/_apis/packaging/feeds/EdFi@Release/nuget/packages/${{ $env:DATABASE_INSTALLER }}/versions/${{ $env:DATABASE_INSTALLER_VERSION }}/content" -OutFile "C:/ODS/${{ github.event.inputs.ods_api_version }}/${{ $env:DATABASE_INSTALLER }}.nupkg" | ||
| Rename-Item -Path "C:/ODS/${{ github.event.inputs.ods_api_version }}/${{ $env:DATABASE_INSTALLER }}.nupkg" -NewName "EdFi.Suite3.RestApi.Databases.Standard.zip" | ||
| Expand-Archive -Path "C:/ODS/${{ github.event.inputs.ods_api_version }}/EdFi.Suite3.RestApi.Databases.Standard.zip" -DestinationPath "C:/ODS/${{ github.event.inputs.ods_api_version }}/${{ $env:DATABASE_INSTALLER }}" -Force | ||
| Remove-Item -Path "C:/ODS/${{ github.event.inputs.ods_api_version }}/${{ $env:DATABASE_INSTALLER }}/configuration.postgreSQL.json" -Force' | ||
|
|
||
| - name: Create Deployment Script | ||
| run: | | ||
| SCRIPT_CONTENT=' | ||
| Set-Location "C:/ODS/${{ github.event.inputs.ods_api_version }}/${{ $env:DATABASE_INSTALLER }}" | ||
|
|
||
| Write-Host "Creating ps1 file..." | ||
| "Import-Module .\Deployment.psm1" | Out-File -FilePath "dbs_installation.ps1" | ||
| "Initialize-DeploymentEnvironment" | Out-File -FilePath "dbs_installation.ps1" -Append | ||
|
|
||
| Write-Host "File created successfully" | ||
| Get-Content -Path "dbs_installation.ps1"' | ||
|
|
||
| az vm run-command invoke \ | ||
| --command-id RunPowerShellScript \ | ||
| --name "${{ github.event.inputs.sql_vm_name }}" \ | ||
| --resource-group "${{ github.event.inputs.resource_group }}" \ | ||
| --scripts "$SCRIPT_CONTENT" | ||
|
|
||
| - name: Create WebApi Installation Script | ||
| run: | | ||
| SCRIPT_CONTENT=' | ||
| Set-Location "C:/ODS/${{ github.event.inputs.ods_api_version }}/EdFi.Suite3.Installer.WebApi" | ||
|
|
||
| Write-Host "Creating WebApi installation script..." | ||
| @" | ||
| Import-Module .\Install-EdFiOdsWebApi.psm1 | ||
| `$parameters = @{ | ||
| PackageVersion = "${{ $env:WEBAPI_VERSION }}" | ||
| PackageName = "${{ $env:WEBAPI }}" | ||
| DbConnectionInfo = @{ | ||
| Engine = "SqlServer" | ||
| Server = "${{ github.event.inputs.db_server }}" | ||
| Username = "${{ secrets.SQL_ADMIN_USERNAME }}" | ||
| Password = "${{ secrets.SQL_ADMIN_PASSWORD }}" | ||
| UseIntegratedSecurity = `$false | ||
| } | ||
| IsSandbox = `$true | ||
| UnEncryptedConnection = `$true | ||
| } | ||
| Install-EdFiOdsWebApi @parameters | ||
| "@ | Out-File -FilePath "webapi_installation.ps1" | ||
|
|
||
| Write-Host "File created successfully" | ||
| Get-Content -Path "webapi_installation.ps1"' | ||
|
|
||
| az vm run-command invoke \ | ||
| --command-id RunPowerShellScript \ | ||
| --name "${{ github.event.inputs.web_api_vm_name }}" \ | ||
| --resource-group "${{ github.event.inputs.resource_group }}" \ | ||
| --scripts "$SCRIPT_CONTENT" | ||
|
|
||
| - name: Create SwaggerUI Installation Script | ||
| run: | | ||
| SCRIPT_CONTENT=' | ||
| Set-Location "C:/ODS/${{ github.event.inputs.ods_api_version }}/EdFi.Suite3.Installer.SwaggerUI" | ||
|
|
||
| Write-Host "Creating ps1 file..." | ||
| @" | ||
| Import-Module .\Install-EdFiOdsSwaggerUI.psm1 | ||
| `$parameters = @{ | ||
| PackageVersion = "${{ $env:SWAGGER_VERSION }}" | ||
| WebApiVersionUrl = "https://edfi-ods/WebApi" | ||
| PrePopulatedKey = "${{ secrets.POPULATED_KEY }}" | ||
| PrePopulatedSecret = "${{ secrets.POPULATED_SECRET }}" | ||
| } | ||
| Install-EdFiOdsSwaggerUI @parameters | ||
| "@ | Out-File -FilePath "swaggerui_installation.ps1" | ||
|
|
||
| Write-Host "File created successfully" | ||
| Get-Content -Path "swaggerui_installation.ps1" | ||
| ' | ||
|
|
||
| az vm run-command invoke \ | ||
| --command-id RunPowerShellScript \ | ||
| --name "${{ github.event.inputs.web_api_vm_name }}" \ | ||
| --resource-group "${{ github.event.inputs.resource_group }}" \ | ||
| --scripts "$SCRIPT_CONTENT" | ||
|
|
||
| - name: Create SandboxAdmin Installation Script | ||
| run: | | ||
| SCRIPT_CONTENT=' | ||
| Set-Location "C:/ODS/${{ github.event.inputs.ods_api_version }}/EdFi.Suite3.Installer.SandboxAdmin" | ||
|
|
||
| Write-Host "Creating ps1 file..." | ||
| @" | ||
| Import-Module .\Install-EdFiOdsSandboxAdmin.psm1 | ||
| `$parameters = @{ | ||
| PackageVersion = "${{ $env:SANDBOXADMIN_VERSION }}" | ||
| WebApiVersionUrl = "https://edfi-ods/WebApi" | ||
| PrePopulatedKey = "${{ secrets.POPULATED_KEY }}" | ||
| PrePopulatedSecret = "${{ secrets.POPULATED_SECRET }}" | ||
| } | ||
| Install-EdFiOdsSandboxAdmin @parameters | ||
| "@ | Out-File -FilePath "sandboxadmin_installation.ps1" | ||
|
|
||
| Write-Host "File created successfully" | ||
| Get-Content -Path "sandboxadmin_installation.ps1" | ||
| ' | ||
|
|
||
| az vm run-command invoke \ | ||
| --command-id RunPowerShellScript \ | ||
| --name "${{ github.event.inputs.web_api_vm_name }}" \ | ||
| --resource-group "${{ github.event.inputs.resource_group }}" \ | ||
| --scripts "$SCRIPT_CONTENT" | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can the IP be set to a fixed value while provisioning the VM? or use the FDQN instead?