rigging

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

README

Rigging

Write end-to-end tests for Kubernetes leveraging lightly templated yaml files.

Setup

Rigging depends on ko to run and be configured in the context of the go test run.

After you have ko working and a target Kubernetes cluster with kubectl, testing should be as simple as running:

go test ./example/... -tags e2e -v

Or to just run TestFoo:

go test ./example/... -run Foo -tags e2e -v -count=1

Rigging Architecture

Note: Rigging assumes the cluster is ready for testing. You can use rigging to setup dependent resources, but this should be limited to resources that are namespaced.

Rigging will create a namespace to be used for the test. All dependent namespace scoped resources that the test depends on should be included in the rig. The namespace used in Rigging will be deleted after the test has finished. This allows Rigging to run many tests in parallel assuming the test author understands any global cluster concerns.

Phases of a Rigging Test

  1. Tests register their interest in an image by RegisterPackage in their init method.

  2. Test calls rigging.NewInstall and receives a rig instance to be used for further testing and cleanup.

    Internally, rigging will:

    1. Apply all given options to the test rig.
    2. Create a new generated namespace.
    3. Produce images (using ko).
    4. Apply config to the given set of yaml config files.
    5. Apply template processed config files to the kubernetes cluster.
  3. Test performs the test implementation.

  4. Test collects results and determine PASS/FAIL.

  5. Test calls rig.Uninstall() to delete all resources and the test namespace.

    Internally, rigging will:

    1. Delete all resources created by the rig.
    2. Delete the generated namespace, if created by the rig.

Documentation

Index

Constants

View Source
const (
	DefaultConfigDirTemplate = "%s/config/%s"
)

Variables

View Source
var RegisterPackage = installer.RegisterPackage

RegisterPackage registers an interest in producing an image based on the provide package.

Functions

This section is empty.

Types

type Option

type Option func(Rigging) error

func WithConfigDirTemplate

func WithConfigDirTemplate(dir string) Option

WithConfigDirTemplate lets you change the configuration directory template. This value will be used to produce the fill file path of manifest files. And used like sprintf(dir, rootDir, name). By default:

  • dir this value will be "%s/config/%s".
  • rootDir is the directory of the caller to New.
  • name is provided in a list for install

func WithImages

func WithImages(images map[string]string) Option

func WithRootDir

func WithRootDir(dir string) Option

type Rigging

type Rigging interface {
	Install(dirs []string, config map[string]string) error
	Uninstall() error
	Objects() []v1.ObjectReference
	WaitForReadyOrDone(ref v1.ObjectReference, timeout time.Duration) (string, error)
	LogsFor(ref v1.ObjectReference) (string, error)
	Namespace() string

	ResourceOriginal(ref v1.ObjectReference) (*unstructured.Unstructured, error)
	ResourceNow(ref v1.ObjectReference) (*unstructured.Unstructured, error)
}

func New

func New(opts ...Option) (Rigging, error)

func NewInstall

func NewInstall(opts []Option, dirs []string, config map[string]string) (Rigging, error)

Directories

Path Synopsis
cmd
example
pkg

Jump to

Keyboard shortcuts

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