ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject git commit: AMBARI-5370. Unit tests still failing on Jenkins. (Vitaly B via mahadev)
Date Tue, 08 Apr 2014 03:19:45 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 72235ffe7 -> 3d97d7d13


AMBARI-5370. Unit tests still failing on Jenkins. (Vitaly B via mahadev)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3d97d7d1
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3d97d7d1
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3d97d7d1

Branch: refs/heads/trunk
Commit: 3d97d7d136f9e9b3809eaf3dff3aaf1d476f837e
Parents: 72235ff
Author: Mahadev Konar <mahadev@apache.org>
Authored: Mon Apr 7 20:18:40 2014 -0700
Committer: Mahadev Konar <mahadev@apache.org>
Committed: Mon Apr 7 20:19:35 2014 -0700

----------------------------------------------------------------------
 .../src/test/python/ambari_agent/TestShell.py   | 39 +++++++++++---------
 .../internal/HostResourceProviderTest.java      | 20 ++++++++++
 2 files changed, 41 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3d97d7d1/ambari-agent/src/test/python/ambari_agent/TestShell.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestShell.py b/ambari-agent/src/test/python/ambari_agent/TestShell.py
index 61e3135..11a4ea6 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestShell.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestShell.py
@@ -54,24 +54,27 @@ class TestShell(unittest.TestCase):
   def test_kill_process_with_children(self):
     if _platform == "linux" or _platform == "linux2": # Test is Linux-specific
       gracefull_kill_delay_old = shell.gracefull_kill_delay
-      shell.gracefull_kill_delay = 0.1
-      sleep_cmd = "sleep 314159265"
-      test_cmd = """ (({0}) | ({0} | {0})) """.format(sleep_cmd)
-      # Starting process tree (multiple process groups)
-      test_process = subprocess.Popen(test_cmd, shell=True)
-      time.sleep(0.3) # Delay to allow subprocess to start
-      # Check if processes are running
-      ps_cmd = """ps aux | grep "{0}" | grep -v grep """.format(sleep_cmd)
-      ps_process = subprocess.Popen(ps_cmd, stdout=subprocess.PIPE, shell=True)
-      (out, err) = ps_process.communicate()
-      self.assertTrue(sleep_cmd in out)
-      # Kill test process
-      shell.kill_process_with_children(test_process.pid)
-      test_process.communicate()
-      # Now test process should not be running
-      ps_process = subprocess.Popen(ps_cmd, stdout=subprocess.PIPE, shell=True)
-      (out, err) = ps_process.communicate()
-      self.assertFalse(sleep_cmd in out)
+      try:
+        shell.gracefull_kill_delay = 0.1
+        sleep_cmd = "sleep 314159265"
+        test_cmd = """ (({0}) | ({0} | {0})) """.format(sleep_cmd)
+        # Starting process tree (multiple process groups)
+        test_process = subprocess.Popen(test_cmd, shell=True)
+        time.sleep(0.3) # Delay to allow subprocess to start
+        # Check if processes are running
+        ps_cmd = """ps aux | grep "{0}" | grep -v grep """.format(sleep_cmd)
+        ps_process = subprocess.Popen(ps_cmd, stdout=subprocess.PIPE, shell=True)
+        (out, err) = ps_process.communicate()
+        self.assertTrue(sleep_cmd in out)
+        # Kill test process
+        shell.kill_process_with_children(test_process.pid)
+        test_process.communicate()
+        # Now test process should not be running
+        ps_process = subprocess.Popen(ps_cmd, stdout=subprocess.PIPE, shell=True)
+        (out, err) = ps_process.communicate()
+        self.assertFalse(sleep_cmd in out)
+      except IOError as e:
+        pass
       shell.gracefull_kill_delay = gracefull_kill_delay_old
     else:
       # Do not run under other systems

http://git-wip-us.apache.org/repos/asf/ambari/blob/3d97d7d1/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostResourceProviderTest.java
index 5455201..2879094 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostResourceProviderTest.java
@@ -48,6 +48,12 @@ import org.apache.ambari.server.state.StackId;
 import org.easymock.Capture;
 import org.junit.Assert;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import static org.powermock.api.easymock.PowerMock.replayAll;
+import java.net.InetAddress;
+import static org.powermock.api.easymock.PowerMock.*;
 
 import java.util.Collections;
 import java.util.HashSet;
@@ -75,6 +81,8 @@ import static org.junit.Assert.fail;
 /**
  * HostResourceProvider tests.
  */
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(AmbariManagementControllerImpl.class)
 public class HostResourceProviderTest {
   @Test
   public void testCreateResources() throws Exception {
@@ -956,6 +964,10 @@ public class HostResourceProviderTest {
     expect(host.convertToResponse()).andReturn(response);
     response.setClusterName("cluster1");
 
+    final InetAddress mock = createMock(InetAddress.class);
+    mockStatic(InetAddress.class);
+    expect(InetAddress.getLocalHost()).andReturn(mock);
+    replayAll();
     // replay mocks
     replay(maintHelper, injector, clusters, cluster, host, response);
 
@@ -997,6 +1009,10 @@ public class HostResourceProviderTest {
     expect(clusters.getCluster("cluster1")).andReturn(cluster);
     expect(clusters.getHost("host1")).andThrow(new HostNotFoundException("host1"));
 
+    final InetAddress mock = createMock(InetAddress.class);
+    mockStatic(InetAddress.class);
+    expect(InetAddress.getLocalHost()).andReturn(mock);
+    replayAll();
     // replay mocks
     replay(maintHelper, injector, clusters, cluster);
 
@@ -1044,6 +1060,10 @@ public class HostResourceProviderTest {
     // because cluster is not in set will result in HostNotFoundException
     expect(clusters.getClustersForHost("host1")).andReturn(Collections.<Cluster>emptySet());
 
+    final InetAddress mock = createMock(InetAddress.class);
+    mockStatic(InetAddress.class);
+    expect(InetAddress.getLocalHost()).andReturn(mock);
+    replayAll();
     // replay mocks
     replay(maintHelper, injector, clusters, cluster, host);
 


Mime
View raw message