cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject git commit: updated refs/heads/master to 607a63b
Date Mon, 01 Jun 2015 19:11:43 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 6c1dde8f8 -> 607a63b12


Mocking the Connect object used in the LibvirtMigrateCommandWrapper

When executing the tests in an environment where Libvirt is also installed, it
caused errors.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

This closes #342


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/607a63b1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/607a63b1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/607a63b1

Branch: refs/heads/master
Commit: 607a63b12d1ca5d76d31177ecef3806d08628b41
Parents: 6c1dde8
Author: wilderrodrigues <wrodrigues@schubergphilis.com>
Authored: Mon Jun 1 14:45:43 2015 +0200
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Mon Jun 1 21:11:25 2015 +0200

----------------------------------------------------------------------
 .../resource/wrapper/LibvirtMigrateCommandWrapper.java  |  2 +-
 .../kvm/resource/wrapper/LibvirtUtilitiesHelper.java    |  4 ++++
 .../kvm/resource/LibvirtComputingResourceTest.java      | 12 ++++++------
 3 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/607a63b1/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
index 235793c..1847818 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java
@@ -86,7 +86,7 @@ public final class LibvirtMigrateCommandWrapper extends CommandWrapper<MigrateCo
              */
             xmlDesc = dm.getXMLDesc(0).replace(libvirtComputingResource.getPrivateIp(), command.getDestinationIp());
 
-            dconn = new Connect("qemu+tcp://" + command.getDestinationIp() + "/system");
+            dconn = libvirtUtilitiesHelper.retrieveQemuConnection("qemu+tcp://" + command.getDestinationIp()
+ "/system");
 
             //run migration in thread so we can monitor it
             s_logger.info("Live migration of instance " + vmName + " initiated");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/607a63b1/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUtilitiesHelper.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUtilitiesHelper.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUtilitiesHelper.java
index 98bf642..8c8f6e6 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUtilitiesHelper.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUtilitiesHelper.java
@@ -86,4 +86,8 @@ public class LibvirtUtilitiesHelper {
     public String retrieveBashScriptPath() {
         return LibvirtComputingResource.BASH_SCRIPT_PATH;
     }
+
+    public Connect retrieveQemuConnection(final String qemuURI) throws LibvirtException {
+        return new Connect(qemuURI);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/607a63b1/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
index eaaed39..d3c8824 100644
--- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
+++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
@@ -1205,13 +1205,10 @@ public class LibvirtComputingResourceTest {
         verify(vm, times(1)).getNics();
     }
 
-    @Test(expected = UnsatisfiedLinkError.class)
+    @Test
     public void testMigrateCommand() {
-        // The Connect constructor used inside the LibvirtMigrateCommandWrapper has a call
to native methods, which
-        // makes difficult to test it now.
-        // Will keep it expecting the UnsatisfiedLinkError and fix later.
-
         final Connect conn = Mockito.mock(Connect.class);
+        final Connect dconn = Mockito.mock(Connect.class);
         final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class);
 
         final String vmName = "Test";
@@ -1225,6 +1222,8 @@ public class LibvirtComputingResourceTest {
         when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper);
         try {
             when(libvirtUtilitiesHelper.getConnectionByVmName(vmName)).thenReturn(conn);
+            when(libvirtUtilitiesHelper.retrieveQemuConnection("qemu+tcp://" + command.getDestinationIp()
+ "/system")).thenReturn(dconn);
+
         } catch (final LibvirtException e) {
             fail(e.getMessage());
         }
@@ -1259,11 +1258,12 @@ public class LibvirtComputingResourceTest {
         assertNotNull(wrapper);
 
         final Answer answer = wrapper.execute(command, libvirtComputingResource);
-        assertFalse(answer.getResult());
+        assertTrue(answer.getResult());
 
         verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper();
         try {
             verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(vmName);
+            verify(libvirtUtilitiesHelper, times(1)).retrieveQemuConnection("qemu+tcp://"
+ command.getDestinationIp() + "/system");
         } catch (final LibvirtException e) {
             fail(e.getMessage());
         }


Mime
View raw message