Переглянути джерело

AMBARI-16670: PXF start and service check operations should consider all PXF agents status (Goutam Tadi via mithmatt)

Matt 9 роки тому
батько
коміт
da12d44189

+ 11 - 0
ambari-web/app/controllers/main/service/item.js

@@ -1060,9 +1060,20 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
     if (this.get('content.serviceName') == 'HAWQ' && this.get('content.hostComponents').filterProperty('componentName', 'HAWQMASTER').someProperty('workStatus', App.HostComponentStatus.started)) {
       return false;
     }
+    if (this.get('content.serviceName') == 'PXF' && App.HostComponent.find().filterProperty('componentName', 'PXF').someProperty('workStatus', App.HostComponentStatus.started)) {
+      return false;
+    }
     return (this.get('content.healthStatus') != 'green');
   }.property('content.healthStatus','isPending', 'App.isHaEnabled'),
 
+  isSmokeTestDisabled: function () {
+    if (this.get('isClientsOnlyService')) return false;
+    // Disable PXF service check if at least one PXF is down
+    if (this.get('content.serviceName') === 'PXF')
+      return App.HostComponent.find().filterProperty('componentName', 'PXF').someProperty('workStatus','INSTALLED');
+    return this.get('isStopDisabled');
+  }.property('content.serviceName'),
+
   /**
    * Determine if service has than one service client components
    */

+ 2 - 1
ambari-web/app/models/host_component.js

@@ -278,6 +278,7 @@ App.HostComponentActionMap = {
     var HS = ctx.get('controller.content.hostComponents').findProperty('componentName', 'HAWQSTANDBY');
     var HMComponent = App.MasterComponent.find('HAWQMASTER');
     var HSComponent = App.MasterComponent.find('HAWQSTANDBY');
+
     return {
       RESTART_ALL: {
         action: 'restartAllHostComponents',
@@ -290,7 +291,7 @@ App.HostComponentActionMap = {
         action: 'runSmokeTest',
         label: Em.I18n.t('services.service.actions.run.smoke'),
         cssClass: 'icon-thumbs-up-alt',
-        disabled: ctx.get('controller.isClientsOnlyService') ? false : ctx.get('controller.isStopDisabled')
+        disabled: ctx.get('controller.isSmokeTestDisabled')
       },
       REFRESH_CONFIGS: {
         action: 'refreshConfigs',

+ 55 - 6
ambari-web/test/controllers/main/service/item_test.js

@@ -404,7 +404,7 @@ describe('App.MainServiceItemController', function () {
     });
 
     describe("modal messages", function() {
-      
+
       beforeEach(function () {
         sinon.stub(App.StackService, 'find').returns([
           Em.Object.create({
@@ -412,7 +412,7 @@ describe('App.MainServiceItemController', function () {
             displayName: 'HDFS',
             isInstalled: true,
             isSelected: true,
-            requiredServices:["ZOOKEEPER"] 
+            requiredServices:["ZOOKEEPER"]
           }),
           Em.Object.create({
             serviceName: 'HIVE',
@@ -443,7 +443,7 @@ describe('App.MainServiceItemController', function () {
           })
         ]);
       });
-      
+
       it ("should confirm stop if serviceHealth is INSTALLED", function() {
         mainServiceItemController.startStopPopup(event, "INSTALLED");
         expect(Em.I18n.t.calledWith('services.service.stop.confirmMsg')).to.be.ok;
@@ -455,14 +455,14 @@ describe('App.MainServiceItemController', function () {
         expect(Em.I18n.t.calledWith('services.service.start.confirmMsg')).to.be.ok;
         expect(Em.I18n.t.calledWith('services.service.start.confirmButton')).to.be.ok;
       });
-      
+
       it ("should not display a dependent list if it is to start a service", function() {
         var _mainServiceItemController = App.MainServiceItemController.create(
             {content: {serviceName: "HDFS", passiveState:'OFF'}});
         _mainServiceItemController.startStopPopup(event, "");
         expect(Em.I18n.t.calledWith('services.service.stop.warningMsg.dependent.services')).to.not.be.ok;
       });
-      
+
       describe ("should display dependent list if other services depend on the one to be stopped", function() {
         beforeEach(function () {
           var _mainServiceItemController = App.MainServiceItemController.create(
@@ -510,7 +510,7 @@ describe('App.MainServiceItemController', function () {
           expect(this.fullMsg).to.be.equal(this.msg + " " + this.dependencies);
         });
       });
-      
+
       afterEach(function () {
         App.StackService.find.restore();
       });
@@ -1007,6 +1007,55 @@ describe('App.MainServiceItemController', function () {
     });
   });
 
+  describe("#isPXFStopDisabled", function () {
+
+    var hostComponentStub;
+
+    before(function () {
+      hostComponentStub = sinon.stub(App.HostComponent.find(), 'filterProperty');
+    });
+    after(function () {
+      hostComponentStub.restore();
+    });
+
+    var tests = [
+      {
+        content: {
+          serviceName: 'PXF',
+        },
+        isPending: false,
+        pxfWorkstatus: [{"workStatus": "STARTED"}, {"workStatus": "STARTED"}],
+        disabled: false,
+        m: "Enabled because all agents are started."
+      },
+      {
+        content: {
+          serviceName: 'PXF',
+        },
+        isPending: false,
+        pxfWorkstatus: [{"workStatus": "INSTALLED"}, {"workStatus": "STARTED"}],
+        disabled: false,
+        m: "Enabled because atleast one agent is started."
+      },
+      {
+        content: {
+          serviceName: 'PXF',
+        },
+        isPending: false,
+        pxfWorkstatus: [{"workStatus": "INSTALLED"}, {"workStatus": "INSTALLED"}],
+        disabled: true,
+        m: "Disabled because all PXF agents are down."
+      }
+    ];
+    tests.forEach(function (test) {
+      it(test.m, function () {
+        hostComponentStub.withArgs('componentName', 'PXF').returns(test.pxfWorkstatus);
+        var mainServiceItemController = App.MainServiceItemController.create({content: test.content, isPending: test.isPending});
+        expect(mainServiceItemController.get('isStopDisabled')).to.equal(test.disabled);
+      });
+    });
+  });
+
   describe("#runRebalancer", function () {
 
     beforeEach(function () {

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

@@ -550,7 +550,8 @@ describe('App.MainServiceItemView', function () {
               }),
               isSeveralClients: false,
               clientComponents: [],
-              isStopDisabled: false
+              isStopDisabled: false,
+              isSmokeTestDisabled: false
             }),
             mastersExcludedCommands: mastersExcludedCommands,
             hasConfigTab: hasConfigTab