AMBARI-16761. Add Service Wizard is broken after ambari-server restart 
(alexantonenko)


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

Branch: refs/heads/trunk
Commit: 420c8d58c8dd0fd60b36b9376c170d96c95c59c7
Parents: 6672b74
Author: Alex Antonenko <[email protected]>
Authored: Thu May 19 12:01:07 2016 +0300
Committer: Alex Antonenko <[email protected]>
Committed: Thu May 19 12:43:52 2016 +0300

----------------------------------------------------------------------
 .../controllers/main/service/add_controller.js  | 12 +++++
 .../main/service/add_controller_test.js         | 47 ++++++++++++++++++++
 2 files changed, 59 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/420c8d58/ambari-web/app/controllers/main/service/add_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/add_controller.js 
b/ambari-web/app/controllers/main/service/add_controller.js
index 6d4f991..c8763c7 100644
--- a/ambari-web/app/controllers/main/service/add_controller.js
+++ b/ambari-web/app/controllers/main/service/add_controller.js
@@ -385,6 +385,18 @@ App.AddServiceController = 
App.WizardController.extend(App.AddSecurityConfigs, {
   },
 
   /**
+   * Load information about hosts with clients components
+   */
+  loadClients: function () {
+    var clients = this.getDBProperty('clientInfo');
+    if (clients) {
+      this.set('content.clients', clients);
+    } else {
+      this.saveClients();
+    }
+  },
+
+  /**
    * Remove all loaded data.
    * Created as copy for App.router.clearAllSteps
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/420c8d58/ambari-web/test/controllers/main/service/add_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/add_controller_test.js 
b/ambari-web/test/controllers/main/service/add_controller_test.js
index 01f87a8..3939632 100644
--- a/ambari-web/test/controllers/main/service/add_controller_test.js
+++ b/ambari-web/test/controllers/main/service/add_controller_test.js
@@ -515,4 +515,51 @@ describe('App.AddServiceController', function() {
     });
   });
 
+  describe('#loadClients', function () {
+
+    var cases = [
+      {
+        clients: null,
+        contentClients: [],
+        saveClientsCallCount: 1,
+        title: 'no clients info in local db'
+      },
+      {
+        clients: [{}],
+        contentClients: [{}],
+        saveClientsCallCount: 0,
+        title: 'clients info saved in local db'
+      }
+    ];
+
+    cases.forEach(function (item) {
+
+      describe(item.title, function () {
+
+        beforeEach(function () {
+          sinon.stub(addServiceController, 
'getDBProperty').withArgs('clientInfo').returns(item.clients);
+          sinon.stub(addServiceController, 'saveClients', Em.K);
+          addServiceController.set('content.clients', []);
+          addServiceController.loadClients();
+        });
+
+        afterEach(function () {
+          addServiceController.getDBProperty.restore();
+          addServiceController.saveClients.restore();
+        });
+
+        it('content.clients', function () {
+          expect(addServiceController.get('content.clients', 
[])).to.eql(item.contentClients);
+        });
+
+        it('saveClients call', function () {
+          
expect(addServiceController.saveClients.callCount).to.equal(item.saveClientsCallCount);
+        });
+
+      });
+
+    });
+
+  });
+
 });

Reply via email to