Skip to content

Latest commit

 

History

History
322 lines (244 loc) · 8.35 KB

Invoke-AvmTestIntegration.md

File metadata and controls

322 lines (244 loc) · 8.35 KB

Invoke-AvmTestIntegration

Synopsis

Run Bicep ARM validation/what-if or Terraform integration tests.

Description

For Bicep, compiles tests/e2e/**/main.test.bicep, substitutes #name# tokens only in temporary ARM JSON, then runs Azure CLI deployment validate and what-if. Requires an explicit subscription ID. Resource-group validation requires an existing group; this tier never creates one. An .e2eignore marker excludes an example. -Example selects one or more examples; -Recurse includes nested module scopes. Missing or entirely ignored tests report 'skipped'.

For Terraform, runs 'terraform test' against tests/integration/ through Invoke-AvmTerraformTestSuite -Tier integration. After setup.ps1 and .env loading, checks ARM_* authentication inputs or the enabled Azure CLI subscription before init/test. CLI subscription and tenant IDs are supplied only to child processes. Nothing signs in or changes the selected CLI account; providers still validate credentials and resource permissions. Unit tests do not perform this preflight.

Unlike the bare build-only 'avm test' verb, this tier needs Azure credentials at runtime. Terraform integration tests can provision resources; Bicep validation and what-if do not deploy them.

Modules that ship no tests/integration/*.tftest.hcl report Status 'skipped' with RunsTotal = 0 rather than a pass, so an absent tier can never look like a green one. Existing targets that execute no runs or skip selected runs fail rather than reporting a pass.

This verb is a standalone command; it needs credentials, so it is NOT part of the 'avm pre-commit' or 'avm pr-check' gauntlets.

Recognized capacity and region-ineligible failures are retried only after Terraform confirms completed test teardown. Assertions, authorization, configuration, cleanup, and unknown errors are not retried. Each new invocation recreates Terraform's test fixtures, so a fixture that selects a random region can choose another region.

Routed by the dispatcher: 'avm test integration'.

CLI commands

  • avm test integration

Syntax

Invoke-AvmTestIntegration [[-Path] <string>] [-Ecosystem <string>] [-AllowPathFallback] [-NoInit] [-MaxRetry <int>] [-SubscriptionId <string>] [-ResourceGroupName <string>] [-ManagementGroupId <string>] [-Location <string>] [-TokenFile <string>] [-Tokens <IDictionary>] [-ParameterFile <string>] [-Parameters <IDictionary>] [-Example <string[]>] [-Recurse] [-Operation <string>] [-SkipModuleVersionCheck] [<CommonParameters>]

Parameters

-AllowPathFallback

When set, accept a PATH-resolved tool binary that self-reports the lock-pinned version.

Property Value
Type Switch
Required false
Position named
Default value False
Accept pipeline input false
Accept wildcard characters false

-Ecosystem

Force the ecosystem selector. Defaults to 'auto'.

Property Value
Type String
Required false
Position named
Default value auto
Accept pipeline input false
Accept wildcard characters false

-Example

Bicep-only: select a case by folder name or root-relative path. An ignored, missing or ambiguous explicit selection is an error.

Property Value
Type String[]
Required false
Position named
Default value @()
Accept pipeline input false
Accept wildcard characters false

-Location

Bicep-only: deployment metadata location for subscription, management group and tenant tests.

Property Value
Type String
Required false
Position named
Default value
Accept pipeline input false
Accept wildcard characters false

-ManagementGroupId

Bicep-only: management group for management-group-scope tests.

Property Value
Type String
Required false
Position named
Default value
Accept pipeline input false
Accept wildcard characters false

-MaxRetry

Terraform-only retry budget for transient capacity failures (0-10). Defaults to 2; Bicep ARM validation does not retry.

Property Value
Type Int32
Required false
Position named
Default value 2
Accept pipeline input false
Accept wildcard characters false

-NoInit

Terraform-only: skip the automatic terraform init step.

Property Value
Type Switch
Required false
Position named
Default value False
Accept pipeline input false
Accept wildcard characters false

-Operation

Bicep-only: Both (default), Validate or WhatIf.

Property Value
Type String
Required false
Position named
Default value Both
Accept pipeline input false
Accept wildcard characters false

-ParameterFile

Bicep-only: existing ARM JSON parameter file. Relative paths resolve under the module root. A temporary copy receives token substitution.

Property Value
Type String
Required false
Position named
Default value
Accept pipeline input false
Accept wildcard characters false

-Parameters

Bicep-only: direct PowerShell hashtable alternative to -ParameterFile. Values are written to a temporary ARM parameter file, not command-line arguments.

Property Value
Type IDictionary
Required false
Position named
Default value @{}
Accept pipeline input false
Accept wildcard characters false

-Path

Working directory whose enclosing module to test. Defaults to the current location.

Property Value
Type String
Required false
Position 1
Default value $PWD.Path
Accept pipeline input false
Accept wildcard characters false

-Recurse

Bicep-only: include nested module test scopes.

Property Value
Type Switch
Required false
Position named
Default value False
Accept pipeline input false
Accept wildcard characters false

-ResourceGroupName

Bicep-only: name of an existing group for resource-group-scope tests.

Property Value
Type String
Required false
Position named
Default value
Accept pipeline input false
Accept wildcard characters false

-SkipModuleVersionCheck

Skip the PowerShell Gallery check that otherwise stops the command when a newer Avm.Authoring version is available. Writes a warning once.

Property Value
Type Switch
Required false
Position named
Default value False
Accept pipeline input false
Accept wildcard characters false

-SubscriptionId

Bicep-only: explicit subscription GUID. Ambient defaults are never used.

Property Value
Type String
Required false
Position named
Default value
Accept pipeline input false
Accept wildcard characters false

-TokenFile

Bicep-only: JSON object mapping token names to string values. Relative paths resolve under the module root. Subscription and management group IDs are supplied by their dedicated parameters, not this file.

Property Value
Type String
Required false
Position named
Default value
Accept pipeline input false
Accept wildcard characters false

-Tokens

Bicep-only: direct PowerShell hashtable alternative to -TokenFile.

Property Value
Type IDictionary
Required false
Position named
Default value @{}
Accept pipeline input false
Accept wildcard characters false
Aliases AdditionalTokens

Examples

EXAMPLE 1

avm test integration

EXAMPLE 2

avm test integration --max-retry 0

EXAMPLE 3

Invoke-AvmTestIntegration -Path C:\repos\terraform-azurerm-avm-res-foo

EXAMPLE 4

avm test integration --subscription-id 00000000-0000-0000-0000-000000000001 --resource-group-name existing-test-rg --token-file test-tokens.json

Outputs

  • pscustomobject with Engine, Tool, ToolPath, ToolSource, Status, FilesProcessed, RunsTotal, RunsPassed, RunsFailed, Issues. Bicep additionally reports IgnoredFiles, RunsSkipped and WhatIfChanges.