Skip to content

Commit 3d65f34

Browse files
committed
Fix NASBackupProviderTest failures for zone-scoped ConfigKey values
The test helper overrideConfigValue() was only setting _value on ConfigKey, but zone-scoped configs (valueIn(zoneId)) fall back to _defaultValue when s_depot is null in test context. Also set _defaultValue via ReflectionTestUtils to ensure valueIn() returns the expected test value. Fixes: 4 assertion failures (compression, bandwidth, encryption, integrity_check details all returned null) and 1 error (encryption without passphrase expected CloudRuntimeException but got NullPointerException from null config value).
1 parent 4884980 commit 3d65f34

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,13 @@ public void testGetVMHypervisorHostFallbackToZoneWideKVMHost() {
357357

358358
private void overrideConfigValue(final ConfigKey configKey, final Object value) {
359359
try {
360+
// Set _value for value() calls
360361
Field f = ConfigKey.class.getDeclaredField("_value");
361362
f.setAccessible(true);
362-
f.set(configKey, value);
363+
f.set(configKey, value != null ? configKey.valueOf((String) value) : null);
364+
365+
// Also set _defaultValue via Spring's ReflectionTestUtils (handles final fields)
366+
ReflectionTestUtils.setField(configKey, "_defaultValue", String.valueOf(value));
363367
} catch (IllegalAccessException | NoSuchFieldException e) {
364368
Assert.fail(e.getMessage());
365369
}

0 commit comments

Comments
 (0)