mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Clean shutdown of persistentvolume integration tests
This commit is contained in:
parent
f68e72a360
commit
c6e3bd732e
@ -20,7 +20,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http/httptest"
|
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
@ -36,13 +35,13 @@ import (
|
|||||||
restclient "k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
ref "k8s.io/client-go/tools/reference"
|
ref "k8s.io/client-go/tools/reference"
|
||||||
fakecloud "k8s.io/cloud-provider/fake"
|
fakecloud "k8s.io/cloud-provider/fake"
|
||||||
|
kubeapiservertesting "k8s.io/kubernetes/cmd/kube-apiserver/app/testing"
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
persistentvolumecontroller "k8s.io/kubernetes/pkg/controller/volume/persistentvolume"
|
persistentvolumecontroller "k8s.io/kubernetes/pkg/controller/volume/persistentvolume"
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
volumetest "k8s.io/kubernetes/pkg/volume/testing"
|
volumetest "k8s.io/kubernetes/pkg/volume/testing"
|
||||||
"k8s.io/kubernetes/test/integration/framework"
|
"k8s.io/kubernetes/test/integration/framework"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -105,16 +104,17 @@ func testSleep() {
|
|||||||
|
|
||||||
func TestPersistentVolumeRecycler(t *testing.T) {
|
func TestPersistentVolumeRecycler(t *testing.T) {
|
||||||
klog.V(2).Infof("TestPersistentVolumeRecycler started")
|
klog.V(2).Infof("TestPersistentVolumeRecycler started")
|
||||||
_, s, closeFn := framework.RunAnAPIServer(nil)
|
s := kubeapiservertesting.StartTestServerOrDie(t, nil, []string{"--disable-admission-plugins=ServiceAccount,StorageObjectInUseProtection"}, framework.SharedEtcd())
|
||||||
defer closeFn()
|
defer s.TearDownFn()
|
||||||
|
namespaceName := "pv-recycler"
|
||||||
|
|
||||||
ns := framework.CreateTestingNamespace("pv-recycler", t)
|
testClient, ctrl, informers, watchPV, watchPVC := createClients(namespaceName, t, s, defaultSyncPeriod)
|
||||||
defer framework.DeleteTestingNamespace(ns, t)
|
|
||||||
|
|
||||||
testClient, ctrl, informers, watchPV, watchPVC := createClients(ns, t, s, defaultSyncPeriod)
|
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
|
|
||||||
|
ns := framework.CreateNamespaceOrDie(testClient, namespaceName, t)
|
||||||
|
defer framework.DeleteNamespaceOrDie(testClient, ns, t)
|
||||||
|
|
||||||
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
||||||
// non-namespaced objects (PersistenceVolumes).
|
// non-namespaced objects (PersistenceVolumes).
|
||||||
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
||||||
@ -160,16 +160,17 @@ func TestPersistentVolumeRecycler(t *testing.T) {
|
|||||||
|
|
||||||
func TestPersistentVolumeDeleter(t *testing.T) {
|
func TestPersistentVolumeDeleter(t *testing.T) {
|
||||||
klog.V(2).Infof("TestPersistentVolumeDeleter started")
|
klog.V(2).Infof("TestPersistentVolumeDeleter started")
|
||||||
_, s, closeFn := framework.RunAnAPIServer(nil)
|
s := kubeapiservertesting.StartTestServerOrDie(t, nil, []string{"--disable-admission-plugins=ServiceAccount,StorageObjectInUseProtection"}, framework.SharedEtcd())
|
||||||
defer closeFn()
|
defer s.TearDownFn()
|
||||||
|
namespaceName := "pv-deleter"
|
||||||
|
|
||||||
ns := framework.CreateTestingNamespace("pv-deleter", t)
|
testClient, ctrl, informers, watchPV, watchPVC := createClients(namespaceName, t, s, defaultSyncPeriod)
|
||||||
defer framework.DeleteTestingNamespace(ns, t)
|
|
||||||
|
|
||||||
testClient, ctrl, informers, watchPV, watchPVC := createClients(ns, t, s, defaultSyncPeriod)
|
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
|
|
||||||
|
ns := framework.CreateNamespaceOrDie(testClient, namespaceName, t)
|
||||||
|
defer framework.DeleteNamespaceOrDie(testClient, ns, t)
|
||||||
|
|
||||||
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
||||||
// non-namespaced objects (PersistenceVolumes).
|
// non-namespaced objects (PersistenceVolumes).
|
||||||
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
||||||
@ -220,16 +221,17 @@ func TestPersistentVolumeBindRace(t *testing.T) {
|
|||||||
// Test a race binding many claims to a PV that is pre-bound to a specific
|
// Test a race binding many claims to a PV that is pre-bound to a specific
|
||||||
// PVC. Only this specific PVC should get bound.
|
// PVC. Only this specific PVC should get bound.
|
||||||
klog.V(2).Infof("TestPersistentVolumeBindRace started")
|
klog.V(2).Infof("TestPersistentVolumeBindRace started")
|
||||||
_, s, closeFn := framework.RunAnAPIServer(nil)
|
s := kubeapiservertesting.StartTestServerOrDie(t, nil, []string{"--disable-admission-plugins=ServiceAccount,StorageObjectInUseProtection"}, framework.SharedEtcd())
|
||||||
defer closeFn()
|
defer s.TearDownFn()
|
||||||
|
namespaceName := "pv-bind-race"
|
||||||
|
|
||||||
ns := framework.CreateTestingNamespace("pv-bind-race", t)
|
testClient, ctrl, informers, watchPV, watchPVC := createClients(namespaceName, t, s, defaultSyncPeriod)
|
||||||
defer framework.DeleteTestingNamespace(ns, t)
|
|
||||||
|
|
||||||
testClient, ctrl, informers, watchPV, watchPVC := createClients(ns, t, s, defaultSyncPeriod)
|
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
|
|
||||||
|
ns := framework.CreateNamespaceOrDie(testClient, namespaceName, t)
|
||||||
|
defer framework.DeleteNamespaceOrDie(testClient, ns, t)
|
||||||
|
|
||||||
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
||||||
// non-namespaced objects (PersistenceVolumes).
|
// non-namespaced objects (PersistenceVolumes).
|
||||||
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
||||||
@ -290,16 +292,17 @@ func TestPersistentVolumeBindRace(t *testing.T) {
|
|||||||
|
|
||||||
// TestPersistentVolumeClaimLabelSelector test binding using label selectors
|
// TestPersistentVolumeClaimLabelSelector test binding using label selectors
|
||||||
func TestPersistentVolumeClaimLabelSelector(t *testing.T) {
|
func TestPersistentVolumeClaimLabelSelector(t *testing.T) {
|
||||||
_, s, closeFn := framework.RunAnAPIServer(nil)
|
s := kubeapiservertesting.StartTestServerOrDie(t, nil, []string{"--disable-admission-plugins=ServiceAccount,StorageObjectInUseProtection"}, framework.SharedEtcd())
|
||||||
defer closeFn()
|
defer s.TearDownFn()
|
||||||
|
namespaceName := "pvc-label-selector"
|
||||||
|
|
||||||
ns := framework.CreateTestingNamespace("pvc-label-selector", t)
|
testClient, controller, informers, watchPV, watchPVC := createClients(namespaceName, t, s, defaultSyncPeriod)
|
||||||
defer framework.DeleteTestingNamespace(ns, t)
|
|
||||||
|
|
||||||
testClient, controller, informers, watchPV, watchPVC := createClients(ns, t, s, defaultSyncPeriod)
|
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
|
|
||||||
|
ns := framework.CreateNamespaceOrDie(testClient, namespaceName, t)
|
||||||
|
defer framework.DeleteNamespaceOrDie(testClient, ns, t)
|
||||||
|
|
||||||
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
||||||
// non-namespaced objects (PersistenceVolumes).
|
// non-namespaced objects (PersistenceVolumes).
|
||||||
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
||||||
@ -371,16 +374,17 @@ func TestPersistentVolumeClaimLabelSelector(t *testing.T) {
|
|||||||
// TestPersistentVolumeClaimLabelSelectorMatchExpressions test binding using
|
// TestPersistentVolumeClaimLabelSelectorMatchExpressions test binding using
|
||||||
// MatchExpressions label selectors
|
// MatchExpressions label selectors
|
||||||
func TestPersistentVolumeClaimLabelSelectorMatchExpressions(t *testing.T) {
|
func TestPersistentVolumeClaimLabelSelectorMatchExpressions(t *testing.T) {
|
||||||
_, s, closeFn := framework.RunAnAPIServer(nil)
|
s := kubeapiservertesting.StartTestServerOrDie(t, nil, []string{"--disable-admission-plugins=ServiceAccount,StorageObjectInUseProtection"}, framework.SharedEtcd())
|
||||||
defer closeFn()
|
defer s.TearDownFn()
|
||||||
|
namespaceName := "pvc-match-expressions"
|
||||||
|
|
||||||
ns := framework.CreateTestingNamespace("pvc-match-expressions", t)
|
testClient, controller, informers, watchPV, watchPVC := createClients(namespaceName, t, s, defaultSyncPeriod)
|
||||||
defer framework.DeleteTestingNamespace(ns, t)
|
|
||||||
|
|
||||||
testClient, controller, informers, watchPV, watchPVC := createClients(ns, t, s, defaultSyncPeriod)
|
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
|
|
||||||
|
ns := framework.CreateNamespaceOrDie(testClient, namespaceName, t)
|
||||||
|
defer framework.DeleteNamespaceOrDie(testClient, ns, t)
|
||||||
|
|
||||||
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
||||||
// non-namespaced objects (PersistenceVolumes).
|
// non-namespaced objects (PersistenceVolumes).
|
||||||
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
||||||
@ -471,16 +475,17 @@ func TestPersistentVolumeClaimLabelSelectorMatchExpressions(t *testing.T) {
|
|||||||
// TestPersistentVolumeMultiPVs tests binding of one PVC to 100 PVs with
|
// TestPersistentVolumeMultiPVs tests binding of one PVC to 100 PVs with
|
||||||
// different size.
|
// different size.
|
||||||
func TestPersistentVolumeMultiPVs(t *testing.T) {
|
func TestPersistentVolumeMultiPVs(t *testing.T) {
|
||||||
_, s, closeFn := framework.RunAnAPIServer(nil)
|
s := kubeapiservertesting.StartTestServerOrDie(t, nil, []string{"--disable-admission-plugins=ServiceAccount,StorageObjectInUseProtection"}, framework.SharedEtcd())
|
||||||
defer closeFn()
|
defer s.TearDownFn()
|
||||||
|
namespaceName := "multi-pvs"
|
||||||
|
|
||||||
ns := framework.CreateTestingNamespace("multi-pvs", t)
|
testClient, controller, informers, watchPV, watchPVC := createClients(namespaceName, t, s, defaultSyncPeriod)
|
||||||
defer framework.DeleteTestingNamespace(ns, t)
|
|
||||||
|
|
||||||
testClient, controller, informers, watchPV, watchPVC := createClients(ns, t, s, defaultSyncPeriod)
|
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
|
|
||||||
|
ns := framework.CreateNamespaceOrDie(testClient, namespaceName, t)
|
||||||
|
defer framework.DeleteNamespaceOrDie(testClient, ns, t)
|
||||||
|
|
||||||
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
||||||
// non-namespaced objects (PersistenceVolumes).
|
// non-namespaced objects (PersistenceVolumes).
|
||||||
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
||||||
@ -561,16 +566,17 @@ func TestPersistentVolumeMultiPVs(t *testing.T) {
|
|||||||
// TestPersistentVolumeMultiPVsPVCs tests binding of 100 PVC to 100 PVs.
|
// TestPersistentVolumeMultiPVsPVCs tests binding of 100 PVC to 100 PVs.
|
||||||
// This test is configurable by KUBE_INTEGRATION_PV_* variables.
|
// This test is configurable by KUBE_INTEGRATION_PV_* variables.
|
||||||
func TestPersistentVolumeMultiPVsPVCs(t *testing.T) {
|
func TestPersistentVolumeMultiPVsPVCs(t *testing.T) {
|
||||||
_, s, closeFn := framework.RunAnAPIServer(nil)
|
s := kubeapiservertesting.StartTestServerOrDie(t, nil, []string{"--disable-admission-plugins=ServiceAccount,StorageObjectInUseProtection"}, framework.SharedEtcd())
|
||||||
defer closeFn()
|
defer s.TearDownFn()
|
||||||
|
namespaceName := "multi-pvs-pvcs"
|
||||||
|
|
||||||
ns := framework.CreateTestingNamespace("multi-pvs-pvcs", t)
|
testClient, binder, informers, watchPV, watchPVC := createClients(namespaceName, t, s, defaultSyncPeriod)
|
||||||
defer framework.DeleteTestingNamespace(ns, t)
|
|
||||||
|
|
||||||
testClient, binder, informers, watchPV, watchPVC := createClients(ns, t, s, defaultSyncPeriod)
|
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
|
|
||||||
|
ns := framework.CreateNamespaceOrDie(testClient, namespaceName, t)
|
||||||
|
defer framework.DeleteNamespaceOrDie(testClient, ns, t)
|
||||||
|
|
||||||
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
||||||
// non-namespaced objects (PersistenceVolumes).
|
// non-namespaced objects (PersistenceVolumes).
|
||||||
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
||||||
@ -721,21 +727,22 @@ func TestPersistentVolumeMultiPVsPVCs(t *testing.T) {
|
|||||||
// TestPersistentVolumeControllerStartup tests startup of the controller.
|
// TestPersistentVolumeControllerStartup tests startup of the controller.
|
||||||
// The controller should not unbind any volumes when it starts.
|
// The controller should not unbind any volumes when it starts.
|
||||||
func TestPersistentVolumeControllerStartup(t *testing.T) {
|
func TestPersistentVolumeControllerStartup(t *testing.T) {
|
||||||
_, s, closeFn := framework.RunAnAPIServer(nil)
|
s := kubeapiservertesting.StartTestServerOrDie(t, nil, []string{"--disable-admission-plugins=ServiceAccount,StorageObjectInUseProtection"}, framework.SharedEtcd())
|
||||||
defer closeFn()
|
defer s.TearDownFn()
|
||||||
|
namespaceName := "controller-startup"
|
||||||
ns := framework.CreateTestingNamespace("controller-startup", t)
|
|
||||||
defer framework.DeleteTestingNamespace(ns, t)
|
|
||||||
|
|
||||||
objCount := getObjectCount()
|
objCount := getObjectCount()
|
||||||
|
|
||||||
const shortSyncPeriod = 2 * time.Second
|
const shortSyncPeriod = 2 * time.Second
|
||||||
syncPeriod := getSyncPeriod(shortSyncPeriod)
|
syncPeriod := getSyncPeriod(shortSyncPeriod)
|
||||||
|
|
||||||
testClient, binder, informers, watchPV, watchPVC := createClients(ns, t, s, shortSyncPeriod)
|
testClient, binder, informers, watchPV, watchPVC := createClients(namespaceName, t, s, shortSyncPeriod)
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
|
|
||||||
|
ns := framework.CreateNamespaceOrDie(testClient, namespaceName, t)
|
||||||
|
defer framework.DeleteNamespaceOrDie(testClient, ns, t)
|
||||||
|
|
||||||
// Create *bound* volumes and PVCs
|
// Create *bound* volumes and PVCs
|
||||||
pvs := make([]*v1.PersistentVolume, objCount)
|
pvs := make([]*v1.PersistentVolume, objCount)
|
||||||
pvcs := make([]*v1.PersistentVolumeClaim, objCount)
|
pvcs := make([]*v1.PersistentVolumeClaim, objCount)
|
||||||
@ -850,16 +857,17 @@ func TestPersistentVolumeControllerStartup(t *testing.T) {
|
|||||||
// TestPersistentVolumeProvisionMultiPVCs tests provisioning of many PVCs.
|
// TestPersistentVolumeProvisionMultiPVCs tests provisioning of many PVCs.
|
||||||
// This test is configurable by KUBE_INTEGRATION_PV_* variables.
|
// This test is configurable by KUBE_INTEGRATION_PV_* variables.
|
||||||
func TestPersistentVolumeProvisionMultiPVCs(t *testing.T) {
|
func TestPersistentVolumeProvisionMultiPVCs(t *testing.T) {
|
||||||
_, s, closeFn := framework.RunAnAPIServer(nil)
|
s := kubeapiservertesting.StartTestServerOrDie(t, nil, []string{"--disable-admission-plugins=ServiceAccount,StorageObjectInUseProtection"}, framework.SharedEtcd())
|
||||||
defer closeFn()
|
defer s.TearDownFn()
|
||||||
|
namespaceName := "provision-multi-pvs"
|
||||||
|
|
||||||
ns := framework.CreateTestingNamespace("provision-multi-pvs", t)
|
testClient, binder, informers, watchPV, watchPVC := createClients(namespaceName, t, s, defaultSyncPeriod)
|
||||||
defer framework.DeleteTestingNamespace(ns, t)
|
|
||||||
|
|
||||||
testClient, binder, informers, watchPV, watchPVC := createClients(ns, t, s, defaultSyncPeriod)
|
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
|
|
||||||
|
ns := framework.CreateNamespaceOrDie(testClient, namespaceName, t)
|
||||||
|
defer framework.DeleteNamespaceOrDie(testClient, ns, t)
|
||||||
|
|
||||||
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
||||||
// non-namespaced objects (PersistenceVolumes and StorageClasses).
|
// non-namespaced objects (PersistenceVolumes and StorageClasses).
|
||||||
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
||||||
@ -945,16 +953,17 @@ func TestPersistentVolumeProvisionMultiPVCs(t *testing.T) {
|
|||||||
// TestPersistentVolumeMultiPVsDiffAccessModes tests binding of one PVC to two
|
// TestPersistentVolumeMultiPVsDiffAccessModes tests binding of one PVC to two
|
||||||
// PVs with different access modes.
|
// PVs with different access modes.
|
||||||
func TestPersistentVolumeMultiPVsDiffAccessModes(t *testing.T) {
|
func TestPersistentVolumeMultiPVsDiffAccessModes(t *testing.T) {
|
||||||
_, s, closeFn := framework.RunAnAPIServer(nil)
|
s := kubeapiservertesting.StartTestServerOrDie(t, nil, []string{"--disable-admission-plugins=ServiceAccount,StorageObjectInUseProtection"}, framework.SharedEtcd())
|
||||||
defer closeFn()
|
defer s.TearDownFn()
|
||||||
|
namespaceName := "multi-pvs-diff-access"
|
||||||
|
|
||||||
ns := framework.CreateTestingNamespace("multi-pvs-diff-access", t)
|
testClient, controller, informers, watchPV, watchPVC := createClients(namespaceName, t, s, defaultSyncPeriod)
|
||||||
defer framework.DeleteTestingNamespace(ns, t)
|
|
||||||
|
|
||||||
testClient, controller, informers, watchPV, watchPVC := createClients(ns, t, s, defaultSyncPeriod)
|
|
||||||
defer watchPV.Stop()
|
defer watchPV.Stop()
|
||||||
defer watchPVC.Stop()
|
defer watchPVC.Stop()
|
||||||
|
|
||||||
|
ns := framework.CreateNamespaceOrDie(testClient, namespaceName, t)
|
||||||
|
defer framework.DeleteNamespaceOrDie(testClient, ns, t)
|
||||||
|
|
||||||
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
// NOTE: This test cannot run in parallel, because it is creating and deleting
|
||||||
// non-namespaced objects (PersistenceVolumes).
|
// non-namespaced objects (PersistenceVolumes).
|
||||||
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
defer testClient.CoreV1().PersistentVolumes().DeleteCollection(context.TODO(), metav1.DeleteOptions{}, metav1.ListOptions{})
|
||||||
@ -1093,21 +1102,17 @@ func waitForAnyPersistentVolumeClaimPhase(w watch.Interface, phase v1.Persistent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createClients(ns *v1.Namespace, t *testing.T, s *httptest.Server, syncPeriod time.Duration) (*clientset.Clientset, *persistentvolumecontroller.PersistentVolumeController, informers.SharedInformerFactory, watch.Interface, watch.Interface) {
|
func createClients(namespaceName string, t *testing.T, s *kubeapiservertesting.TestServer, syncPeriod time.Duration) (*clientset.Clientset, *persistentvolumecontroller.PersistentVolumeController, informers.SharedInformerFactory, watch.Interface, watch.Interface) {
|
||||||
// Use higher QPS and Burst, there is a test for race conditions which
|
// Use higher QPS and Burst, there is a test for race conditions which
|
||||||
// creates many objects and default values were too low.
|
// creates many objects and default values were too low.
|
||||||
binderClient := clientset.NewForConfigOrDie(&restclient.Config{
|
binderConfig := restclient.CopyConfig(s.ClientConfig)
|
||||||
Host: s.URL,
|
binderConfig.QPS = 1000000
|
||||||
ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}},
|
binderConfig.Burst = 1000000
|
||||||
QPS: 1000000,
|
binderClient := clientset.NewForConfigOrDie(binderConfig)
|
||||||
Burst: 1000000,
|
testConfig := restclient.CopyConfig(s.ClientConfig)
|
||||||
})
|
testConfig.QPS = 1000000
|
||||||
testClient := clientset.NewForConfigOrDie(&restclient.Config{
|
testConfig.Burst = 1000000
|
||||||
Host: s.URL,
|
testClient := clientset.NewForConfigOrDie(testConfig)
|
||||||
ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}},
|
|
||||||
QPS: 1000000,
|
|
||||||
Burst: 1000000,
|
|
||||||
})
|
|
||||||
|
|
||||||
host := volumetest.NewFakeVolumeHost(t, "/tmp/fake", nil, nil)
|
host := volumetest.NewFakeVolumeHost(t, "/tmp/fake", nil, nil)
|
||||||
plugin := &volumetest.FakeVolumePlugin{
|
plugin := &volumetest.FakeVolumePlugin{
|
||||||
@ -1146,7 +1151,7 @@ func createClients(ns *v1.Namespace, t *testing.T, s *httptest.Server, syncPerio
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to watch PersistentVolumes: %v", err)
|
t.Fatalf("Failed to watch PersistentVolumes: %v", err)
|
||||||
}
|
}
|
||||||
watchPVC, err := testClient.CoreV1().PersistentVolumeClaims(ns.Name).Watch(context.TODO(), metav1.ListOptions{})
|
watchPVC, err := testClient.CoreV1().PersistentVolumeClaims(namespaceName).Watch(context.TODO(), metav1.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to watch PersistentVolumeClaims: %v", err)
|
t.Fatalf("Failed to watch PersistentVolumeClaims: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user