You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2015/11/18 18:06:55 UTC
ambari git commit: AMBARI-13952. Unable to delete newly added host
component
Repository: ambari
Updated Branches:
refs/heads/branch-2.1 bdd29b766 -> 59658afe6
AMBARI-13952. Unable to delete newly added host component
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/59658afe
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/59658afe
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/59658afe
Branch: refs/heads/branch-2.1
Commit: 59658afe6bad041b1584ec996a8a202349edcc04
Parents: bdd29b7
Author: Alex Antonenko <hi...@gmail.com>
Authored: Wed Nov 18 19:04:08 2015 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Wed Nov 18 19:04:08 2015 +0200
----------------------------------------------------------------------
ambari-web/app/utils/ajax/ajax.js | 6 +-
.../main/host/details/host_component_view.js | 23 +------
.../host/details/host_component_view_test.js | 65 ++++++++------------
3 files changed, 31 insertions(+), 63 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/59658afe/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 05841af..258c7c1 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -998,9 +998,11 @@ var urls = {
},
'service.metrics.flume.incoming_event_put_successCount': {
'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=metrics/flume/flume/CHANNEL/EventPutSuccessCount/rate[{fromSeconds},{toSeconds},{stepSeconds}]'
- },'service.metrics.flume.incoming_event_put_successCount.mma': {
+ },
+ 'service.metrics.flume.incoming_event_put_successCount.mma': {
'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=metrics/flume/flume/CHANNEL/EventPutSuccessCount/rate/avg[{fromSeconds},{toSeconds},{stepSeconds}],metrics/flume/flume/CHANNEL/EventPutSuccessCount/rate/max[{fromSeconds},{toSeconds},{stepSeconds}],metrics/flume/flume/CHANNEL/EventPutSuccessCount/rate/min[{fromSeconds},{toSeconds},{stepSeconds}]'
- },'service.metrics.flume.incoming_event_put_successCount.sum': {
+ },
+ 'service.metrics.flume.incoming_event_put_successCount.sum': {
'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=metrics/flume/flume/CHANNEL/EventPutSuccessCount/rate/sum[{fromSeconds},{toSeconds},{stepSeconds}]'
},
'service.metrics.flume.outgoing_event_take_success_count': {
http://git-wip-us.apache.org/repos/asf/ambari/blob/59658afe/ambari-web/app/views/main/host/details/host_component_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/details/host_component_view.js b/ambari-web/app/views/main/host/details/host_component_view.js
index dec1e86..9605a92 100644
--- a/ambari-web/app/views/main/host/details/host_component_view.js
+++ b/ambari-web/app/views/main/host/details/host_component_view.js
@@ -207,27 +207,10 @@ App.HostComponentView = Em.View.extend({
*/
isDeleteComponentDisabled: function () {
var stackComponentCount = App.StackServiceComponent.find(this.get('hostComponent.componentName')).get('minToInstall');
- var installedCount = this.get('componentCounter');
+ var installedCount = App.HostComponent.getCount(this.get('hostComponent.componentName'), 'totalCount');
return (installedCount <= stackComponentCount)
|| ![App.HostComponentStatus.stopped, App.HostComponentStatus.unknown, App.HostComponentStatus.install_failed, App.HostComponentStatus.upgrade_failed, App.HostComponentStatus.init].contains(this.get('workStatus'));
- }.property('workStatus', 'componentCounter'),
-
- /**
- * gets number of current component that are applied to the cluster;
- * @returns {Number}
- */
- componentCounter: function() {
- var component;
- var stackServiceComponent = App.StackServiceComponent.find(this.get('hostComponent.componentName'));
- if (stackServiceComponent && App.get('router.clusterController.isHostContentLoaded')) {
- if (stackServiceComponent.get('isMaster')) {
- component = App.MasterComponent.find().findProperty('componentName', this.get('content.componentName'))
- } else {
- component = App.SlaveComponent.find().findProperty('componentName', this.get('content.componentName'));
- }
- }
- return component ? component.get('totalCount') : 0;
- }.property('App.router.clusterController.isHostContentLoaded'),
+ }.property('workStatus'),
/**
* Gets number of current running components that are applied to the cluster
@@ -390,7 +373,7 @@ App.HostComponentView = Em.View.extend({
if (component.get('cardinality') !== '1') {
if (!this.get('isStart')) {
- if (this.get('componentCounter') > 1) {
+ if (App.HostComponent.getCount(this.get('hostComponent.componentName'), 'totalCount') > 1) {
if (this.runningComponentCounter()) {
return false;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/59658afe/ambari-web/test/views/main/host/details/host_component_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host/details/host_component_view_test.js b/ambari-web/test/views/main/host/details/host_component_view_test.js
index 6f765de..bbcc897 100644
--- a/ambari-web/test/views/main/host/details/host_component_view_test.js
+++ b/ambari-web/test/views/main/host/details/host_component_view_test.js
@@ -36,7 +36,6 @@ describe('App.HostComponentView', function() {
return Em.get(App.router, k);
});
hostComponentView = App.HostComponentView.create({
- componentCounter: 1,
startBlinking: function(){},
doBlinking: function(){},
getDesiredAdminState: function(){return $.ajax({});},
@@ -243,50 +242,33 @@ describe('App.HostComponentView', function() {
describe('#isDeleteComponentDisabled', function() {
beforeEach(function() {
- sinon.stub(App.StackServiceComponent, 'find', function(component) {
- var min = component == 'comp0' ? 0 : 1;
- return Em.Object.create({minToInstall: min});
- });
+ this.mock = sinon.stub(App.StackServiceComponent, 'find');
+ sinon.stub(App.HostComponent, 'getCount').returns(1);
});
afterEach(function() {
- App.StackServiceComponent.find.restore();
+ this.mock.restore();
+ App.HostComponent.getCount.restore();
});
- var tests = ['INSTALLED', 'UNKNOWN', 'INSTALL_FAILED', 'UPGRADE_FAILED', 'INIT'];
- var testE = false;
- var defaultE = true;
-
- App.HostComponentStatus.getStatusesList().forEach(function(status) {
- it(status, function() {
- App.store.load(App.StackServiceComponent, {
- id: 1,
- component_name: 'comp0'
- });
- hostComponentView.get('hostComponent').set('componentName', 'comp0');
- hostComponentView.get('hostComponent').set('workStatus', status);
- var e = tests.contains(status) ? testE : defaultE;
- expect(hostComponentView.get('isDeleteComponentDisabled')).to.equal(e);
- });
+ it('delete is disabled because min cardinality 1', function() {
+ this.mock.returns(Em.Object.create({minToInstall: 1}));
+ hostComponentView.get('hostComponent').set('componentName', 'C1');
+ hostComponentView.propertyDidChange('isDeleteComponentDisabled');
+ expect(hostComponentView.get('isDeleteComponentDisabled')).to.be.true;
});
- it('delete is disabled because min cardinality 1', function() {
- App.store.load(App.StackServiceComponent, {
- id: 2,
- component_name: 'comp1'
- });
- hostComponentView.get('hostComponent').set('componentName', 'comp1');
- hostComponentView.get('hostComponent').set('workStatus', 'INSTALLED');
- expect(hostComponentView.get('isDeleteComponentDisabled')).to.equal(true);
+ it('delete is disabled because min cardinality 0 and status INSTALLED', function() {
+ this.mock.returns(Em.Object.create({minToInstall: 0}));
+ hostComponentView.get('hostComponent').set('workStatus', 'INIT');
+ hostComponentView.propertyDidChange('isDeleteComponentDisabled');
+ expect(hostComponentView.get('isDeleteComponentDisabled')).to.be.false;
});
- it('delete is enabled because min cardinality 0', function() {
- App.store.load(App.StackServiceComponent, {
- id: 2,
- component_name: 'comp0'
- });
- hostComponentView.get('hostComponent').set('componentName', 'comp0');
- hostComponentView.get('hostComponent').set('workStatus', 'INSTALLED');
- expect(hostComponentView.get('isDeleteComponentDisabled')).to.equal(false);
+ it('delete is enabled because min cardinality 0 and status STARTED', function() {
+ this.mock.returns(Em.Object.create({minToInstall: 0}));
+ hostComponentView.get('hostComponent').set('workStatus', 'STARTED');
+ hostComponentView.propertyDidChange('isDeleteComponentDisabled');
+ expect(hostComponentView.get('isDeleteComponentDisabled')).to.be.true;
});
});
@@ -506,7 +488,7 @@ describe('App.HostComponentView', function() {
});
});
- hostComponentView.set('componentCounter', 2);
+ sinon.stub(App.HostComponent, 'getCount').returns(2);
sinon.stub(hostComponentView, 'runningComponentCounter', function () {
return 1;
@@ -528,7 +510,7 @@ describe('App.HostComponentView', function() {
});
});
- hostComponentView.set('componentCounter', 2);
+ sinon.stub(App.HostComponent, 'getCount').returns(2);
sinon.stub(hostComponentView, 'runningComponentCounter', function () {
return 0;
@@ -550,7 +532,7 @@ describe('App.HostComponentView', function() {
});
});
- hostComponentView.set('componentCounter', 2);
+ sinon.stub(App.HostComponent, 'getCount').returns(2);
sinon.stub(hostComponentView, 'runningComponentCounter', function () {
return 2;
@@ -572,7 +554,7 @@ describe('App.HostComponentView', function() {
});
});
- hostComponentView.set('componentCounter', 1);
+ sinon.stub(App.HostComponent, 'getCount').returns(1);
sinon.stub(hostComponentView, 'runningComponentCounter', function () {
return 1;
@@ -585,6 +567,7 @@ describe('App.HostComponentView', function() {
afterEach(function() {
App.HostComponentActionMap.getMap.restore();
App.StackServiceComponent.find.restore();
+ App.HostComponent.getCount.restore();
hostComponentView.runningComponentCounter.restore();
});
});