kgetset

package module
v0.0.0-...-3b5592d Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

README

kgetset

kgetset is a verification tool to test CustomResourceDefinition(s) and CustomResource(s)

Testsuite

  • Bring up a microk8s cluster
  • Run microk8s.kubectl apply -f suite.yaml
    • This job verifies below test cases:

Test Case 1

  • This is implemented in hello package
- Setup:
  - Apply a CRD into K8s
  - Fetch this CRD from K8s
  - Verify if both instances match
- Teardown:
  - Delete the CRD from K8s

Test Case 2 [WIP]

- Setup:
  - Apply a CRD into K8s
- When:
  - Create a CR of above CRD at K8s
  - Create a second CR of above CRD but using a new schema
- Then:
  - Fetch first CR from K8s & match with local instance
  - Fetch second CR from k8s & match with local instance
- Teardown:
  - Delete the CRD from K8s
- PostTeardown:
  - Verify if all the CRs get deleted

Documentation

Overview

This entire piece of code is lifted from MetaController

refer - https://github.com/GoogleCloudPlatform/metacontroller

Index

Constants

View Source
const (
	StepSetup = iota + 1
	StepPostSetup

	StepGiven
	StepWhen
	StepThen

	StepTeardown
	StepPostTeardown
)

Variables

This section is empty.

Functions

func GetLastApplied

func GetLastApplied(obj *unstructured.Unstructured) (map[string]interface{}, error)

GetLastApplied returns the last applied state from the provided object

func Merge

func Merge(observed, lastApplied, desired map[string]interface{}) (map[string]interface{}, error)

Merge updates the given observed object to apply the desired changes. It returns an updated copy of the observed object if no error occurs.

  last
applied
   |
  \|/

desired --->(state)<--- observed

func SetLastApplied

func SetLastApplied(obj *unstructured.Unstructured, lastApplied map[string]interface{}) error

SetLastApplied sets the last applied state against the provided object

Types

type BDD

type BDD interface {
	Given() error
	When() error
	Then() error
}

type DynClient

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

func NewDynClient

func NewDynClient() (*DynClient, error)

func NewDynClientOrDie

func NewDynClientOrDie() *DynClient

func (*DynClient) GetResourceInterface

func (uc *DynClient) GetResourceInterface(
	gvk schema.GroupVersionKind,
	ns ...string,
) (dynamic.ResourceInterface, error)

type TestAbstract

type TestAbstract struct {
	WaitPostSteps []int
	WaitTime      time.Duration

	Steps []func() error

	Setupfn     func() error
	PostSetupfn func() error

	Teardownfn     func() error
	PostTeardownfn func() error

	Givenfn func() error
	Whenfn  func() error
	Thenfn  func() error
	// contains filtered or unexported fields
}

TestAbstract as the name suggests abstracts some of the common features required by instances implementing bdd or testsuite interface

func (*TestAbstract) Given

func (t *TestAbstract) Given() error

func (*TestAbstract) PostSetup

func (t *TestAbstract) PostSetup() error

func (*TestAbstract) PostTeardown

func (t *TestAbstract) PostTeardown() error

func (*TestAbstract) Setup

func (t *TestAbstract) Setup() error

func (*TestAbstract) Teardown

func (t *TestAbstract) Teardown() error

func (*TestAbstract) Test

func (t *TestAbstract) Test() error

func (*TestAbstract) Then

func (t *TestAbstract) Then() error

func (*TestAbstract) When

func (t *TestAbstract) When() error

type TestFns

type TestFns []func() error

func (TestFns) Run

func (f TestFns) Run() error

type Testsuite

type Testsuite interface {
	Test() error
}

Directories

Path Synopsis
util

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳