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/09/09 10:48:12 UTC
[1/2] ambari git commit: AMBARI-13014. RU: Installing version stuck
on host (dlysnichenko)
Repository: ambari
Updated Branches:
refs/heads/branch-2.1 8c254337b -> 6d9b99751
refs/heads/trunk 27803b592 -> 82396b1fd
AMBARI-13014. RU: Installing version stuck on host (dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/82396b1f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/82396b1f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/82396b1f
Branch: refs/heads/trunk
Commit: 82396b1fd322506b705662d097176481c94130d9
Parents: 27803b5
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Wed Sep 9 11:47:12 2015 +0300
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Wed Sep 9 11:47:12 2015 +0300
----------------------------------------------------------------------
.../libraries/functions/repo_version_history.py | 10 ++-
.../custom_actions/TestRepoVersionHistory.py | 71 ++++++++++++++++++++
2 files changed, 80 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/82396b1f/ambari-common/src/main/python/resource_management/libraries/functions/repo_version_history.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/repo_version_history.py b/ambari-common/src/main/python/resource_management/libraries/functions/repo_version_history.py
index f8ea7c9..d585dea 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/repo_version_history.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/repo_version_history.py
@@ -78,7 +78,15 @@ def write_actual_version_to_history_file(repository_version, actual_version):
value = repository_version + "," + actual_version
key_exists = False
try:
- if read_actual_version_from_history_file(repository_version) is None:
+ if os.path.isfile(REPO_VERSION_HISTORY_FILE):
+ with open(REPO_VERSION_HISTORY_FILE, "r") as f:
+ for line in f.readlines():
+ line_parts = line.split(",")
+ if line_parts and len(line_parts) == 2 and line_parts[0] == repository_version and line_parts[1] == actual_version:
+ key_exists = True
+ break
+
+ if not key_exists:
with open(REPO_VERSION_HISTORY_FILE, "a") as f:
f.write(repository_version + "," + actual_version + "\n")
wrote_value = True
http://git-wip-us.apache.org/repos/asf/ambari/blob/82396b1f/ambari-server/src/test/python/custom_actions/TestRepoVersionHistory.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/custom_actions/TestRepoVersionHistory.py b/ambari-server/src/test/python/custom_actions/TestRepoVersionHistory.py
new file mode 100644
index 0000000..1eccb2f
--- /dev/null
+++ b/ambari-server/src/test/python/custom_actions/TestRepoVersionHistory.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+'''
+import os
+import tempfile
+from stacks.utils.RMFTestCase import *
+from resource_management.libraries.functions import repo_version_history
+import logging
+
+from only_for_platform import not_for_platform, PLATFORM_WINDOWS
+
+@not_for_platform(PLATFORM_WINDOWS)
+class TestRepoVersionHistory(RMFTestCase):
+
+
+
+ def test_read_and_write_repo_version_history(self):
+ f, filename = tempfile.mkstemp()
+
+
+ try:
+ # Check read of empty file
+ repo_version_history.REPO_VERSION_HISTORY_FILE = filename
+ repo_version_history.Logger = logging.getLogger()
+ result = repo_version_history.read_actual_version_from_history_file('2.3.2.0')
+ self.assertEquals(result, None)
+
+ # Check read of single value
+ repo_version_history.write_actual_version_to_history_file('2.3.2.0', '2.3.2.0-210')
+ result = repo_version_history.read_actual_version_from_history_file('2.3.2.0')
+ self.assertEquals(result, '2.3.2.0-210')
+
+ # Check read after update
+ repo_version_history.write_actual_version_to_history_file('2.3.2.0', '2.3.2.0-2716')
+ result = repo_version_history.read_actual_version_from_history_file('2.3.2.0')
+ self.assertEquals(result, '2.3.2.0-2716')
+
+ # Check read after update
+ repo_version_history.write_actual_version_to_history_file('2.3.2.0', '2.3.2.0-2758')
+ result = repo_version_history.read_actual_version_from_history_file('2.3.2.0')
+ self.assertEquals(result, '2.3.2.0-2758')
+
+ # Check read after writing down version for another stack
+ repo_version_history.write_actual_version_to_history_file('2.3.1.0', '2.3.1.0-27')
+ result = repo_version_history.read_actual_version_from_history_file('2.3.1.0')
+ self.assertEquals(result, '2.3.1.0-27')
+ result = repo_version_history.read_actual_version_from_history_file('2.3.2.0')
+ self.assertEquals(result, '2.3.2.0-2758')
+
+ # Check read of another stack
+ result = repo_version_history.read_actual_version_from_history_file('2.3.0.0')
+ self.assertEquals(result, None)
+
+ finally:
+ os.unlink(filename)
[2/2] ambari git commit: AMBARI-13014. RU: Installing version stuck
on host (dlysnichenko)
Posted by dm...@apache.org.
AMBARI-13014. RU: Installing version stuck on host (dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6d9b9975
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6d9b9975
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6d9b9975
Branch: refs/heads/branch-2.1
Commit: 6d9b99751597365221048021e34af20607942b25
Parents: 8c25433
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Wed Sep 9 11:47:12 2015 +0300
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Wed Sep 9 11:48:24 2015 +0300
----------------------------------------------------------------------
.../libraries/functions/repo_version_history.py | 10 ++-
.../custom_actions/TestRepoVersionHistory.py | 71 ++++++++++++++++++++
2 files changed, 80 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/6d9b9975/ambari-common/src/main/python/resource_management/libraries/functions/repo_version_history.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/repo_version_history.py b/ambari-common/src/main/python/resource_management/libraries/functions/repo_version_history.py
index f8ea7c9..d585dea 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/repo_version_history.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/repo_version_history.py
@@ -78,7 +78,15 @@ def write_actual_version_to_history_file(repository_version, actual_version):
value = repository_version + "," + actual_version
key_exists = False
try:
- if read_actual_version_from_history_file(repository_version) is None:
+ if os.path.isfile(REPO_VERSION_HISTORY_FILE):
+ with open(REPO_VERSION_HISTORY_FILE, "r") as f:
+ for line in f.readlines():
+ line_parts = line.split(",")
+ if line_parts and len(line_parts) == 2 and line_parts[0] == repository_version and line_parts[1] == actual_version:
+ key_exists = True
+ break
+
+ if not key_exists:
with open(REPO_VERSION_HISTORY_FILE, "a") as f:
f.write(repository_version + "," + actual_version + "\n")
wrote_value = True
http://git-wip-us.apache.org/repos/asf/ambari/blob/6d9b9975/ambari-server/src/test/python/custom_actions/TestRepoVersionHistory.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/custom_actions/TestRepoVersionHistory.py b/ambari-server/src/test/python/custom_actions/TestRepoVersionHistory.py
new file mode 100644
index 0000000..1eccb2f
--- /dev/null
+++ b/ambari-server/src/test/python/custom_actions/TestRepoVersionHistory.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+'''
+import os
+import tempfile
+from stacks.utils.RMFTestCase import *
+from resource_management.libraries.functions import repo_version_history
+import logging
+
+from only_for_platform import not_for_platform, PLATFORM_WINDOWS
+
+@not_for_platform(PLATFORM_WINDOWS)
+class TestRepoVersionHistory(RMFTestCase):
+
+
+
+ def test_read_and_write_repo_version_history(self):
+ f, filename = tempfile.mkstemp()
+
+
+ try:
+ # Check read of empty file
+ repo_version_history.REPO_VERSION_HISTORY_FILE = filename
+ repo_version_history.Logger = logging.getLogger()
+ result = repo_version_history.read_actual_version_from_history_file('2.3.2.0')
+ self.assertEquals(result, None)
+
+ # Check read of single value
+ repo_version_history.write_actual_version_to_history_file('2.3.2.0', '2.3.2.0-210')
+ result = repo_version_history.read_actual_version_from_history_file('2.3.2.0')
+ self.assertEquals(result, '2.3.2.0-210')
+
+ # Check read after update
+ repo_version_history.write_actual_version_to_history_file('2.3.2.0', '2.3.2.0-2716')
+ result = repo_version_history.read_actual_version_from_history_file('2.3.2.0')
+ self.assertEquals(result, '2.3.2.0-2716')
+
+ # Check read after update
+ repo_version_history.write_actual_version_to_history_file('2.3.2.0', '2.3.2.0-2758')
+ result = repo_version_history.read_actual_version_from_history_file('2.3.2.0')
+ self.assertEquals(result, '2.3.2.0-2758')
+
+ # Check read after writing down version for another stack
+ repo_version_history.write_actual_version_to_history_file('2.3.1.0', '2.3.1.0-27')
+ result = repo_version_history.read_actual_version_from_history_file('2.3.1.0')
+ self.assertEquals(result, '2.3.1.0-27')
+ result = repo_version_history.read_actual_version_from_history_file('2.3.2.0')
+ self.assertEquals(result, '2.3.2.0-2758')
+
+ # Check read of another stack
+ result = repo_version_history.read_actual_version_from_history_file('2.3.0.0')
+ self.assertEquals(result, None)
+
+ finally:
+ os.unlink(filename)