ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject ambari git commit: AMBARI-11185. Edit Repositories on an added repo version fails with 500 status code. (Di Li via Jaimin)
Date Fri, 05 Jun 2015 20:49:17 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk c7b0688a4 -> 8e496ce61


AMBARI-11185. Edit Repositories on an added repo version fails with 500 status code. (Di Li
via Jaimin)


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

Branch: refs/heads/trunk
Commit: 8e496ce6114fd6ee0a8450ab9cbde6df68bbca1a
Parents: c7b0688
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Fri Jun 5 13:48:52 2015 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Fri Jun 5 13:48:52 2015 -0700

----------------------------------------------------------------------
 .../main/admin/stack_and_upgrade_controller.js  | 24 ++++++++++++----
 .../stack_upgrade/upgrade_version_box_view.js   | 20 +++++++++++++
 .../admin/stack_and_upgrade_controller_test.js  | 24 ++++++++++++++++
 .../upgrade_version_box_view_test.js            | 30 +++++++++++++++++++-
 4 files changed, 92 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8e496ce6/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
index 890e5d8..ac8f8cf 100644
--- a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
+++ b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
@@ -557,6 +557,17 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
   },
 
   /**
+   * Return stack version for the repo object
+   * @param {Em.Object} repo
+   * */
+  getStackVersionNumber: function(repo){
+    var stackVersionNumber = repo.get('stackVersion');
+    if(null == stackVersionNumber)
+      stackVersionNumber = App.get('currentStackVersion');
+    return stackVersionNumber;
+  },
+  
+  /**
    * perform validation if <code>skip<code> is  false and run save if
    * validation successfull or run save without validation is <code>skip<code>
is true
    * @param {Em.Object} repo
@@ -571,13 +582,15 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
         deferred.resolve(data);
       } else {
         var repoVersion = self.prepareRepoForSaving(repo);
-
+        var stackVersionNumber = self.getStackVersionNumber(repo);
+        console.log("Repository stack version:"+stackVersionNumber);
+        
         App.ajax.send({
           name: 'admin.stack_versions.edit.repo',
           sender: this,
           data: {
             stackName: App.get('currentStackName'),
-            stackVersion: App.get('currentStackVersionNumber'),
+            stackVersion: stackVersionNumber,
             repoVersionId: repo.get('repoVersionId'),
             repoVersion: repoVersion
           }
@@ -588,7 +601,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
     });
     return deferred.promise();
   },
-
+  
   /**
    * send request for validation for each repository
    * @param {Em.Object} repo
@@ -599,10 +612,11 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
     var deferred = $.Deferred(),
       totalCalls = 0,
       invalidUrls = [];
-
+    
     if (skip) {
       deferred.resolve(invalidUrls);
     } else {
+      var stackVersionNumber = this.getStackVersionNumber(repo);
       repo.get('operatingSystems').forEach(function (os) {
         if (os.get('isSelected')) {
           os.get('repositories').forEach(function (repo) {
@@ -616,7 +630,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
                 baseUrl: repo.get('baseUrl'),
                 osType: os.get('osType'),
                 stackName: App.get('currentStackName'),
-                stackVersion: App.get('currentStackVersionNumber')
+                stackVersion: stackVersionNumber
               }
             })
               .success(function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/8e496ce6/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
index f9c4ef2..28d1428 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
@@ -186,6 +186,25 @@ App.UpgradeVersionBoxView = Em.View.extend({
   },
 
   /**
+   * @param App.RepositoryVersion
+   * */
+  getStackVersionNumber: function(repository){
+    var stackVersion = null; 
+    var systems = repository.get('operatingSystems');
+    
+    systems.forEach(function(os){
+      repos = os.get('repositories');
+      repos.forEach(function(repo){
+        stackVersion = repo.get('stackVersion');
+        if(null != stackVersion)
+          return stackVersion;
+      });
+    });
+
+    return stackVersion; 
+  },
+  
+  /**
    * show popup with repositories to edit
    * @return {App.ModalPopup}
    */
@@ -197,6 +216,7 @@ App.UpgradeVersionBoxView = Em.View.extend({
       repoVersionId: repoRecord.get('id'),
       displayName: repoRecord.get('displayName'),
       repositoryVersion: repoRecord.get('displayName'),
+      stackVersion: self.getStackVersionNumber(repoRecord),
       operatingSystems: repoRecord.get('operatingSystems').map(function (os) {
         return Em.Object.create({
           osType: os.get('osType'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/8e496ce6/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
index b8b4fe3..4177619 100644
--- a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
@@ -763,6 +763,30 @@ describe('App.MainAdminStackAndUpgradeController', function() {
     });
   });
 
+  describe("#getStackVersionNumber()", function(){
+    it("get stack version number", function(){
+      var repo = Em.Object.create({
+        "stackVersionType": 'HDP',
+        "stackVersion": '2.3',
+        "repositoryVersion": '2.2.1'
+      });
+      
+      var stackVersion = controller.getStackVersionNumber(repo);
+      expect(stackVersion).to.equal('2.3');
+    });
+    
+    it("get default stack version number", function(){
+      App.set('currentStackVersion', '1.2.3');
+      var repo = Em.Object.create({
+        "stackVersionType": 'HDP',
+        "repositoryVersion": '2.2.1'
+      });
+      
+      var stackVersion = controller.getStackVersionNumber(repo);
+      expect(stackVersion).to.equal('1.2.3');
+    });
+  });
+  
   describe("#saveRepoOS()", function() {
     before(function(){
       this.mock = sinon.stub(controller, 'validateRepoVersions');

http://git-wip-us.apache.org/repos/asf/ambari/blob/8e496ce6/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
index 0ff7688..e45bfd3 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
@@ -182,7 +182,35 @@ describe('App.UpgradeVersionBoxView', function () {
       expect(view.get('controller').upgrade.called).to.be.false;
     });
   });
-
+  
+  describe("#getStackVersionNumber()", function(){
+    it("get stack version number", function(){
+      var repoRecord = Em.Object.create({
+        operatingSystems: [
+          Em.Object.create({
+            osType: "redhat6",
+            repositories: [Em.Object.create({
+                "baseUrl": "111121",
+                "repoId": "HDP-2.3",
+                "repoName": "HDP",
+                "stackVersion": "2.3",
+                hasError: false
+            }), Em.Object.create({
+                "baseUrl": "1",
+                "repoId": "HDP-UTILS-1.1.0.20",
+                "repoName": "HDP-UTILS",
+                "stackVersion": "2.3",
+                hasError: false
+              })]
+           })
+        ]
+      });
+      
+      var stackVersionNumber = view.getStackVersionNumber(repoRecord);
+      expect(stackVersionNumber).to.equal('2.3');
+    });
+  });
+  
   describe("#editRepositories()", function () {
     beforeEach(function () {
       sinon.stub(App.RepositoryVersion, 'find').returns(Em.Object.create({


Mime
View raw message