@@ -78,9 +78,10 @@ import (
78
78
// function to call as the actual test. Available functions are:
79
79
// - testSyncSnapshot - calls syncSnapshot on the first snapshot in initialSnapshots.
80
80
// - testSyncSnapshotError - calls syncSnapshot on the first snapshot in initialSnapshots
81
- // and expects an error to be returned.
81
+ // and expects an error to be returned.
82
82
// - testSyncContent - calls syncContent on the first content in initialContents.
83
83
// - any custom function for specialized tests.
84
+ //
84
85
// The test then contains list of contents/snapshots that are expected at the end
85
86
// of the test and list of generated events.
86
87
type controllerTest struct {
@@ -123,21 +124,21 @@ var noerrors = []reactorError{}
123
124
124
125
// snapshotReactor is a core.Reactor that simulates etcd and API server. It
125
126
// stores:
126
- // - Latest version of snapshots contents saved by the controller.
127
- // - Queue of all saves (to simulate "content/snapshot updated" events). This queue
128
- // contains all intermediate state of an object - e.g. a snapshot.VolumeName
129
- // is updated first and snapshot.Phase second. This queue will then contain both
130
- // updates as separate entries.
131
- // - Number of changes since the last call to snapshotReactor.syncAll().
132
- // - Optionally, content and snapshot fake watchers which should be the same ones
133
- // used by the controller. Any time an event function like deleteContentEvent
134
- // is called to simulate an event, the reactor's stores are updated and the
135
- // controller is sent the event via the fake watcher.
136
- // - Optionally, list of error that should be returned by reactor, simulating
137
- // etcd / API server failures. These errors are evaluated in order and every
138
- // error is returned only once. I.e. when the reactor finds matching
139
- // reactorError, it return appropriate error and removes the reactorError from
140
- // the list.
127
+ // - Latest version of snapshots contents saved by the controller.
128
+ // - Queue of all saves (to simulate "content/snapshot updated" events). This queue
129
+ // contains all intermediate state of an object - e.g. a snapshot.VolumeName
130
+ // is updated first and snapshot.Phase second. This queue will then contain both
131
+ // updates as separate entries.
132
+ // - Number of changes since the last call to snapshotReactor.syncAll().
133
+ // - Optionally, content and snapshot fake watchers which should be the same ones
134
+ // used by the controller. Any time an event function like deleteContentEvent
135
+ // is called to simulate an event, the reactor's stores are updated and the
136
+ // controller is sent the event via the fake watcher.
137
+ // - Optionally, list of error that should be returned by reactor, simulating
138
+ // etcd / API server failures. These errors are evaluated in order and every
139
+ // error is returned only once. I.e. when the reactor finds matching
140
+ // reactorError, it return appropriate error and removes the reactorError from
141
+ // the list.
141
142
type snapshotReactor struct {
142
143
secrets map [string ]* v1.Secret
143
144
volumes map [string ]* v1.PersistentVolume
@@ -1296,11 +1297,11 @@ var (
1296
1297
)
1297
1298
1298
1299
// wrapTestWithInjectedOperation returns a testCall that:
1299
- // - starts the controller and lets it run original testCall until
1300
- // scheduleOperation() call. It blocks the controller there and calls the
1301
- // injected function to simulate that something is happening when the
1302
- // controller waits for the operation lock. Controller is then resumed and we
1303
- // check how it behaves.
1300
+ // - starts the controller and lets it run original testCall until
1301
+ // scheduleOperation() call. It blocks the controller there and calls the
1302
+ // injected function to simulate that something is happening when the
1303
+ // controller waits for the operation lock. Controller is then resumed and we
1304
+ // check how it behaves.
1304
1305
func wrapTestWithInjectedOperation (toWrap testCall , injectBeforeOperation func (ctrl * csiSnapshotCommonController , reactor * snapshotReactor )) testCall {
1305
1306
1306
1307
return func (ctrl * csiSnapshotCommonController , reactor * snapshotReactor , test controllerTest ) error {
@@ -1344,10 +1345,10 @@ func evaluateTestResults(ctrl *csiSnapshotCommonController, reactor *snapshotRea
1344
1345
1345
1346
// Test single call to syncSnapshot and syncContent methods.
1346
1347
// For all tests:
1347
- // 1. Fill in the controller with initial data
1348
- // 2. Call the tested function (syncSnapshot/syncContent) via
1349
- // controllerTest.testCall *once*.
1350
- // 3. Compare resulting contents and snapshots with expected contents and snapshots.
1348
+ // 1. Fill in the controller with initial data
1349
+ // 2. Call the tested function (syncSnapshot/syncContent) via
1350
+ // controllerTest.testCall *once*.
1351
+ // 3. Compare resulting contents and snapshots with expected contents and snapshots.
1351
1352
func runSyncTests (t * testing.T , tests []controllerTest , snapshotClasses []* crdv1.VolumeSnapshotClass ) {
1352
1353
snapshotscheme .AddToScheme (scheme .Scheme )
1353
1354
for _ , test := range tests {
0 commit comments