فهرست منبع

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

Alex Antonenko 9 سال پیش
والد
کامیت
e30453f1b3

+ 12 - 0
ambari-web/app/controllers/main/service/add_controller.js

@@ -384,6 +384,18 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs, {
     this.set('content.clients', clients);
   },
 
+  /**
+   * 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

+ 47 - 0
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);
+        });
+
+      });
+
+    });
+
+  });
+
 });