[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-9368?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15264759#comment-15264759
 ] 

ASF GitHub Bot commented on CLOUDSTACK-9368:
--------------------------------------------

Github user rafaelweingartner commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1518#discussion_r61646120
  
    --- Diff: 
plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/resource/VmwareResourceTest.java
 ---
    @@ -117,4 +154,79 @@ public void testStartVm3dgpuEnabled() throws Exception{
             verify(vmMo3dgpu).configureVm(any(VirtualMachineConfigSpec.class));
         }
     
    -}
    +    // 
---------------------------------------------------------------------------------------------------
    +
    +    @Test
    +    public void testgetNfsVersionFromNfsTONull(){
    +        assertFalse(_resource.getStorageNfsVersionFromNfsTO(null));
    +    }
    +
    +    @Test
    +    public void testgetNfsVersionFromNfsTONfsVersionNull(){
    +        
when(srcDataNfsTO.getNfsVersion()).thenReturn(NFS_VERSION_NOT_PRESENT);
    +        assertFalse(_resource.getStorageNfsVersionFromNfsTO(srcDataNfsTO));
    +    }
    +
    +    @Test
    +    public void testgetNfsVersionFromNfsTONfsVersion(){
    +        assertTrue(_resource.getStorageNfsVersionFromNfsTO(srcDataNfsTO));
    +    }
    +
    +    // 
---------------------------------------------------------------------------------------------------
    +
    +    @Test
    +    public void testSetCurrentNfsVersionInProcessorAndHandler(){
    +        _resource.setCurrentNfsVersionInProcessorAndHandler();
    +        verify(storageHandler).reconfigureNfsVersion(any(Integer.class));
    +    }
    +
    +    // 
---------------------------------------------------------------------------------------------------
    +
    +    @Test
    +    public void testExamineStorageSubSystemCommandNfsVersionNotPresent(){
    +        
when(srcDataNfsTO.getNfsVersion()).thenReturn(NFS_VERSION_NOT_PRESENT);
    +        _resource.examineStorageSubSystemCommandNfsVersion(storageCmd);
    +        verify(_resource, 
never()).setCurrentNfsVersionInProcessorAndHandler();
    +    }
    +
    +    @Test
    +    public void testExamineStorageSubSystemCommandNfsVersion(){
    +        _resource.examineStorageSubSystemCommandNfsVersion(storageCmd);
    +        verify(_resource).setCurrentNfsVersionInProcessorAndHandler();
    +    }
    +
    +    // 
---------------------------------------------------------------------------------------------------
    +
    +    @Test
    +    public void testStorageSetNfsVersion(){
    +        
_resource.checkStorageProcessorAndHandlerNfsVersionAttribute(storageCmd);
    +        assertEquals(NFS_VERSION, _resource._storageNfsVersion);
    +
    +        //Call again to verify that version won't be set again once it is 
set (examineStorageSubSystemCommandNfsVersion - only one time)
    +        
_resource.checkStorageProcessorAndHandlerNfsVersionAttribute(storageCmd);
    +        
verify(_resource).examineStorageSubSystemCommandNfsVersion(storageCmd);     
//Only 1 time, default for verify.
    +    }
    +
    +    @Test
    +    public void testStorageNfsVersionNotPresent(){
    --- End diff --
    
    I believe this method could be simpler. 
    If it wants to test what is coded now. It would only need check if 
"_storageNfsVersion == null", then, Mockito.verify(mock, 
times(0)).examineStorageSubSystemCommandNfsVersion
    
    Also for the other case you can use Mockito.doNothing, when calling 
"examineStorageSubSystemCommandNfsVersion". This is an integration test, you do 
not need to test the whole execution flow, you only need to test if the method 
(the one being tested) is calling the methods it should.
    
    That means, to test the 
"checkStorageProcessorAndHandlerNfsVersionAttribute", you only need to worry 
about the "examineStorageSubSystemCommandNfsVersion" method.


> Fix for Support configurable NFS version for Secondary Storage mounts
> ---------------------------------------------------------------------
>
>                 Key: CLOUDSTACK-9368
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9368
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>          Components: VMware
>    Affects Versions: 4.9.0
>            Reporter: Nicolas Vazquez
>             Fix For: 4.9.0
>
>
> This issue address a problem introduced in 
> [CLOUDSTACK-9252|https://issues.apache.org/jira/browse/CLOUDSTACK-9252] in 
> which NFS version couldn't be changed after hosts resources were configured 
> on startup (for hosts using `VmwareResource`), and as host parameters didn't 
> include `nfs.version` key, it was set `null`.
> h4. Proposed solution
> In this proposed solution `nfsVersion` would be passed in `NfsTO` through 
> `CopyCommand` to `VmwareResource`, who will check if NFS version is still 
> configured or not. If not, it will use the one sent in the command and will 
> set it to its storage processor and storage handler. After those setups, it 
> will proceed executing command.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to