integration

package
v0.0.0-...-9451de5 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: BSD-3-Clause Imports: 17 Imported by: 0

README

Integration tests

Package integration provides a set of integration tests for tsuru. The testing behavior can be configured by a set of environment variables.

These tests might be ran on an existing tsuru installation (by providing the correct amount of environment variables) or it can test a new installation (locally or in a cloud) by leveraging tsuru installer.

Basics

The integration testing consists of a sequence of steps defined as the type:

ExecFlow{}

These steps are registered in the global flows variable. Each step has a provides field which registers what resources this step provides, and will only run if this resource is not provided by an environment variable TSURU_INTEGRATION_<provides>. They also might require specific resources by setting the requires field.

Running locally

$ make test-int

Examples

Environment Variables

The following variables may be set to customize the integration testing, these are all prefixed with TSURU_INTEGRATION_.

General
  • enabled - enables integration testing
  • maxconcurrency - test concurrency
  • verbose - test verbosity
  • examplesdir - path to the platforms examples
  • nodeopts - Additional options passed to node creation.
  • installername - Name of the installation to be created.
  • provisioners - List of provisioners to test. Defaults to docker.
  • clusters - List of cluster providers. Defaults to swarm. Available values are gke, swarm and minikube.
  • platforms - List of platforms to test. Defaults to all platforms available on https://github.com/tsuru/platforms
Flow control
  • platformimages
  • installerconfig
  • installercompose
  • targetaddr
  • team
  • poolnames
  • installedplatforms
  • serviceimage
  • servicename
Cluster configuration
gke
  • GCE_ZONE - the GCE zone where you want the Tsuru instance to be created
  • GCE_PROJECT_ID - ID for a project created in GCE
  • GCE_MACHINE_TYPE - Machine type to be used for the kubernetes cluster master

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ResultMatches = &baseMatcher{
	name:   "ResultMatches",
	params: []string{"result", "expected"},
	check: func(result *Result, params []interface{}) (bool, string) {
		expected, ok := params[1].(Expected)
		if !ok {
			return false, fmt.Sprintf("second param must be a Expected, got %T", params[0])
		}
		err := result.Compare(expected)
		if err != nil {
			return false, fmt.Sprintf("%v\n%v", err.Error(), result)
		}
		return true, ""
	},
}
View Source
var ResultOk = &baseMatcher{
	name:   "ResultOK",
	params: []string{"result"},
	check: func(result *Result, params []interface{}) (bool, string) {
		if result.Error != nil || result.ExitCode != 0 {
			return false, fmt.Sprintf("result error: %v", result)
		}
		if result.Timeout {
			return false, fmt.Sprintf("result timeout after %v: %v", result.Command.Timeout, result)
		}
		return true, ""
	},
}

Functions

This section is empty.

Types

type ClusterManager

type ClusterManager interface {
	Name() string
	Provisioner() string
	Start() *Result
	Delete() *Result
	UpdateParams() (params []string, createNode bool)
}

ClusterManager is an abstraction to a Tsuru cluster

type CmdWithExp

type CmdWithExp struct {
	C *Command
	E []Expected
}

type Command

type Command struct {
	Command  string
	Args     []string
	Input    string
	Timeout  time.Duration
	NoExpand bool
}

func NewCommand

func NewCommand(cmd string, args ...string) *Command

func (*Command) Run

func (c *Command) Run(e *Environment) *Result

func (*Command) WithArgs

func (c *Command) WithArgs(args ...string) *Command

func (*Command) WithInput

func (c *Command) WithInput(input string) *Command

func (*Command) WithNoExpand

func (c *Command) WithNoExpand() *Command

func (*Command) WithTimeout

func (c *Command) WithTimeout(timeout time.Duration) *Command

type Environment

type Environment struct {
	// contains filtered or unexported fields
}

func NewEnvironment

func NewEnvironment() *Environment

func (*Environment) Add

func (e *Environment) Add(k string, v string)

func (*Environment) All

func (e *Environment) All(k string) []string

func (*Environment) Clone

func (e *Environment) Clone() *Environment

func (*Environment) Get

func (e *Environment) Get(k string) string

func (*Environment) Has

func (e *Environment) Has(k string) bool

func (*Environment) IsDry

func (e *Environment) IsDry() bool

func (*Environment) Set

func (e *Environment) Set(k string, v ...string)

func (*Environment) SetLocal

func (e *Environment) SetLocal(k string, v ...string)

func (*Environment) String

func (e *Environment) String() string

func (*Environment) VerboseLevel

func (e *Environment) VerboseLevel() int

type ExecFlow

type ExecFlow struct {
	// contains filtered or unexported fields
}

func (*ExecFlow) Rollback

func (f *ExecFlow) Rollback(c *check.C, env *Environment)

func (*ExecFlow) Run

func (f *ExecFlow) Run(c *check.C, env *Environment)

type Expected

type Expected struct {
	ExitCode int
	Timeout  bool
	Err      string
	Stderr   string
	Stdout   string
}

type KubectlClusterManager

type KubectlClusterManager struct {
	// contains filtered or unexported fields
}

KubectlClusterManager represents a kubectl context

func (*KubectlClusterManager) Delete

func (m *KubectlClusterManager) Delete() *Result

func (*KubectlClusterManager) Name

func (m *KubectlClusterManager) Name() string

func (*KubectlClusterManager) Provisioner

func (m *KubectlClusterManager) Provisioner() string

func (*KubectlClusterManager) Start

func (m *KubectlClusterManager) Start() *Result

func (*KubectlClusterManager) UpdateParams

func (m *KubectlClusterManager) UpdateParams() ([]string, bool)

type MinikubeClusterManager

type MinikubeClusterManager struct {
	// contains filtered or unexported fields
}

MinikubeClusterManager represents a minikube local instance

func (*MinikubeClusterManager) Delete

func (m *MinikubeClusterManager) Delete() *Result

func (*MinikubeClusterManager) IP

func (*MinikubeClusterManager) Name

func (m *MinikubeClusterManager) Name() string

func (*MinikubeClusterManager) Provisioner

func (m *MinikubeClusterManager) Provisioner() string

func (*MinikubeClusterManager) Start

func (m *MinikubeClusterManager) Start() *Result

func (*MinikubeClusterManager) UpdateParams

func (m *MinikubeClusterManager) UpdateParams() ([]string, bool)

type Result

type Result struct {
	Cmd      *exec.Cmd
	Command  *Command
	ExitCode int
	Error    error
	Timeout  bool
	Stdout   safe.Buffer
	Stderr   safe.Buffer
	Env      *Environment
}

func (*Result) Compare

func (r *Result) Compare(expected Expected) error

func (*Result) SetError

func (r *Result) SetError(err error)

func (*Result) String

func (r *Result) String() string

type SwarmClusterManager

type SwarmClusterManager struct {
	// contains filtered or unexported fields
}

func (*SwarmClusterManager) Delete

func (m *SwarmClusterManager) Delete() *Result

func (*SwarmClusterManager) Name

func (m *SwarmClusterManager) Name() string

func (*SwarmClusterManager) Provisioner

func (m *SwarmClusterManager) Provisioner() string

func (*SwarmClusterManager) RequiredNodes

func (m *SwarmClusterManager) RequiredNodes() int

func (*SwarmClusterManager) Start

func (m *SwarmClusterManager) Start() *Result

func (*SwarmClusterManager) UpdateParams

func (m *SwarmClusterManager) UpdateParams() ([]string, bool)

Directories

Path Synopsis
testapps
https-healthcheck
Generate a self-signed X.509 certificate for a TLS server.
Generate a self-signed X.509 certificate for a TLS server.

Jump to

Keyboard shortcuts

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