e2eutil

package
v0.0.0-...-b140147 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckVersionReached

func CheckVersionReached(t *testing.T, kubeClient kubernetes.Interface, version string, retries int, vs *api.VaultService, targetVaultPods ...string) error

CheckVersionReached checks if all the targetVaultPods are of the specified version

func CreateCluster

func CreateCluster(t *testing.T, crClient runtime.Client, vs *api.VaultService) (*api.VaultService, error)

CreateCluster creates a vault CR with the desired spec

func DeleteCluster

func DeleteCluster(t *testing.T, crClient runtime.Client, vs *api.VaultService) error

DeleteCluster deletes the vault CR specified by cluster spec

func EtcdWaitUntilSizeReached

func EtcdWaitUntilSizeReached(t *testing.T, dynClient runtime.Client, size, retries int, cl *eopapi.EtcdCluster) ([]string, error)

func InitializeVault

func InitializeVault(t *testing.T, dynClient runtime.Client, vault *api.VaultService, vClient *vaultapi.Client) (*api.VaultService, *vaultapi.InitResponse)

InitializeVault initializes the specified vault cluster and waits for all available nodes to appear as sealed. Requires established portforwarded connections to the vault pods Returns the updated vault cluster and the initialization response which includes the unseal key

func LogfWithTimestamp

func LogfWithTimestamp(t *testing.T, format string, args ...interface{})

LogfWithTimestamp is used for formatted test logs with the timestamp appended

func MapObjectToArbitraryData

func MapObjectToArbitraryData(obj interface{}) (map[string]interface{}, error)

MapSecretToArbitraryData converts the obj(custom data type) to the arbitrary data format (map[string]interface{}) that is used as the data in a vault secret. See https://github.com/hashicorp/vault/blob/master/api/secret.go#L19-L21

func NewCluster

func NewCluster(genName, namespace string, size int) *api.VaultService

NewCluster returns a minimal vault cluster CR

func PodLabelForOperator

func PodLabelForOperator(name string) map[string]string

PodLabelForOperator returns a label of the form name=<name>

func ResizeCluster

func ResizeCluster(t *testing.T, crClient runtime.Client, vs *api.VaultService, size int) (*api.VaultService, error)

ResizeCluster updates the Nodes field of the vault CR

func SetupUnsealedVaultCluster

func SetupUnsealedVaultCluster(t *testing.T, kubeClient kubernetes.Interface, dynClient runtime.Client, namespace string) (*api.VaultService, *vaultapi.TLSConfig, string)

SetupUnsealedVaultCluster initializes a vault cluster and unseals the 1st vault node.

func SetupVaultClient

func SetupVaultClient(t *testing.T, kubeClient kubernetes.Interface, namespace string, tlsConfig *vaultapi.TLSConfig, podName string) *vaultapi.Client

Portforwarding is necessary if outside the cluster. This version of e2eutil in the vault-operator repo contained a port-forwarding mechanism: https://github.com/coreos/vault-operator/tree/e5d03827065b1429c163e8a5ed69c32c8d9a3046/test/e2e/e2eutil SetupVaultClient creates a vault client for the specified pod

func UnsealVaultNode

func UnsealVaultNode(unsealKey string, vClient *vaultapi.Client) error

UnsealVaultNode unseals the specified vault pod by portforwarding to it via its vault client

func UpdateVersion

func UpdateVersion(t *testing.T, crClient runtime.Client, vs *api.VaultService, version string) (*api.VaultService, error)

UpdateVersion updates the Version field of the vault CR

func VaultTLSFromSecret

func VaultTLSFromSecret(vr *api.VaultService, dynClient runtime.Client) (*vaultapi.TLSConfig, error)

VaultTLSFromSecret reads Vault CR's TLS secret and converts it into a vault client's TLS config struct.

func VerifySecretData

func VerifySecretData(t *testing.T, vClient *vaultapi.Client, secretData map[string]interface{}, keyPath, podName string)

VerifySecretData gets secret of the "keyPath" and compares it against the given secretData.

func WaitActiveVaultsUp

func WaitActiveVaultsUp(t *testing.T, vaultsCRClient runtime.Client, retries int, vs *api.VaultService) (*api.VaultService, error)

WaitActiveVaultsUp retries until there is 1 active node in the CR status

func WaitAvailableVaultsUp

func WaitAvailableVaultsUp(t *testing.T, vaultsCRClient runtime.Client, size, retries int, vs *api.VaultService) (*api.VaultService, error)

WaitAvailableVaultsUp retries until the desired number of vault nodes are shown as available in the CR status

func WaitForCluster

func WaitForCluster(t *testing.T, kubeClient kubernetes.Interface, dynClient runtime.Client, vaultCR *api.VaultService) (*api.VaultService, *vaultapi.TLSConfig)

WaitForCluster waits for all available nodes of a cluster to appear in the vault CR status Returns the updated vault cluster and the TLS configuration to use for vault clients interacting with the cluster

func WaitPodsDeletedCompletely

func WaitPodsDeletedCompletely(kubecli kubernetes.Interface, namespace string, retries int, lo metav1.ListOptions) ([]*v1.Pod, error)

WaitPodsDeletedCompletely waits until the pods are completely removed(not just terminating) for the given label selector

func WaitPodsWithImageDeleted

func WaitPodsWithImageDeleted(kubecli kubernetes.Interface, namespace, image string, retries int, lo metav1.ListOptions) ([]*v1.Pod, error)

WaitPodsWithImageDeleted waits until the pods with the specified image and labels are removed

func WaitSealedVaultsUp

func WaitSealedVaultsUp(t *testing.T, vaultsCRClient runtime.Client, size, retries int, vs *api.VaultService) (*api.VaultService, error)

WaitSealedVaultsUp retries until the desired number of vault nodes are shown as sealed in the CR status

func WaitStandbyVaultsUp

func WaitStandbyVaultsUp(t *testing.T, vaultsCRClient runtime.Client, size, retries int, vs *api.VaultService) (*api.VaultService, error)

WaitStandbyVaultsUp retries until the desired number of vault nodes are shown as standby in the CR status

func WaitUntilActiveIsFrom

func WaitUntilActiveIsFrom(t *testing.T, vaultsCRClient runtime.Client, retries int, vs *api.VaultService, targetVaultPods ...string) (*api.VaultService, error)

WaitUntilActiveIsFrom waits until the active node is from one of the target pods

func WaitUntilAvailableAreFrom

func WaitUntilAvailableAreFrom(t *testing.T, vaultsCRClient runtime.Client, retries int, vs *api.VaultService, targetVaultPods ...string) (*api.VaultService, error)

WaitUntilAvailableAreFrom waits until all the available nodes are from the target pods

func WaitUntilOperatorReady

func WaitUntilOperatorReady(kubecli kubernetes.Interface, namespace, name string) error

WaitUntilOperatorReady will wait until the first pod with the label name=<name> is ready.

func WaitUntilStandbyAreFrom

func WaitUntilStandbyAreFrom(t *testing.T, vaultsCRClient runtime.Client, retries int, vs *api.VaultService, targetVaultPods ...string) (*api.VaultService, error)

WaitUntilStandbyAreFrom waits until all the standby nodes are from the target pods

func WaitUntilVaultConditionTrue

func WaitUntilVaultConditionTrue(t *testing.T, vaultsCRClient runtime.Client, retries int, vs *api.VaultService, checkCondition checkConditionFunc) (*api.VaultService, error)

WaitUntilVaultConditionTrue retries until the specified condition check becomes true for the vault CR

func WriteSecretData

func WriteSecretData(t *testing.T, vaultCR *api.VaultService, kubeClient kubernetes.Interface, tlsConfig *vaultapi.TLSConfig, rootToken, namespace string) (*vaultapi.Client, string, map[string]interface{}, string)

WriteSecretData writes secret data into vault.

Types

type SampleSecret

type SampleSecret struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

Jump to

Keyboard shortcuts

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