Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] replace full sync static sleeps with full sync trigger API calls #2465

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions tests/e2e/csi_cns_telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ package e2e
import (
"context"
"fmt"
"os"
"strconv"
"time"

ginkgo "github.com/onsi/ginkgo/v2"
Expand All @@ -32,19 +30,23 @@ import (
"k8s.io/kubernetes/test/e2e/framework"
fnodes "k8s.io/kubernetes/test/e2e/framework/node"
fpv "k8s.io/kubernetes/test/e2e/framework/pv"
k8sClient "sigs.k8s.io/controller-runtime/pkg/client"
cnsoperatorv1alpha1 "sigs.k8s.io/vsphere-csi-driver/v3/pkg/apis/cnsoperator"
k8s "sigs.k8s.io/vsphere-csi-driver/v3/pkg/kubernetes"
)

var _ = ginkgo.Describe("[csi-block-vanilla] [csi-file-vanilla] [csi-block-vanilla-serialized] "+
"CNS-CSI Cluster Distribution Telemetry", func() {

f := framework.NewDefaultFramework("csi-cns-telemetry")
var (
client clientset.Interface
namespace string
scParameters map[string]string
datastoreURL string
csiNamespace string
csiReplicas int32
client clientset.Interface
namespace string
scParameters map[string]string
datastoreURL string
csiNamespace string
csiReplicas int32
cnsOperatorClient k8sClient.Client
)

ginkgo.BeforeEach(func() {
Expand Down Expand Up @@ -73,6 +75,12 @@ var _ = ginkgo.Describe("[csi-block-vanilla] [csi-file-vanilla] [csi-block-vanil
restartSuccess, err := restartCSIDriver(ctx, client, csiNamespace, csiReplicas)
gomega.Expect(restartSuccess).To(gomega.BeTrue(), "csi driver restart not successful")
gomega.Expect(err).NotTo(gomega.HaveOccurred())

cnsOperatorClient, err = k8s.NewClientForGroup(ctx, f.ClientConfig(), cnsoperatorv1alpha1.GroupName)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

enableFullSyncTriggerFss(ctx, client, csiSystemNamespace, fullSyncFss)

})

ginkgo.AfterEach(func() {
Expand Down Expand Up @@ -106,16 +114,8 @@ var _ = ginkgo.Describe("[csi-block-vanilla] [csi-file-vanilla] [csi-block-vanil
var pvclaim1 *v1.PersistentVolumeClaim
var storageclasspvc2 *storagev1.StorageClass
var pvclaim2 *v1.PersistentVolumeClaim
var fullSyncWaitTime int
var err error

// Read full-sync value.
if os.Getenv(envFullSyncWaitTime) != "" {
fullSyncWaitTime, err = strconv.Atoi(os.Getenv(envFullSyncWaitTime))
framework.Logf("Full-Sync interval time value is = %v", fullSyncWaitTime)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}

ginkgo.By("Creating a PVC")
scParameters[scParamDatastoreURL] = datastoreURL
storageclasspvc1, pvclaim1, err = createPVCAndStorageClass(client,
Expand Down Expand Up @@ -204,9 +204,8 @@ var _ = ginkgo.Describe("[csi-block-vanilla] [csi-file-vanilla] [csi-block-vanil

// For Old PVCs to reflect the latest Cluster-Distribution Value, wait for
// full sync.
framework.Logf("Sleeping full-sync interval for all the volumes Metadata " +
"to reflect the cluster-distribution value to = Empty")
time.Sleep(time.Duration(fullSyncWaitTime) * time.Second)
ginkgo.By("Trigger 2 full syncs")
triggerFullSync(ctx, client, cnsOperatorClient)

// Add additional safe wait time for cluster-distribution to reflect on
// metadata.
Expand Down Expand Up @@ -235,7 +234,9 @@ var _ = ginkgo.Describe("[csi-block-vanilla] [csi-file-vanilla] [csi-block-vanil
// full sync.
framework.Logf("Sleeping full-sync interval for all the volumes Metadata to reflect "+
"the cluster-distribution value to = %s", vanillaClusterDistributionWithSpecialChar)
time.Sleep(time.Duration(fullSyncWaitTime) * time.Second)

ginkgo.By("Trigger 2 full syncs")
triggerFullSync(ctx, client, cnsOperatorClient)

// Add additional safe wait time for cluster-distribution to reflect on
// metadata.
Expand Down
18 changes: 0 additions & 18 deletions tests/e2e/csi_cns_telemetry_vc_reboot.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ package e2e
import (
"context"
"fmt"
"os"
"strconv"
"time"

ginkgo "github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -94,16 +92,8 @@ var _ bool = ginkgo.Describe("[csi-block-vanilla] [csi-file-vanilla] "+
var pvclaim *v1.PersistentVolumeClaim
var storageclass2 *storagev1.StorageClass
var pvclaim2 *v1.PersistentVolumeClaim
var fullSyncWaitTime int
var err error

// Read full-sync value.
if os.Getenv(envFullSyncWaitTime) != "" {
fullSyncWaitTime, err = strconv.Atoi(os.Getenv(envFullSyncWaitTime))
framework.Logf("Full-Sync interval time value is = %v", fullSyncWaitTime)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}

ginkgo.By("Creating Storage Class and PVC")
// Decide which test setup is available to run.
if vanillaCluster {
Expand Down Expand Up @@ -279,16 +269,8 @@ var _ bool = ginkgo.Describe("[csi-block-vanilla] [csi-file-vanilla] "+
defer cancel()
var storageclass *storagev1.StorageClass
var pvclaim *v1.PersistentVolumeClaim
var fullSyncWaitTime int
var err error

// Read full-sync value.
if os.Getenv(envFullSyncWaitTime) != "" {
fullSyncWaitTime, err = strconv.Atoi(os.Getenv(envFullSyncWaitTime))
framework.Logf("Full-Sync interval time value is = %v", fullSyncWaitTime)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}

ginkgo.By("Rebooting VC")
vcAddress := e2eVSphere.Config.Global.VCenterHostname + ":" + sshdPort
err = invokeVCenterReboot(vcAddress)
Expand Down
38 changes: 12 additions & 26 deletions tests/e2e/csi_snapshot_basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import (
"github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/object"
"golang.org/x/crypto/ssh"
k8sClient "sigs.k8s.io/controller-runtime/pkg/client"
cnsoperatorv1alpha1 "sigs.k8s.io/vsphere-csi-driver/v3/pkg/apis/cnsoperator"
k8s "sigs.k8s.io/vsphere-csi-driver/v3/pkg/kubernetes"

v1 "k8s.io/api/core/v1"
storagev1 "k8s.io/api/storage/v1"
Expand Down Expand Up @@ -69,6 +72,7 @@ var _ = ginkgo.Describe("Volume Snapshot Basic Test", func() {
defaultDatastore *object.Datastore
defaultDatacenter *object.Datacenter
isVsanHealthServiceStopped bool
cnsOperatorClient k8sClient.Client
)

ginkgo.BeforeEach(func() {
Expand All @@ -82,6 +86,8 @@ var _ = ginkgo.Describe("Volume Snapshot Basic Test", func() {
if !(len(nodeList.Items) > 0) {
framework.Failf("Unable to find ready and schedulable Node")
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

//Get snapshot client using the rest config
if !guestCluster {
Expand Down Expand Up @@ -148,6 +154,10 @@ var _ = ginkgo.Describe("Volume Snapshot Basic Test", func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred())
}
}
cnsOperatorClient, err = k8s.NewClientForGroup(ctx, f.ClientConfig(), cnsoperatorv1alpha1.GroupName)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

enableFullSyncTriggerFss(ctx, client, csiSystemNamespace, fullSyncFss)
})

ginkgo.AfterEach(func() {
Expand Down Expand Up @@ -3896,22 +3906,8 @@ var _ = ginkgo.Describe("Volume Snapshot Basic Test", func() {
// After reboot.
bootstrap()

fullSyncWaitTime := 0

if os.Getenv(envFullSyncWaitTime) != "" {
fullSyncWaitTime, err = strconv.Atoi(os.Getenv(envFullSyncWaitTime))
gomega.Expect(err).NotTo(gomega.HaveOccurred())
// Full sync interval can be 1 min at minimum so full sync wait time
// has to be more than 120s.
if fullSyncWaitTime < 120 || fullSyncWaitTime > defaultFullSyncWaitTime {
framework.Failf("The FullSync Wait time %v is not set correctly", fullSyncWaitTime)
}
} else {
fullSyncWaitTime = defaultFullSyncWaitTime
}

ginkgo.By(fmt.Sprintf("Double Sleeping for %v seconds to allow full sync finish", fullSyncWaitTime))
time.Sleep(time.Duration(2*fullSyncWaitTime) * time.Second)
ginkgo.By("Trigger 2 full syncs")
triggerFullSync(ctx, client, cnsOperatorClient)

ginkgo.By("Verify volume snapshot is created")
for _, snapshot := range volumesnapshots {
Expand Down Expand Up @@ -7086,16 +7082,6 @@ var _ = ginkgo.Describe("Volume Snapshot Basic Test", func() {
//After reboot
bootstrap()

fullSyncWaitTime := 0

if os.Getenv(envFullSyncWaitTime) != "" {
fullSyncWaitTime, err = strconv.Atoi(os.Getenv(envFullSyncWaitTime))
gomega.Expect(err).NotTo(gomega.HaveOccurred())
if fullSyncWaitTime < 120 || fullSyncWaitTime > defaultFullSyncWaitTime {
framework.Failf("The FullSync Wait time %v is not set correctly", fullSyncWaitTime)
}
}

ginkgo.By("Wait for the PVC to be bound")
_, err = fpv.WaitForPVClaimBoundPhase(client, pvclaims2, framework.ClaimProvisionTimeout)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
Expand Down
Loading