OctopusTerraformTestFramework

module
v2.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2026 License: Apache-2.0

README

This module is a reusable test framework to create an Octopus instance connected to MSSQL and populated with Terraform modules.

An example of a test looks like this:

package main

import (
	"fmt"
	"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
	"github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework/v2/test"
	"path/filepath"
	"testing"
)

func TestCreateSpaceAndUseIt(t *testing.T) {
	testFramework := test.OctopusContainerTest{}
	testFramework.ArrangeTest(t, func(t *testing.T, container *test.OctopusContainer, client *client.Client) error {
        _, err := testFramework.Act(t, container, "terraform", "2-usenewspace", []string{})
        return err
    })
	
}

You must have a directory called 1-singlespace as a sibling to the directory called in the Act method. This directory must contain a Terraform module that creates a new Octopus space and returns the new space ID as the output variable octopus_space_id. For example:

test
  - terraform
    - 1-singlespace
    - 2-usenewspace

An example of this directory has been provided at 1-singlespace.

Environment variables

  • OCTOTESTWAITFORAPI - set to false to remove the check of the API between creating a space and populating it. The default is to run these checks.
  • OCTOTESTIMAGEURL - set to the Docker image URL for the Octopus Server to use in the tests. Defaults to the public image on DockerHub (i.e. octopusdeploy/octopusdeploy)
  • OCTOTESTVERSION - set to the tag of the Docker image to use in the tests. The default is latest.
  • OCTOTESTRETRYCOUNT - set to the number of retries to use for any individual test. Defaults to 3.
  • OCTOTESTDUMPSTATE - set to true to dump the Terraform state if a request for an output variable fails. Defaults to false.
  • OCTOTESTDEFAULTSPACEID - Terraform seems to have a bug where the state file is not written correctly. If this happens, the ID of the newly created space can not be read. Setting this env var allows you to recover from this error by setting the default value of the new space (usually Spaces-2).
  • OCTOTESTSKIPINIT - set to true to skip terraform init. Skipping the init phase is useful when you define a provider override in the ~/.terraformrc file.
  • OCTODISABLEOCTOCONTAINERLOGGING - set to true to skip logging output from the Octopus container.
  • LICENSE - Set to the base 64 encoded version of an Octopus XML license. See Octopus Dev License in 1Password for a value.
  • ENABLE_USAGE - set to N to stop Octopus from sending telemetry.

MacOs Troubleshooting

If the MSSQL image seg faults or containers do not appear to start in Docker Desktop, you may need to override the the DOCKER_HOST environment variable.

Run docker context ls to find the Docker Desktop docker file:

% docker context ls

NAME              DESCRIPTION                               DOCKER ENDPOINT                                                                                  ERROR
default           Current DOCKER_HOST based configuration   unix:///var/run/docker.sock
desktop-linux *   Docker Desktop                            unix:///Users/matthewcasperson/.docker/run/docker.sock
podman            Podman                                    unix:///var/folders/d2/0y02y4ld21g4kx5fvw1lk52h0000gn/T/podman/podman-machine-default-api.sock

In the example above, DOCKER_HOST must be set to unix:///Users/matthewcasperson/.docker/run/docker.sock.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL