Skip to content

Commit

Permalink
fix and document test case
Browse files Browse the repository at this point in the history
  • Loading branch information
atantawi authored and openshift-merge-robot committed Aug 14, 2023
1 parent 0ce5cee commit 55c21c1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/quotaplugins/quota-forest/quota-manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ A summary of the API interface to the Quota Manager follows.
- refresh (effect) updates from caches
- `UpdateForest(forestName)`
- Undo consumer allocation: Two calls are provided to try to allocate a consumer, and if unaccepted, to undo the effect of the allocation trial. If the trial is accepted, no further action is needed. Otherwise, the undo has to be called right after the try allocation, without making any calls to change the trees or allocate/deallocate consumers. These operations are intended only during Normal mode.
(Note: This design pattern puts the burden on the caller of the quota manager to make sure that TryAllocate() and UndoAllocate() are run in an atomic fashion. So, a lock is needed for that purpose. An example is provided in the TestQuotaManagerParallelTryUndoAllocation() in [quotamanagerundo_test.go](quota/quotamanagerundo_test.go))
- `TryAllocate(treeName, consumerID)`
- `UndoAllocate(treeName, consumerID)`
- `TryAllocateForest(forestName, consumerID)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ func TestTreeAllocateTryAndUndo(t *testing.T) {
func TestForestAllocateTryAndUndo(t *testing.T) {
forestName := "testForest"
forestTreesSpecs := []string{testTreeSpec, serviceTreeSpec}
var err error

// define tests
var tests = []struct {
name string
Expand Down Expand Up @@ -410,6 +410,7 @@ func TestForestAllocateTryAndUndo(t *testing.T) {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
var err error
// After keeps the state of the quota manager after applying a test case
qmAfter := quota.NewManager()
initializeForestQuotaManager(t, qmAfter, forestName, forestTreesSpecs, testForestConsumersSpecMap,
Expand Down

0 comments on commit 55c21c1

Please sign in to comment.