diff --git a/pkg/controller/persistentvolume/persistentvolume_controller_test.go b/pkg/controller/persistentvolume/persistentvolume_controller_test.go index 67a103d06a..552874f331 100644 --- a/pkg/controller/persistentvolume/persistentvolume_controller_test.go +++ b/pkg/controller/persistentvolume/persistentvolume_controller_test.go @@ -48,7 +48,7 @@ func TestControllerSync(t *testing.T) { newVolumeArray("volume5-1", "10Gi", "", "", api.VolumeAvailable, api.PersistentVolumeReclaimRetain), newClaimArray("claim5-1", "uid5-1", "1Gi", "", api.ClaimPending), newClaimArray("claim5-1", "uid5-1", "1Gi", "", api.ClaimPending), - noevents, + noevents, noerrors, // Custom test function that generates an add event func(ctrl *PersistentVolumeController, reactor *volumeReactor, test controllerTest) error { volume := newVolume("volume5-1", "10Gi", "", "", api.VolumePending, api.PersistentVolumeReclaimRetain) @@ -64,7 +64,7 @@ func TestControllerSync(t *testing.T) { newVolumeArray("volume5-2", "10Gi", "uid5-2", "claim5-2", api.VolumeBound, api.PersistentVolumeReclaimRetain, annBoundByController), noclaims, /* added in testAddClaim5_2 */ newClaimArray("claim5-2", "uid5-2", "1Gi", "volume5-2", api.ClaimBound, annBoundByController, annBindCompleted), - noevents, + noevents, noerrors, // Custom test function that generates an add event func(ctrl *PersistentVolumeController, reactor *volumeReactor, test controllerTest) error { claim := newClaim("claim5-2", "uid5-2", "1Gi", "", api.ClaimPending) @@ -80,7 +80,7 @@ func TestControllerSync(t *testing.T) { newVolumeArray("volume5-3", "10Gi", "uid5-3", "claim5-3", api.VolumeReleased, api.PersistentVolumeReclaimRetain, annBoundByController), newClaimArray("claim5-3", "uid5-3", "1Gi", "volume5-3", api.ClaimBound, annBoundByController, annBindCompleted), noclaims, - noevents, + noevents, noerrors, // Custom test function that generates a delete event func(ctrl *PersistentVolumeController, reactor *volumeReactor, test controllerTest) error { obj := ctrl.claims.List()[0] @@ -103,7 +103,7 @@ func TestControllerSync(t *testing.T) { novolumes, newClaimArray("claim5-4", "uid5-4", "1Gi", "volume5-4", api.ClaimBound, annBoundByController, annBindCompleted), newClaimArray("claim5-4", "uid5-4", "1Gi", "volume5-4", api.ClaimLost, annBoundByController, annBindCompleted), - []string{"Warning ClaimLost"}, + []string{"Warning ClaimLost"}, noerrors, // Custom test function that generates a delete event func(ctrl *PersistentVolumeController, reactor *volumeReactor, test controllerTest) error { obj := ctrl.volumes.store.List()[0] @@ -130,7 +130,7 @@ func TestControllerSync(t *testing.T) { claimSource := framework.NewFakeControllerSource() ctrl := newPersistentVolumeController(client) ctrl.initializeController(time.Minute, volumeSource, claimSource) - reactor := newVolumeReactor(client, ctrl, volumeSource, claimSource) + reactor := newVolumeReactor(client, ctrl, volumeSource, claimSource, test.errors) for _, claim := range test.initialClaims { claimSource.Add(claim) reactor.claims[claim.Name] = claim diff --git a/pkg/controller/persistentvolume/persistentvolume_delete_test.go b/pkg/controller/persistentvolume/persistentvolume_delete_test.go index c1a3dee955..03ef84b94d 100644 --- a/pkg/controller/persistentvolume/persistentvolume_delete_test.go +++ b/pkg/controller/persistentvolume/persistentvolume_delete_test.go @@ -36,7 +36,7 @@ func TestDeleteSync(t *testing.T) { novolumes, noclaims, noclaims, - noevents, + noevents, noerrors, // Inject deleter into the controller and call syncVolume. The // deleter simulates one delete() call that succeeds. wrapTestWithControllerConfig(operationDelete, []error{nil}, testSyncVolume), @@ -48,7 +48,7 @@ func TestDeleteSync(t *testing.T) { novolumes, noclaims, noclaims, - noevents, + noevents, noerrors, // Inject deleter into the controller and call syncVolume. The // deleter simulates one delete() call that succeeds. wrapTestWithControllerConfig(operationDelete, []error{nil}, testSyncVolume), @@ -60,7 +60,7 @@ func TestDeleteSync(t *testing.T) { newVolumeArray("volume8-3", "1Gi", "uid8-3", "claim8-3", api.VolumeFailed, api.PersistentVolumeReclaimDelete), noclaims, noclaims, - []string{"Warning VolumeFailedDelete"}, testSyncVolume, + []string{"Warning VolumeFailedDelete"}, noerrors, testSyncVolume, }, { // delete failure - newDeleter returns error @@ -69,7 +69,7 @@ func TestDeleteSync(t *testing.T) { newVolumeArray("volume8-4", "1Gi", "uid8-4", "claim8-4", api.VolumeFailed, api.PersistentVolumeReclaimDelete), noclaims, noclaims, - []string{"Warning VolumeFailedDelete"}, + []string{"Warning VolumeFailedDelete"}, noerrors, wrapTestWithControllerConfig(operationDelete, []error{}, testSyncVolume), }, { @@ -79,7 +79,7 @@ func TestDeleteSync(t *testing.T) { newVolumeArray("volume8-5", "1Gi", "uid8-5", "claim8-5", api.VolumeFailed, api.PersistentVolumeReclaimDelete), noclaims, noclaims, - []string{"Warning VolumeFailedDelete"}, + []string{"Warning VolumeFailedDelete"}, noerrors, wrapTestWithControllerConfig(operationDelete, []error{errors.New("Mock delete error")}, testSyncVolume), }, { @@ -89,7 +89,7 @@ func TestDeleteSync(t *testing.T) { novolumes, noclaims, noclaims, - noevents, + noevents, noerrors, wrapTestWithInjectedOperation(wrapTestWithControllerConfig(operationDelete, []error{}, testSyncVolume), func(ctrl *PersistentVolumeController, reactor *volumeReactor) { // Delete the volume before delete operation starts reactor.lock.Lock() @@ -106,7 +106,7 @@ func TestDeleteSync(t *testing.T) { newVolumeArray("volume8-7", "1Gi", "uid8-7", "claim8-7", api.VolumeBound, api.PersistentVolumeReclaimDelete, annBoundByController), noclaims, newClaimArray("claim8-7", "uid8-7", "10Gi", "volume8-7", api.ClaimBound), - noevents, + noevents, noerrors, wrapTestWithInjectedOperation(wrapTestWithControllerConfig(operationDelete, []error{}, testSyncVolume), func(ctrl *PersistentVolumeController, reactor *volumeReactor) { reactor.lock.Lock() defer reactor.lock.Unlock() @@ -127,7 +127,7 @@ func TestDeleteSync(t *testing.T) { novolumes, newClaimArray("claim8-9", "uid8-9-x", "10Gi", "", api.ClaimPending), newClaimArray("claim8-9", "uid8-9-x", "10Gi", "", api.ClaimPending), - noevents, + noevents, noerrors, // Inject deleter into the controller and call syncVolume. The // deleter simulates one delete() call that succeeds. wrapTestWithControllerConfig(operationDelete, []error{nil}, testSyncVolume), @@ -160,7 +160,7 @@ func TestDeleteMultiSync(t *testing.T) { novolumes, noclaims, noclaims, - []string{"Warning VolumeFailedDelete"}, + []string{"Warning VolumeFailedDelete"}, noerrors, wrapTestWithControllerConfig(operationDelete, []error{errors.New("Mock delete error"), nil}, testSyncVolume), }, } diff --git a/pkg/controller/persistentvolume/persistentvolume_framework_test.go b/pkg/controller/persistentvolume/persistentvolume_framework_test.go index 8558d89fcc..b1f798d0f0 100644 --- a/pkg/controller/persistentvolume/persistentvolume_framework_test.go +++ b/pkg/controller/persistentvolume/persistentvolume_framework_test.go @@ -83,6 +83,8 @@ type controllerTest struct { // Expected events - any event with prefix will pass, we don't check full // event message. expectedEvents []string + // Errors to produce on matching action + errors []reactorError // Function to call as the test. test testCall } @@ -96,6 +98,7 @@ var versionConflictError = errors.New("VersionError") var novolumes []*api.PersistentVolume var noclaims []*api.PersistentVolumeClaim var noevents = []string{} +var noerrors = []reactorError{} // volumeReactor is a core.Reactor that simulates etcd and API server. It // stores: @@ -108,6 +111,11 @@ var noevents = []string{} // - Optionally, volume and claim event sources. When set, all changed // volumes/claims are sent as Modify event to these sources. These sources can // be linked back to the controller watcher as "volume/claim updated" events. +// - Optionally, list of error that should be returned by reactor, simulating +// etcd / API server failures. These errors are evaluated in order and every +// error is returned only once. I.e. when the reactor finds matching +// reactorError, it return appropriate error and removes the reactorError from +// the list. type volumeReactor struct { volumes map[string]*api.PersistentVolume claims map[string]*api.PersistentVolumeClaim @@ -117,6 +125,17 @@ type volumeReactor struct { volumeSource *framework.FakeControllerSource claimSource *framework.FakeControllerSource lock sync.Mutex + errors []reactorError +} + +// reactorError is an error that is returned by test reactor (=simulated +// etcd+/API server) when an action performed by the reactor matches given verb +// ("get", "update", "create", "delete" or "*"") on given resource +// ("persistentvolumes", "persistentvolumeclaims" or "*"). +type reactorError struct { + verb string + resource string + error error } // React is a callback called by fake kubeClient from the controller. @@ -134,6 +153,13 @@ func (r *volumeReactor) React(action core.Action) (handled bool, ret runtime.Obj glog.V(4).Infof("reactor got operation %q on %q", action.GetVerb(), action.GetResource()) + // Inject error when requested + err = r.injectReactError(action) + if err != nil { + return true, nil, err + } + + // Test did not requst to inject an error, continue simulating API server. switch { case action.Matches("create", "persistentvolumes"): obj := action.(core.UpdateAction).GetObject() @@ -246,6 +272,26 @@ func (r *volumeReactor) React(action core.Action) (handled bool, ret runtime.Obj return false, nil, nil } +// injectReactError returns an error when the test requested given action to +// fail. nil is returned otherwise. +func (r *volumeReactor) injectReactError(action core.Action) error { + if len(r.errors) == 0 { + // No more errors to inject, everything should succeed. + return nil + } + + for i, expected := range r.errors { + glog.V(4).Infof("trying to match %q %q with %q %q", expected.verb, expected.resource, action.GetVerb(), action.GetResource()) + if action.Matches(expected.verb, expected.resource) { + // That's the action we're waiting for, remove it from injectedErrors + r.errors = append(r.errors[:i], r.errors[i+1:]...) + glog.V(4).Infof("reactor found matching error at index %d: %q %q, returning %v", i, expected.verb, expected.resource, expected.error) + return expected.error + } + } + return nil +} + // checkVolumes compares all expectedVolumes with set of volumes at the end of // the test and reports differences. func (r *volumeReactor) checkVolumes(t *testing.T, expectedVolumes []*api.PersistentVolume) error { @@ -425,13 +471,14 @@ func (r *volumeReactor) waitTest() { } } -func newVolumeReactor(client *fake.Clientset, ctrl *PersistentVolumeController, volumeSource, claimSource *framework.FakeControllerSource) *volumeReactor { +func newVolumeReactor(client *fake.Clientset, ctrl *PersistentVolumeController, volumeSource, claimSource *framework.FakeControllerSource, errors []reactorError) *volumeReactor { reactor := &volumeReactor{ volumes: make(map[string]*api.PersistentVolume), claims: make(map[string]*api.PersistentVolumeClaim), ctrl: ctrl, volumeSource: volumeSource, claimSource: claimSource, + errors: errors, } client.AddReactor("*", "*", reactor.React) return reactor @@ -677,7 +724,7 @@ func runSyncTests(t *testing.T, tests []controllerTest) { // Initialize the controller client := &fake.Clientset{} ctrl := newPersistentVolumeController(client) - reactor := newVolumeReactor(client, ctrl, nil, nil) + reactor := newVolumeReactor(client, ctrl, nil, nil, test.errors) for _, claim := range test.initialClaims { ctrl.claims.Add(claim) reactor.claims[claim.Name] = claim @@ -721,7 +768,7 @@ func runMultisyncTests(t *testing.T, tests []controllerTest) { // Initialize the controller client := &fake.Clientset{} ctrl := newPersistentVolumeController(client) - reactor := newVolumeReactor(client, ctrl, nil, nil) + reactor := newVolumeReactor(client, ctrl, nil, nil, test.errors) for _, claim := range test.initialClaims { ctrl.claims.Add(claim) reactor.claims[claim.Name] = claim diff --git a/pkg/controller/persistentvolume/persistentvolume_provision_test.go b/pkg/controller/persistentvolume/persistentvolume_provision_test.go index 5655c4e629..ecfa165d08 100644 --- a/pkg/controller/persistentvolume/persistentvolume_provision_test.go +++ b/pkg/controller/persistentvolume/persistentvolume_provision_test.go @@ -37,7 +37,7 @@ func TestProvisionSync(t *testing.T) { newClaimArray("claim11-1", "uid11-1", "1Gi", "", api.ClaimPending, annClass), // Binding will be completed in the next syncClaim newClaimArray("claim11-1", "uid11-1", "1Gi", "", api.ClaimPending, annClass), - noevents, wrapTestWithControllerConfig(operationProvision, []error{nil}, testSyncClaim), + noevents, noerrors, wrapTestWithControllerConfig(operationProvision, []error{nil}, testSyncClaim), }, { // Provision failure - plugin not found @@ -46,7 +46,7 @@ func TestProvisionSync(t *testing.T) { novolumes, newClaimArray("claim11-2", "uid11-2", "1Gi", "", api.ClaimPending, annClass), newClaimArray("claim11-2", "uid11-2", "1Gi", "", api.ClaimPending, annClass), - []string{"Warning ProvisioningFailed"}, + []string{"Warning ProvisioningFailed"}, noerrors, testSyncClaim, }, { @@ -56,7 +56,7 @@ func TestProvisionSync(t *testing.T) { novolumes, newClaimArray("claim11-3", "uid11-3", "1Gi", "", api.ClaimPending, annClass), newClaimArray("claim11-3", "uid11-3", "1Gi", "", api.ClaimPending, annClass), - []string{"Warning ProvisioningFailed"}, + []string{"Warning ProvisioningFailed"}, noerrors, wrapTestWithControllerConfig(operationProvision, []error{}, testSyncClaim), }, { @@ -66,7 +66,7 @@ func TestProvisionSync(t *testing.T) { novolumes, newClaimArray("claim11-4", "uid11-4", "1Gi", "", api.ClaimPending, annClass), newClaimArray("claim11-4", "uid11-4", "1Gi", "", api.ClaimPending, annClass), - []string{"Warning ProvisioningFailed"}, + []string{"Warning ProvisioningFailed"}, noerrors, wrapTestWithControllerConfig(operationProvision, []error{errors.New("Moc provisioner error")}, testSyncClaim), }, { @@ -129,7 +129,7 @@ func TestProvisionMultiSync(t *testing.T) { newClaimArray("claim12-1", "uid12-1", "1Gi", "", api.ClaimPending, annClass), // Binding will be completed in the next syncClaim newClaimArray("claim12-1", "uid12-1", "1Gi", "pv-provisioned-for-uid12-1", api.ClaimBound, annClass, annBoundByController, annBindCompleted), - noevents, wrapTestWithControllerConfig(operationProvision, []error{nil}, testSyncClaim), + noevents, noerrors, wrapTestWithControllerConfig(operationProvision, []error{nil}, testSyncClaim), }, } diff --git a/pkg/controller/persistentvolume/persistentvolume_recycle_test.go b/pkg/controller/persistentvolume/persistentvolume_recycle_test.go index acac9436a2..14203b04c4 100644 --- a/pkg/controller/persistentvolume/persistentvolume_recycle_test.go +++ b/pkg/controller/persistentvolume/persistentvolume_recycle_test.go @@ -36,7 +36,7 @@ func TestRecycleSync(t *testing.T) { newVolumeArray("volume6-1", "1Gi", "", "", api.VolumeAvailable, api.PersistentVolumeReclaimRecycle), noclaims, noclaims, - noevents, + noevents, noerrors, // Inject recycler into the controller and call syncVolume. The // recycler simulates one recycle() call that succeeds. wrapTestWithControllerConfig(operationRecycle, []error{nil}, testSyncVolume), @@ -48,7 +48,7 @@ func TestRecycleSync(t *testing.T) { newVolumeArray("volume6-2", "1Gi", "", "claim6-2", api.VolumeAvailable, api.PersistentVolumeReclaimRecycle), noclaims, noclaims, - noevents, + noevents, noerrors, // Inject recycler into the controller and call syncVolume. The // recycler simulates one recycle() call that succeeds. wrapTestWithControllerConfig(operationRecycle, []error{nil}, testSyncVolume), @@ -60,7 +60,7 @@ func TestRecycleSync(t *testing.T) { newVolumeArray("volume6-3", "1Gi", "uid6-3", "claim6-3", api.VolumeFailed, api.PersistentVolumeReclaimRecycle), noclaims, noclaims, - []string{"Warning VolumeFailedRecycle"}, testSyncVolume, + []string{"Warning VolumeFailedRecycle"}, noerrors, testSyncVolume, }, { // recycle failure - newRecycler returns error @@ -69,7 +69,7 @@ func TestRecycleSync(t *testing.T) { newVolumeArray("volume6-4", "1Gi", "uid6-4", "claim6-4", api.VolumeFailed, api.PersistentVolumeReclaimRecycle), noclaims, noclaims, - []string{"Warning VolumeFailedRecycle"}, + []string{"Warning VolumeFailedRecycle"}, noerrors, wrapTestWithControllerConfig(operationRecycle, []error{}, testSyncVolume), }, { @@ -79,7 +79,7 @@ func TestRecycleSync(t *testing.T) { newVolumeArray("volume6-5", "1Gi", "uid6-5", "claim6-5", api.VolumeFailed, api.PersistentVolumeReclaimRecycle), noclaims, noclaims, - []string{"Warning VolumeFailedRecycle"}, + []string{"Warning VolumeFailedRecycle"}, noerrors, wrapTestWithControllerConfig(operationRecycle, []error{errors.New("Mock recycle error")}, testSyncVolume), }, { @@ -89,7 +89,7 @@ func TestRecycleSync(t *testing.T) { novolumes, noclaims, noclaims, - noevents, + noevents, noerrors, wrapTestWithInjectedOperation(wrapTestWithControllerConfig(operationRecycle, []error{}, testSyncVolume), func(ctrl *PersistentVolumeController, reactor *volumeReactor) { // Delete the volume before recycle operation starts reactor.lock.Lock() @@ -106,7 +106,7 @@ func TestRecycleSync(t *testing.T) { newVolumeArray("volume6-7", "1Gi", "", "", api.VolumeAvailable, api.PersistentVolumeReclaimRecycle), noclaims, noclaims, - noevents, + noevents, noerrors, wrapTestWithInjectedOperation(wrapTestWithControllerConfig(operationRecycle, []error{}, testSyncVolume), func(ctrl *PersistentVolumeController, reactor *volumeReactor) { // Mark the volume as Available before the recycler starts reactor.lock.Lock() @@ -127,7 +127,7 @@ func TestRecycleSync(t *testing.T) { newVolumeArray("volume6-8", "1Gi", "", "claim6-8", api.VolumeAvailable, api.PersistentVolumeReclaimRecycle), noclaims, noclaims, - noevents, + noevents, noerrors, wrapTestWithInjectedOperation(wrapTestWithControllerConfig(operationRecycle, []error{}, testSyncVolume), func(ctrl *PersistentVolumeController, reactor *volumeReactor) { // Mark the volume as Available before the recycler starts reactor.lock.Lock() @@ -145,7 +145,7 @@ func TestRecycleSync(t *testing.T) { newVolumeArray("volume6-9", "1Gi", "", "claim6-9", api.VolumeAvailable, api.PersistentVolumeReclaimRecycle), newClaimArray("claim6-9", "uid6-9-x", "10Gi", "", api.ClaimPending), newClaimArray("claim6-9", "uid6-9-x", "10Gi", "", api.ClaimPending), - noevents, + noevents, noerrors, // Inject recycler into the controller and call syncVolume. The // recycler simulates one recycle() call that succeeds. wrapTestWithControllerConfig(operationRecycle, []error{nil}, testSyncVolume), @@ -157,7 +157,7 @@ func TestRecycleSync(t *testing.T) { newVolumeArray("volume6-10", "1Gi", "uid6-10", "claim6-10", api.VolumeFailed, "Unknown"), noclaims, noclaims, - []string{"Warning VolumeUnknownReclaimPolicy"}, testSyncVolume, + []string{"Warning VolumeUnknownReclaimPolicy"}, noerrors, testSyncVolume, }, } runSyncTests(t, tests) @@ -187,7 +187,7 @@ func TestRecycleMultiSync(t *testing.T) { newVolumeArray("volume7-1", "1Gi", "", "claim7-1", api.VolumeAvailable, api.PersistentVolumeReclaimRecycle), noclaims, noclaims, - []string{"Warning VolumeFailedRecycle"}, + []string{"Warning VolumeFailedRecycle"}, noerrors, wrapTestWithControllerConfig(operationRecycle, []error{errors.New("Mock recycle error"), nil}, testSyncVolume), }, } diff --git a/pkg/controller/persistentvolume/persistentvolume_sync_test.go b/pkg/controller/persistentvolume/persistentvolume_sync_test.go index 8cdb5442b8..b981c17d91 100644 --- a/pkg/controller/persistentvolume/persistentvolume_sync_test.go +++ b/pkg/controller/persistentvolume/persistentvolume_sync_test.go @@ -39,7 +39,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume1-1", "1Gi", "uid1-1", "claim1-1", api.VolumeBound, api.PersistentVolumeReclaimRetain, annBoundByController), newClaimArray("claim1-1", "uid1-1", "1Gi", "", api.ClaimPending), newClaimArray("claim1-1", "uid1-1", "1Gi", "volume1-1", api.ClaimBound, annBoundByController, annBindCompleted), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // syncClaim does not do anything when there is no matching volume. @@ -48,7 +48,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume1-2", "1Gi", "", "", api.VolumePending, api.PersistentVolumeReclaimRetain), newClaimArray("claim1-2", "uid1-2", "10Gi", "", api.ClaimPending), newClaimArray("claim1-2", "uid1-2", "10Gi", "", api.ClaimPending), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // syncClaim resets claim.Status to Pending when there is no @@ -58,7 +58,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume1-3", "1Gi", "", "", api.VolumePending, api.PersistentVolumeReclaimRetain), newClaimArray("claim1-3", "uid1-3", "10Gi", "", api.ClaimBound), newClaimArray("claim1-3", "uid1-3", "10Gi", "", api.ClaimPending), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // syncClaim binds claims to the smallest matching volume @@ -73,7 +73,7 @@ func TestSync(t *testing.T) { }, newClaimArray("claim1-4", "uid1-4", "1Gi", "", api.ClaimPending), newClaimArray("claim1-4", "uid1-4", "1Gi", "volume1-4_2", api.ClaimBound, annBoundByController, annBindCompleted), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // syncClaim binds a claim only to volume that points to it (by @@ -89,7 +89,7 @@ func TestSync(t *testing.T) { }, newClaimArray("claim1-5", "uid1-5", "1Gi", "", api.ClaimPending), newClaimArray("claim1-5", "uid1-5", "1Gi", "volume1-5_1", api.ClaimBound, annBoundByController, annBindCompleted), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // syncClaim binds a claim only to volume that points to it (by @@ -105,7 +105,7 @@ func TestSync(t *testing.T) { }, newClaimArray("claim1-6", "uid1-6", "1Gi", "", api.ClaimPending), newClaimArray("claim1-6", "uid1-6", "1Gi", "volume1-6_1", api.ClaimBound, annBoundByController, annBindCompleted), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // syncClaim does not bind claim to a volume prebound to a claim with @@ -115,7 +115,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume1-7", "10Gi", "uid1-777", "claim1-7", api.VolumePending, api.PersistentVolumeReclaimRetain), newClaimArray("claim1-7", "uid1-7", "1Gi", "", api.ClaimPending), newClaimArray("claim1-7", "uid1-7", "1Gi", "", api.ClaimPending), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // syncClaim completes binding - simulates controller crash after @@ -125,7 +125,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume1-8", "1Gi", "uid1-8", "claim1-8", api.VolumeBound, api.PersistentVolumeReclaimRetain, annBoundByController), newClaimArray("claim1-8", "uid1-8", "1Gi", "", api.ClaimPending), newClaimArray("claim1-8", "uid1-8", "1Gi", "volume1-8", api.ClaimBound, annBoundByController, annBindCompleted), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // syncClaim completes binding - simulates controller crash after @@ -135,7 +135,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume1-9", "1Gi", "uid1-9", "claim1-9", api.VolumeBound, api.PersistentVolumeReclaimRetain, annBoundByController), newClaimArray("claim1-9", "uid1-9", "1Gi", "", api.ClaimPending), newClaimArray("claim1-9", "uid1-9", "1Gi", "volume1-9", api.ClaimBound, annBoundByController, annBindCompleted), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // syncClaim completes binding - simulates controller crash after @@ -145,7 +145,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume1-10", "1Gi", "uid1-10", "claim1-10", api.VolumeBound, api.PersistentVolumeReclaimRetain, annBoundByController), newClaimArray("claim1-10", "uid1-10", "1Gi", "volume1-10", api.ClaimPending, annBoundByController, annBindCompleted), newClaimArray("claim1-10", "uid1-10", "1Gi", "volume1-10", api.ClaimBound, annBoundByController, annBindCompleted), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, // [Unit test set 2] User asked for a specific PV. // Test the binding when pv.ClaimRef is already set by controller or @@ -157,7 +157,7 @@ func TestSync(t *testing.T) { novolumes, newClaimArray("claim2-1", "uid2-1", "10Gi", "volume2-1", api.ClaimPending), newClaimArray("claim2-1", "uid2-1", "10Gi", "volume2-1", api.ClaimPending), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // syncClaim with claim pre-bound to a PV that does not exist. @@ -167,7 +167,7 @@ func TestSync(t *testing.T) { novolumes, newClaimArray("claim2-2", "uid2-2", "10Gi", "volume2-2", api.ClaimBound), newClaimArray("claim2-2", "uid2-2", "10Gi", "volume2-2", api.ClaimPending), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // syncClaim with claim pre-bound to a PV that exists and is @@ -177,7 +177,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume2-3", "1Gi", "uid2-3", "claim2-3", api.VolumeBound, api.PersistentVolumeReclaimRetain, annBoundByController), newClaimArray("claim2-3", "uid2-3", "10Gi", "volume2-3", api.ClaimPending), newClaimArray("claim2-3", "uid2-3", "10Gi", "volume2-3", api.ClaimBound, annBindCompleted), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // claim with claim pre-bound to a PV that is pre-bound to the claim @@ -187,7 +187,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume2-4", "1Gi", "uid2-4", "claim2-4", api.VolumeBound, api.PersistentVolumeReclaimRetain), newClaimArray("claim2-4", "uid2-4", "10Gi", "volume2-4", api.ClaimPending), newClaimArray("claim2-4", "uid2-4", "10Gi", "volume2-4", api.ClaimBound, annBindCompleted), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // syncClaim with claim pre-bound to a PV that is pre-bound to the @@ -198,7 +198,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume2-5", "1Gi", "uid2-5", "claim2-5", api.VolumeBound, api.PersistentVolumeReclaimRetain), newClaimArray("claim2-5", "uid2-5", "10Gi", "volume2-5", api.ClaimPending), newClaimArray("claim2-5", "uid2-5", "10Gi", "volume2-5", api.ClaimBound, annBindCompleted), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // syncClaim with claim pre-bound to a PV that is bound to different @@ -208,7 +208,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume2-6", "1Gi", "uid2-6_1", "claim2-6_1", api.VolumeBound, api.PersistentVolumeReclaimRetain), newClaimArray("claim2-6", "uid2-6", "10Gi", "volume2-6", api.ClaimBound), newClaimArray("claim2-6", "uid2-6", "10Gi", "volume2-6", api.ClaimPending), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // syncClaim with claim bound by controller to a PV that is bound to @@ -218,7 +218,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume2-7", "1Gi", "uid2-7_1", "claim2-7_1", api.VolumeBound, api.PersistentVolumeReclaimRetain), newClaimArray("claim2-7", "uid2-7", "10Gi", "volume2-7", api.ClaimBound, annBoundByController), newClaimArray("claim2-7", "uid2-7", "10Gi", "volume2-7", api.ClaimBound, annBoundByController), - noevents, testSyncClaimError, + noevents, noerrors, testSyncClaimError, }, // [Unit test set 3] Syncing bound claim { @@ -229,7 +229,7 @@ func TestSync(t *testing.T) { novolumes, newClaimArray("claim3-1", "uid3-1", "10Gi", "", api.ClaimBound, annBoundByController, annBindCompleted), newClaimArray("claim3-1", "uid3-1", "10Gi", "", api.ClaimLost, annBoundByController, annBindCompleted), - []string{"Warning ClaimLost"}, testSyncClaim, + []string{"Warning ClaimLost"}, noerrors, testSyncClaim, }, { // syncClaim with claim bound to non-exising volume. Check it's @@ -239,7 +239,7 @@ func TestSync(t *testing.T) { novolumes, newClaimArray("claim3-2", "uid3-2", "10Gi", "volume3-2", api.ClaimBound, annBoundByController, annBindCompleted), newClaimArray("claim3-2", "uid3-2", "10Gi", "volume3-2", api.ClaimLost, annBoundByController, annBindCompleted), - []string{"Warning ClaimLost"}, testSyncClaim, + []string{"Warning ClaimLost"}, noerrors, testSyncClaim, }, { // syncClaim with claim bound to unbound volume. Check it's bound. @@ -249,7 +249,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume3-3", "10Gi", "uid3-3", "claim3-3", api.VolumeBound, api.PersistentVolumeReclaimRetain, annBoundByController), newClaimArray("claim3-3", "uid3-3", "10Gi", "volume3-3", api.ClaimPending, annBoundByController, annBindCompleted), newClaimArray("claim3-3", "uid3-3", "10Gi", "volume3-3", api.ClaimBound, annBoundByController, annBindCompleted), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // syncClaim with claim bound to volume with missing (or different) @@ -259,7 +259,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume3-4", "10Gi", "claim3-4-x", "claim3-4", api.VolumePending, api.PersistentVolumeReclaimRetain), newClaimArray("claim3-4", "uid3-4", "10Gi", "volume3-4", api.ClaimPending, annBoundByController, annBindCompleted), newClaimArray("claim3-4", "uid3-4", "10Gi", "volume3-4", api.ClaimLost, annBoundByController, annBindCompleted), - []string{"Warning ClaimMisbound"}, testSyncClaim, + []string{"Warning ClaimMisbound"}, noerrors, testSyncClaim, }, { // syncClaim with claim bound to bound volume. Check that the @@ -270,7 +270,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume3-5", "10Gi", "uid3-5", "claim3-5", api.VolumeBound, api.PersistentVolumeReclaimRetain), newClaimArray("claim3-5", "uid3-5", "10Gi", "volume3-5", api.ClaimPending, annBindCompleted), newClaimArray("claim3-5", "uid3-5", "10Gi", "volume3-5", api.ClaimBound, annBindCompleted), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // syncClaim with claim bound to a volume that is bound to different @@ -281,7 +281,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume3-6", "10Gi", "uid3-6-x", "claim3-6-x", api.VolumePending, api.PersistentVolumeReclaimRetain), newClaimArray("claim3-6", "uid3-6", "10Gi", "volume3-6", api.ClaimPending, annBindCompleted), newClaimArray("claim3-6", "uid3-6", "10Gi", "volume3-6", api.ClaimLost, annBindCompleted), - []string{"Warning ClaimMisbound"}, testSyncClaim, + []string{"Warning ClaimMisbound"}, noerrors, testSyncClaim, }, // [Unit test set 4] All syncVolume tests. { @@ -291,7 +291,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume4-1", "10Gi", "", "", api.VolumeAvailable, api.PersistentVolumeReclaimRetain), noclaims, noclaims, - noevents, testSyncVolume, + noevents, noerrors, testSyncVolume, }, { // syncVolume with prebound pending volume. Check it's marked as @@ -301,7 +301,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume4-2", "10Gi", "", "claim4-2", api.VolumeAvailable, api.PersistentVolumeReclaimRetain), noclaims, noclaims, - noevents, testSyncVolume, + noevents, noerrors, testSyncVolume, }, { // syncVolume with volume bound to missing claim. @@ -311,7 +311,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume4-3", "10Gi", "uid4-3", "claim4-3", api.VolumeReleased, api.PersistentVolumeReclaimRetain), noclaims, noclaims, - noevents, testSyncVolume, + noevents, noerrors, testSyncVolume, }, { // syncVolume with volume bound to claim with different UID. @@ -321,7 +321,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume4-4", "10Gi", "uid4-4", "claim4-4", api.VolumeReleased, api.PersistentVolumeReclaimRetain), newClaimArray("claim4-4", "uid4-4-x", "10Gi", "volume4-4", api.ClaimBound, annBindCompleted), newClaimArray("claim4-4", "uid4-4-x", "10Gi", "volume4-4", api.ClaimBound, annBindCompleted), - noevents, testSyncVolume, + noevents, noerrors, testSyncVolume, }, { // syncVolume with volume bound by controller to unbound claim. @@ -331,7 +331,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume4-5", "10Gi", "uid4-5", "claim4-5", api.VolumeBound, api.PersistentVolumeReclaimRetain, annBoundByController), newClaimArray("claim4-5", "uid4-5", "10Gi", "", api.ClaimPending), newClaimArray("claim4-5", "uid4-5", "10Gi", "", api.ClaimPending), - noevents, testSyncVolume, + noevents, noerrors, testSyncVolume, }, { // syncVolume with volume bound by user to unbound claim. @@ -341,7 +341,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume4-5", "10Gi", "uid4-5", "claim4-5", api.VolumeBound, api.PersistentVolumeReclaimRetain), newClaimArray("claim4-5", "uid4-5", "10Gi", "", api.ClaimPending), newClaimArray("claim4-5", "uid4-5", "10Gi", "", api.ClaimPending), - noevents, testSyncVolume, + noevents, noerrors, testSyncVolume, }, { // syncVolume with volume bound to bound claim. @@ -351,7 +351,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume4-6", "10Gi", "uid4-6", "claim4-6", api.VolumeBound, api.PersistentVolumeReclaimRetain), newClaimArray("claim4-6", "uid4-6", "10Gi", "volume4-6", api.ClaimBound), newClaimArray("claim4-6", "uid4-6", "10Gi", "volume4-6", api.ClaimBound), - noevents, testSyncVolume, + noevents, noerrors, testSyncVolume, }, { // syncVolume with volume bound by controller to claim bound to @@ -361,7 +361,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume4-7", "10Gi", "", "", api.VolumeAvailable, api.PersistentVolumeReclaimRetain), newClaimArray("claim4-7", "uid4-7", "10Gi", "volume4-7-x", api.ClaimBound), newClaimArray("claim4-7", "uid4-7", "10Gi", "volume4-7-x", api.ClaimBound), - noevents, testSyncVolume, + noevents, noerrors, testSyncVolume, }, { // syncVolume with volume bound by user to claim bound to @@ -372,7 +372,7 @@ func TestSync(t *testing.T) { newVolumeArray("volume4-8", "10Gi", "", "claim4-8", api.VolumeAvailable, api.PersistentVolumeReclaimRetain), newClaimArray("claim4-8", "uid4-8", "10Gi", "volume4-8-x", api.ClaimBound), newClaimArray("claim4-8", "uid4-8", "10Gi", "volume4-8-x", api.ClaimBound), - noevents, testSyncVolume, + noevents, noerrors, testSyncVolume, }, } runSyncTests(t, tests) @@ -402,7 +402,7 @@ func TestMultiSync(t *testing.T) { newVolumeArray("volume10-1", "1Gi", "uid10-1", "claim10-1", api.VolumeBound, api.PersistentVolumeReclaimRetain, annBoundByController), newClaimArray("claim10-1", "uid10-1", "1Gi", "", api.ClaimPending), newClaimArray("claim10-1", "uid10-1", "1Gi", "volume10-1", api.ClaimBound, annBoundByController, annBindCompleted), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, { // Two controllers bound two PVs to single claim. Test one of them @@ -418,7 +418,7 @@ func TestMultiSync(t *testing.T) { }, newClaimArray("claim10-2", "uid10-2", "1Gi", "volume10-2-1", api.ClaimBound, annBoundByController, annBindCompleted), newClaimArray("claim10-2", "uid10-2", "1Gi", "volume10-2-1", api.ClaimBound, annBoundByController, annBindCompleted), - noevents, testSyncClaim, + noevents, noerrors, testSyncClaim, }, }