Unverified Commit 5d8a2b9e authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #57258 from vmware/multi-vc-e2e-test

Automatic merge from submit-queue (batch tested with PRs 55918, 57258). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Add multi-vc configuration for e2e tests **What this PR does / why we need it**: Currently, we accept configuration for only single VC in e2e tests. This PR adds support for multiple VC configuration for e2e tests. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes https://github.com/vmware/kubernetes/issues/412 **Special notes for your reviewer**: Internally reviewed here: https://github.com/vmware/kubernetes/pull/418 **Release note**: ```release-note NONE ``` // cc @divyenpatel @shaominchen
parents c1f2da78 4683a947
...@@ -23,3 +23,4 @@ retry_time ...@@ -23,3 +23,4 @@ retry_time
file_content_in_loop file_content_in_loop
break_on_expected_content break_on_expected_content
Premium_LRS Premium_LRS
VCP_STRESS_ITERATIONS
...@@ -21,7 +21,6 @@ go_library( ...@@ -21,7 +21,6 @@ go_library(
"//pkg/cloudprovider/providers/vsphere/vclib/diskmanagers:go_default_library", "//pkg/cloudprovider/providers/vsphere/vclib/diskmanagers:go_default_library",
"//pkg/controller:go_default_library", "//pkg/controller:go_default_library",
"//vendor/github.com/golang/glog:go_default_library", "//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/vmware/govmomi:go_default_library",
"//vendor/github.com/vmware/govmomi/vim25:go_default_library", "//vendor/github.com/vmware/govmomi/vim25:go_default_library",
"//vendor/github.com/vmware/govmomi/vim25/mo:go_default_library", "//vendor/github.com/vmware/govmomi/vim25/mo:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library", "//vendor/golang.org/x/net/context:go_default_library",
......
...@@ -354,3 +354,10 @@ func (nm *NodeManager) renewNodeInfo(nodeInfo *NodeInfo, reconnect bool) (*NodeI ...@@ -354,3 +354,10 @@ func (nm *NodeManager) renewNodeInfo(nodeInfo *NodeInfo, reconnect bool) (*NodeI
vm := nodeInfo.vm.RenewVM(vsphereInstance.conn.GoVmomiClient) vm := nodeInfo.vm.RenewVM(vsphereInstance.conn.GoVmomiClient)
return &NodeInfo{vm: &vm, dataCenter: vm.Datacenter, vcServer: nodeInfo.vcServer}, nil return &NodeInfo{vm: &vm, dataCenter: vm.Datacenter, vcServer: nodeInfo.vcServer}, nil
} }
func (nodeInfo *NodeInfo) VM() *vclib.VirtualMachine {
if nodeInfo == nil {
return nil
}
return nodeInfo.vm
}
...@@ -1159,3 +1159,10 @@ func (vs *VSphere) NodeDeleted(obj interface{}) { ...@@ -1159,3 +1159,10 @@ func (vs *VSphere) NodeDeleted(obj interface{}) {
glog.V(4).Infof("Node deleted: %+v", node) glog.V(4).Infof("Node deleted: %+v", node)
vs.nodeManager.UnRegisterNode(node) vs.nodeManager.UnRegisterNode(node)
} }
func (vs *VSphere) NodeManager() (nodeManager *NodeManager) {
if vs == nil {
return nil
}
return vs.nodeManager
}
...@@ -21,12 +21,10 @@ import ( ...@@ -21,12 +21,10 @@ import (
"errors" "errors"
"os" "os"
"regexp" "regexp"
"runtime"
"strings" "strings"
"time" "time"
"github.com/golang/glog" "github.com/golang/glog"
"github.com/vmware/govmomi"
"github.com/vmware/govmomi/vim25" "github.com/vmware/govmomi/vim25"
"fmt" "fmt"
...@@ -34,7 +32,6 @@ import ( ...@@ -34,7 +32,6 @@ import (
"path/filepath" "path/filepath"
"github.com/vmware/govmomi/vim25/mo" "github.com/vmware/govmomi/vim25/mo"
"k8s.io/api/core/v1"
k8stypes "k8s.io/apimachinery/pkg/types" k8stypes "k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere/vclib" "k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere/vclib"
"k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere/vclib/diskmanagers" "k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere/vclib/diskmanagers"
...@@ -46,63 +43,37 @@ const ( ...@@ -46,63 +43,37 @@ const (
Folder = "Folder" Folder = "Folder"
VirtualMachine = "VirtualMachine" VirtualMachine = "VirtualMachine"
DummyDiskName = "kube-dummyDisk.vmdk" DummyDiskName = "kube-dummyDisk.vmdk"
vSphereConfFileEnvVar = "VSPHERE_CONF_FILE"
) )
// GetVSphere reads vSphere configuration from system environment and construct vSphere object // GetVSphere reads vSphere configuration from system environment and construct vSphere object
func GetVSphere() (*VSphere, error) { func GetVSphere() (*VSphere, error) {
cfg := getVSphereConfig() cfg, err := getVSphereConfig()
vSphereConn := getVSphereConn(cfg) if err != nil {
client, err := GetgovmomiClient(vSphereConn) return nil, err
}
vs, err := newControllerNode(*cfg)
if err != nil { if err != nil {
return nil, err return nil, err
} }
vSphereConn.GoVmomiClient = client
vsphereIns := &VSphereInstance{
conn: vSphereConn,
cfg: &VirtualCenterConfig{
User: cfg.Global.User,
Password: cfg.Global.Password,
VCenterPort: cfg.Global.VCenterPort,
Datacenters: cfg.Global.Datacenters,
RoundTripperCount: cfg.Global.RoundTripperCount,
},
}
vsphereInsMap := make(map[string]*VSphereInstance)
vsphereInsMap[cfg.Global.VCenterIP] = vsphereIns
// TODO: Initialize nodeManager and set it in VSphere.
vs := &VSphere{
vsphereInstanceMap: vsphereInsMap,
hostName: "",
cfg: cfg,
nodeManager: &NodeManager{
vsphereInstanceMap: vsphereInsMap,
nodeInfoMap: make(map[string]*NodeInfo),
registeredNodes: make(map[string]*v1.Node),
},
}
runtime.SetFinalizer(vs, logout)
return vs, nil return vs, nil
} }
func getVSphereConfig() *VSphereConfig { func getVSphereConfig() (*VSphereConfig, error) {
var cfg VSphereConfig confFileLocation := os.Getenv(vSphereConfFileEnvVar)
cfg.Global.VCenterIP = os.Getenv("VSPHERE_VCENTER") if confFileLocation == "" {
cfg.Global.VCenterPort = os.Getenv("VSPHERE_VCENTER_PORT") return nil, fmt.Errorf("Env variable 'VSPHERE_CONF_FILE' is not set.")
cfg.Global.User = os.Getenv("VSPHERE_USER") }
cfg.Global.Password = os.Getenv("VSPHERE_PASSWORD") confFile, err := os.Open(confFileLocation)
cfg.Global.Datacenters = os.Getenv("VSPHERE_DATACENTER") if err != nil {
cfg.Global.DefaultDatastore = os.Getenv("VSPHERE_DATASTORE") return nil, err
cfg.Global.WorkingDir = os.Getenv("VSPHERE_WORKING_DIR") }
cfg.Global.VMName = os.Getenv("VSPHERE_VM_NAME") defer confFile.Close()
cfg.Global.InsecureFlag = false cfg, err := readConfig(confFile)
if strings.ToLower(os.Getenv("VSPHERE_INSECURE")) == "true" { if err != nil {
cfg.Global.InsecureFlag = true return nil, err
} }
cfg.Workspace.VCenterIP = cfg.Global.VCenterIP return &cfg, nil
cfg.Workspace.Datacenter = cfg.Global.Datacenters
cfg.Workspace.DefaultDatastore = cfg.Global.DefaultDatastore
cfg.Workspace.Folder = cfg.Global.WorkingDir
return &cfg
} }
func getVSphereConn(cfg *VSphereConfig) *vclib.VSphereConnection { func getVSphereConn(cfg *VSphereConfig) *vclib.VSphereConnection {
...@@ -117,16 +88,6 @@ func getVSphereConn(cfg *VSphereConfig) *vclib.VSphereConnection { ...@@ -117,16 +88,6 @@ func getVSphereConn(cfg *VSphereConfig) *vclib.VSphereConnection {
return vSphereConn return vSphereConn
} }
// GetgovmomiClient gets the goVMOMI client for the vsphere connection object
func GetgovmomiClient(conn *vclib.VSphereConnection) (*govmomi.Client, error) {
if conn == nil {
cfg := getVSphereConfig()
conn = getVSphereConn(cfg)
}
client, err := conn.NewClient(context.TODO())
return client, err
}
// Returns the accessible datastores for the given node VM. // Returns the accessible datastores for the given node VM.
func getAccessibleDatastores(ctx context.Context, nodeVmDetail *NodeDetails, nodeManager *NodeManager) ([]*vclib.DatastoreInfo, error) { func getAccessibleDatastores(ctx context.Context, nodeVmDetail *NodeDetails, nodeManager *NodeManager) ([]*vclib.DatastoreInfo, error) {
accessibleDatastores, err := nodeVmDetail.vm.GetAllAccessibleDatastores(ctx) accessibleDatastores, err := nodeVmDetail.vm.GetAllAccessibleDatastores(ctx)
...@@ -512,3 +473,40 @@ func (vs *VSphere) checkDiskAttached(ctx context.Context, nodes []k8stypes.NodeN ...@@ -512,3 +473,40 @@ func (vs *VSphere) checkDiskAttached(ctx context.Context, nodes []k8stypes.NodeN
} }
return nodesToRetry, nil return nodesToRetry, nil
} }
func (vs *VSphere) IsDummyVMPresent(vmName string) (bool, error) {
isDummyVMPresent := false
// Create context
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
vsi, err := vs.getVSphereInstanceForServer(vs.cfg.Workspace.VCenterIP, ctx)
if err != nil {
return isDummyVMPresent, err
}
dc, err := vclib.GetDatacenter(ctx, vsi.conn, vs.cfg.Workspace.Datacenter)
if err != nil {
return isDummyVMPresent, err
}
vmFolder, err := dc.GetFolderByPath(ctx, vs.cfg.Workspace.Folder)
if err != nil {
return isDummyVMPresent, err
}
vms, err := vmFolder.GetVirtualMachines(ctx)
if err != nil {
return isDummyVMPresent, err
}
for _, vm := range vms {
if vm.Name() == vmName {
isDummyVMPresent = true
break
}
}
return isDummyVMPresent, nil
}
...@@ -11,6 +11,7 @@ go_library( ...@@ -11,6 +11,7 @@ go_library(
"persistent_volumes-vsphere.go", "persistent_volumes-vsphere.go",
"pv_reclaimpolicy.go", "pv_reclaimpolicy.go",
"pvc_label_selector.go", "pvc_label_selector.go",
"vsphere_common.go",
"vsphere_scale.go", "vsphere_scale.go",
"vsphere_statefulsets.go", "vsphere_statefulsets.go",
"vsphere_stress.go", "vsphere_stress.go",
...@@ -36,7 +37,6 @@ go_library( ...@@ -36,7 +37,6 @@ go_library(
"//test/e2e/storage/utils:go_default_library", "//test/e2e/storage/utils:go_default_library",
"//vendor/github.com/onsi/ginkgo:go_default_library", "//vendor/github.com/onsi/ginkgo:go_default_library",
"//vendor/github.com/onsi/gomega:go_default_library", "//vendor/github.com/onsi/gomega:go_default_library",
"//vendor/github.com/vmware/govmomi/find:go_default_library",
"//vendor/github.com/vmware/govmomi/vim25/types:go_default_library", "//vendor/github.com/vmware/govmomi/vim25/types:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library", "//vendor/golang.org/x/net/context:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library", "//vendor/k8s.io/api/core/v1:go_default_library",
......
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package vsphere
import (
. "github.com/onsi/gomega"
"os"
"strconv"
)
const (
SPBMPolicyName = "VSPHERE_SPBM_POLICY_NAME"
StorageClassDatastoreName = "VSPHERE_DATASTORE"
SecondSharedDatastore = "VSPHERE_SECOND_SHARED_DATASTORE"
KubernetesClusterName = "VSPHERE_KUBERNETES_CLUSTER"
SPBMTagPolicy = "VSPHERE_SPBM_TAG_POLICY"
)
const (
VCPClusterDatastore = "CLUSTER_DATASTORE"
SPBMPolicyDataStoreCluster = "VSPHERE_SPBM_POLICY_DS_CLUSTER"
)
const (
VCPScaleVolumeCount = "VCP_SCALE_VOLUME_COUNT"
VCPScaleVolumesPerPod = "VCP_SCALE_VOLUME_PER_POD"
VCPScaleInstances = "VCP_SCALE_INSTANCES"
)
const (
VCPStressInstances = "VCP_STRESS_INSTANCES"
VCPStressIterations = "VCP_STRESS_ITERATIONS"
)
const (
VCPPerfVolumeCount = "VCP_PERF_VOLUME_COUNT"
VCPPerfVolumesPerPod = "VCP_PERF_VOLUME_PER_POD"
VCPPerfIterations = "VCP_PERF_ITERATIONS"
)
func GetAndExpectStringEnvVar(varName string) string {
varValue := os.Getenv(varName)
Expect(varValue).NotTo(BeEmpty(), "ENV "+varName+" is not set")
return varValue
}
func GetAndExpectIntEnvVar(varName string) int {
varValue := GetAndExpectStringEnvVar(varName)
varIntValue, err := strconv.Atoi(varValue)
Expect(err).NotTo(HaveOccurred(), "Error Parsing "+varName)
return varIntValue
}
...@@ -18,7 +18,6 @@ package vsphere ...@@ -18,7 +18,6 @@ package vsphere
import ( import (
"fmt" "fmt"
"os"
"strconv" "strconv"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
...@@ -63,12 +62,11 @@ var _ = utils.SIGDescribe("vcp at scale [Feature:vsphere] ", func() { ...@@ -63,12 +62,11 @@ var _ = utils.SIGDescribe("vcp at scale [Feature:vsphere] ", func() {
volumeCount int volumeCount int
numberOfInstances int numberOfInstances int
volumesPerPod int volumesPerPod int
nodeVolumeMapChan chan map[string][]string
nodes *v1.NodeList
policyName string policyName string
datastoreName string datastoreName string
nodeVolumeMapChan chan map[string][]string
nodes *v1.NodeList
scNames = []string{storageclass1, storageclass2, storageclass3, storageclass4} scNames = []string{storageclass1, storageclass2, storageclass3, storageclass4}
err error
) )
BeforeEach(func() { BeforeEach(func() {
...@@ -78,27 +76,15 @@ var _ = utils.SIGDescribe("vcp at scale [Feature:vsphere] ", func() { ...@@ -78,27 +76,15 @@ var _ = utils.SIGDescribe("vcp at scale [Feature:vsphere] ", func() {
nodeVolumeMapChan = make(chan map[string][]string) nodeVolumeMapChan = make(chan map[string][]string)
// Read the environment variables // Read the environment variables
volumeCountStr := os.Getenv("VCP_SCALE_VOLUME_COUNT") volumeCount = GetAndExpectIntEnvVar(VCPScaleVolumeCount)
Expect(volumeCountStr).NotTo(BeEmpty(), "ENV VCP_SCALE_VOLUME_COUNT is not set") volumesPerPod = GetAndExpectIntEnvVar(VCPScaleVolumesPerPod)
volumeCount, err = strconv.Atoi(volumeCountStr)
Expect(err).NotTo(HaveOccurred(), "Error Parsing VCP_SCALE_VOLUME_COUNT") numberOfInstances = GetAndExpectIntEnvVar(VCPScaleInstances)
volumesPerPodStr := os.Getenv("VCP_SCALE_VOLUME_PER_POD")
Expect(volumesPerPodStr).NotTo(BeEmpty(), "ENV VCP_SCALE_VOLUME_PER_POD is not set")
volumesPerPod, err = strconv.Atoi(volumesPerPodStr)
Expect(err).NotTo(HaveOccurred(), "Error Parsing VCP_SCALE_VOLUME_PER_POD")
numberOfInstancesStr := os.Getenv("VCP_SCALE_INSTANCES")
Expect(numberOfInstancesStr).NotTo(BeEmpty(), "ENV VCP_SCALE_INSTANCES is not set")
numberOfInstances, err = strconv.Atoi(numberOfInstancesStr)
Expect(err).NotTo(HaveOccurred(), "Error Parsing VCP_SCALE_INSTANCES")
Expect(numberOfInstances > 5).NotTo(BeTrue(), "Maximum allowed instances are 5") Expect(numberOfInstances > 5).NotTo(BeTrue(), "Maximum allowed instances are 5")
Expect(numberOfInstances > volumeCount).NotTo(BeTrue(), "Number of instances should be less than the total volume count") Expect(numberOfInstances > volumeCount).NotTo(BeTrue(), "Number of instances should be less than the total volume count")
policyName = os.Getenv("VSPHERE_SPBM_POLICY_NAME") policyName = GetAndExpectStringEnvVar(SPBMPolicyName)
datastoreName = os.Getenv("VSPHERE_DATASTORE") datastoreName = GetAndExpectStringEnvVar(StorageClassDatastoreName)
Expect(policyName).NotTo(BeEmpty(), "ENV VSPHERE_SPBM_POLICY_NAME is not set")
Expect(datastoreName).NotTo(BeEmpty(), "ENV VSPHERE_DATASTORE is not set")
nodes = framework.GetReadySchedulableNodesOrDie(client) nodes = framework.GetReadySchedulableNodesOrDie(client)
if len(nodes.Items) < 2 { if len(nodes.Items) < 2 {
......
...@@ -18,8 +18,6 @@ package vsphere ...@@ -18,8 +18,6 @@ package vsphere
import ( import (
"fmt" "fmt"
"os"
"strconv"
"sync" "sync"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
...@@ -50,10 +48,10 @@ var _ = utils.SIGDescribe("vsphere cloud provider stress [Feature:vsphere]", fun ...@@ -50,10 +48,10 @@ var _ = utils.SIGDescribe("vsphere cloud provider stress [Feature:vsphere]", fun
namespace string namespace string
instances int instances int
iterations int iterations int
err error
scNames = []string{storageclass1, storageclass2, storageclass3, storageclass4}
policyName string policyName string
datastoreName string datastoreName string
err error
scNames = []string{storageclass1, storageclass2, storageclass3, storageclass4}
) )
BeforeEach(func() { BeforeEach(func() {
...@@ -67,23 +65,16 @@ var _ = utils.SIGDescribe("vsphere cloud provider stress [Feature:vsphere]", fun ...@@ -67,23 +65,16 @@ var _ = utils.SIGDescribe("vsphere cloud provider stress [Feature:vsphere]", fun
// if VCP_STRESS_INSTANCES = 12 and VCP_STRESS_ITERATIONS is 10. 12 threads will run in parallel for 10 times. // if VCP_STRESS_INSTANCES = 12 and VCP_STRESS_ITERATIONS is 10. 12 threads will run in parallel for 10 times.
// Resulting 120 Volumes and POD Creation. Volumes will be provisioned with each different types of Storage Class, // Resulting 120 Volumes and POD Creation. Volumes will be provisioned with each different types of Storage Class,
// Each iteration creates PVC, verify PV is provisioned, then creates a pod, verify volume is attached to the node, and then delete the pod and delete pvc. // Each iteration creates PVC, verify PV is provisioned, then creates a pod, verify volume is attached to the node, and then delete the pod and delete pvc.
instancesStr := os.Getenv("VCP_STRESS_INSTANCES") instances = GetAndExpectIntEnvVar(VCPStressInstances)
Expect(instancesStr).NotTo(BeEmpty(), "ENV VCP_STRESS_INSTANCES is not set")
instances, err = strconv.Atoi(instancesStr)
Expect(err).NotTo(HaveOccurred(), "Error Parsing VCP-STRESS-INSTANCES")
Expect(instances <= volumesPerNode*len(nodeList.Items)).To(BeTrue(), fmt.Sprintf("Number of Instances should be less or equal: %v", volumesPerNode*len(nodeList.Items))) Expect(instances <= volumesPerNode*len(nodeList.Items)).To(BeTrue(), fmt.Sprintf("Number of Instances should be less or equal: %v", volumesPerNode*len(nodeList.Items)))
Expect(instances > len(scNames)).To(BeTrue(), "VCP_STRESS_INSTANCES should be greater than 3 to utilize all 4 types of storage classes") Expect(instances > len(scNames)).To(BeTrue(), "VCP_STRESS_INSTANCES should be greater than 3 to utilize all 4 types of storage classes")
iterationStr := os.Getenv("VCP_STRESS_ITERATIONS") iterations = GetAndExpectIntEnvVar(VCPStressIterations)
Expect(instancesStr).NotTo(BeEmpty(), "ENV VCP_STRESS_ITERATIONS is not set")
iterations, err = strconv.Atoi(iterationStr)
Expect(err).NotTo(HaveOccurred(), "Error Parsing VCP_STRESS_ITERATIONS") Expect(err).NotTo(HaveOccurred(), "Error Parsing VCP_STRESS_ITERATIONS")
Expect(iterations > 0).To(BeTrue(), "VCP_STRESS_ITERATIONS should be greater than 0") Expect(iterations > 0).To(BeTrue(), "VCP_STRESS_ITERATIONS should be greater than 0")
policyName = os.Getenv("VSPHERE_SPBM_POLICY_NAME") policyName = GetAndExpectStringEnvVar(SPBMPolicyName)
datastoreName = os.Getenv("VSPHERE_DATASTORE") datastoreName = GetAndExpectStringEnvVar(StorageClassDatastoreName)
Expect(policyName).NotTo(BeEmpty(), "ENV VSPHERE_SPBM_POLICY_NAME is not set")
Expect(datastoreName).NotTo(BeEmpty(), "ENV VSPHERE_DATASTORE is not set")
}) })
It("vsphere stress tests", func() { It("vsphere stress tests", func() {
......
...@@ -18,7 +18,6 @@ package vsphere ...@@ -18,7 +18,6 @@ package vsphere
import ( import (
"fmt" "fmt"
"os"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
...@@ -43,18 +42,19 @@ import ( ...@@ -43,18 +42,19 @@ import (
var _ = utils.SIGDescribe("Volume Provisioning On Clustered Datastore [Feature:vsphere]", func() { var _ = utils.SIGDescribe("Volume Provisioning On Clustered Datastore [Feature:vsphere]", func() {
f := framework.NewDefaultFramework("volume-provision") f := framework.NewDefaultFramework("volume-provision")
var client clientset.Interface var (
var namespace string client clientset.Interface
var scParameters map[string]string namespace string
var clusterDatastore string scParameters map[string]string
clusterDatastore string
)
BeforeEach(func() { BeforeEach(func() {
framework.SkipUnlessProviderIs("vsphere") framework.SkipUnlessProviderIs("vsphere")
client = f.ClientSet client = f.ClientSet
namespace = f.Namespace.Name namespace = f.Namespace.Name
scParameters = make(map[string]string) scParameters = make(map[string]string)
clusterDatastore = GetAndExpectStringEnvVar(VCPClusterDatastore)
clusterDatastore = os.Getenv("CLUSTER_DATASTORE")
Expect(clusterDatastore).NotTo(BeEmpty(), "Please set CLUSTER_DATASTORE system environment. eg: export CLUSTER_DATASTORE=<cluster_name>/<datastore_name")
}) })
/* /*
...@@ -129,9 +129,8 @@ var _ = utils.SIGDescribe("Volume Provisioning On Clustered Datastore [Feature:v ...@@ -129,9 +129,8 @@ var _ = utils.SIGDescribe("Volume Provisioning On Clustered Datastore [Feature:v
2. invokeValidPolicyTest - util to do e2e dynamic provision test 2. invokeValidPolicyTest - util to do e2e dynamic provision test
*/ */
It("verify dynamic provision with spbm policy on clustered datastore", func() { It("verify dynamic provision with spbm policy on clustered datastore", func() {
storagePolicy := os.Getenv("VSPHERE_SPBM_POLICY_DS_CLUSTER") policyDatastoreCluster := GetAndExpectStringEnvVar(SPBMPolicyDataStoreCluster)
Expect(storagePolicy).NotTo(BeEmpty(), "Please set VSPHERE_SPBM_POLICY_DS_CLUSTER system environment") scParameters[SpbmStoragePolicy] = policyDatastoreCluster
scParameters[SpbmStoragePolicy] = storagePolicy
invokeValidPolicyTest(f, client, namespace, scParameters) invokeValidPolicyTest(f, client, namespace, scParameters)
}) })
}) })
...@@ -17,12 +17,10 @@ limitations under the License. ...@@ -17,12 +17,10 @@ limitations under the License.
package vsphere package vsphere
import ( import (
"os"
"path/filepath" "path/filepath"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/vim25/types" "github.com/vmware/govmomi/vim25/types"
"golang.org/x/net/context" "golang.org/x/net/context"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
...@@ -30,7 +28,6 @@ import ( ...@@ -30,7 +28,6 @@ import (
k8stype "k8s.io/apimachinery/pkg/types" k8stype "k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/uuid" "k8s.io/apimachinery/pkg/util/uuid"
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
vsphere "k8s.io/kubernetes/pkg/cloudprovider/providers/vsphere"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/storage/utils" "k8s.io/kubernetes/test/e2e/storage/utils"
) )
...@@ -152,7 +149,7 @@ func invokeTest(f *framework.Framework, client clientset.Interface, namespace st ...@@ -152,7 +149,7 @@ func invokeTest(f *framework.Framework, client clientset.Interface, namespace st
By("Waiting for pod to be running") By("Waiting for pod to be running")
Expect(framework.WaitForPodNameRunningInNamespace(client, pod.Name, namespace)).To(Succeed()) Expect(framework.WaitForPodNameRunningInNamespace(client, pod.Name, namespace)).To(Succeed())
Expect(verifyDiskFormat(nodeName, pv.Spec.VsphereVolume.VolumePath, diskFormat)).To(BeTrue(), "DiskFormat Verification Failed") Expect(verifyDiskFormat(client, nodeName, pv.Spec.VsphereVolume.VolumePath, diskFormat)).To(BeTrue(), "DiskFormat Verification Failed")
var volumePaths []string var volumePaths []string
volumePaths = append(volumePaths, pv.Spec.VsphereVolume.VolumePath) volumePaths = append(volumePaths, pv.Spec.VsphereVolume.VolumePath)
...@@ -162,22 +159,22 @@ func invokeTest(f *framework.Framework, client clientset.Interface, namespace st ...@@ -162,22 +159,22 @@ func invokeTest(f *framework.Framework, client clientset.Interface, namespace st
} }
func verifyDiskFormat(nodeName string, pvVolumePath string, diskFormat string) bool { func verifyDiskFormat(client clientset.Interface, nodeName string, pvVolumePath string, diskFormat string) bool {
By("Verifing disk format") By("Verifing disk format")
eagerlyScrub := false eagerlyScrub := false
thinProvisioned := false thinProvisioned := false
diskFound := false diskFound := false
pvvmdkfileName := filepath.Base(pvVolumePath) + filepath.Ext(pvVolumePath) pvvmdkfileName := filepath.Base(pvVolumePath) + filepath.Ext(pvVolumePath)
govMoMiClient, err := vsphere.GetgovmomiClient(nil) ctx, cancel := context.WithCancel(context.Background())
Expect(err).NotTo(HaveOccurred()) defer cancel()
f := find.NewFinder(govMoMiClient.Client, true) vsp, err := getVSphere(client)
ctx, _ := context.WithCancel(context.Background()) Expect(err).NotTo(HaveOccurred())
vm, err := f.VirtualMachine(ctx, os.Getenv("VSPHERE_WORKING_DIR")+nodeName) nodeInfo, err := vsp.NodeManager().GetNodeInfo(k8stype.NodeName(nodeName))
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
vmDevices, err := vm.Device(ctx) vmDevices, err := nodeInfo.VM().Device(ctx)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
disks := vmDevices.SelectByType((*types.VirtualDisk)(nil)) disks := vmDevices.SelectByType((*types.VirtualDisk)(nil))
......
...@@ -18,7 +18,6 @@ package vsphere ...@@ -18,7 +18,6 @@ package vsphere
import ( import (
"fmt" "fmt"
"os"
"strings" "strings"
"time" "time"
...@@ -58,8 +57,7 @@ var _ = utils.SIGDescribe("Volume Disk Size [Feature:vsphere]", func() { ...@@ -58,8 +57,7 @@ var _ = utils.SIGDescribe("Volume Disk Size [Feature:vsphere]", func() {
client = f.ClientSet client = f.ClientSet
namespace = f.Namespace.Name namespace = f.Namespace.Name
scParameters = make(map[string]string) scParameters = make(map[string]string)
datastore = os.Getenv("VSPHERE_DATASTORE") datastore = GetAndExpectStringEnvVar(StorageClassDatastoreName)
Expect(datastore).NotTo(BeEmpty())
nodeList := framework.GetReadySchedulableNodesOrDie(f.ClientSet) nodeList := framework.GetReadySchedulableNodesOrDie(f.ClientSet)
if !(len(nodeList.Items) > 0) { if !(len(nodeList.Items) > 0) {
framework.Failf("Unable to find ready and schedulable Node") framework.Failf("Unable to find ready and schedulable Node")
......
...@@ -18,13 +18,10 @@ package vsphere ...@@ -18,13 +18,10 @@ package vsphere
import ( import (
"fmt" "fmt"
"os"
"path/filepath"
"time" "time"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vmware/govmomi/find"
"golang.org/x/net/context" "golang.org/x/net/context"
vimtypes "github.com/vmware/govmomi/vim25/types" vimtypes "github.com/vmware/govmomi/vim25/types"
...@@ -47,11 +44,10 @@ import ( ...@@ -47,11 +44,10 @@ import (
var _ = utils.SIGDescribe("Node Poweroff [Feature:vsphere] [Slow] [Disruptive]", func() { var _ = utils.SIGDescribe("Node Poweroff [Feature:vsphere] [Slow] [Disruptive]", func() {
f := framework.NewDefaultFramework("node-poweroff") f := framework.NewDefaultFramework("node-poweroff")
var ( var (
client clientset.Interface client clientset.Interface
namespace string namespace string
vsp *vsphere.VSphere vsp *vsphere.VSphere
workingDir string err error
err error
) )
BeforeEach(func() { BeforeEach(func() {
...@@ -64,8 +60,6 @@ var _ = utils.SIGDescribe("Node Poweroff [Feature:vsphere] [Slow] [Disruptive]", ...@@ -64,8 +60,6 @@ var _ = utils.SIGDescribe("Node Poweroff [Feature:vsphere] [Slow] [Disruptive]",
Expect(len(nodeList.Items) > 1).To(BeTrue(), "At least 2 nodes are required for this test") Expect(len(nodeList.Items) > 1).To(BeTrue(), "At least 2 nodes are required for this test")
vsp, err = getVSphere(client) vsp, err = getVSphere(client)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
workingDir = os.Getenv("VSPHERE_WORKING_DIR")
Expect(workingDir).NotTo(BeEmpty())
}) })
/* /*
...@@ -118,16 +112,10 @@ var _ = utils.SIGDescribe("Node Poweroff [Feature:vsphere] [Slow] [Disruptive]", ...@@ -118,16 +112,10 @@ var _ = utils.SIGDescribe("Node Poweroff [Feature:vsphere] [Slow] [Disruptive]",
Expect(isAttached).To(BeTrue(), "Disk is not attached to the node") Expect(isAttached).To(BeTrue(), "Disk is not attached to the node")
By(fmt.Sprintf("Power off the node: %v", node1)) By(fmt.Sprintf("Power off the node: %v", node1))
govMoMiClient, err := vsphere.GetgovmomiClient(nil) nodeInfo, err := vsp.NodeManager().GetNodeInfo(node1)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
vm := nodeInfo.VM()
f := find.NewFinder(govMoMiClient.Client, true)
ctx, _ := context.WithCancel(context.Background()) ctx, _ := context.WithCancel(context.Background())
vmPath := filepath.Join(workingDir, string(node1))
vm, err := f.VirtualMachine(ctx, vmPath)
Expect(err).NotTo(HaveOccurred())
_, err = vm.PowerOff(ctx) _, err = vm.PowerOff(ctx)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
defer vm.PowerOn(ctx) defer vm.PowerOn(ctx)
......
...@@ -18,8 +18,6 @@ package vsphere ...@@ -18,8 +18,6 @@ package vsphere
import ( import (
"fmt" "fmt"
"os"
"strconv"
"time" "time"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
...@@ -56,39 +54,25 @@ var _ = utils.SIGDescribe("vcp-performance [Feature:vsphere]", func() { ...@@ -56,39 +54,25 @@ var _ = utils.SIGDescribe("vcp-performance [Feature:vsphere]", func() {
client clientset.Interface client clientset.Interface
namespace string namespace string
nodeSelectorList []*NodeSelector nodeSelectorList []*NodeSelector
policyName string
datastoreName string
volumeCount int volumeCount int
volumesPerPod int volumesPerPod int
iterations int iterations int
policyName string
datastoreName string
) )
BeforeEach(func() { BeforeEach(func() {
var err error
framework.SkipUnlessProviderIs("vsphere") framework.SkipUnlessProviderIs("vsphere")
client = f.ClientSet client = f.ClientSet
namespace = f.Namespace.Name namespace = f.Namespace.Name
// Read the environment variables // Read the environment variables
volumeCountStr := os.Getenv("VCP_PERF_VOLUME_COUNT") volumeCount = GetAndExpectIntEnvVar(VCPPerfVolumeCount)
Expect(volumeCountStr).NotTo(BeEmpty(), "ENV VCP_PERF_VOLUME_COUNT is not set") volumesPerPod = GetAndExpectIntEnvVar(VCPPerfVolumesPerPod)
volumeCount, err = strconv.Atoi(volumeCountStr) iterations = GetAndExpectIntEnvVar(VCPPerfIterations)
Expect(err).NotTo(HaveOccurred(), "Error Parsing VCP_PERF_VOLUME_COUNT")
policyName = GetAndExpectStringEnvVar(SPBMPolicyName)
volumesPerPodStr := os.Getenv("VCP_PERF_VOLUME_PER_POD") datastoreName = GetAndExpectStringEnvVar(StorageClassDatastoreName)
Expect(volumesPerPodStr).NotTo(BeEmpty(), "ENV VCP_PERF_VOLUME_PER_POD is not set")
volumesPerPod, err = strconv.Atoi(volumesPerPodStr)
Expect(err).NotTo(HaveOccurred(), "Error Parsing VCP_PERF_VOLUME_PER_POD")
iterationsStr := os.Getenv("VCP_PERF_ITERATIONS")
Expect(iterationsStr).NotTo(BeEmpty(), "ENV VCP_PERF_ITERATIONS is not set")
iterations, err = strconv.Atoi(iterationsStr)
Expect(err).NotTo(HaveOccurred(), "Error Parsing VCP_PERF_ITERATIONS")
policyName = os.Getenv("VSPHERE_SPBM_GOLD_POLICY")
datastoreName = os.Getenv("VSPHERE_DATASTORE")
Expect(policyName).NotTo(BeEmpty(), "ENV VSPHERE_SPBM_GOLD_POLICY is not set")
Expect(datastoreName).NotTo(BeEmpty(), "ENV VSPHERE_DATASTORE is not set")
nodes := framework.GetReadySchedulableNodesOrDie(client) nodes := framework.GetReadySchedulableNodesOrDie(client)
Expect(len(nodes.Items)).To(BeNumerically(">=", 1), "Requires at least %d nodes (not %d)", 2, len(nodes.Items)) Expect(len(nodes.Items)).To(BeNumerically(">=", 1), "Requires at least %d nodes (not %d)", 2, len(nodes.Items))
......
...@@ -18,7 +18,6 @@ package vsphere ...@@ -18,7 +18,6 @@ package vsphere
import ( import (
"fmt" "fmt"
"os"
"strconv" "strconv"
"time" "time"
...@@ -225,7 +224,7 @@ var _ = utils.SIGDescribe("Volume Placement", func() { ...@@ -225,7 +224,7 @@ var _ = utils.SIGDescribe("Volume Placement", func() {
volumeOptions = new(vclib.VolumeOptions) volumeOptions = new(vclib.VolumeOptions)
volumeOptions.CapacityKB = 2097152 volumeOptions.CapacityKB = 2097152
volumeOptions.Name = "e2e-vmdk-" + strconv.FormatInt(time.Now().UnixNano(), 10) volumeOptions.Name = "e2e-vmdk-" + strconv.FormatInt(time.Now().UnixNano(), 10)
volumeOptions.Datastore = os.Getenv("VSPHERE_SECOND_SHARED_DATASTORE") volumeOptions.Datastore = GetAndExpectStringEnvVar(SecondSharedDatastore)
volumePath, err := createVSphereVolume(vsp, volumeOptions) volumePath, err := createVSphereVolume(vsp, volumeOptions)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
volumePaths = append(volumePaths, volumePath) volumePaths = append(volumePaths, volumePath)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment