You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dm...@apache.org on 2015/01/08 20:49:37 UTC
[1/2] ambari git commit: AMBARI-9050. Stack Advisor Exception During
install (dlysnichenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 76b7d3d46 -> eaa65facf
AMBARI-9050. Stack Advisor Exception During install (dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/48aea274
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/48aea274
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/48aea274
Branch: refs/heads/trunk
Commit: 48aea274efedb325db8be9ce20124fb7a00d5408
Parents: 76b7d3d
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Thu Jan 8 21:47:38 2015 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Thu Jan 8 21:47:38 2015 +0200
----------------------------------------------------------------------
ambari-agent/src/main/python/ambari_agent/Hardware.py | 9 ++++++++-
ambari-agent/src/test/python/ambari_agent/TestController.py | 3 +++
ambari-agent/src/test/python/ambari_agent/TestHardware.py | 3 ++-
ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py | 4 ++++
.../src/test/python/ambari_agent/TestRegistration.py | 2 ++
5 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/48aea274/ambari-agent/src/main/python/ambari_agent/Hardware.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/Hardware.py b/ambari-agent/src/main/python/ambari_agent/Hardware.py
index 7b8e501..ba53e12 100644
--- a/ambari-agent/src/main/python/ambari_agent/Hardware.py
+++ b/ambari-agent/src/main/python/ambari_agent/Hardware.py
@@ -78,13 +78,20 @@ class Hardware:
lines = dfdata.splitlines()
for l in lines:
mountinfo = Hardware.extractMountInfo(l)
- if mountinfo != None and os.access(mountinfo['mountpoint'], os.W_OK):
+ if mountinfo != None and Hardware._chk_mount(mountinfo['mountpoint']):
mounts.append(mountinfo)
pass
pass
return mounts
@staticmethod
+ def _chk_mount(mountpoint):
+ if subprocess.call("sudo test -w '{0}'".format(mountpoint), shell=True) == 0:
+ return True
+ else:
+ return False
+
+ @staticmethod
def _osdisks_win():
mounts = []
runner = shellRunner()
http://git-wip-us.apache.org/repos/asf/ambari/blob/48aea274/ambari-agent/src/test/python/ambari_agent/TestController.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestController.py b/ambari-agent/src/test/python/ambari_agent/TestController.py
index 24d416a..92ce46f 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestController.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestController.py
@@ -41,6 +41,7 @@ with patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_
from ambari_agent import hostname
from ambari_agent.Controller import AGENT_AUTO_RESTART_EXIT_CODE
from ambari_commons import OSCheck
+ from ambari_agent.Hardware import Hardware
import ambari_commons
@only_for_platform(PLATFORM_LINUX)
@@ -166,6 +167,7 @@ class TestController(unittest.TestCase):
+ @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
@patch("urllib2.build_opener")
@patch("urllib2.install_opener")
@patch.object(Controller, "ActionQueue")
@@ -204,6 +206,7 @@ class TestController(unittest.TestCase):
self.assertTrue(aq.start.called)
+ @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
@patch("urllib2.build_opener")
@patch("urllib2.install_opener")
@patch.object(ActionQueue.ActionQueue, "run")
http://git-wip-us.apache.org/repos/asf/ambari/blob/48aea274/ambari-agent/src/test/python/ambari_agent/TestHardware.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestHardware.py b/ambari-agent/src/test/python/ambari_agent/TestHardware.py
index 2a24d40..164417b 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHardware.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHardware.py
@@ -19,7 +19,7 @@ limitations under the License.
'''
from unittest import TestCase
-from mock.mock import patch
+from mock.mock import patch, MagicMock
import unittest
import platform
from only_for_platform import only_for_platform, PLATFORM_LINUX
@@ -33,6 +33,7 @@ with patch("platform.linux_distribution", return_value = ('Suse','11','Final')):
@only_for_platform(PLATFORM_LINUX)
@patch.object(platform,"linux_distribution", new = ('Suse','11','Final'))
class TestHardware(TestCase):
+ @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
@patch.object(OSCheck, "get_os_type")
@patch.object(OSCheck, "get_os_version")
def test_build(self, get_os_version_mock, get_os_type_mock):
http://git-wip-us.apache.org/repos/asf/ambari/blob/48aea274/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py b/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py
index 1145cd8..fc52c95 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py
@@ -29,6 +29,7 @@ import sys
with patch("platform.linux_distribution", return_value = ('Suse','11','Final')):
+ from ambari_agent.Hardware import Hardware
from ambari_agent.Heartbeat import Heartbeat
from ambari_agent.ActionQueue import ActionQueue
from ambari_agent.LiveStatus import LiveStatus
@@ -75,6 +76,7 @@ class TestHeartbeat(TestCase):
self.assertEquals(not heartbeat.reports, True, "Heartbeat should not contain task in progress")
+ @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
@patch.object(ActionQueue, "result")
@patch.object(HostInfoLinux, "register")
def test_no_mapping(self, register_mock, result_mock):
@@ -196,6 +198,7 @@ class TestHeartbeat(TestCase):
self.assertEquals(hb, expected)
+ @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
@patch.object(HostInfoLinux, 'register')
def test_heartbeat_no_host_check_cmd_in_queue(self, register_mock):
config = AmbariConfig.AmbariConfig().getConfig()
@@ -221,6 +224,7 @@ class TestHeartbeat(TestCase):
self.assertFalse(args[1])
+ @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
@patch.object(HostInfoLinux, 'register')
def test_heartbeat_host_check_no_cmd(self, register_mock):
config = AmbariConfig.AmbariConfig().getConfig()
http://git-wip-us.apache.org/repos/asf/ambari/blob/48aea274/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestRegistration.py b/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
index 676266f..41f9880 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
@@ -29,10 +29,12 @@ with patch("platform.linux_distribution", return_value = ('Suse','11','Final')):
from ambari_agent.Register import Register
from ambari_agent.AmbariConfig import AmbariConfig
from ambari_commons import OSCheck, Firewall, FirewallChecks
+ from ambari_agent.Hardware import Hardware
class TestRegistration(TestCase):
@only_for_platform(PLATFORM_LINUX)
+ @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
@patch.object(FirewallChecks, "run_os_command")
@patch.object(OSCheck, "get_os_type")
@patch.object(OSCheck, "get_os_version")
[2/2] ambari git commit: AMBARI-9011. Repository versions url href
are broken when installing a new version on the cluster. (dlysnichenko)
Posted by dm...@apache.org.
AMBARI-9011. Repository versions url href are broken when installing a new version on the cluster. (dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/eaa65fac
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/eaa65fac
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/eaa65fac
Branch: refs/heads/trunk
Commit: eaa65facf817aedbfd0ae55e74281ab04974aaba
Parents: 48aea27
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Thu Jan 8 21:48:59 2015 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Thu Jan 8 21:48:59 2015 +0200
----------------------------------------------------------------------
.../services/ClusterStackVersionService.java | 21 ++++++++++++++++++++
.../ClusterStackVersionServiceTest.java | 11 ++++++++++
2 files changed, 32 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/eaa65fac/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterStackVersionService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterStackVersionService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterStackVersionService.java
index 406e255..eb8a461 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterStackVersionService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterStackVersionService.java
@@ -84,6 +84,27 @@ public class ClusterStackVersionService extends BaseService {
return handleRequest(headers, null, ui, Request.Type.GET, createResource(stackVersionId));
}
+
+ /**
+ * Gets the cluster stack versions service.
+ *
+ * @param request
+ * the request
+ * @param stackVersion
+ * the stack name
+ *
+ * @return the repository stack version service
+ */
+ @Path("{stackVersionId}/repository_versions")
+ public RepositoryVersionService getRepositoryVersionService(@Context javax.ws.rs.core.Request request,
+ @PathParam("stackVersionId") String stackVersion) {
+ final Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
+ mapIds.put(Resource.Type.Cluster, clusterName);
+ mapIds.put(Resource.Type.ClusterStackVersion, stackVersion);
+ return new RepositoryVersionService(mapIds);
+ }
+
+
/**
* Handles: POST /{clustername}/stack_versions requests
* Distribute repositories/install packages.
http://git-wip-us.apache.org/repos/asf/ambari/blob/eaa65fac/ambari-server/src/test/java/org/apache/ambari/server/api/services/ClusterStackVersionServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/ClusterStackVersionServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/ClusterStackVersionServiceTest.java
index 7972bd1..19d8d41 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/ClusterStackVersionServiceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/ClusterStackVersionServiceTest.java
@@ -18,10 +18,13 @@
package org.apache.ambari.server.api.services;
+import junit.framework.TestCase;
import org.apache.ambari.server.api.resources.ResourceInstance;
import org.apache.ambari.server.api.services.parsers.RequestBodyParser;
import org.apache.ambari.server.api.services.serializers.ResultSerializer;
import org.apache.ambari.server.controller.spi.Resource.Type;
+import org.easymock.EasyMock;
+import org.junit.Test;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.UriInfo;
@@ -58,6 +61,14 @@ public class ClusterStackVersionServiceTest extends BaseServiceTest {
return listInvocations;
}
+ @Test
+ public void testGetRepositoryVersionService() {
+ ClusterStackVersionService clusterStackVersionService = new TestClusterStackVersionService("cluster");
+ RepositoryVersionService rvs =
+ clusterStackVersionService.getRepositoryVersionService(EasyMock.createMock(javax.ws.rs.core.Request.class), "1");
+ TestCase.assertNotNull(rvs);
+ }
+
private class TestClusterStackVersionService extends ClusterStackVersionService {
public TestClusterStackVersionService(String clusterName) {
super(clusterName);