Skip to content

Commit bedcc2a

Browse files
committed
test(nas-backup): enable incremental in active-checkpoint test
After defaulting nas.backup.incremental.enabled to false (per the PR-stated opt-in promise, addressed in earlier review-fix commit), decideChainReturnsFullWhenVmHasNoActiveCheckpoint started failing the Mockito strict-stubbing check — the new master-switch gate short-circuits decideChain before vm.getState() and the VM_ACTIVE_CHECKPOINT_ID lookup are reached, leaving three stubs flagged as "unnecessary". Mirror the same ReflectionTestUtils.setField pattern that decideChainReturnsFullWhenIncrementalDisabled uses, but with value="true" so we get past the master-switch gate and actually exercise the active-checkpoint-id branch this test is meant to cover.
1 parent 4f3375a commit bedcc2a

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

plugins/backup/nas/src/test/java/org/apache/cloudstack/backup/NASBackupProviderTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,15 @@ public void decideChainReturnsFullWhenVmHasNoActiveCheckpoint() {
411411
Mockito.when(vm.getDataCenterId()).thenReturn(zoneId);
412412
Mockito.when(vm.getState()).thenReturn(VMInstanceVO.State.Running);
413413

414+
// Master switch defaults to false (opt-in by zone) — explicitly enable it for this
415+
// test so we exercise the "no active_checkpoint_id" branch rather than short-circuit
416+
// at the master-switch gate.
417+
ReflectionTestUtils.setField(nasBackupProvider, "NASBackupIncrementalEnabled",
418+
new org.apache.cloudstack.framework.config.ConfigKey<>("Advanced", Boolean.class,
419+
"nas.backup.incremental.enabled", "true",
420+
"test override — enabled", true,
421+
org.apache.cloudstack.framework.config.ConfigKey.Scope.Zone));
422+
414423
Mockito.when(vmInstanceDetailsDao.findDetail(vmId, NASBackupChainKeys.VM_ACTIVE_CHECKPOINT_ID)).thenReturn(null);
415424

416425
NASBackupProvider.ChainDecision decision = nasBackupProvider.decideChain(vm);

0 commit comments

Comments
 (0)