dstester

package module
v0.0.0-...-cc887c0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package dstester is a collection of tools to make testing Terraform resources created for DeployStack easier.

Index

Constants

This section is empty.

Variables

View Source
var ErrorCheckFail = fmt.Errorf("there was an issue with the poll")

ErrorCheckFail is thrown when a check fails

View Source
var ErrorURLFail = fmt.Errorf("the url did not return 200 after time allotted")

ErrorURLFail is thrown when a http poll fails

Functions

func Clean

func Clean(t *testing.T, tf Terraform, resources Resources)

Clean calls the deletion version of all of the gcloud commands to wipe out all of the resources in the project

func DebugCommands

func DebugCommands(t *testing.T, tf Terraform, resources Resources)

DebugCommands will spit out all of the executables that the framework calls under the covers for debugging purposes

func TestOperations

func TestOperations(t *testing.T, operations Operations, tf Terraform)

TestOperations Cycles through the operations and runs them.

func TestStack

func TestStack(t *testing.T, tf Terraform, resources Resources, ops OperationsSets, debug bool)

TestStack runs the test for an entire Deploystack test given the right inputs

func TextExistence

func TextExistence(t *testing.T, items []Resource)

TextExistence runs through and tests for the existence of each of the GCPResources

func TextNonExistence

func TextNonExistence(t *testing.T, items []Resource)

TextNonExistence runs through and tests for the lack of existence of each of the GCPResources

Types

type Operation

type Operation struct {
	Output   string
	Type     string
	Attempts int
	Interval int
	Query    string
	Custom   string
}

Operation represents an intersitial check to be run between terraform apply and terraform destroy

func (Operation) Do

func (o Operation) Do(tf Terraform) (bool, error)

Do performs the operation that the check is supposed to run

type Operations

type Operations struct {
	Items []Operation
	Label string
	Key   string
}

Operations are a set of operations to perform and certain times in the lifecycle of a test

func (*Operations) Add

func (os *Operations) Add(o Operation)

Add an operation to the list of operations

type OperationsSets

type OperationsSets map[string]Operations

OperationsSets are the whole collection of all of the pre and post operations

func NewOperationsSet

func NewOperationsSet() OperationsSets

NewOperationsSet returns the default set of operation sets

func (*OperationsSets) Add

func (os *OperationsSets) Add(target string, o Operation)

Add an operation to the underlying set of Operations.

type Resource

type Resource struct {
	Product   string            // Portion of the gcloud command between gcloud and describe
	Name      string            // The name of the resource to describe
	Field     string            // The field to use in format directive. Defaults to 'name'
	Append    string            // A string of content to be added to the end of the command string
	Project   string            // The GCP project to use for the gcloud command
	Expected  string            // The exepcted value that will be checking for. Defaults to vaule of Name
	Arguments map[string]string // A set of key value pairs that will be added to the end of the gcloud command
}

Resource represents a resource in Google Cloud that we want to check to see if it exists. In most cases a gcloud command will be built using this content

func (*Resource) Exists

func (g *Resource) Exists() (string, error)

Exists runs a gcloud describe call to ensure that the resource exists

type Resources

type Resources struct {
	Items   []Resource
	Project string
}

Resources is a list of resources

func (*Resources) Init

func (gs *Resources) Init()

Init runs through the items in the list and sets some prereqs

type Terraform

type Terraform struct {
	Dir  string            // directory containing .tf files
	Vars map[string]string // collection of vars passed into terraform call
}

Terraform is a resource for calling Terraform with a consistent set of variables.

func (Terraform) Apply

func (tf Terraform) Apply() (string, error)

Apply runs a terraform apply command passing in the variables to the command

func (Terraform) Destroy

func (tf Terraform) Destroy() (string, error)

Destroy runs a terraform destroy command

func (Terraform) DestroyForTest

func (tf Terraform) DestroyForTest(test *testing.T, debug bool)

DestroyForTest runs terraform destroy and can output extra information if debug is set to true

func (Terraform) Init

func (tf Terraform) Init() (string, error)

Init runs a terraform init command

func (Terraform) InitApplyForTest

func (tf Terraform) InitApplyForTest(test *testing.T, debug bool)

InitApplyForTest runs terraform init and apply and can output extra information if debug is set to true

func (Terraform) Output

func (tf Terraform) Output(variable string) (string, error)

Output extracts a terraform output variable from the terraform state

Jump to

Keyboard shortcuts

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