abh1sar commented on code in PR #10034:
URL: https://github.com/apache/cloudstack/pull/10034#discussion_r1872790339


##########
plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptorTest.java:
##########
@@ -78,14 +93,87 @@ public void testCreateStoragePoolWithNFSMountOpts() throws 
Exception {
 
         Connect conn =  Mockito.mock(Connect.class);
         StoragePool sp = Mockito.mock(StoragePool.class);
-        StoragePoolInfo spinfo = Mockito.mock(StoragePoolInfo.class);
         Mockito.when(LibvirtConnection.getConnection()).thenReturn(conn);
         Mockito.when(conn.storagePoolLookupByUUIDString(uuid)).thenReturn(sp);
         Mockito.when(sp.isActive()).thenReturn(1);
         Mockito.when(sp.getXMLDesc(0)).thenReturn(poolXml);
+        
Mockito.when(Script.runSimpleBashScriptForExitValue(anyString())).thenReturn(-1);
 
         Map<String, String> details = new HashMap<>();
         details.put("nfsmountopts", "vers=4.1, nconnect=4");
         KVMStoragePool pool = libvirtStorageAdaptor.createStoragePool(uuid, 
null, 0, dir, null, Storage.StoragePoolType.NetworkFilesystem, details, true);

Review Comment:
   ```suggestion
            
Mockito.when(Script.runSimpleBashScriptForExitValue(anyString())).thenReturn(0);
   
           StoragePoolInfo poolInfo = Mockito.mock(StoragePoolInfo.class);
           ReflectionTestUtils.setField(poolInfo, "state", 
StoragePoolInfo.StoragePoolState.VIR_STORAGE_POOL_RUNNING);
           Mockito.when(sp.getInfo()).thenReturn(poolInfo);
   
           Map<String, String> details = new HashMap<>();
           details.put("nfsmountopts", "vers=4.1, nconnect=8");
           KVMStoragePool pool = libvirtStorageAdaptor.createStoragePool(uuid, 
null, 0, dir, null, Storage.StoragePoolType.NetworkFilesystem, details, true);
   
           Assert.assertEquals(pool.getUuid(), uuid);
           Assert.assertEquals(pool.getType(), 
Storage.StoragePoolType.NetworkFilesystem);
           Assert.assertEquals(pool.getLocalPath(), targetPath);
   ```
   
   Not related to your change, trying to fix the bad test case I had written. 
   Since Script is mocked now,
   we can convert this test case to positive by removing the (expected = 
CloudRuntimeException.class)
   
   If you prefer that this gets fixed in a separate PR, I can do that.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to