|
24 | 24 | import com.cloud.server.ManagementService; |
25 | 25 | import com.cloud.storage.Snapshot; |
26 | 26 | import com.cloud.storage.SnapshotVO; |
| 27 | +import com.cloud.storage.StoragePoolStatus; |
27 | 28 | import com.cloud.storage.Volume; |
28 | 29 | import com.cloud.storage.VolumeVO; |
29 | 30 | import com.cloud.storage.dao.SnapshotDao; |
@@ -104,6 +105,7 @@ void setUp() { |
104 | 105 | pool = mock(StoragePoolVO.class); |
105 | 106 | lenient().when(pool.getId()).thenReturn(1L); |
106 | 107 | lenient().when(pool.getName()).thenReturn("ontap-pool-1"); |
| 108 | + lenient().when(pool.getStatus()).thenReturn(StoragePoolStatus.Up); |
107 | 109 |
|
108 | 110 | poolDetails = new HashMap<>(); |
109 | 111 | poolDetails.put(OntapStorageConstants.STORAGE_IP, "192.168.1.10"); |
@@ -226,12 +228,30 @@ void poolMessage_containsPoolNameClusterUuidAndSnapshotKeys() { |
226 | 228 |
|
227 | 229 | String desc = capturePoolMessage(); |
228 | 230 | assertTrue(desc.contains("ontap-pool-1"), "should contain pool name"); |
| 231 | + assertTrue(desc.contains("\"poolStatus\":\"Up\""), "should contain pool status"); |
229 | 232 | assertTrue(desc.contains("cluster-uuid-1"), "should contain cluster UUID"); |
230 | 233 | assertTrue(desc.contains("volumeSnapshotCount"), "should contain volumeSnapshotCount"); |
231 | 234 | assertTrue(desc.contains("vmSnapshotCount"), "should contain vmSnapshotCount"); |
232 | 235 | assertTrue(desc.contains("\"multiPrimaryStoragePoolVm\":false"), "desc=" + desc); |
233 | 236 | } |
234 | 237 |
|
| 238 | + @Test |
| 239 | + void poolMessage_includesMaintenanceStatus() { |
| 240 | + when(pool.getStatus()).thenReturn(StoragePoolStatus.Maintenance); |
| 241 | + when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails); |
| 242 | + when(mockStrategy.getClusterInfo()).thenReturn(mockCluster); |
| 243 | + when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1"); |
| 244 | + when(volumeDao.findNonDestroyedVolumesByPoolId(eq(1L), isNull())).thenReturn(Collections.emptyList()); |
| 245 | + |
| 246 | + try (MockedStatic<OntapStorageUtils> u = mockStatic(OntapStorageUtils.class)) { |
| 247 | + u.when(() -> OntapStorageUtils.getStrategyByStoragePoolDetails(any())).thenReturn(mockStrategy); |
| 248 | + asupManager.pushAsupForStoragePool(pool, new HashSet<>()); |
| 249 | + } |
| 250 | + |
| 251 | + String desc = capturePoolMessage(); |
| 252 | + assertTrue(desc.contains("\"poolStatus\":\"Maintenance\""), "desc=" + desc); |
| 253 | + } |
| 254 | + |
235 | 255 | @Test |
236 | 256 | void poolMessage_volumeSnapshots_zeroWhenNoVolumes() { |
237 | 257 | when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails); |
|
0 commit comments