Skip to content

Commit

Permalink
Update Terraform Azure Test Resource Type (#8254)
Browse files Browse the repository at this point in the history
# Description

We have been seeing flakyness in terraform recipe azure storage test due
to fluctuating create latencies of azure storage account provisioning
causing subsequent requests on the resource to fail due to 409. Since
the main goal of this test is to validate that Azure provider/auth is
correctly configured for Terraform recipes, we don't specifically need
to provision Azure storage. So switching the test to create a resource
group, which will provision faster for reliability in testing.

More details and investigation on this are logged in the comments here:
#8237.

## Type of change

Fixes: #8172

## Contributor checklist
Please verify that the PR meets the following requirements, where
applicable:

- [NA] An overview of proposed schema changes is included in a linked
GitHub issue.
- [NA] A design document PR is created in the [design-notes
repository](https://github.com/radius-project/design-notes/), if new
APIs are being introduced.
- [NA] If applicable, design document has been reviewed and approved by
Radius maintainers/approvers.
- [NA] A PR for the [samples
repository](https://github.com/radius-project/samples) is created, if
existing samples are affected by the changes in this PR.
- [NA] A PR for the [documentation
repository](https://github.com/radius-project/docs) is created, if the
changes in this PR affect the documentation or any user facing updates
are made.
- [NA] A PR for the [recipes
repository](https://github.com/radius-project/recipes) is created, if
existing recipes are affected by the changes in this PR.

Signed-off-by: Karishma Chawla <[email protected]>
  • Loading branch information
kachawla authored Jan 21, 2025
1 parent 283e44f commit fa809bf
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ limitations under the License.
package resource_test

// This file contains tests for Terraform recipes functionality - covering general behaviors that should
// be consistent across all resource types. These tests mostly use the extender resource type and mostly
// avoid cloud resources to avoid unnecessary coupling and reliability issues.
// be consistent across all resource types.
//
// Tests in this file should only use cloud resources if absolutely necessary.
// New tests using cloud resources should be added if absolutely necessary.
//
// Tests in this file should be kept *roughly* in sync with recipe_bicep_test and any other drivers.

Expand All @@ -44,12 +43,12 @@ var (
secretPrefix = "tfstate-default-"
)

// Test_TerraformRecipe_AzureStorage creates an Extender resource consuming a Terraform recipe that deploys an Azure blob storage instance.
func Test_TerraformRecipe_AzureStorage(t *testing.T) {
template := "testdata/corerp-resources-terraform-azurestorage.bicep"
name := "corerp-resources-terraform-azstorage"
appName := "corerp-resources-terraform-azstorage-app"
envName := "corerp-resources-terraform-azstorage-env"
// Test_TerraformRecipe_AzureResourceGroup creates an Extender resource consuming a Terraform recipe that deploys an Azure resource group instance.
func Test_TerraformRecipe_AzureResourceGroup(t *testing.T) {
template := "testdata/corerp-resources-terraform-azurerg.bicep"
name := "corerp-resources-terraform-azrg"
appName := "corerp-resources-terraform-azrg-app"
envName := "corerp-resources-terraform-azrg-env"

test := rp.NewRPTest(t, name, []rp.TestStep{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ param moduleServer string
param appName string

resource env 'Applications.Core/environments@2023-10-01-preview' = {
name: 'corerp-resources-terraform-azstorage-env'
name: 'corerp-resources-terraform-azrg-env'
properties: {
compute: {
kind: 'kubernetes'
resourceId: 'self'
namespace: 'corerp-resources-terraform-azstorage-env'
namespace: 'corerp-resources-terraform-azrg-env'
}
providers: {
azure: {
Expand All @@ -25,9 +25,9 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = {
'Applications.Core/extenders': {
default: {
templateKind: 'terraform'
templatePath: '${moduleServer}/azure-storage.zip'
templatePath: '${moduleServer}/azure-rg.zip'
parameters: {
resource_group_name: resourceGroup().name
name: 'tfrg${uniqueString(resourceGroup().id)}'
location: location
}
}
Expand All @@ -50,7 +50,7 @@ resource app 'Applications.Core/applications@2023-10-01-preview' = {
}

resource webapp 'Applications.Core/extenders@2023-10-01-preview' = {
name: 'corerp-resources-terraform-azstorage'
name: 'corerp-resources-terraform-azrg'
properties: {
application: app.id
environment: env.id
Expand Down
13 changes: 13 additions & 0 deletions test/testrecipes/test-terraform-recipes/azure-rg/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.114.0"
}
}
}

resource "azurerm_resource_group" "test_rg" {
name = var.name
location = var.location
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variable "resource_group_name" {
variable "name" {
type = string
}

Expand Down
32 changes: 0 additions & 32 deletions test/testrecipes/test-terraform-recipes/azure-storage/main.tf

This file was deleted.

This file was deleted.

0 comments on commit fa809bf

Please sign in to comment.