vsphere

package
v1.19.0-rc.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	SPBMPolicyName             = "VSPHERE_SPBM_POLICY_NAME"
	StorageClassDatastoreName  = "VSPHERE_DATASTORE"
	SecondSharedDatastore      = "VSPHERE_SECOND_SHARED_DATASTORE"
	KubernetesClusterName      = "VSPHERE_KUBERNETES_CLUSTER"
	SPBMTagPolicy              = "VSPHERE_SPBM_TAG_POLICY"
	VCPClusterDatastore        = "CLUSTER_DATASTORE"
	SPBMPolicyDataStoreCluster = "VSPHERE_SPBM_POLICY_DS_CLUSTER"
)

environment variables related to datastore parameters

View Source
const (
	VCPScaleVolumeCount   = "VCP_SCALE_VOLUME_COUNT"
	VCPScaleVolumesPerPod = "VCP_SCALE_VOLUME_PER_POD"
	VCPScaleInstances     = "VCP_SCALE_INSTANCES"
)

environment variables used for scaling tests

View Source
const (
	VCPStressInstances  = "VCP_STRESS_INSTANCES"
	VCPStressIterations = "VCP_STRESS_ITERATIONS"
)

environment variables used for stress tests

View Source
const (
	VCPPerfVolumeCount   = "VCP_PERF_VOLUME_COUNT"
	VCPPerfVolumesPerPod = "VCP_PERF_VOLUME_PER_POD"
	VCPPerfIterations    = "VCP_PERF_ITERATIONS"
)

environment variables used for performance tests

View Source
const (
	VCPZoneVsanDatastore1      = "VCP_ZONE_VSANDATASTORE1"
	VCPZoneVsanDatastore2      = "VCP_ZONE_VSANDATASTORE2"
	VCPZoneLocalDatastore      = "VCP_ZONE_LOCALDATASTORE"
	VCPZoneCompatPolicyName    = "VCP_ZONE_COMPATPOLICY_NAME"
	VCPZoneNonCompatPolicyName = "VCP_ZONE_NONCOMPATPOLICY_NAME"
	VCPZoneA                   = "VCP_ZONE_A"
	VCPZoneB                   = "VCP_ZONE_B"
	VCPZoneC                   = "VCP_ZONE_C"
	VCPZoneD                   = "VCP_ZONE_D"
	VCPInvalidZone             = "VCP_INVALID_ZONE"
)

environment variables used for zone tests

View Source
const (
	Datastore                    = "datastore"
	PolicyDiskStripes            = "diskStripes"
	PolicyHostFailuresToTolerate = "hostFailuresToTolerate"
	PolicyCacheReservation       = "cacheReservation"
	PolicyObjectSpaceReservation = "objectSpaceReservation"
	PolicyIopsLimit              = "iopsLimit"
	DiskFormat                   = "diskformat"
	SpbmStoragePolicy            = "storagepolicyname"
)

storage class parameters

View Source
const (
	ThinDisk                                   = "thin"
	BronzeStoragePolicy                        = "bronze"
	HostFailuresToTolerateCapabilityVal        = "0"
	CacheReservationCapabilityVal              = "20"
	DiskStripesCapabilityVal                   = "1"
	ObjectSpaceReservationCapabilityVal        = "30"
	IopsLimitCapabilityVal                     = "100"
	StripeWidthCapabilityVal                   = "2"
	DiskStripesCapabilityInvalidVal            = "14"
	HostFailuresToTolerateCapabilityInvalidVal = "4"
)

test values for storage class parameters

View Source
const (
	SCSIUnitsAvailablePerNode = 55
	CreateOp                  = "CreateOp"
	AttachOp                  = "AttachOp"
	DetachOp                  = "DetachOp"
	DeleteOp                  = "DeleteOp"
)
This test calculates latency numbers for volume lifecycle operations

1. Create 4 type of storage classes 2. Read the total number of volumes to be created and volumes per pod 3. Create total PVCs (number of volumes) 4. Create Pods with attached volumes per pod 5. Verify access to the volumes 6. Delete pods and wait for volumes to detach 7. Delete the PVCs

View Source
const (
	NodeLabelKey = "vsphere_e2e_label"
)

Perform vsphere volume life cycle management at scale based on user configurable value for number of volumes. The following actions will be performed as part of this test.

1. Create Storage Classes of 4 Categories (Default, SC with Non Default Datastore, SC with SPBM Policy, SC with VSAN Storage Capabilities.) 2. Read VCP_SCALE_VOLUME_COUNT, VCP_SCALE_INSTANCES, VCP_SCALE_VOLUMES_PER_POD, VSPHERE_SPBM_POLICY_NAME, VSPHERE_DATASTORE from System Environment. 3. Launch VCP_SCALE_INSTANCES goroutine for creating VCP_SCALE_VOLUME_COUNT volumes. Each goroutine is responsible for create/attach of VCP_SCALE_VOLUME_COUNT/VCP_SCALE_INSTANCES volumes. 4. Read VCP_SCALE_VOLUMES_PER_POD from System Environment. Each pod will be have VCP_SCALE_VOLUMES_PER_POD attached to it. 5. Once all the go routines are completed, we delete all the pods and volumes.

View Source
const VSphereCSIMigrationEnabled = "VSPHERE_CSI_MIGRATION_ENABLED"

VSphereCSIMigrationEnabled is the environment variables to help determine test verification flow.

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap(fw *framework.Framework)

Bootstrap takes care of initializing necessary test context for vSphere tests

func Connect

func Connect(ctx context.Context, vs *VSphere) error

Connect makes connection to vSphere No actions are taken if a connection exists and alive. Otherwise, a new client will be created.

func GetAndExpectBoolEnvVar added in v1.19.0

func GetAndExpectBoolEnvVar(varName string) bool

GetAndExpectBoolEnvVar returns the bool value of an environment variable if environment variable is not set return false

func GetAndExpectIntEnvVar

func GetAndExpectIntEnvVar(varName string) int

GetAndExpectIntEnvVar returns the integer value of an environment variable or fails if the variable is not set

func GetAndExpectStringEnvVar

func GetAndExpectStringEnvVar(varName string) string

GetAndExpectStringEnvVar returns the string value of an environment variable or fails if the variable is not set

func GetVSphereInstances

func GetVSphereInstances() (map[string]*VSphere, error)

GetVSphereInstances parses vsphere.conf and returns VSphere instances

func NewClient

func NewClient(ctx context.Context, vs *VSphere) (*govmomi.Client, error)

NewClient creates a new client for vSphere connection

func PerformVolumeLifeCycleInParallel

func PerformVolumeLifeCycleInParallel(f *framework.Framework, client clientset.Interface, namespace string, instanceID string, sc *storagev1.StorageClass, iterations int, wg *sync.WaitGroup)

PerformVolumeLifeCycleInParallel performs volume lifecycle operations Called as a go routine to perform operations in parallel

func VolumeCreateAndAttach

func VolumeCreateAndAttach(client clientset.Interface, namespace string, sc []*storagev1.StorageClass, volumeCountPerInstance int, volumesPerPod int, nodeSelectorList []*NodeSelector, nodeVolumeMapChan chan map[string][]string)

VolumeCreateAndAttach peforms create and attach operations of vSphere persistent volumes at scale

Types

type Config

type Config struct {
	Username          string
	Password          string
	Hostname          string
	Port              string
	Datacenters       string
	RoundTripperCount uint
	DefaultDatastore  string
	Folder            string
}

Config represents vSphere configuration

type ConfigFile

type ConfigFile struct {
	Global struct {
		// vCenter username.
		User string `gcfg:"user"`
		// vCenter password in clear text.
		Password string `gcfg:"password"`
		// vCenter port.
		VCenterPort string `gcfg:"port"`
		// True if vCenter uses self-signed cert.
		InsecureFlag bool `gcfg:"insecure-flag"`
		// Datacenter in which VMs are located.
		Datacenters string `gcfg:"datacenters"`
		// Soap round tripper count (retries = RoundTripper - 1)
		RoundTripperCount uint `gcfg:"soap-roundtrip-count"`
	}

	VirtualCenter map[string]*Config

	Network struct {
		// PublicNetwork is name of the network the VMs are joined to.
		PublicNetwork string `gcfg:"public-network"`
	}

	Disk struct {
		// SCSIControllerType defines SCSI controller to be used.
		SCSIControllerType string `dcfg:"scsicontrollertype"`
	}

	// Endpoint used to create volumes
	Workspace struct {
		VCenterIP        string `gcfg:"server"`
		Datacenter       string `gcfg:"datacenter"`
		Folder           string `gcfg:"folder"`
		DefaultDatastore string `gcfg:"default-datastore"`
		ResourcePoolPath string `gcfg:"resourcepool-path"`
	}
}

ConfigFile represents the content of vsphere.conf file. Users specify the configuration of one or more vSphere instances in vsphere.conf where the Kubernetes master and worker nodes are running.

type Context added in v1.18.0

type Context struct {
	NodeMapper       *NodeMapper
	VSphereInstances map[string]*VSphere
}

Context holds common information for vSphere tests

var TestContext Context

TestContext should be used by all tests to access common context data. It should be initialized only once, during bootstrapping the tests.

type NodeInfo

type NodeInfo struct {
	Name              string
	DataCenterRef     types.ManagedObjectReference
	VirtualMachineRef types.ManagedObjectReference
	HostSystemRef     types.ManagedObjectReference
	VSphere           *VSphere
	Zones             []string
}

NodeInfo contains information about vcenter nodes

func GetReadySchedulableNodeInfos

func GetReadySchedulableNodeInfos() []*NodeInfo

GetReadySchedulableNodeInfos returns NodeInfo objects for all nodes with Ready and schedulable state

func GetReadySchedulableRandomNodeInfo

func GetReadySchedulableRandomNodeInfo() *NodeInfo

GetReadySchedulableRandomNodeInfo returns NodeInfo object for one of the Ready and Schedulable Node. if multiple nodes are present with Ready and Scheduable state then one of the Node is selected randomly and it's associated NodeInfo object is returned.

type NodeMapper

type NodeMapper struct {
}

NodeMapper contains information to generate nameToNodeInfo and vcToZoneDatastore maps

func (*NodeMapper) GenerateNodeMap

func (nm *NodeMapper) GenerateNodeMap(vSphereInstances map[string]*VSphere, nodeList v1.NodeList) error

GenerateNodeMap populates node name to node info map

func (*NodeMapper) GenerateZoneToDatastoreMap added in v1.14.0

func (nm *NodeMapper) GenerateZoneToDatastoreMap() error

GenerateZoneToDatastoreMap generates a mapping of zone to datastore for easily verifying volume placement

func (*NodeMapper) GetDatastoresInZone added in v1.14.0

func (nm *NodeMapper) GetDatastoresInZone(vc string, zone string) []string

GetDatastoresInZone returns all the datastores in the specified zone

func (*NodeMapper) GetNodeInfo

func (nm *NodeMapper) GetNodeInfo(nodeName string) *NodeInfo

GetNodeInfo returns NodeInfo for given nodeName

func (*NodeMapper) SetNodeInfo

func (nm *NodeMapper) SetNodeInfo(nodeName string, nodeInfo *NodeInfo)

SetNodeInfo sets NodeInfo for given nodeName. This function is not thread safe. Users need to handle concurrency.

type NodeSelector

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

NodeSelector holds

type VSphere

type VSphere struct {
	Config *Config
	Client *govmomi.Client
}

VSphere represents a vSphere instance where one or more kubernetes nodes are running.

func (*VSphere) CreateVolume

func (vs *VSphere) CreateVolume(volumeOptions *VolumeOptions, dataCenterRef types.ManagedObjectReference) (string, error)

CreateVolume creates a vsphere volume using given volume parameters specified in VolumeOptions. If volume is created successfully the canonical disk path is returned else error is returned.

func (*VSphere) DeleteVolume

func (vs *VSphere) DeleteVolume(volumePath string, dataCenterRef types.ManagedObjectReference) error

DeleteVolume deletes the vmdk file specified in the volumePath. if an error is encountered while deleting volume, error is returned.

func (*VSphere) GetAllDatacenter

func (vs *VSphere) GetAllDatacenter(ctx context.Context) ([]*object.Datacenter, error)

GetAllDatacenter returns all the DataCenter Objects

func (*VSphere) GetDatacenter

func (vs *VSphere) GetDatacenter(ctx context.Context, datacenterPath string) (*object.Datacenter, error)

GetDatacenter returns the DataCenter Object for the given datacenterPath

func (*VSphere) GetDatacenterFromObjectReference

func (vs *VSphere) GetDatacenterFromObjectReference(ctx context.Context, dc object.Reference) *object.Datacenter

GetDatacenterFromObjectReference returns the DataCenter Object for the given datacenter reference

func (*VSphere) GetDatastoreRefFromName added in v1.14.0

func (vs *VSphere) GetDatastoreRefFromName(ctx context.Context, dc object.Reference, datastoreName string) (types.ManagedObjectReference, error)

GetDatastoreRefFromName returns the datastore reference of the specified datastore

func (*VSphere) GetDatastoresMountedOnHost added in v1.14.0

func (vs *VSphere) GetDatastoresMountedOnHost(ctx context.Context, host types.ManagedObjectReference) []types.ManagedObjectReference

GetDatastoresMountedOnHost returns the datastore references of all the datastores mounted on the specified host

func (*VSphere) GetFolderByPath

func (vs *VSphere) GetFolderByPath(ctx context.Context, dc object.Reference, folderPath string) (vmFolderMor types.ManagedObjectReference, err error)

GetFolderByPath gets the Folder Object Reference from the given folder path folderPath should be the full path to folder

func (*VSphere) GetHostFromVMReference added in v1.14.0

func (vs *VSphere) GetHostFromVMReference(ctx context.Context, vm types.ManagedObjectReference) types.ManagedObjectReference

GetHostFromVMReference returns host object reference of the host on which the specified VM resides

func (*VSphere) GetVMByUUID

func (vs *VSphere) GetVMByUUID(ctx context.Context, vmUUID string, dc object.Reference) (object.Reference, error)

GetVMByUUID returns the VM object Reference from the given vmUUID

func (*VSphere) IsVMPresent

func (vs *VSphere) IsVMPresent(vmName string, dataCenterRef types.ManagedObjectReference) (isVMPresent bool, err error)

IsVMPresent checks if VM with the name specified in the vmName argument, is present in the vCenter inventory. if VM is present, function returns true else false.

type VolumeOptions

type VolumeOptions struct {
	Name               string
	CapacityKB         int
	DiskFormat         string
	SCSIControllerType string
	Datastore          string
}

VolumeOptions specifies various options for a volume.

Jump to

Keyboard shortcuts

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