mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
Merge pull request #115863 from jsafrane/remove-vsphere-test-global
Remove global vSphere framework variable
This commit is contained in:
commit
b6582ffcd5
@ -1284,7 +1284,7 @@ func (v *vSphereDriver) PrepareTest(ctx context.Context, f *framework.Framework)
|
|||||||
ginkgo.DeferCleanup(func(ctx context.Context) {
|
ginkgo.DeferCleanup(func(ctx context.Context) {
|
||||||
// Driver Cleanup function
|
// Driver Cleanup function
|
||||||
// Logout each vSphere client connection to prevent session leakage
|
// Logout each vSphere client connection to prevent session leakage
|
||||||
nodes := vspheretest.GetReadySchedulableNodeInfos(ctx)
|
nodes := vspheretest.GetReadySchedulableNodeInfos(ctx, f.ClientSet)
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
if node.VSphere.Client != nil {
|
if node.VSphere.Client != nil {
|
||||||
_ = node.VSphere.Client.Logout(ctx)
|
_ = node.VSphere.Client.Logout(ctx)
|
||||||
@ -1301,7 +1301,7 @@ func (v *vSphereDriver) PrepareTest(ctx context.Context, f *framework.Framework)
|
|||||||
func (v *vSphereDriver) CreateVolume(ctx context.Context, config *storageframework.PerTestConfig, volType storageframework.TestVolType) storageframework.TestVolume {
|
func (v *vSphereDriver) CreateVolume(ctx context.Context, config *storageframework.PerTestConfig, volType storageframework.TestVolType) storageframework.TestVolume {
|
||||||
f := config.Framework
|
f := config.Framework
|
||||||
vspheretest.Bootstrap(f)
|
vspheretest.Bootstrap(f)
|
||||||
nodeInfo := vspheretest.GetReadySchedulableRandomNodeInfo(ctx)
|
nodeInfo := vspheretest.GetReadySchedulableRandomNodeInfo(ctx, f.ClientSet)
|
||||||
volumePath, err := nodeInfo.VSphere.CreateVolume(&vspheretest.VolumeOptions{}, nodeInfo.DataCenterRef)
|
volumePath, err := nodeInfo.VSphere.CreateVolume(&vspheretest.VolumeOptions{}, nodeInfo.DataCenterRef)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
return &vSphereVolume{
|
return &vSphereVolume{
|
||||||
|
@ -26,21 +26,21 @@ import (
|
|||||||
|
|
||||||
var once sync.Once
|
var once sync.Once
|
||||||
var waiting = make(chan bool)
|
var waiting = make(chan bool)
|
||||||
var f *framework.Framework
|
|
||||||
|
|
||||||
// Bootstrap takes care of initializing necessary test context for vSphere tests
|
// Bootstrap takes care of initializing necessary test context for vSphere tests
|
||||||
func Bootstrap(fw *framework.Framework) {
|
func Bootstrap(fw *framework.Framework) {
|
||||||
done := make(chan bool)
|
done := make(chan bool)
|
||||||
f = fw
|
|
||||||
go func() {
|
go func() {
|
||||||
once.Do(bootstrapOnce)
|
once.Do(func() {
|
||||||
|
bootstrapOnce(fw)
|
||||||
|
})
|
||||||
<-waiting
|
<-waiting
|
||||||
done <- true
|
done <- true
|
||||||
}()
|
}()
|
||||||
<-done
|
<-done
|
||||||
}
|
}
|
||||||
|
|
||||||
func bootstrapOnce() {
|
func bootstrapOnce(f *framework.Framework) {
|
||||||
// 1. Read vSphere conf and get VSphere instances
|
// 1. Read vSphere conf and get VSphere instances
|
||||||
vsphereInstances, err := GetVSphereInstances()
|
vsphereInstances, err := GetVSphereInstances()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -70,7 +70,7 @@ var _ = utils.SIGDescribe("PersistentVolumes:vsphere [Feature:vsphere]", func()
|
|||||||
clientPod = nil
|
clientPod = nil
|
||||||
pvc = nil
|
pvc = nil
|
||||||
pv = nil
|
pv = nil
|
||||||
nodeInfo = GetReadySchedulableRandomNodeInfo(ctx)
|
nodeInfo = GetReadySchedulableRandomNodeInfo(ctx, c)
|
||||||
|
|
||||||
volLabel = labels.Set{e2epv.VolumeSelectorKey: ns}
|
volLabel = labels.Set{e2epv.VolumeSelectorKey: ns}
|
||||||
selector = metav1.SetAsLabelSelector(volLabel)
|
selector = metav1.SetAsLabelSelector(volLabel)
|
||||||
|
@ -58,7 +58,7 @@ var _ = utils.SIGDescribe("PersistentVolumes [Feature:vsphere][Feature:ReclaimPo
|
|||||||
e2eskipper.SkipUnlessProviderIs("vsphere")
|
e2eskipper.SkipUnlessProviderIs("vsphere")
|
||||||
ginkgo.DeferCleanup(testCleanupVSpherePersistentVolumeReclaim, c, nodeInfo, ns, volumePath, pv, pvc)
|
ginkgo.DeferCleanup(testCleanupVSpherePersistentVolumeReclaim, c, nodeInfo, ns, volumePath, pv, pvc)
|
||||||
Bootstrap(f)
|
Bootstrap(f)
|
||||||
nodeInfo = GetReadySchedulableRandomNodeInfo(ctx)
|
nodeInfo = GetReadySchedulableRandomNodeInfo(ctx, c)
|
||||||
pv = nil
|
pv = nil
|
||||||
pvc = nil
|
pvc = nil
|
||||||
volumePath = ""
|
volumePath = ""
|
||||||
@ -81,7 +81,7 @@ var _ = utils.SIGDescribe("PersistentVolumes [Feature:vsphere][Feature:ReclaimPo
|
|||||||
volumePath, pv, pvc, err = testSetupVSpherePersistentVolumeReclaim(ctx, c, nodeInfo, ns, v1.PersistentVolumeReclaimDelete)
|
volumePath, pv, pvc, err = testSetupVSpherePersistentVolumeReclaim(ctx, c, nodeInfo, ns, v1.PersistentVolumeReclaimDelete)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
deletePVCAfterBind(ctx, c, ns, pvc, pv)
|
deletePVCAfterBind(ctx, c, ns, pvc, pv, f.Timeouts)
|
||||||
pvc = nil
|
pvc = nil
|
||||||
|
|
||||||
ginkgo.By("verify pv is deleted")
|
ginkgo.By("verify pv is deleted")
|
||||||
@ -241,11 +241,11 @@ func testCleanupVSpherePersistentVolumeReclaim(ctx context.Context, c clientset.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// func to wait until PV and PVC bind and once bind completes, delete the PVC
|
// func to wait until PV and PVC bind and once bind completes, delete the PVC
|
||||||
func deletePVCAfterBind(ctx context.Context, c clientset.Interface, ns string, pvc *v1.PersistentVolumeClaim, pv *v1.PersistentVolume) {
|
func deletePVCAfterBind(ctx context.Context, c clientset.Interface, ns string, pvc *v1.PersistentVolumeClaim, pv *v1.PersistentVolume, timeouts *framework.TimeoutContext) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
ginkgo.By("wait for the pv and pvc to bind")
|
ginkgo.By("wait for the pv and pvc to bind")
|
||||||
framework.ExpectNoError(e2epv.WaitOnPVandPVC(ctx, c, f.Timeouts, ns, pv, pvc))
|
framework.ExpectNoError(e2epv.WaitOnPVandPVC(ctx, c, timeouts, ns, pv, pvc))
|
||||||
|
|
||||||
ginkgo.By("delete pvc")
|
ginkgo.By("delete pvc")
|
||||||
framework.ExpectNoError(e2epv.DeletePersistentVolumeClaim(ctx, c, pvc.Name, ns), "Failed to delete PVC ", pvc.Name)
|
framework.ExpectNoError(e2epv.DeletePersistentVolumeClaim(ctx, c, pvc.Name, ns), "Failed to delete PVC ", pvc.Name)
|
||||||
|
@ -68,7 +68,7 @@ var _ = utils.SIGDescribe("PersistentVolumes [Feature:vsphere][Feature:LabelSele
|
|||||||
c = f.ClientSet
|
c = f.ClientSet
|
||||||
ns = f.Namespace.Name
|
ns = f.Namespace.Name
|
||||||
Bootstrap(f)
|
Bootstrap(f)
|
||||||
nodeInfo = GetReadySchedulableRandomNodeInfo(ctx)
|
nodeInfo = GetReadySchedulableRandomNodeInfo(ctx, c)
|
||||||
framework.ExpectNoError(e2enode.WaitForAllNodesSchedulable(ctx, c, f.Timeouts.NodeSchedulable))
|
framework.ExpectNoError(e2enode.WaitForAllNodesSchedulable(ctx, c, f.Timeouts.NodeSchedulable))
|
||||||
ssdlabels = make(map[string]string)
|
ssdlabels = make(map[string]string)
|
||||||
ssdlabels["volume-type"] = "ssd"
|
ssdlabels["volume-type"] = "ssd"
|
||||||
|
@ -752,8 +752,8 @@ func getUUIDFromProviderID(providerID string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetReadySchedulableNodeInfos returns NodeInfo objects for all nodes with Ready and schedulable state
|
// GetReadySchedulableNodeInfos returns NodeInfo objects for all nodes with Ready and schedulable state
|
||||||
func GetReadySchedulableNodeInfos(ctx context.Context) []*NodeInfo {
|
func GetReadySchedulableNodeInfos(ctx context.Context, c clientset.Interface) []*NodeInfo {
|
||||||
nodeList, err := e2enode.GetReadySchedulableNodes(ctx, f.ClientSet)
|
nodeList, err := e2enode.GetReadySchedulableNodes(ctx, c)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
var nodesInfo []*NodeInfo
|
var nodesInfo []*NodeInfo
|
||||||
for _, node := range nodeList.Items {
|
for _, node := range nodeList.Items {
|
||||||
@ -768,8 +768,8 @@ func GetReadySchedulableNodeInfos(ctx context.Context) []*NodeInfo {
|
|||||||
// GetReadySchedulableRandomNodeInfo returns NodeInfo object for one of the Ready and Schedulable Node.
|
// GetReadySchedulableRandomNodeInfo returns NodeInfo object for one of the Ready and Schedulable Node.
|
||||||
// if multiple nodes are present with Ready and Schedulable state then one of the Node is selected randomly
|
// if multiple nodes are present with Ready and Schedulable state then one of the Node is selected randomly
|
||||||
// and it's associated NodeInfo object is returned.
|
// and it's associated NodeInfo object is returned.
|
||||||
func GetReadySchedulableRandomNodeInfo(ctx context.Context) *NodeInfo {
|
func GetReadySchedulableRandomNodeInfo(ctx context.Context, c clientset.Interface) *NodeInfo {
|
||||||
nodesInfo := GetReadySchedulableNodeInfos(ctx)
|
nodesInfo := GetReadySchedulableNodeInfos(ctx, c)
|
||||||
gomega.Expect(nodesInfo).NotTo(gomega.BeEmpty())
|
gomega.Expect(nodesInfo).NotTo(gomega.BeEmpty())
|
||||||
return nodesInfo[rand.Int()%len(nodesInfo)]
|
return nodesInfo[rand.Int()%len(nodesInfo)]
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ var _ = utils.SIGDescribe("Volume Provisioning On Clustered Datastore [Feature:v
|
|||||||
Bootstrap(f)
|
Bootstrap(f)
|
||||||
client = f.ClientSet
|
client = f.ClientSet
|
||||||
namespace = f.Namespace.Name
|
namespace = f.Namespace.Name
|
||||||
nodeInfo = GetReadySchedulableRandomNodeInfo(ctx)
|
nodeInfo = GetReadySchedulableRandomNodeInfo(ctx, client)
|
||||||
scParameters = make(map[string]string)
|
scParameters = make(map[string]string)
|
||||||
clusterDatastore = GetAndExpectStringEnvVar(VCPClusterDatastore)
|
clusterDatastore = GetAndExpectStringEnvVar(VCPClusterDatastore)
|
||||||
})
|
})
|
||||||
|
@ -74,7 +74,7 @@ var _ = utils.SIGDescribe("Volume Disk Format [Feature:vsphere]", func() {
|
|||||||
Bootstrap(f)
|
Bootstrap(f)
|
||||||
client = f.ClientSet
|
client = f.ClientSet
|
||||||
namespace = f.Namespace.Name
|
namespace = f.Namespace.Name
|
||||||
nodeName = GetReadySchedulableRandomNodeInfo(ctx).Name
|
nodeName = GetReadySchedulableRandomNodeInfo(ctx, client).Name
|
||||||
nodeLabelValue = "vsphere_e2e_" + string(uuid.NewUUID())
|
nodeLabelValue = "vsphere_e2e_" + string(uuid.NewUUID())
|
||||||
nodeKeyValueLabel = map[string]string{NodeLabelKey: nodeLabelValue}
|
nodeKeyValueLabel = map[string]string{NodeLabelKey: nodeLabelValue}
|
||||||
e2enode.AddOrUpdateLabelOnNode(client, nodeName, NodeLabelKey, nodeLabelValue)
|
e2enode.AddOrUpdateLabelOnNode(client, nodeName, NodeLabelKey, nodeLabelValue)
|
||||||
|
@ -80,7 +80,7 @@ var _ = utils.SIGDescribe("Volume FStype [Feature:vsphere]", func() {
|
|||||||
Bootstrap(f)
|
Bootstrap(f)
|
||||||
client = f.ClientSet
|
client = f.ClientSet
|
||||||
namespace = f.Namespace.Name
|
namespace = f.Namespace.Name
|
||||||
gomega.Expect(GetReadySchedulableNodeInfos(ctx)).NotTo(gomega.BeEmpty())
|
gomega.Expect(GetReadySchedulableNodeInfos(ctx, client)).NotTo(gomega.BeEmpty())
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("verify fstype - ext3 formatted volume", func(ctx context.Context) {
|
ginkgo.It("verify fstype - ext3 formatted volume", func(ctx context.Context) {
|
||||||
|
@ -70,7 +70,7 @@ var _ = utils.SIGDescribe("Volume Operations Storm [Feature:vsphere]", func() {
|
|||||||
Bootstrap(f)
|
Bootstrap(f)
|
||||||
client = f.ClientSet
|
client = f.ClientSet
|
||||||
namespace = f.Namespace.Name
|
namespace = f.Namespace.Name
|
||||||
gomega.Expect(GetReadySchedulableNodeInfos(ctx)).NotTo(gomega.BeEmpty())
|
gomega.Expect(GetReadySchedulableNodeInfos(ctx, client)).NotTo(gomega.BeEmpty())
|
||||||
if scale := os.Getenv("VOLUME_OPS_SCALE"); scale != "" {
|
if scale := os.Getenv("VOLUME_OPS_SCALE"); scale != "" {
|
||||||
volumeOpsScale, err = strconv.Atoi(scale)
|
volumeOpsScale, err = strconv.Atoi(scale)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user