utils

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendBytesToFile added in v1.2.2

func AppendBytesToFile(filePath string, bytes []byte) error

AppendBytesToFile appends to a file if it already exists or creates it if it does not. AppendBytesToFile returns an error instead of failing if the write doesn't work in case the caller wants to proceed anyway.

func ArchiveServiceLogs added in v1.2.1

func ArchiveServiceLogs(cs clientset.Interface, reportPath string) error

ArchiveServiceLogs collects the logs on the node and controller service pods and writes them in the specified report path. Logs will be collected from beegfs and csi-provisioner containers. This should typically be called after the test suite completes. It may also make sense to call it if a test will intentionally redeploy pods (as this action results in a reset of container logs). ArchiveServiceLogs returns the first error it generates instead of failing in case the caller wants to proceed anyway.

func GetBeegfsDriverInUse added in v1.2.2

func GetBeegfsDriverInUse(dc dynamic.Interface) *beegfsv1.BeegfsDriver

GetBeegfsDriverInUse returns a pointer to a BeegfsDriver if one and only one exists on the cluster. Consuming tests fail if:

  • The cluster knows about the BeegfsDriver resource but has non.
  • The cluster has more than one BeegfsDriver.
  • The attempt to list BeegfsDrivers fails for an unknown reason.

GetBeegfsDriverInUse returns nil if the cluster doesn't know about BeegfsDriver resources.

func GetConfigMapInUse added in v1.2.2

func GetConfigMapInUse(cs clientset.Interface) corev1.ConfigMap

GetConfigMapInUse returns the ConfigMap being used to configure the BeeGFS CSI driver. Consuming tests fail if:

  • The BeeGFS CSI driver controller service isn't using a ConfigMap (this is virtually impossible).
  • The ConfigMap can't be retrieved.

func GetPluginConfigInUse added in v1.2.2

GetPluginConfigInUse returns a PluginConfigFromFile from the BeegfsDriver if a cluster is operator-enabled or the ConfigMap otherwise. Consuming tests fail if this isn't possible.

func GetRunningControllerPod added in v1.2.2

func GetRunningControllerPod(cs clientset.Interface) (corev1.Pod, error)

GetRunningControllerPod waits PodStartTimeout for exactly one controller service Pod to be running (in any namespace) and returns it or an error.

func GetRunningControllerPodOrFail added in v1.2.2

func GetRunningControllerPodOrFail(cs clientset.Interface) corev1.Pod

GetRunningControllerPodOrFail waits PodStartTimeout for exactly one controller service Pod to be running (in any namespace) and returns it or fails.

func GetRunningNodePods added in v1.2.2

func GetRunningNodePods(cs clientset.Interface) ([]corev1.Pod, error)

GetRunningNodePods waits PodStartTimeout for at least one node service Pod to be running (in any namespace) and returns all node service pods it finds or an error.

func GetRunningNodePodsOrFail added in v1.2.2

func GetRunningNodePodsOrFail(cs clientset.Interface) []corev1.Pod

GetRunningNodePodsOrFail waits PodStartTimeout for at least one node service Pod to be running (in any namespace) and returns all node service pods it finds or an error.

func UpdatePluginConfigInUse added in v1.2.2

func UpdatePluginConfigInUse(cs clientset.Interface, dc dynamic.Interface, config beegfsv1.PluginConfigFromFile)

UpdatePluginConfigInUse updates the BeegfsDriver (if it exists) or the ConfigMap with a new PluginConfigFromFile. Consuming tests fail if this does not work.

func VerifyDirectoryModeUidGidInPod

func VerifyDirectoryModeUidGidInPod(f *e2eframework.Framework, directory, expectedMode, expectedUID, expectedGID string, pod *corev1.Pod)

VerifyDirectoryModeUidGidInPod verifies expected mode, UID, and GID of the target directory This implementation is similar to [`VerifyFilePathGidInPod`](https://github.com/kubernetes/kubernetes/blob/v1.21.0/test/e2e/storage/utils/utils.go#L709).

func VerifyNoOrphanedMounts added in v1.2.1

func VerifyNoOrphanedMounts(cs clientset.Interface)

VerifyNoOrphanedMounts uses SSH to access all cluster nodes and verify that none of them have a BeeGFS file system mounted as a PersistentVolume. VerifyNoOrphanedMounts could be used within a single test case, but mounts are orphaned intermittently and it would be unlikely to catch an orphan mount without including an extremely long stress test within the case. It is currently preferred to use VerifyNoOrphanedMounts before and after an entire suite of tests runs to ensure none of the tests within the suite causes a mount to be orphaned.

Types

type FSExec

type FSExec struct {
	Resource *storageframework.VolumeResource // Export for easy inspection.
	// contains filtered or unexported fields
}

FSExec makes it easy to execute commands on a node that has a BeeGFS file system mounted. FSExec handles creating a volume resource, creating a pod to mount it, and tracking the node that has it mounted. This frees the caller to worry only about what command to execute.

func NewFSExec

func NewFSExec(cfg *storageframework.PerTestConfig, driver *driver.BeegfsDriver, sizeRange e2evolume.SizeRange) FSExec

NewFSExec initializes an FSExec.

func (*FSExec) Cleanup

func (e *FSExec) Cleanup() error

Cleanup removes the resources used by FSExec from the cluster.

func (*FSExec) IssueCommandWithBeegfsPaths

func (e *FSExec) IssueCommandWithBeegfsPaths(cmdFmtString string, beegfsPaths ...string) (string, error)

IssueCommandWithBeegfsPaths takes a format string (like the ones passed to fmt.Printf, fmt.Sprintf, etc.) and any number of BeeGFS relative paths. It converts the relative paths to absolute paths on the host that will execute a command.

func (*FSExec) IssueCommandWithResult

func (e *FSExec) IssueCommandWithResult(cmd string) (string, error)

IssueCommandWithResult works exactly like hostExec.IssueCommandWithResult, except that it identifies the correct node (the one with our BeeGFS file system mounted) on which to execute the passed command automatically.

Jump to

Keyboard shortcuts

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