Skip to content

Test Plan

Sheng Chen edited this page Apr 25, 2018 · 25 revisions

Basic

Features

Prerequisite: To test extension features, we need to have a terraform project.
If you don't have one, find it from: https://github.com/terraform-providers/terraform-provider-azurerm/tree/master/examples

Basic Command (local)

Prerequisite: Running basic command locally requires users have terraform binary in the system path. See Running Terraform from Azure CLI for instructions on SPN setup.

NOTE: On Windows press F1 to open Command Palette. On Mac, press ⌘+SHIFT+P to open Command Palette.

Init

  • Open the Command Palette.
  • Select 'Terraform Azure: init'.
  • Will run terraform init in the current workspace folder.

Validate

  • Open the Command Palette.
  • Select 'Terraform Azure: validate'.
  • Will run terraform validate in the current workspace folder.
  • If there is syntax errors in the current terraform project, they will be shown as the command result.

Plan

  • Open the Command Palette.
  • Select 'Terraform Azure: plan'.
  • Will run terraform plan in the current workspace folder.
  • The command will show what actions are necessary to achieve the desired state specified in the configuration files.

Apply

  • Open the Command Palette.
  • Select 'Terraform Azure: apply'.
  • Will run terraform apply in the current workspace folder.
  • Will apply the changes required to reach the desired state of the configuration.

Refresh

  • Open the Command Palette.
  • Select 'Terraform Azure: refresh'.
  • Will run terraform refresh in the current workspace folder.
  • Will reconcile the state Terraform knows about (via its state file) with the real-world infrastructure.

Destroy

  • Open the Command Palette.
  • Select 'Terraform Azure: destroy'.
  • Will run terraform destroy in the current workspace folder.
  • Will destroy the Terraform-managed infrastructure.

Basic Command (cloudshell)

Init

  • Open the Command Palette.
  • Select 'Terraform Azure: init'.
  • Will run terraform init in the current working directory.

Validate

  • Open the Command Palette.
  • Select 'Terraform Azure: validate'.
  • Will run terraform validate in the current working directory.
  • If there is syntax errors in the current terraform project, they will be shown as the command result.

Plan

  • Open the Command Palette.
  • Select 'Terraform Azure: plan'.
  • Will run terraform plan in the current working directory.
  • The command will show what actions are necessary to achieve the desired state specified in the configuration files.

Apply

  • Open the Command Palette.
  • Select 'Terraform Azure: apply'.
  • Will run terraform apply in the current working directory.
  • Will apply the changes required to reach the desired state of the configuration.

Refresh

  • Open the Command Palette.
  • Select 'Terraform Azure: refresh'.
  • Will run terraform refresh in the current working directory.
  • Will reconcile the state Terraform knows about (via its state file) with the real-world infrastructure.

Destroy

  • Open the Command Palette.
  • Select 'Terraform Azure: destroy'.
  • Will run terraform destroy in the current working directory.
  • Will destroy the Terraform-managed infrastructure.

Execute Test (local)

Prerequisite:

  • This feature needs Docker installed and in the system path. If not, extension will tell user Docker is not installed.
  • For the E2E test, the extension use Test Kitchen as the integration tool for testing infrastructure code. If you don't hava an project that has setup the integration tests, you can use this one: https://github.com/Azure/terraform-azurerm-network

Lint

  • Open the Command Palette.
  • Select 'Terraform Azure: execute test', then 'lint'.
  • A Docker image will be run.
  • Go to the output channel to see the result.

End to End

  • Open the Command Palette.
  • Select 'Terraform Azure: execute test', then 'end to end'.
  • A Docker image will be run.
  • Go to the output channel to see the result.

Customize

  • Open the Command Palette.
  • Select 'Terraform Azure: execute test', then 'custom'.
  • A Docker image will be run and running the user customized command.
  • Go to the output channel to see the result.

Execute Test (cloudshell)

Notes: All the tests will be run in a real ACI on Azure, you can specify the ACI name and resource group name in VS Code settings, otherwise, extension will use default values. See README.MD for details.

Lint

  • Open the Command Palette.
  • Select 'Terraform Azure: execute test', then 'lint'.
  • An ACI will be provisioned through terraform if target resource not exists.
  • Entering 'az container logs -g tfTestResourceGroup -n tfTestContainerGroup' in the cloud shell terminal to view logs.

End to End

  • Open the Command Palette.
  • Select 'Terraform Azure: execute test', then 'end to end'.
  • An ACI will be provisioned through terraform if target resource not exists.
  • The ACI will run the E2E test.
  • Entering 'az container logs -g tfTestResourceGroup -n tfTestContainerGroup' in the cloud shell terminal to view logs.

Customize

  • Open the Command Palette.
  • Select 'Terraform Azure: execute test', then 'custom'.
  • An ACI will be provisioned through terraform if target resource not exists.
  • The ACI will run the user customized command after starting up.
  • Entering 'az container logs -g tfTestResourceGroup -n tfTestContainerGroup' in the cloud shell terminal to view logs.

Visualize (local)

Prerequisite: This feature needs Dot installed and in the system path. If not, extension will tell user Dot is not installed.

  • Open a terraform project in vscode workspace.
  • Click 'F1' to open the Command Palette.
  • Select 'Terraform Azure: visualize'.
  • A graph will be shown in VS Code representing either a configuration or execution plan.

Visualize (cloudshell)

  • Popup an message dialog telling user that this feature is only available in integrated terminal.

Push (local)

  • Popup an message dialog telling user that this feature is only available when using cloud shell.

Push (cloudshell)

  • Push terraform project files onto the cloud. You can specify the file type you want to upload through extension settings. See README.MD for details.