@@ -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 {
@@ -127,21 +128,21 @@ var (
127
128
128
129
// snapshotReactor is a core.Reactor that simulates etcd and API server. It
129
130
// stores:
130
- // - Latest version of snapshots contents saved by the controller.
131
- // - Queue of all saves (to simulate "content/snapshot updated" events). This queue
132
- // contains all intermediate state of an object - e.g. a snapshot.VolumeName
133
- // is updated first and snapshot.Phase second. This queue will then contain both
134
- // updates as separate entries.
135
- // - Number of changes since the last call to snapshotReactor.syncAll().
136
- // - Optionally, content and snapshot fake watchers which should be the same ones
137
- // used by the controller. Any time an event function like deleteContentEvent
138
- // is called to simulate an event, the reactor's stores are updated and the
139
- // controller is sent the event via the fake watcher.
140
- // - Optionally, list of error that should be returned by reactor, simulating
141
- // etcd / API server failures. These errors are evaluated in order and every
142
- // error is returned only once. I.e. when the reactor finds matching
143
- // reactorError, it return appropriate error and removes the reactorError from
144
- // the list.
131
+ // - Latest version of snapshots contents saved by the controller.
132
+ // - Queue of all saves (to simulate "content/snapshot updated" events). This queue
133
+ // contains all intermediate state of an object - e.g. a snapshot.VolumeName
134
+ // is updated first and snapshot.Phase second. This queue will then contain both
135
+ // updates as separate entries.
136
+ // - Number of changes since the last call to snapshotReactor.syncAll().
137
+ // - Optionally, content and snapshot fake watchers which should be the same ones
138
+ // used by the controller. Any time an event function like deleteContentEvent
139
+ // is called to simulate an event, the reactor's stores are updated and the
140
+ // controller is sent the event via the fake watcher.
141
+ // - Optionally, list of error that should be returned by reactor, simulating
142
+ // etcd / API server failures. These errors are evaluated in order and every
143
+ // error is returned only once. I.e. when the reactor finds matching
144
+ // reactorError, it return appropriate error and removes the reactorError from
145
+ // the list.
145
146
type snapshotReactor struct {
146
147
secrets map [string ]* v1.Secret
147
148
volumes map [string ]* v1.PersistentVolume
@@ -1301,11 +1302,11 @@ var (
1301
1302
)
1302
1303
1303
1304
// wrapTestWithInjectedOperation returns a testCall that:
1304
- // - starts the controller and lets it run original testCall until
1305
- // scheduleOperation() call. It blocks the controller there and calls the
1306
- // injected function to simulate that something is happening when the
1307
- // controller waits for the operation lock. Controller is then resumed and we
1308
- // check how it behaves.
1305
+ // - starts the controller and lets it run original testCall until
1306
+ // scheduleOperation() call. It blocks the controller there and calls the
1307
+ // injected function to simulate that something is happening when the
1308
+ // controller waits for the operation lock. Controller is then resumed and we
1309
+ // check how it behaves.
1309
1310
func wrapTestWithInjectedOperation (toWrap testCall , injectBeforeOperation func (ctrl * csiSnapshotCommonController , reactor * snapshotReactor )) testCall {
1310
1311
return func (ctrl * csiSnapshotCommonController , reactor * snapshotReactor , test controllerTest ) error {
1311
1312
// Inject a hook before async operation starts
@@ -1348,10 +1349,10 @@ func evaluateTestResults(ctrl *csiSnapshotCommonController, reactor *snapshotRea
1348
1349
1349
1350
// Test single call to syncSnapshot and syncContent methods.
1350
1351
// For all tests:
1351
- // 1. Fill in the controller with initial data
1352
- // 2. Call the tested function (syncSnapshot/syncContent) via
1353
- // controllerTest.testCall *once*.
1354
- // 3. Compare resulting contents and snapshots with expected contents and snapshots.
1352
+ // 1. Fill in the controller with initial data
1353
+ // 2. Call the tested function (syncSnapshot/syncContent) via
1354
+ // controllerTest.testCall *once*.
1355
+ // 3. Compare resulting contents and snapshots with expected contents and snapshots.
1355
1356
func runSyncTests (t * testing.T , tests []controllerTest , snapshotClasses []* crdv1.VolumeSnapshotClass ) {
1356
1357
snapshotscheme .AddToScheme (scheme .Scheme )
1357
1358
for _ , test := range tests {
0 commit comments