Parcourir la source

AMBARI-10080 After adding a HS2 instance properties are modifed uncessarily. (atkach)

Andrii Tkach il y a 10 ans
Parent
commit
8cf83e953f

+ 1 - 1
ambari-web/app/controllers/main/host/details.js

@@ -753,7 +753,7 @@ App.MainHostDetailsController = Em.Controller.extend({
       this.set('fromDeleteHost', false);
       return hiveHosts.without(this.get('content.hostName'));
     }
-    return hiveHosts;
+    return hiveHosts.sort();
   },
 
   /**

+ 78 - 0
ambari-web/test/controllers/main/host/details_test.js

@@ -2352,4 +2352,82 @@ describe('App.MainHostDetailsController', function () {
       expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
     });
   });
+
+  describe('#getHiveHosts()', function () {
+
+    var cases = [
+      {
+        'input': {
+          'hiveMetastoreHost': '',
+          'fromDeleteHost': false,
+          'deleteHiveMetaStore': false
+        },
+        'hiveHosts': ['h1', 'h2'],
+        'title': 'adding HiveServer2'
+      },
+      {
+        'input': {
+          'hiveMetastoreHost': 'h0',
+          'fromDeleteHost': false,
+          'deleteHiveMetaStore': false
+        },
+        'hiveHosts': ['h0', 'h1', 'h2'],
+        'title': 'adding Hive Metastore'
+      },
+      {
+        'input': {
+          'hiveMetastoreHost': '',
+          'content.hostName': 'h1',
+          'fromDeleteHost': false,
+          'deleteHiveMetaStore': true
+        },
+        'hiveHosts': ['h2'],
+        'title': 'deleting Hive component'
+      },
+      {
+        'input': {
+          'hiveMetastoreHost': '',
+          'content.hostName': 'h2',
+          'fromDeleteHost': true,
+          'deleteHiveMetaStore': false
+        },
+        'hiveHosts': ['h1'],
+        'title': 'deleting host with Hive component'
+      }
+    ];
+
+    before(function () {
+      sinon.stub(App.HostComponent, 'find').returns([
+        {
+          componentName: 'HIVE_METASTORE',
+          hostName: 'h2'
+        },
+        {
+          componentName: 'HIVE_METASTORE',
+          hostName: 'h1'
+        },
+        {
+          componentName: 'HIVE_SERVER',
+          hostName: 'h3'
+        }
+      ]);
+    });
+
+    after(function () {
+      App.HostComponent.find.restore();
+    });
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        Em.keys(item.input).forEach(function (key) {
+          controller.set(key, item.input[key]);
+        });
+        expect(controller.getHiveHosts()).to.eql(item.hiveHosts);
+        expect(controller.get('hiveMetastoreHost')).to.be.empty;
+        expect(controller.get('fromDeleteHost')).to.be.false;
+        expect(controller.get('deleteHiveMetaStore')).to.be.false;
+      });
+    });
+
+  });
 });

+ 1 - 1
ambari-web/test/views/main/service/item_test.js

@@ -21,7 +21,7 @@ require('views/main/service/item');
 
 var view;
 
-describe.only('App.MainServiceItemView', function () {
+describe('App.MainServiceItemView', function () {
 
   describe('#mastersExcludedCommands', function () {