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

    https://github.com/apache/cloudstack/pull/559#discussion_r33921332
  
    --- Diff: 
plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixRequestWrapperTest.java
 ---
    @@ -1320,14 +1322,23 @@ public void testOvsDestroyTunnelCommandFailed() {
     
         @Test
         public void testUpdateHostPasswordCommand() {
    -        final UpdateHostPasswordCommand updatePwd = new 
UpdateHostPasswordCommand("test", "123");
    +        final ExecutionResult executionResult = 
Mockito.mock(ExecutionResult.class);
    +
    +        final UpdateHostPasswordCommand updatePwd = new 
UpdateHostPasswordCommand("test", "123", "127.0.0.1");
    +
    +        final StringBuffer buff = new StringBuffer();
    +        buff.append(updatePwd.getUsername());
    +        buff.append(' ');
    +        buff.append(updatePwd.getNewPassword());
    +
    +        when(citrixResourceBase.executeInVR(updatePwd.getHostIp(), 
VRScripts.UPDATE_HOST_PASSWD, buff.toString())).thenReturn(executionResult);
    --- End diff --
    
    Why do we need this mock here? 
    The test always succeeds as the SshHelper.execute fails with 
"java.io.IOException: There was a problem while connecting to 127.0.0.1:22"
    If I add the below line to test, it always fails
    verify(citrixResourceBase, 
Mockito.atLeastOnce()).executeInVR(Mockito.anyString(),Mockito.anyString(), 
Mockito.anyString());`
    
    Wanted but not invoked:
    `citrixResourceBase.executeInVR(
        <any>,
        <any>,
        <any>
    );`
    -> at 
`com.cloud.hypervisor.xenserver.resource.wrapper.xenbase.CitrixRequestWrapperTest.testUpdateHostPasswordCommand(CitrixRequestWrapperTest.java:1341)`
    
    However, there were other interactions with this mock:
    -> at 
`com.cloud.hypervisor.xenserver.resource.wrapper.xenbase.CitrixUpdateHostPasswordCommandWrapper.execute(CitrixUpdateHostPasswordCommandWrapper.java:57)`



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to