integtest

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	K8sClient client.Client

	TestForest *forest.Forest
)
View Source
var GVKs = map[string]schema.GroupVersionKind{
	"secrets":               {Group: "", Version: "v1", Kind: "Secret"},
	api.RoleResource:        {Group: api.RBACGroup, Version: "v1", Kind: api.RoleKind},
	api.RoleBindingResource: {Group: api.RBACGroup, Version: "v1", Kind: api.RoleBindingKind},
	"networkpolicies":       {Group: "networking.k8s.io", Version: "v1", Kind: "NetworkPolicy"},
	"resourcequotas":        {Group: "", Version: "v1", Kind: "ResourceQuota"},
	"limitranges":           {Group: "", Version: "v1", Kind: "LimitRange"},
	"configmaps":            {Group: "", Version: "v1", Kind: "ConfigMap"},

	"crontabs":            {Group: "stable.example.com", Version: "v1", Kind: "CronTab"},
	"subnamespaceanchors": {Group: "hnc.x-k8s.io", Version: "v1alpha2", Kind: "SubnamespaceAnchor"},
}

GVKs maps a resource to its corresponding GVK.

Functions

func AddNamespaceLabel

func AddNamespaceLabel(ctx context.Context, nm, k, v string)

func AddToHNCConfig

func AddToHNCConfig(ctx context.Context, group, resource string, mode api.SynchronizationMode)

func CanGetHierarchy

func CanGetHierarchy(ctx context.Context, nm string) func() bool

func CleanupObjects

func CleanupObjects(ctx context.Context)

CleanupObjects makes a best attempt to cleanup all objects created from MakeObject.

func CreateNS

func CreateNS(ctx context.Context, prefix string) string

CreateNS is a convenience function to create a namespace and wait for its singleton to be created. It's used in other tests in this package, but basically duplicates the code in this test (it didn't originally). TODO: refactor.

func CreateNSName

func CreateNSName(prefix string) string

CreateNSName generates random namespace names. Namespaces are never deleted in test-env because the building Namespace controller (which finalizes namespaces) doesn't run; I searched Github and found that everyone who was deleting namespaces was *also* very intentionally generating random names, so I guess this problem is widespread.

func CreateNSWithLabel

func CreateNSWithLabel(ctx context.Context, prefix string, label map[string]string) string

CreateNSWithLabel has similar function to CreateNS with label as additional parameter

func CreateNSWithLabelAnnotation

func CreateNSWithLabelAnnotation(ctx context.Context, prefix string, l map[string]string, a map[string]string) string

CreateNSWithLabelAnnotation has similar function to CreateNS with label and annotation as additional parameters.

func CreateNSes

func CreateNSes(ctx context.Context, num int) []string

Namespaces are named "a-<rand>", "b-<rand>", etc

func DeleteObject

func DeleteObject(ctx context.Context, resource string, nsName, name string)

DeleteObject deletes an object of the given kind in a specific namespace. The kind and its corresponding GVK should be included in the GVKs map.

func GetAnnotation added in v1.0.0

func GetAnnotation(ctx context.Context, from, key string) func() string

func GetHNCConfig

func GetHNCConfig(ctx context.Context) (*api.HNCConfiguration, error)

func GetHNCConfigWithName

func GetHNCConfigWithName(ctx context.Context, nm string) (*api.HNCConfiguration, error)

func GetHierarchy

func GetHierarchy(ctx context.Context, nm string) *api.HierarchyConfiguration

func GetLabel

func GetLabel(ctx context.Context, from, label string) func() string

func GetNamespace

func GetNamespace(ctx context.Context, nm string) *corev1.Namespace

func GetNamespaceWithOffset

func GetNamespaceWithOffset(offset int, ctx context.Context, nm string) *corev1.Namespace

func GetObject

func GetObject(ctx context.Context, resource string, nsName, name string) (*unstructured.Unstructured, error)

func HNCAfterSuite

func HNCAfterSuite()

func HNCBeforeSuite

func HNCBeforeSuite()

All tests in the reconcilers_test package are in one suite. As a result, they share the same test environment (e.g., same api server).

func HNCRun

func HNCRun(t *testing.T, title string)

func HasChild

func HasChild(ctx context.Context, nm, cnm string) func() bool

func HasCondition

func HasCondition(ctx context.Context, nm string, tp, reason string) func() bool

func HasObject

func HasObject(ctx context.Context, resource string, nsName, name string) func() bool

HasObject returns true if a namespace contains a specific object of the given kind.

The kind and its corresponding GVK should be included in the GVKs map.

func MakeObject

func MakeObject(ctx context.Context, resource string, nsName, name string)

MakeObject creates an empty object of the given kind in a specific namespace. The kind and its corresponding GVK should be included in the GVKs map.

func MakeObjectWithAnnotations added in v1.0.0

func MakeObjectWithAnnotations(ctx context.Context, resource string, nsName,
	name string, a map[string]string)

MakeObjectWithAnnotations creates an empty object with annotation given kind in a specific namespace. The kind and its corresponding GVK should be included in the GVKs map.

func MakeObjectWithLabels added in v1.0.0

func MakeObjectWithLabels(ctx context.Context, resource string, nsName,
	name string, l map[string]string)

MakeObjectWithLabels creates an empty object with label given kind in a specific namespace. The kind and its corresponding GVK should be included in the GVKs map.

func MakeSecrettWithType added in v1.1.0

func MakeSecrettWithType(ctx context.Context, nsName, name, scType string)

MakeSecrettWithType creates an empty Secret with type given kind in a specific namespace.

func NewHierarchy

func NewHierarchy(nm string) *api.HierarchyConfiguration

func NewOrGetHierarchy

func NewOrGetHierarchy(ctx context.Context, nm string) *api.HierarchyConfiguration

func ObjectInheritedFrom

func ObjectInheritedFrom(ctx context.Context, resource string, nsName, name string) string

ObjectInheritedFrom returns the name of the namespace where a specific object of a given kind is propagated from or an empty string if the object is not a propagated object. The kind and its corresponding GVK should be included in the GVKs map.

func RemoveNamespaceLabel

func RemoveNamespaceLabel(ctx context.Context, nm, k string)

func ReplaceStrings

func ReplaceStrings(str string, table map[string]string) string

ReplaceStrings returns a copy of str with all non-overlapping instances of the keys in table replaced by values in table

func ResetHNCConfigToDefault

func ResetHNCConfigToDefault(ctx context.Context)

func SetParent

func SetParent(ctx context.Context, nm, pnm string)

func TestCheckHRQDrift added in v1.1.0

func TestCheckHRQDrift() bool

func TryUpdateHierarchy

func TryUpdateHierarchy(ctx context.Context, h *api.HierarchyConfiguration) error

func UpdateHNCConfig

func UpdateHNCConfig(ctx context.Context, c *api.HNCConfiguration) error

func UpdateHierarchy

func UpdateHierarchy(ctx context.Context, h *api.HierarchyConfiguration)

func UpdateNamespace

func UpdateNamespace(ctx context.Context, ns *corev1.Namespace)

func UpdateObjectWithAnnotations added in v1.0.0

func UpdateObjectWithAnnotations(ctx context.Context, resource, nsName, name string, a map[string]string)

UpdateObjectWithAnnotations gets an object given it's kind, nsName and name, adds the annotation and updates this object

Types

This section is empty.

Jump to

Keyboard shortcuts

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