You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ab...@apache.org on 2014/08/11 19:12:14 UTC
git commit: AMBARI-6820 Fix UI unit tests. (Max Shepel via ababiichuk)
Repository: ambari
Updated Branches:
refs/heads/trunk 0677c8d12 -> 989492ba8
AMBARI-6820 Fix UI unit tests. (Max Shepel via ababiichuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/989492ba
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/989492ba
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/989492ba
Branch: refs/heads/trunk
Commit: 989492ba8da41b1eca7c8aae53adda5c837e906b
Parents: 0677c8d
Author: aBabiichuk <ab...@cybervisiontech.com>
Authored: Mon Aug 11 20:10:21 2014 +0300
Committer: aBabiichuk <ab...@cybervisiontech.com>
Committed: Mon Aug 11 20:10:21 2014 +0300
----------------------------------------------------------------------
ambari-web/app/utils/ajax/ajax.js | 8 +-
ambari-web/test/app_test.js | 270 +++++++++----------
.../admin/highAvailability_controller_test.js | 198 ++------------
.../test/controllers/main/host/details_test.js | 19 +-
.../main/service/add_controller_test.js | 11 +-
.../main/service/info/config_test.js | 14 +-
.../service/reassign/step2_controller_test.js | 21 +-
.../service/reassign/step4_controller_test.js | 10 +-
.../test/controllers/wizard/step6_test.js | 14 -
.../test/controllers/wizard/step8_test.js | 8 +
.../test/utils/host_progress_popup_test.js | 5 +
ambari-web/test/views/application_test.js | 18 +-
.../host/details/host_component_view_test.js | 82 ++++--
.../decommissionable_test.js | 49 +++-
14 files changed, 297 insertions(+), 430 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/989492ba/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 b76e40d..832d347 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -2011,13 +2011,13 @@ var ajax = Em.Object.extend({
showStatus = 500;
}
var statusCode = jqXHR.status + " status code";
- if (jqXHR.status === showStatus && !this.modalPopup) {
- this.modalPopup = App.ModalPopup.show({
+ if (jqXHR.status === showStatus && !this.get('modalPopup')) {
+ this.set('modalPopup', App.ModalPopup.show({
header: Em.I18n.t('common.error'),
secondary: false,
onPrimary: function () {
this.hide();
- self.modalPopup = null;
+ self.set('modalPopup', null);
},
bodyClass: Ember.View.extend({
classNames: ['api-error'],
@@ -2027,7 +2027,7 @@ var ajax = Em.Object.extend({
message: message,
showMessage: !!message
})
- });
+ }));
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/989492ba/ambari-web/test/app_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/app_test.js b/ambari-web/test/app_test.js
index 2c502c2..4367797 100644
--- a/ambari-web/test/app_test.js
+++ b/ambari-web/test/app_test.js
@@ -368,147 +368,143 @@ describe('App', function () {
describe('#components', function () {
- var testCases = [
- {
- key: 'allComponents',
- data: [
- Em.Object.create({
- componentName: 'C1'
- })
- ],
- result: ['C1']
- },
- {
- key: 'reassignable',
- data: [
- Em.Object.create({
- componentName: 'C2',
- isReassignable: true
- })
- ],
- result: ['C2']
- },
- {
- key: 'restartable',
- data: [
- Em.Object.create({
- componentName: 'C3',
- isRestartable: true
- })
- ],
- result: ['C3']
- },
- {
- key: 'deletable',
- data: [
- Em.Object.create({
- componentName: 'C4',
- isDeletable: true
- })
- ],
- result: ['C4']
- },
- {
- key: 'rollinRestartAllowed',
- data: [
- Em.Object.create({
- componentName: 'C5',
- isRollinRestartAllowed: true
- })
- ],
- result: ['C5']
- },
- {
- key: 'decommissionAllowed',
- data: [
- Em.Object.create({
- componentName: 'C6',
- isDecommissionAllowed: true
- })
- ],
- result: ['C6']
- },
- {
- key: 'refreshConfigsAllowed',
- data: [
- Em.Object.create({
- componentName: 'C7',
- isRefreshConfigsAllowed: true
- })
- ],
- result: ['C7']
- },
- {
- key: 'addableToHost',
- data: [
- Em.Object.create({
- componentName: 'C8',
- isAddableToHost: true
- })
- ],
- result: ['C8']
- },
- {
- key: 'addableMasterInstallerWizard',
- data: [
- Em.Object.create({
- componentName: 'C9',
- isMasterAddableInstallerWizard: true
- })
- ],
- result: ['C9']
- },
- {
- key: 'multipleMasters',
- data: [
- Em.Object.create({
- componentName: 'C10',
- isMasterWithMultipleInstances: true
- })
- ],
- result: ['C10']
- },
- {
- key: 'slaves',
- data: [
- Em.Object.create({
- componentName: 'C11',
- isSlave: true
- })
- ],
- result: ['C11']
- },
- {
- key: 'masters',
- data: [
- Em.Object.create({
- componentName: 'C12',
- isMaster: true
- })
- ],
- result: ['C12']
- },
- {
- key: 'clients',
- data: [
- Em.Object.create({
- componentName: 'C13',
- isClient: true
- })
- ],
- result: ['C13']
- }
- ];
+ var i = 0,
+ testCases = [
+ {
+ key: 'allComponents',
+ data: [
+ Em.Object.create({
+ componentName: 'C1'
+ })
+ ],
+ result: ['C1']
+ },
+ {
+ key: 'reassignable',
+ data: [
+ Em.Object.create({
+ componentName: 'C2',
+ isReassignable: true
+ })
+ ],
+ result: ['C2']
+ },
+ {
+ key: 'restartable',
+ data: [
+ Em.Object.create({
+ componentName: 'C3',
+ isRestartable: true
+ })
+ ],
+ result: ['C3']
+ },
+ {
+ key: 'deletable',
+ data: [
+ Em.Object.create({
+ componentName: 'C4',
+ isDeletable: true
+ })
+ ],
+ result: ['C4']
+ },
+ {
+ key: 'rollinRestartAllowed',
+ data: [
+ Em.Object.create({
+ componentName: 'C5',
+ isRollinRestartAllowed: true
+ })
+ ],
+ result: ['C5']
+ },
+ {
+ key: 'decommissionAllowed',
+ data: [
+ Em.Object.create({
+ componentName: 'C6',
+ isDecommissionAllowed: true
+ })
+ ],
+ result: ['C6']
+ },
+ {
+ key: 'refreshConfigsAllowed',
+ data: [
+ Em.Object.create({
+ componentName: 'C7',
+ isRefreshConfigsAllowed: true
+ })
+ ],
+ result: ['C7']
+ },
+ {
+ key: 'addableToHost',
+ data: [
+ Em.Object.create({
+ componentName: 'C8',
+ isAddableToHost: true
+ })
+ ],
+ result: ['C8']
+ },
+ {
+ key: 'addableMasterInstallerWizard',
+ data: [
+ Em.Object.create({
+ componentName: 'C9',
+ isMasterAddableInstallerWizard: true
+ })
+ ],
+ result: ['C9']
+ },
+ {
+ key: 'multipleMasters',
+ data: [
+ Em.Object.create({
+ componentName: 'C10',
+ isMasterWithMultipleInstances: true
+ })
+ ],
+ result: ['C10']
+ },
+ {
+ key: 'slaves',
+ data: [
+ Em.Object.create({
+ componentName: 'C11',
+ isSlave: true
+ })
+ ],
+ result: ['C11']
+ },
+ {
+ key: 'clients',
+ data: [
+ Em.Object.create({
+ componentName: 'C12',
+ isClient: true
+ })
+ ],
+ result: ['C12']
+ }
+ ];
+
+ beforeEach(function () {
+ sinon.stub(App.StackServiceComponent, 'find', function () {
+ return testCases[i].data;
+ });
+ });
+
+ afterEach(function () {
+ i++;
+ App.StackServiceComponent.find.restore();
+ })
testCases.forEach(function (test) {
it(test.key + ' should contain ' + test.result, function () {
- sinon.stub(App.StackServiceComponent, 'find', function () {
- return test.data;
- });
-
expect(App.get('components.' + test.key)).to.eql(test.result);
-
- App.StackServiceComponent.find.restore();
})
})
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/989492ba/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js b/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js
index 2859235..5547dfe 100644
--- a/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/highAvailability_controller_test.js
@@ -45,12 +45,19 @@ describe('App.MainAdminHighAvailabilityController', function () {
});
it('Security enabled', function () {
- controller.set('securityEnabled', true);
+ sinon.stub(controller, 'get', function (k) {
+ if (k === 'securityEnabled') return true;
+ return Em.get(controller, k);
+ });
expect(controller.enableHighAvailability()).to.be.false;
expect(controller.showErrorPopup.calledOnce).to.be.true;
+ controller.get.restore();
});
it('NAMENODE in INSTALLED state', function () {
- controller.set('securityEnabled', false);
+ sinon.stub(controller, 'get', function (k) {
+ if (k === 'securityEnabled') return false;
+ return Em.get(controller, k);
+ });
hostComponents = [
Em.Object.create({
componentName: 'NAMENODE',
@@ -76,6 +83,7 @@ describe('App.MainAdminHighAvailabilityController', function () {
expect(controller.enableHighAvailability()).to.be.false;
expect(controller.showErrorPopup.calledOnce).to.be.true;
App.router.get.restore();
+ controller.get.restore();
});
it('Cluster has less than 3 ZOOKEPER_SERVER components', function () {
hostComponents = [
@@ -93,7 +101,10 @@ describe('App.MainAdminHighAvailabilityController', function () {
App.router.get.restore();
});
it('total hosts number less than 3', function () {
- controller.set('securityEnabled', false);
+ sinon.stub(controller, 'get', function (k) {
+ if (k === 'securityEnabled') return false;
+ return Em.get(controller, k);
+ });
hostComponents = [
Em.Object.create({
componentName: 'NAMENODE',
@@ -118,9 +129,13 @@ describe('App.MainAdminHighAvailabilityController', function () {
expect(controller.enableHighAvailability()).to.be.false;
expect(controller.showErrorPopup.calledOnce).to.be.true;
App.router.get.restore();
+ controller.get.restore();
});
it('All checks passed', function () {
- controller.set('securityEnabled', false);
+ sinon.stub(controller, 'get', function (k) {
+ if (k === 'securityEnabled') return false;
+ return Em.get(controller, k);
+ });
hostComponents = [
Em.Object.create({
componentName: 'NAMENODE',
@@ -146,133 +161,7 @@ describe('App.MainAdminHighAvailabilityController', function () {
expect(App.router.transitionTo.calledWith('main.admin.enableHighAvailability')).to.be.true;
expect(controller.showErrorPopup.calledOnce).to.be.false;
App.router.get.restore();
- });
- });
-
- describe('#setSecurityStatus()', function () {
-
- beforeEach(function () {
- sinon.stub(App.ajax, "send", Em.K);
- });
- afterEach(function () {
- App.ajax.send.restore();
- });
-
- it('testMode = true', function () {
- App.testEnableSecurity = false;
- App.testMode = true;
- controller.set('securityEnabled', false);
- controller.set('dataIsLoaded', false);
- controller.setSecurityStatus();
- expect(controller.get('securityEnabled')).to.be.true;
- expect(controller.get('dataIsLoaded')).to.be.true;
- expect(App.ajax.send.called).to.be.false;
-
- });
- it('testMode = false', function () {
- App.testMode = false;
- controller.set('securityEnabled', false);
- controller.set('dataIsLoaded', false);
- controller.setSecurityStatus();
- expect(controller.get('securityEnabled')).to.be.false;
- expect(controller.get('dataIsLoaded')).to.be.false;
- expect(App.ajax.send.calledOnce).to.be.true;
- });
- });
-
- describe('#getSecurityStatusFromServerSuccessCallback()', function () {
-
- beforeEach(function () {
- sinon.stub(controller, "getServiceConfigsFromServer", Em.K);
- sinon.stub(controller, "showErrorPopup", Em.K);
- });
- afterEach(function () {
- controller.getServiceConfigsFromServer.restore();
- controller.showErrorPopup.restore();
- });
-
- it('desired_configs is empty', function () {
- var data = {
- Clusters: {
- desired_configs: {}
- }
- };
- controller.getSecurityStatusFromServerSuccessCallback(data);
- expect(controller.showErrorPopup.calledOnce).to.be.true;
- });
- it('desired_configs does not have "hadoop-env"', function () {
- var data = {
- Clusters: {
- desired_configs: {
- 'hdfs-site': {}
- }
- }
- };
- controller.getSecurityStatusFromServerSuccessCallback(data);
- expect(controller.showErrorPopup.calledOnce).to.be.true;
- });
- it('desired_configs has "hadoop-env"', function () {
- var data = {
- Clusters: {
- desired_configs: {
- 'hadoop-env': {
- tag: 1
- }
- }
- }
- };
- controller.getSecurityStatusFromServerSuccessCallback(data);
- expect(controller.get('tag')).to.equal(1);
- expect(controller.getServiceConfigsFromServer.calledOnce).to.be.true;
- expect(controller.showErrorPopup.called).to.be.false;
- });
- });
-
- describe('#getSecurityStatusFromServerSuccessCallback()', function () {
-
- beforeEach(function () {
- sinon.stub(controller, "getServiceConfigsFromServer", Em.K);
- sinon.stub(controller, "showErrorPopup", Em.K);
- });
- afterEach(function () {
- controller.getServiceConfigsFromServer.restore();
- controller.showErrorPopup.restore();
- });
-
- it('desired_configs is empty', function () {
- var data = {
- Clusters: {
- desired_configs: {}
- }
- };
- controller.getSecurityStatusFromServerSuccessCallback(data);
- expect(controller.showErrorPopup.calledOnce).to.be.true;
- });
- it('desired_configs does not have "hadoop-env"', function () {
- var data = {
- Clusters: {
- desired_configs: {
- 'hdfs-site': {}
- }
- }
- };
- controller.getSecurityStatusFromServerSuccessCallback(data);
- expect(controller.showErrorPopup.calledOnce).to.be.true;
- });
- it('desired_configs has "hadoop-env"', function () {
- var data = {
- Clusters: {
- desired_configs: {
- 'hadoop-env': {
- tag: 1
- }
- }
- }
- };
- controller.getSecurityStatusFromServerSuccessCallback(data);
- expect(controller.get('tag')).to.equal(1);
- expect(controller.getServiceConfigsFromServer.calledOnce).to.be.true;
- expect(controller.showErrorPopup.called).to.be.false;
+ controller.get.restore();
});
});
@@ -291,51 +180,4 @@ describe('App.MainAdminHighAvailabilityController', function () {
});
});
- describe('#getServiceConfigsFromServer()', function () {
- it('configs present', function () {
- sinon.stub(App.router.get('configurationController'), 'getConfigsByTags', function () {
- return {
- done: function (callback) {
- callback([{tag: '1'}]);
- }
- }
- });
- sinon.stub(controller, 'isSecurityEnabled', function(){
- return true;
- });
- controller.set('tag', '1');
- controller.getServiceConfigsFromServer();
-
- expect(App.router.get('configurationController').getConfigsByTags.calledWith([
- {
- siteName: "hadoop-env",
- tagName: '1'
- }
- ])).to.be.true;
- expect(controller.isSecurityEnabled.calledOnce).to.be.true;
- expect(controller.get('dataIsLoaded')).to.be.true;
- expect(controller.get('securityEnabled')).to.be.true;
-
- App.router.get('configurationController').getConfigsByTags.restore();
- controller.isSecurityEnabled.restore();
- });
- });
-
- describe('#isSecurityEnabled()', function () {
- it('properties is null', function () {
- expect(controller.isSecurityEnabled(null)).to.be.false;
- });
- it('properties is empty object', function () {
- expect(controller.isSecurityEnabled({})).to.be.false;
- });
- it('security_enabled is false', function () {
- expect(controller.isSecurityEnabled({security_enabled: false})).to.be.false;
- });
- it('security_enabled is true', function () {
- expect(controller.isSecurityEnabled({security_enabled: true})).to.be.true;
- });
- it('security_enabled is "true"', function () {
- expect(controller.isSecurityEnabled({security_enabled: 'true'})).to.be.true;
- });
- });
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/989492ba/ambari-web/test/controllers/main/host/details_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/details_test.js b/ambari-web/test/controllers/main/host/details_test.js
index 01ae311..769b052 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -29,9 +29,9 @@ describe('App.MainHostDetailsController', function () {
beforeEach(function() {
controller = App.MainHostDetailsController.create({
- getSecurityStatus: function () {
+ securityEnabled: function () {
return this.get('mockSecurityStatus');
- },
+ }.property(),
mockSecurityStatus: false
});
});
@@ -340,21 +340,6 @@ describe('App.MainHostDetailsController', function () {
});
});
- describe('#addNewComponentSuccessCallback()', function () {
-
- beforeEach(function () {
- sinon.stub(App.ajax, "send", Em.K);
- });
- afterEach(function () {
- App.ajax.send.restore();
- });
-
- it('Query should be sent', function () {
- controller.addNewComponentSuccessCallback({}, {}, {component: Em.Object.create()});
- expect(App.ajax.send.calledOnce).to.be.true;
- });
- });
-
describe('#installNewComponentSuccessCallback()', function () {
beforeEach(function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/989492ba/ambari-web/test/controllers/main/service/add_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/add_controller_test.js b/ambari-web/test/controllers/main/service/add_controller_test.js
index 88d7bbc..3e9b2cc 100644
--- a/ambari-web/test/controllers/main/service/add_controller_test.js
+++ b/ambari-web/test/controllers/main/service/add_controller_test.js
@@ -32,16 +32,11 @@ describe('App.AddServiceController', function() {
var t = {
additionalClients: {
componentName: "TEZ_CLIENT",
- hostName: "hostName"
+ hostNames: ["hostName1", "hostName2"]
},
RequestInfo: {
- "context": Em.I18n.t('requestInfo.installHostComponent') + " hostName",
- "operation_level": {
- "level": "HOST_COMPONENT",
- "cluster_name": "tdk",
- "host_name": "hostName",
- "service_name": "TEZ"
- }
+ "context": Em.I18n.t('requestInfo.installHostComponent') + ' ' + App.format.role("TEZ_CLIENT"),
+ "query": "HostRoles/component_name=TEZ_CLIENT&HostRoles/host_name.in(hostName1,hostName2)"
},
Body: {
HostRoles: {
http://git-wip-us.apache.org/repos/asf/ambari/blob/989492ba/ambari-web/test/controllers/main/service/info/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js
index 3d38545..a49e298 100644
--- a/ambari-web/test/controllers/main/service/info/config_test.js
+++ b/ambari-web/test/controllers/main/service/info/config_test.js
@@ -1230,17 +1230,19 @@ describe("App.MainServiceInfoConfigsController", function () {
}
},
_serviceConfigProperty: {},
- serviceConfigProperty: {
- value: "parentSCP"
- },
+ serviceConfigProperty: Em.Object.create({
+ value: "parentSCP",
+ supportsFinal: true
+ }),
defaultGroupSelected: true,
newSCP: {
value: "value",
isOriginalSCP: false,
- parentSCP:{
- value: "parentSCP"
- },
+ parentSCP:Em.Object.create({
+ value: "parentSCP",
+ supportsFinal: true
+ }),
group: {
value: "group1"
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/989492ba/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js b/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js
index 5e89c7e..6962dda 100644
--- a/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js
+++ b/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js
@@ -38,6 +38,7 @@ describe('App.ReassignMasterWizardStep2Controller', function () {
beforeEach(function () {
sinon.stub(App.router, 'send', Em.K);
+ sinon.stub(controller, 'loadComponents', Em.K);
sinon.stub(controller, 'loadStepCallback', Em.K);
sinon.stub(controller, 'rebalanceSingleComponentHosts', Em.K);
});
@@ -46,9 +47,14 @@ describe('App.ReassignMasterWizardStep2Controller', function () {
controller.rebalanceSingleComponentHosts.restore();
App.router.send.restore();
controller.loadStepCallback.restore();
+ controller.loadComponents.restore();
});
it('SECONDARY_NAMENODE is absent, reassign component is NAMENODE', function () {
+ sinon.stub(App, 'get', function (k) {
+ if (k === 'isHaEnabled') return true;
+ return Em.get(App, k);
+ });
controller.set('content.reassign.component_name', 'NAMENODE');
controller.set('content.masterComponentHosts', []);
@@ -56,8 +62,13 @@ describe('App.ReassignMasterWizardStep2Controller', function () {
expect(controller.get('showCurrentHost')).to.be.false;
expect(controller.get('componentToRebalance')).to.equal('NAMENODE');
expect(controller.get('rebalanceComponentHostsCounter')).to.equal(1);
+ App.get.restore();
});
it('SECONDARY_NAMENODE is present, reassign component is NAMENODE', function () {
+ sinon.stub(App, 'get', function (k) {
+ if (k === 'isHaEnabled') return false;
+ return Em.get(App, k);
+ });
controller.set('content.reassign.component_name', 'NAMENODE');
controller.set('content.masterComponentHosts', [
{
@@ -68,6 +79,7 @@ describe('App.ReassignMasterWizardStep2Controller', function () {
controller.loadStep();
expect(controller.get('showCurrentHost')).to.be.true;
expect(controller.rebalanceSingleComponentHosts.calledWith('NAMENODE'));
+ App.get.restore();
});
it('SECONDARY_NAMENODE is absent, reassign component is not NAMENODE', function () {
controller.set('content.reassign.component_name', 'COMP');
@@ -78,12 +90,15 @@ describe('App.ReassignMasterWizardStep2Controller', function () {
expect(controller.rebalanceSingleComponentHosts.calledWith('COMP'));
});
it('if HA is enabled then multipleComponents should contain NAMENODE', function () {
- sinon.stub(App,'get', function() {
- return true;
+ controller.get('multipleComponents').clear();
+ sinon.stub(App, 'get', function (k) {
+ if (k === 'isHaEnabled') return true;
+ return Em.get(App, k);
});
controller.loadStep();
- expect(controller.get('multipleComponents')).to.eql(['NAMENODE']);
+ expect(controller.get('multipleComponents')).to.contain('NAMENODE');
+ expect(controller.get('multipleComponents')).to.have.length(1);
App.get.restore();
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/989492ba/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js b/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js
index 289c285..6b20bd9 100644
--- a/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js
+++ b/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js
@@ -347,8 +347,8 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
});
describe('#getStopServicesData()', function () {
- it('restartYarnMRComponents is true', function () {
- controller.set('restartYarnMRComponents', true);
+ it('restarting YARN component', function () {
+ controller.set('content.reassign.component_name', 'RESOURCEMANAGER');
sinon.stub(App.Service, 'find', function () {
return [
{
@@ -364,13 +364,13 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
"ServiceInfo": {
"state": "INSTALLED"
},
- "context": "Stop without HDFS",
+ "context": "Stop required services",
"urlParams": "ServiceInfo/service_name.in(SERVICE1)"
});
App.Service.find.restore();
});
- it('restartYarnMRComponents is false', function () {
- controller.set('restartYarnMRComponents', false);
+ it('restarting non-YARN component', function () {
+ controller.set('content.reassign.component_name', 'NAMENODE');
expect(controller.getStopServicesData()).to.eql({
"ServiceInfo": {
"state": "INSTALLED"
http://git-wip-us.apache.org/repos/asf/ambari/blob/989492ba/ambari-web/test/controllers/wizard/step6_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step6_test.js b/ambari-web/test/controllers/wizard/step6_test.js
index e67add8..6466315 100644
--- a/ambari-web/test/controllers/wizard/step6_test.js
+++ b/ambari-web/test/controllers/wizard/step6_test.js
@@ -107,20 +107,6 @@ describe('App.WizardStep6Controller', function () {
});
});
- describe('#isServiceSelected', function () {
- describe('selected', function () {
- services.forEach(function (service) {
- it(service.serviceName + ' is selected', function () {
- expect(controller.isServiceSelected(service.serviceName)).to.equal(true);
- });
- });
- });
- var unselectedService = 'FAKESERVICE';
- it(unselectedService + ' is not selected', function () {
- expect(controller.isServiceSelected(unselectedService)).to.equal(false);
- });
- });
-
describe('#clearStep', function () {
beforeEach(function () {
sinon.stub(controller, 'clearError', Em.K);
http://git-wip-us.apache.org/repos/asf/ambari/blob/989492ba/ambari-web/test/controllers/wizard/step8_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js
index 14a9801..bff521c 100644
--- a/ambari-web/test/controllers/wizard/step8_test.js
+++ b/ambari-web/test/controllers/wizard/step8_test.js
@@ -289,6 +289,7 @@ describe('App.WizardStep8Controller', function () {
{
globals: [
{name: 'hive_database', value: 'New MySQL Database'},
+ {name: 'hive_database_type', value: 'mysql'},
{name: 'hive_ambari_host', value: 'h1'},
{name: 'hive_hostname', value: 'h2'}
],
@@ -301,6 +302,7 @@ describe('App.WizardStep8Controller', function () {
{
globals: [
{name: 'hive_database', value: 'Existing MySQL Database'},
+ {name: 'hive_database_type', value: 'mysql'},
{name: 'hive_existing_mysql_host', value: 'h1'},
{name: 'hive_hostname', value: 'h2'}
],
@@ -313,6 +315,7 @@ describe('App.WizardStep8Controller', function () {
{
globals: [
{name: 'hive_database', value: 'Existing PostgreSQL Database'},
+ {name: 'hive_database_type', value: 'postgresql'},
{name: 'hive_existing_postgresql_host', value: 'h1'},
{name: 'hive_hostname', value: 'h2'}
],
@@ -325,6 +328,7 @@ describe('App.WizardStep8Controller', function () {
{
globals: [
{name: 'hive_database', value: 'Existing Oracle Database'},
+ {name: 'hive_database_type', value: 'oracle'},
{name: 'hive_existing_oracle_host', value: 'h1'},
{name: 'hive_hostname', value: 'h2'}
],
@@ -354,6 +358,7 @@ describe('App.WizardStep8Controller', function () {
{
globals: [
{name: 'oozie_database', value: 'New Derby Database'},
+ {name: 'oozie_database_type', value: 'derby'},
{name: 'oozie_ambari_host', value: 'h1'},
{name: 'oozie_hostname', value: 'h2'}
],
@@ -367,6 +372,7 @@ describe('App.WizardStep8Controller', function () {
{
globals: [
{name: 'oozie_database', value: 'Existing MySQL Database'},
+ {name: 'oozie_database_type', value: 'mysql'},
{name: 'oozie_existing_mysql_host', value: 'h1'},
{name: 'oozie_hostname', value: 'h2'}
],
@@ -379,6 +385,7 @@ describe('App.WizardStep8Controller', function () {
{
globals: [
{name: 'oozie_database', value: 'Existing PostgreSQL Database'},
+ {name: 'oozie_database_type', value: 'postgresql'},
{name: 'oozie_existing_postgresql_host', value: 'h1'},
{name: 'oozie_hostname', value: 'h2'}
],
@@ -391,6 +398,7 @@ describe('App.WizardStep8Controller', function () {
{
globals: [
{name: 'oozie_database', value: 'Existing Oracle Database'},
+ {name: 'oozie_database_type', value: 'oracle'},
{name: 'oozie_existing_oracle_host', value: 'h1'},
{name: 'oozie_hostname', value: 'h2'}
],
http://git-wip-us.apache.org/repos/asf/ambari/blob/989492ba/ambari-web/test/utils/host_progress_popup_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/host_progress_popup_test.js b/ambari-web/test/utils/host_progress_popup_test.js
index b7656a6..3a9caa2 100644
--- a/ambari-web/test/utils/host_progress_popup_test.js
+++ b/ambari-web/test/utils/host_progress_popup_test.js
@@ -374,12 +374,17 @@ describe('App.HostPopup', function () {
describe('#abortRequestErrorCallback', function () {
beforeEach(function () {
+ sinon.stub(App.ajax, 'get', function(k) {
+ if (k === 'modalPopup') return null;
+ return Em.get(App, k);
+ });
App.HostPopup.createPopup();
sinon.spy(App.ModalPopup, 'show');
});
afterEach(function () {
App.HostPopup.get('isPopup').hide();
App.ModalPopup.show.restore();
+ App.ajax.get.restore();
});
it('should open popup', function () {
App.HostPopup.get('isPopup.bodyClass').create().abortRequestErrorCallback({
http://git-wip-us.apache.org/repos/asf/ambari/blob/989492ba/ambari-web/test/views/application_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/application_test.js b/ambari-web/test/views/application_test.js
index 0fb0911..475a426 100644
--- a/ambari-web/test/views/application_test.js
+++ b/ambari-web/test/views/application_test.js
@@ -24,23 +24,7 @@ var view,
modals = [],
removed = false,
events = [
- {
- event: 'keydown',
- which: 13,
- key: 'Enter',
- html: '<div id="modal"><div class="modal-footer"><span class="btn-success"></span></div></div>',
- particle: '',
- length: 0
- },
- {
- event: 'keydown',
- keyCode: 13,
- key: 'Enter',
- html: '<div id="modal"><div class="modal-footer"><span class="btn-success"></span></div></div>',
- particle: '',
- length: 0
- },
- {
+ {
event: 'keyup',
which: 27,
key: 'Esc',
http://git-wip-us.apache.org/repos/asf/ambari/blob/989492ba/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 c6225e3..4705af6 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
@@ -25,13 +25,31 @@ var hostComponentView;
describe('App.HostComponentView', function() {
beforeEach(function() {
+ sinon.stub(App.router, 'get', function (k) {
+ if (k === 'mainHostDetailsController.content') return Em.Object.create({
+ hostComponents: [
+ {
+ componentName: 'component'
+ }
+ ]
+ });
+ return Em.get(App.router, k);
+ });
hostComponentView = App.HostComponentView.create({
startBlinking: function(){},
doBlinking: function(){},
- getDesiredAdminState: function(){return $.ajax({});}
+ getDesiredAdminState: function(){return $.ajax({});},
+ content: Em.Object.create({
+ componentName: 'component'
+ }),
+ hostComponent: Em.Object.create()
});
});
+ afterEach(function () {
+ App.router.get.restore();
+ });
+
describe('#disabled', function() {
var tests = Em.A([
@@ -66,7 +84,7 @@ describe('App.HostComponentView', function() {
App.HostComponentStatus.getStatusesList().forEach(function(status) {
it(status, function() {
- hostComponentView.set('content', {workStatus: status});
+ hostComponentView.get('hostComponent').set('workStatus', status);
var e = tests.contains(status) ? testE : defaultE;
expect(hostComponentView.get('isUpgradeFailed')).to.equal(e);
});
@@ -82,7 +100,7 @@ describe('App.HostComponentView', function() {
App.HostComponentStatus.getStatusesList().forEach(function(status) {
it(status, function() {
- hostComponentView.set('content', {workStatus: status});
+ hostComponentView.get('hostComponent').set('workStatus', status);
var e = tests.contains(status) ? testE : defaultE;
expect(hostComponentView.get('isInstallFailed')).to.equal(e);
});
@@ -98,7 +116,7 @@ describe('App.HostComponentView', function() {
App.HostComponentStatus.getStatusesList().forEach(function(status) {
it(status, function() {
- hostComponentView.set('content', {workStatus: status});
+ hostComponentView.get('hostComponent').set('workStatus', status);
var e = tests.contains(status) ? testE : defaultE;
expect(hostComponentView.get('isStart')).to.equal(e);
});
@@ -114,7 +132,7 @@ describe('App.HostComponentView', function() {
App.HostComponentStatus.getStatusesList().forEach(function(status) {
it(status, function() {
- hostComponentView.set('content', {workStatus: status});
+ hostComponentView.get('hostComponent').set('workStatus', status);
var e = tests.contains(status) ? testE : defaultE;
expect(hostComponentView.get('isStop')).to.equal(e);
});
@@ -130,7 +148,7 @@ describe('App.HostComponentView', function() {
App.HostComponentStatus.getStatusesList().forEach(function(status) {
it(status, function() {
- hostComponentView.set('content', {workStatus: status});
+ hostComponentView.get('hostComponent').set('workStatus', status);
var e = tests.contains(status) ? testE : defaultE;
expect(hostComponentView.get('isInstalling')).to.equal(e);
});
@@ -146,7 +164,7 @@ describe('App.HostComponentView', function() {
App.HostComponentStatus.getStatusesList().forEach(function(status) {
it(status, function() {
- hostComponentView.set('content', {workStatus: status});
+ hostComponentView.get('hostComponent').set('workStatus', status);
var e = tests.contains(status) ? testE : defaultE;
expect(hostComponentView.get('isInit')).to.equal(e);
});
@@ -162,7 +180,7 @@ describe('App.HostComponentView', function() {
App.HostComponentStatus.getStatusesList().forEach(function(status) {
it(status, function() {
- hostComponentView.set('content', {workStatus: status});
+ hostComponentView.get('hostComponent').set('workStatus', status);
var e = tests.contains(status) ? testE : defaultE;
expect(hostComponentView.get('noActionAvailable')).to.equal(e);
});
@@ -180,7 +198,7 @@ describe('App.HostComponentView', function() {
tests.forEach(function(test) {
it(test.workStatus, function() {
- hostComponentView.set('content', {passiveState: test.passiveState});
+ hostComponentView.get('content').set('passiveState', test.passiveState);
expect(hostComponentView.get('isActive')).to.equal(test.e);
});
});
@@ -195,7 +213,7 @@ describe('App.HostComponentView', function() {
App.HostComponentStatus.getStatusesList().forEach(function(status) {
it(status, function() {
- hostComponentView.set('content', {workStatus: status});
+ hostComponentView.get('hostComponent').set('workStatus', status);
var e = tests.contains(status) ? testE : defaultE;
expect(hostComponentView.get('isRestartComponentDisabled')).to.equal(e);
});
@@ -211,7 +229,7 @@ describe('App.HostComponentView', function() {
App.HostComponentStatus.getStatusesList().forEach(function(status) {
it(status, function() {
- hostComponentView.set('content', {workStatus: status});
+ hostComponentView.get('hostComponent').set('workStatus', status);
var e = tests.contains(status) ? testE : defaultE;
expect(hostComponentView.get('isDeleteComponentDisabled')).to.equal(e);
});
@@ -223,13 +241,13 @@ describe('App.HostComponentView', function() {
var tests = Em.A([
{
- content: Em.Object.create({componentTextStatus: 'status'}),
+ componentTextStatus: 'status',
hostComponent: null,
e: 'status',
m: 'get content status'
},
{
- content: Em.Object.create({componentTextStatus: 'status'}),
+ componentTextStatus: 'status',
hostComponent: Em.Object.create({componentTextStatus: 'new_status'}),
e: 'new_status',
m: 'get hostComponent status'
@@ -242,9 +260,10 @@ describe('App.HostComponentView', function() {
startBlinking: function(){},
doBlinking: function(){},
getDesiredAdminState: function(){return $.ajax({});},
- content: test.content,
- hostComponent: test.hostComponent
+ hostComponent: test.hostComponent,
+ content: Em.Object.create()
});
+ hostComponentView.get('content').set('componentTextStatus', test.componentTextStatus);
expect(hostComponentView.get('componentTextStatus')).to.equal(test.e);
});
});
@@ -255,13 +274,13 @@ describe('App.HostComponentView', function() {
var tests = Em.A([
{
- content: Em.Object.create({workStatus: 'status'}),
+ workStatus: 'status',
hostComponent: null,
e: 'status',
m: 'get content workStatus'
},
{
- content: Em.Object.create({workStatus: 'status'}),
+ workStatus: 'status',
hostComponent: Em.Object.create({workStatus: 'new_status'}),
e: 'new_status',
m: 'get hostComponent workStatus'
@@ -274,9 +293,10 @@ describe('App.HostComponentView', function() {
startBlinking: function(){},
doBlinking: function(){},
getDesiredAdminState: function(){return $.ajax({});},
- content: test.content,
- hostComponent: test.hostComponent
+ hostComponent: test.hostComponent,
+ content: Em.Object.create()
});
+ hostComponentView.get('content').set('workStatus', test.workStatus);
expect(hostComponentView.get('workStatus')).to.equal(test.e);
});
});
@@ -287,35 +307,43 @@ describe('App.HostComponentView', function() {
var tests = Em.A([
{
- content: Em.Object.create({workStatus: App.HostComponentStatus.install_failed,passiveState: 'OFF'}),
+ workStatus: App.HostComponentStatus.install_failed,
+ passiveState: 'OFF',
e: 'health-status-color-red icon-cog'
},
{
- content: Em.Object.create({workStatus: App.HostComponentStatus.installing, passiveState: 'OFF'}),
+ workStatus: App.HostComponentStatus.installing,
+ passiveState: 'OFF',
e: 'health-status-color-blue icon-cog'
},
{
- content: Em.Object.create({workStatus: 'STARTED', passiveState: 'ON'}),
+ workStatus: 'STARTED',
+ passiveState: 'ON',
e: 'health-status-started'
},
{
- content: Em.Object.create({workStatus: 'STARTED', passiveState: 'IMPLIED'}),
+ workStatus: 'STARTED',
+ passiveState: 'IMPLIED',
e: 'health-status-started'
},
{
- content: Em.Object.create({workStatus: 'STARTED', passiveState: 'OFF'}),
+ workStatus: 'STARTED',
+ passiveState: 'OFF',
e: 'health-status-started'
}
]);
tests.forEach(function(test) {
- it(test.content.get('workStatus') + ' ' + test.content.get('passiveState'), function() {
+ it(test.workStatus + ' ' + test.passiveState, function() {
hostComponentView = App.HostComponentView.create({
startBlinking: function(){},
doBlinking: function(){},
getDesiredAdminState: function(){return $.ajax({});},
- content: test.content
+ content: Em.Object.create(),
+ hostComponent: Em.Object.create()
});
+ hostComponentView.get('hostComponent').set('workStatus',test.workStatus);
+ hostComponentView.get('content').set('passiveState', test.passiveState);
expect(hostComponentView.get('statusClass')).to.equal(test.e);
});
});
@@ -330,7 +358,7 @@ describe('App.HostComponentView', function() {
App.HostComponentStatus.getStatusesList().forEach(function(status) {
it(status, function() {
- hostComponentView.set('content', {workStatus: status});
+ hostComponentView.get('hostComponent').set('workStatus', status);
var e = tests.contains(status) ? testE : defaultE;
expect(hostComponentView.get('isInProgress')).to.equal(e);
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/989492ba/ambari-web/test/views/main/host/details/host_component_views/decommissionable_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host/details/host_component_views/decommissionable_test.js b/ambari-web/test/views/main/host/details/host_component_views/decommissionable_test.js
index 520d54f..659cfbd 100644
--- a/ambari-web/test/views/main/host/details/host_component_views/decommissionable_test.js
+++ b/ambari-web/test/views/main/host/details/host_component_views/decommissionable_test.js
@@ -27,13 +27,22 @@ var hostComponentView;
describe('App.Decommissionable', function() {
beforeEach(function() {
- hostComponentView = App.HostComponentView.create(App.Decommissionable, {
- startBlinking: function(){},
- doBlinking: function(){},
- getDesiredAdminState: function(){return $.ajax({});}
+ sinon.stub(App.router, 'get', function (k) {
+ if (k === 'mainHostDetailsController.content') return Em.Object.create({
+ hostComponents: [
+ {
+ componentName: 'component'
+ }
+ ]
+ });
+ return Em.get(App.router, k);
});
});
+ afterEach(function () {
+ App.router.get.restore();
+ });
+
describe('#componentTextStatus', function() {
var tests = Em.A([
@@ -100,42 +109,50 @@ describe('App.Decommissionable', function() {
var tests = Em.A([
{
- content: Em.Object.create({workStatus: App.HostComponentStatus.install_failed,passiveState: 'OFF'}),
+ workStatus: App.HostComponentStatus.install_failed,
+ passiveState: 'OFF',
isComponentRecommissionAvailable: false,
e: 'health-status-color-red icon-cog'
},
{
- content: Em.Object.create({workStatus: App.HostComponentStatus.installing, passiveState: 'OFF'}),
+ workStatus: App.HostComponentStatus.installing,
+ passiveState: 'OFF',
isComponentRecommissionAvailable: false,
e: 'health-status-color-blue icon-cog'
},
{
- content: Em.Object.create({workStatus: 'STARTED', passiveState: 'ON'}),
+ workStatus: 'STARTED',
+ passiveState: 'ON',
isComponentRecommissionAvailable: false,
e: 'health-status-started'
},
{
- content: Em.Object.create({workStatus: 'STARTED', passiveState: 'IMPLIED'}),
+ workStatus: 'STARTED',
+ passiveState: 'IMPLIED',
isComponentRecommissionAvailable: false,
e: 'health-status-started'
},
{
- content: Em.Object.create({workStatus: 'STARTED', passiveState: 'OFF'}),
+ workStatus: 'STARTED',
+ passiveState: 'OFF',
isComponentRecommissionAvailable: false,
e: 'health-status-started'
},
{
- content: Em.Object.create({workStatus: 'STARTED', passiveState: 'OFF'}),
+ workStatus: 'STARTED',
+ passiveState: 'OFF',
isComponentRecommissionAvailable: true,
e: 'health-status-DEAD-ORANGE'
},
{
- content: Em.Object.create({workStatus: 'STARTING', passiveState: 'OFF'}),
+ workStatus: 'STARTING',
+ passiveState: 'OFF',
isComponentRecommissionAvailable: true,
e: 'health-status-DEAD-ORANGE'
},
{
- content: Em.Object.create({workStatus: 'INSTALLED', passiveState: 'OFF'}),
+ workStatus: 'INSTALLED',
+ passiveState: 'OFF',
isComponentRecommissionAvailable: true,
e: 'health-status-DEAD-ORANGE'
}
@@ -143,13 +160,17 @@ describe('App.Decommissionable', function() {
]);
tests.forEach(function(test) {
- it(test.content.get('workStatus') + ' ' + test.content.get('passiveState') + ' ' + test.isComponentRecommissionAvailable?'true':'false', function() {
+ it(test.workStatus + ' ' + test.passiveState + ' ' + test.isComponentRecommissionAvailable?'true':'false', function() {
hostComponentView = App.HostComponentView.create(App.Decommissionable,{
startBlinking: function(){},
doBlinking: function(){},
getDesiredAdminState: function(){return $.ajax({});},
isComponentRecommissionAvailable: test.isComponentRecommissionAvailable,
- content: test.content
+ content: Em.Object.create()
+ });
+ hostComponentView.get('content').setProperties({
+ workStatus: test.workStatus,
+ passiveState: test.passiveState
});
expect(hostComponentView.get('statusClass')).to.equal(test.e);
});