changeset 857:8211cecd53df

Fix failing integration tests The cli tests now use an explicit argument to connect to mongo directly (hopefully overriding all local custom configuration) and do not require a web service running. Reviewed-by: jerboaa Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-December/004773.html
author Omair Majid <omajid@redhat.com>
date Fri, 14 Dec 2012 11:29:10 -0500
parents a0536f7b3be7
children af374b51254f
files distribution/src/test/java/com/redhat/thermostat/distribution/IntegrationTest.java distribution/src/test/java/com/redhat/thermostat/distribution/VmCommandsTest.java
diffstat 2 files changed, 22 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/distribution/src/test/java/com/redhat/thermostat/distribution/IntegrationTest.java	Fri Dec 14 12:53:09 2012 +0100
+++ b/distribution/src/test/java/com/redhat/thermostat/distribution/IntegrationTest.java	Fri Dec 14 11:29:10 2012 -0500
@@ -73,7 +73,9 @@
                 result.append(" ").append(arg);
             }
         }
-        return expect.spawn(result.toString());
+        String toExecute = result.toString();
+        //System.out.println("executing: '" + toExecute + "'");
+        return expect.spawn(toExecute);
     }
 
     public static Spawn spawn(List<String> args) throws IOException {
--- a/distribution/src/test/java/com/redhat/thermostat/distribution/VmCommandsTest.java	Fri Dec 14 12:53:09 2012 +0100
+++ b/distribution/src/test/java/com/redhat/thermostat/distribution/VmCommandsTest.java	Fri Dec 14 11:29:10 2012 -0500
@@ -39,6 +39,9 @@
 import static org.junit.Assert.assertEquals;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -68,7 +71,7 @@
 
     @Test
     public void testListVms() throws Exception {
-        Spawn vmList = spawnThermostat("list-vms");
+        Spawn vmList = commandAgainstMongo("list-vms");
         vmList.expectClose();
 
         assertEquals("HOST_ID HOST VM_ID STATUS VM_NAME\n", vmList.getCurrentStandardOutContents());
@@ -76,7 +79,7 @@
 
     @Test
     public void testVmStat() throws Exception {
-        Spawn vmStat = spawnThermostat("vm-stat");
+        Spawn vmStat = commandAgainstMongo("vm-stat");
         vmStat.expectClose();
 
         System.out.println(vmStat.getCurrentStandardOutContents());
@@ -86,7 +89,7 @@
 
     @Test
     public void testVmInfo() throws Exception {
-        Spawn vmInfo = spawnThermostat("vm-info");
+        Spawn vmInfo = commandAgainstMongo("vm-info");
         vmInfo.expectClose();
 
         assertNoExceptions(vmInfo.getCurrentStandardOutContents(), vmInfo.getCurrentStandardErrContents());
@@ -105,7 +108,7 @@
         };
 
         for (String command : commands) {
-            Spawn heapCommand = spawnThermostat(command);
+            Spawn heapCommand = commandAgainstMongo(command);
             heapCommand.expectClose();
 
             assertCommandIsFound(
@@ -116,4 +119,16 @@
                     heapCommand.getCurrentStandardErrContents());
         }
     }
+
+    private static Spawn commandAgainstMongo(String... args) throws IOException {
+        if (args == null || args.length == 0) {
+            throw new IllegalArgumentException("args must be an array with something");
+        }
+        List<String> completeArgs = new ArrayList<>();
+        completeArgs.addAll(Arrays.asList(args));
+        completeArgs.add("-d");
+        completeArgs.add("mongodb://127.0.0.1:27518");
+        return spawnThermostat(completeArgs.toArray(new String[0]));
+    }
+
 }