Skip to content

Commit

Permalink
fix: SQL Instance Pool - hard coding location of tests to make sure p…
Browse files Browse the repository at this point in the history
…ipeline succeeds (#1748)

## Description

Since we had to disable resource deletion on tests to false, we're hard
coding the location to make sure consequent deployments pass.

Fixes #1744
Closes #1744

## Pipeline Reference

| Pipeline |
| -------- |
|
[![avm.res.sql.instance-pool](https://github.com/yashints/bicep-registry-modules/actions/workflows/avm.res.sql.instance-pool.yml/badge.svg)](https://github.com/yashints/bicep-registry-modules/actions/workflows/avm.res.sql.instance-pool.yml)
|

## Type of Change

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [ ] Update to CI Environment or utlities (Non-module effecting
changes)
- [x] Azure Verified Module updates:
- [ ] Bugfix containing backwards compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [ ] Someone has opened a bug report issue, and I have included "Closes
#{bug_report_issue_number}" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [ ] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [ ] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [ ] Update to documentation

## Checklist

- [x] I'm sure there are no other open Pull Requests for the same
update/change
- [x] I have run `Set-AVMModule` locally to generate the supporting
module files.
- [x] My corresponding pipelines / checks run clean and green without
any errors or warnings
  • Loading branch information
yashints authored Apr 25, 2024
1 parent 3e0c69e commit a89a3ee
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/avm.res.sql.instance-pool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
removeDeployment:
type: boolean
description: "Remove deployed module"
# We had to set this to false because the SQL Instance Pool takes more than 24 hours to get deleted
required: false
default: false
push:
Expand Down
14 changes: 9 additions & 5 deletions avm/res/sql/instance-pool/tests/e2e/defaults/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ metadata description = 'This instance deploys the module with the minimum set of
param resourceGroupName string = 'dep-${namePrefix}-sql.instancepool-${serviceShort}-rg'

@description('Optional. The location to deploy resources to.')
#disable-next-line no-unused-params // A rotation location cannot be used for this test as the SQL Instance Pool deletion is not possible in the same deployment
param resourceLocation string = deployment().location

@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints.')
Expand All @@ -21,6 +22,9 @@ param serviceShort string = 'sipmin'
@description('Optional. A token to inject into the name of each resource. This value can be automatically injected by the CI.')
param namePrefix string = '#_namePrefix_#'

@description('Optional. The static location of the resource group & resources.') // Note, we set the location of the SQL Instance Pool to avoid conflicts with the already existing ones
param tempLocation string = 'uksouth'

// ============ //
// Dependencies //
// ============ //
Expand All @@ -29,20 +33,20 @@ param namePrefix string = '#_namePrefix_#'
// =================
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: resourceGroupName
location: resourceLocation
location: tempLocation
}

module nestedDependencies 'dependencies.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, resourceLocation)}-nestedDependencies'
name: '${uniqueString(deployment().name, tempLocation)}-nestedDependencies'
params: {
virtualNetworkName: 'dep-${namePrefix}-vnet-${serviceShort}'
managedIdentityName: 'dep-${namePrefix}-msi-${serviceShort}'
pairedRegionScriptName: 'dep-${namePrefix}-ds-${serviceShort}'
nsgName: 'dep-${namePrefix}-nsg-${serviceShort}'
routeTableName: 'dep-${namePrefix}-rt-${serviceShort}'
sqlInstancePoolName: '${namePrefix}${serviceShort}001'
location: resourceLocation
location: tempLocation
}
}

Expand All @@ -52,10 +56,10 @@ module nestedDependencies 'dependencies.bicep' = {

module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, resourceLocation)}-test-${serviceShort}'
name: '${uniqueString(deployment().name, tempLocation)}-test-${serviceShort}'
params: {
name: nestedDependencies.outputs.sqlInstancePoolName
location: resourceLocation
location: tempLocation
subnetResourceId: nestedDependencies.outputs.subnetId
}
}
14 changes: 9 additions & 5 deletions avm/res/sql/instance-pool/tests/e2e/waf-aligned/main.test.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ metadata description = 'This instance deploys the module in alignment with the b
param resourceGroupName string = 'dep-${namePrefix}-sql.instancepool-${serviceShort}-rg'

@description('Optional. The location to deploy resources to.')
#disable-next-line no-unused-params // A rotation location cannot be used for this test as the SQL Instance Pool deletion is not possible in the same deployment
param resourceLocation string = deployment().location

@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints.')
Expand All @@ -21,6 +22,9 @@ param serviceShort string = 'sipwaf'
@description('Optional. A token to inject into the name of each resource. This value can be automatically injected by the CI.')
param namePrefix string = '#_namePrefix_#'

@description('Optional. The static location of the resource group & resources.') // Note, we set the location of the SQL Instance Pool to avoid conflicts with the already existing ones
param tempLocation string = 'northeurope'

// ============ //
// Dependencies //
// ============ //
Expand All @@ -29,20 +33,20 @@ param namePrefix string = '#_namePrefix_#'
// =================
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: resourceGroupName
location: resourceLocation
location: tempLocation
}

module nestedDependencies 'dependencies.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, resourceLocation)}-nestedDependencies'
name: '${uniqueString(deployment().name, tempLocation)}-nestedDependencies'
params: {
virtualNetworkName: 'dep-${namePrefix}-vnet-${serviceShort}'
managedIdentityName: 'dep-${namePrefix}-msi-${serviceShort}'
pairedRegionScriptName: 'dep-${namePrefix}-ds-${serviceShort}'
nsgName: 'dep-${namePrefix}-nsg-${serviceShort}'
routeTableName: 'dep-${namePrefix}-rt-${serviceShort}'
sqlInstancePoolName: '${namePrefix}${serviceShort}001'
location: resourceLocation
location: tempLocation
}
}

Expand All @@ -52,10 +56,10 @@ module nestedDependencies 'dependencies.bicep' = {

module testDeployment '../../../main.bicep' = {
scope: resourceGroup
name: '${uniqueString(deployment().name, resourceLocation)}-test-${serviceShort}'
name: '${uniqueString(deployment().name, tempLocation)}-test-${serviceShort}'
params: {
name: nestedDependencies.outputs.sqlInstancePoolName
location: resourceLocation
location: tempLocation
skuName: 'GP_Gen8IM'
subnetResourceId: nestedDependencies.outputs.subnetId
}
Expand Down

0 comments on commit a89a3ee

Please sign in to comment.