integration_tests

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

README

How to run the tests

The following environment variables are needed:

Name Description Default
KUBECONFIG File for a cluster to use for tests. Tests can create and delete namespaces. $HOME/.kube/config
OPERATOR_IMAGE Docker image of the operator to test armory/spinnaker-operator:dev
HALYARD_IMAGE Docker image of Halyard to use for tests armory/halyard:operator-0.3.x
S3_BUCKET S3 bucket name used for spinnaker persistence. Worker nodes should have access to it. operator-int-tests
S3_BUCKET_REGION Region used by the S3 bucket. us-west-2

Run tests with make integration_test.

Tests create dynamic namespaces, they are not deleted after finishing tests. There are two reasons for this:

  1. Deleting a namespace can take a lot of time, and usually this can be done as part of regular maintenance tasks outside of test execution.
  2. If a test fails, it's useful to have the namespaces available to be able to inspect the state of the operator and spinnaker, like detailed log files.

Documentation

Index

Constants

View Source
const (
	KubeconfigVar                        = "KUBECONFIG"
	OperatorImageVar                     = "OPERATOR_IMAGE"
	HalyardImageVar                      = "HALYARD_IMAGE"
	BucketVar                            = "S3_BUCKET"
	BucketRegionVar                      = "AWS_DEFAULT_REGION"
	BucketAccessKeyIdVar                 = "AWS_ACCESS_KEY_ID"
	BucketSecretAccessKeyVar             = "AWS_SECRET_ACCESS_KEY"
	MaxChecksWaitingForAccountsAvailable = 20 // 20 * 2s = 40 seconds
)
View Source
const (
	SpinServiceName                        = "spinnaker"
	MaxErrorsWaitingForStability           = 3
	MaxChecksWaitingForDeploymentStability = 90  // (90 * 2s) = 3 minutes (large images may need to be downloaded + startup time)
	MaxChecksWaitingForSpinnakerStability  = 450 // (300 * 2s) / 60 = 15 minutes
	MaxChecksWaitingForLBStability         = 450 // (300 * 2s) / 60 = 15 minutes
)

Variables

View Source
var SpinBaseSvcs []string

Functions

func ApplyKustomize

func ApplyKustomize(ns, path string, e *TestEnv, t *testing.T) (string, error)

func ApplyKustomizeAndAssert

func ApplyKustomizeAndAssert(ns, path string, e *TestEnv, t *testing.T) bool

func ApplyManifest

func ApplyManifest(ns, path string, e *TestEnv, t *testing.T)

func AssertSpinnakerHealthy

func AssertSpinnakerHealthy(ns, spinName string, e *TestEnv, t *testing.T)

func CopyFileToS3Bucket

func CopyFileToS3Bucket(f, dest string, e *TestEnv, t *testing.T) bool

func CreateNamespace

func CreateNamespace(name string, e *TestEnv, t *testing.T) bool

func DeleteNamespace

func DeleteNamespace(name string, e *TestEnv, t *testing.T)

func DeploySpinnaker

func DeploySpinnaker(ns, kustPath string, e *TestEnv, t *testing.T) (deckUrl string, gateUrl string)

DeploySpinnaker returns spinnaker Deck and Gate public urls

func ExecuteGetRequest

func ExecuteGetRequest(reqUrl string, t *testing.T) string

ExecuteGetRequest Since the integration tests are interacting with the spinnaker URL and the URL is generated within the docker network. We need to emulate a curl call inside of the docker network, so we are using a docker image instead of the CURL command itself for it.

func ExponentialBackOff added in v1.1.2

func ExponentialBackOff(operation backoff.Operation, minutes time.Duration) error

func GetLocalHost added in v1.3.0

func GetLocalHost(t *testing.T) string

func GetPodName

func GetPodName(ns, svc string, e *TestEnv, t *testing.T) string

func LogMainStep

func LogMainStep(t *testing.T, msg string, args ...interface{})

func PrintOperatorLogs

func PrintOperatorLogs(e *TestEnv, t *testing.T)

func RandomString

func RandomString(prefix string) string

func RunCommand

func RunCommand(c string, t *testing.T) (string, error)

func RunCommandAndAssert

func RunCommandAndAssert(c string, t *testing.T) string

func RunCommandInContainerAndAssert

func RunCommandInContainerAndAssert(ns, svc, cmd string, e *TestEnv, t *testing.T) string

func RunCommandInOperatorAndAssert

func RunCommandInOperatorAndAssert(c string, e *TestEnv, t *testing.T) bool

func RunCommandSilent

func RunCommandSilent(c string, t *testing.T) (string, error)

func RunCommandSilentAndAssert

func RunCommandSilentAndAssert(c string, t *testing.T) string

func SubstituteOverlayVars

func SubstituteOverlayVars(overlayHome string, vars interface{}, t *testing.T) bool

func UpdateControlPlaneHost added in v1.3.0

func UpdateControlPlaneHost(path string, t *testing.T)

func WaitForDeploymentToStabilize

func WaitForDeploymentToStabilize(ns, name string, e *TestEnv, t *testing.T) bool

func WaitForLBReady

func WaitForLBReady(ns, statusPath string, e *TestEnv, t *testing.T) string

func WaitForSpinnakerToStabilize

func WaitForSpinnakerToStabilize(ns string, e *TestEnv, t *testing.T)

Types

type Account

type Account struct {
	Name  string   `json:"name,omitempty"`
	Type  string   `json:"type,omitempty"`
	Types []string `json:"types,omitempty"`
}

type Defaults

type Defaults struct {
	HalyardImageDefault            string
	BucketDefault                  string
	BucketRegionDefault            string
	BucketAccessKeyIdDefault       string
	BucketSecretAccessKeyIdDefault string
	OperatorKustomizeBase          string
	CRDManifests                   string
	OperatorImageDefault           string
}

type Operator

type Operator struct {
	KustomizationPath string
	Namespace         string
	PodName           string
}

Operator holds information about the operator installation

type TestEnv

type TestEnv struct {
	Operator    Operator
	SpinDeckUrl string
	SpinGateUrl string
	Vars        Vars
}

TestEnv holds information about the kubernetes cluster used for tests

func CommonSetup

func CommonSetup(d Defaults, t *testing.T) *TestEnv

CommonSetup creates a new environment context, initializing common settings for all tests

func InstallCrdsAndOperator

func InstallCrdsAndOperator(spinNs string, isClusterMode bool, d Defaults, t *testing.T) (e *TestEnv)

func (*TestEnv) Cleanup

func (e *TestEnv) Cleanup(t *testing.T)

func (*TestEnv) DeleteOperator

func (e *TestEnv) DeleteOperator(t *testing.T)

func (*TestEnv) GenerateSpinFiles

func (e *TestEnv) GenerateSpinFiles(kustPath, name, filePath string, t *testing.T) bool

func (*TestEnv) InstallCrds

func (e *TestEnv) InstallCrds(d Defaults, t *testing.T) bool

func (*TestEnv) InstallOperator

func (e *TestEnv) InstallOperator(isCluster bool, t *testing.T) Operator

func (*TestEnv) InstallSpinnaker

func (e *TestEnv) InstallSpinnaker(ns, kustPath string, t *testing.T) bool

func (*TestEnv) KubectlPrefix

func (e *TestEnv) KubectlPrefix() string

func (*TestEnv) VerifyAccountsExist

func (e *TestEnv) VerifyAccountsExist(endpoint string, t *testing.T, accts ...Account) bool

type Vars

type Vars struct {
	Kubeconfig        string
	OperatorImage     string
	HalyardImage      string
	S3Bucket          string
	S3BucketRegion    string
	S3AccessKeyId     string
	S3SecretAccessKey string
	SpinNamespace     string
}

Vars are variables used in kustomize templates

Jump to

Keyboard shortcuts

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