浏览代码

AMBARI-7805. Knox custom commands are shown twice in the service menu. (jaimin)

Jaimin Jetly 10 年之前
父节点
当前提交
0a4408162d

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.2/services/KNOX/metainfo.xml

@@ -22,7 +22,7 @@
       <name>KNOX</name>
       <displayName>Knox</displayName>
       <comment>Provides a single point of authentication and access for Apache Hadoop services in a cluster</comment>
-      <version>0.5.0</version>
+      <version>0.5.0.2.2.0.0</version>
       <components>
         <component>
           <name>KNOX_GATEWAY</name>

+ 1 - 0
ambari-web/app/assets/test/tests.js

@@ -165,6 +165,7 @@ var files = ['test/init_model_test',
   'test/views/main/host/details/host_component_view_test',
   'test/views/main/host/details/host_component_views/decommissionable_test',
   'test/views/main/charts/heatmap/heatmap_host_test',
+  'test/views/main/service/item_test',
   'test/views/main/service/info/config_test',
   'test/views/common/configs/services_config_test',
   'test/views/wizard/step3/hostLogPopupBody_view_test',

+ 6 - 1
ambari-web/app/views/main/service/item.js

@@ -40,7 +40,8 @@ App.MainServiceItemView = Em.View.extend({
   mastersExcludedCommands: {
     'NAMENODE': ['DECOMMISSION', 'REBALANCEHDFS'],
     'RESOURCEMANAGER': ['DECOMMISSION', 'REFRESHQUEUES'],
-    'HBASE_MASTER': ['DECOMMISSION']
+    'HBASE_MASTER': ['DECOMMISSION'],
+    'KNOX_GATEWAY': ['STARTDEMOLDAP','STOPDEMOLDAP']
   },
 
   actionMap: function() {
@@ -65,6 +66,7 @@ App.MainServiceItemView = Em.View.extend({
       },
       REFRESH_YARN_QUEUE: {
         action: 'refreshYarnQueues',
+        customCommand: 'REFRESHQUEUES',
         label: Em.I18n.t('services.service.actions.run.yarnRefreshQueues.menu'),
         cssClass: 'icon-refresh',
         disabled: false
@@ -104,18 +106,21 @@ App.MainServiceItemView = Em.View.extend({
       },
       STARTDEMOLDAP: {
         action: 'startLdapKnox',
+        customCommand: 'STARTDEMOLDAP',
         label: Em.I18n.t('services.service.actions.run.startLdapKnox.context'),
         cssClass: 'icon-play-sign',
         disabled: false
       },
       STOPDEMOLDAP: {
         action: 'stopLdapKnox',
+        customCommand: 'STOPDEMOLDAP',
         label: Em.I18n.t('services.service.actions.run.stopLdapKnox.context'),
         cssClass: 'icon-stop',
         disabled: false
       },
       REBALANCE_HDFS: {
         action: 'rebalanceHdfsNodes',
+        customCommand: 'REBALANCEHDFS',
         context: Em.I18n.t('services.service.actions.run.rebalanceHdfsNodes.context'),
         label: Em.I18n.t('services.service.actions.run.rebalanceHdfsNodes'),
         cssClass: 'icon-refresh',

+ 4 - 14
ambari-web/test/app_test.js

@@ -30,6 +30,8 @@ describe('App', function () {
       loadTags: function () {
       }
     });
+    App.set('defaultStackVersion', "HDP-1.2.2");
+    App.set('currentStackVersion', "HDP-1.2.2");
 
     var testCases = [
       {
@@ -55,28 +57,16 @@ describe('App', function () {
         currentStackVersion: 'HDP-1.3.2',
         defaultStackVersion: 'HDP-1.3.1',
         result: '/stacks/HDP/versions/1.3.2'
-      },
-      {
-        title: 'if defaultStackVersion is "HDPLocal-1.3.1" then stackVersionURL should be "/stacks/HDPLocal/versions/1.3.1"',
-        currentStackVersion: '',
-        defaultStackVersion: 'HDPLocal-1.3.1',
-        result: '/stacks/HDPLocal/versions/1.3.1'
-      },
-      {
-        title: 'if currentStackVersion is "HDPLocal-1.3.1" then stackVersionURL should be "/stacks/HDPLocal/versions/1.3.1"',
-        currentStackVersion: 'HDPLocal-1.3.1',
-        defaultStackVersion: '',
-        result: '/stacks/HDPLocal/versions/1.3.1'
       }
     ];
 
     testCases.forEach(function (test) {
       it(test.title, function () {
-        App.set('currentStackVersion', test.currentStackVersion);
         App.set('defaultStackVersion', test.defaultStackVersion);
+        App.set('currentStackVersion', test.currentStackVersion);
         expect(App.get('stackVersionURL')).to.equal(test.result);
-        App.set('currentStackVersion', "HDP-1.2.2");
         App.set('defaultStackVersion', "HDP-1.2.2");
+        App.set('currentStackVersion', "HDP-1.2.2");
       });
     });
   });

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

@@ -0,0 +1,66 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+require('views/main/service/item');
+
+describe('App.MainServiceItemView', function() {
+
+  var view = App.MainServiceItemView.create({
+    controller: Em.Object.create({
+      content:{
+        hostComponents: []
+      }
+    })
+  });
+
+  describe('#mastersExcludedCommands', function() {
+
+    var nonCustomAction = ['RESTART_ALL', 'RUN_SMOKE_TEST', 'REFRESH_CONFIGS', 'ROLLING_RESTART', 'TOGGLE_PASSIVE', 'TOGGLE_NN_HA', 'TOGGLE_RM_HA', 'MOVE_COMPONENT', 'DOWNLOAD_CLIENT_CONFIGS','MASTER_CUSTOM_COMMAND'];
+
+    var keys = Object.keys(view.mastersExcludedCommands);
+    var mastersExcludedCommands = [];
+    for (var i = 0; i < keys.length; i++) {
+      mastersExcludedCommands[i] = view.mastersExcludedCommands[keys[i]];
+    }
+    console.log("value of masterExcluded: " + mastersExcludedCommands);
+    var allMastersExcludedCommands = mastersExcludedCommands.reduce(function(previous, current){
+      console.log(previous);
+      return previous.concat(current);
+    });
+    var actionMap = view.actionMap();
+
+    var customActionsArray = [];
+    for (var iter in actionMap) {
+      customActionsArray.push(actionMap[iter]);
+    }
+    var customActions = customActionsArray.mapProperty('customCommand').filter(function(action){
+      return !nonCustomAction.contains(action);
+    }).uniq();
+
+    // remove null and undefined from the list
+    customActions = customActions.filter(function(value) { return value != null; });
+
+    customActions.forEach(function(action){
+      it(action + ' should be present in App.MainServiceItemView mastersExcludedCommands object', function() {
+        expect(allMastersExcludedCommands).to.contain(action);
+      });
+    });
+  });
+});
+