Repository: ambari Updated Branches: refs/heads/trunk 09406ac65 -> b8aede2a8
http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/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 1654958..f2c7332 100644 --- a/ambari-web/test/controllers/wizard/step6_test.js +++ b/ambari-web/test/controllers/wizard/step6_test.js @@ -116,25 +116,27 @@ describe('App.WizardStep6Controller', function () { }); describe('#selectAllNodes', function () { + + var hostsObj = Em.A([Em.Object.create({ + hasMaster: false, + isInstalled: false, + checkboxes: Em.A([ + Em.Object.create({ + title: 'l1', + component: 'name', + isInstalled: false, + checked: false + }) + ]) + })]); + var obj = Em.Object.create({ + context: { + name: "name" + } + }); + var clientComponents = Em.A([{component_name: "name1"}]); + it('should make checkbox checked', function () { - var hostsObj = Em.A([Em.Object.create({ - hasMaster: false, - isInstalled: false, - checkboxes: Em.A([ - Em.Object.create({ - title: 'l1', - component: 'name', - isInstalled: false, - checked: false - }) - ]) - })]); - var obj = Em.Object.create({ - context: { - name: "name" - } - }); - var clientComponents = Em.A([{component_name: "name1"}]); controller.set('hosts', hostsObj); controller.set('content.clients', clientComponents); controller.selectAllNodes(obj); @@ -154,25 +156,27 @@ describe('App.WizardStep6Controller', function () { }); describe('#deselectAllNodes', function () { + + var hostsObj = Em.A([Em.Object.create({ + hasMaster: false, + isInstalled: false, + checkboxes: Em.A([ + Em.Object.create({ + title: 'l1', + component: 'name', + isInstalled: false, + checked: true + }) + ]) + })]); + var obj = Em.Object.create({ + context: { + name: "name" + } + }); + var clientComponents = Em.A([{component_name: "name1"}]); + it('should uncheck checkbox', function () { - var hostsObj = Em.A([Em.Object.create({ - hasMaster: false, - isInstalled: false, - checkboxes: Em.A([ - Em.Object.create({ - title: 'l1', - component: 'name', - isInstalled: false, - checked: true - }) - ]) - })]); - var obj = Em.Object.create({ - context: { - name: "name" - } - }); - var clientComponents = Em.A([{component_name: "name1"}]); controller.set('hosts', hostsObj); controller.set('content.clients', clientComponents); controller.deselectAllNodes(obj); @@ -558,6 +562,31 @@ describe('App.WizardStep6Controller', function () { }); describe('#updateValidationsSuccessCallback', function () { + + var hosts = Em.A([Em.Object.create({ + warnMessages: "warn", + errorMessages: "error", + anyMessage: true, + checkboxes: Em.A([Em.Object.create({ + hasWarnMessage: true, + hasErrorMessage: true + })]) + })]); + + var validationData = Em.Object.create({ + resources: Em.A([ + Em.Object.create({ + items: Em.A([ + Em.Object.create({ + "component-name": 'HDFS_CLIENT', + host: "1", + isMaster: true + }) + ]) + }) + ]) + }); + beforeEach(function () { sinon.stub(validationUtils, 'filterNotInstalledComponents', function () { return Em.A([Em.Object.create({ @@ -626,51 +655,49 @@ describe('App.WizardStep6Controller', function () { }) ]; }); + controller.set('hosts', hosts); + controller.updateValidationsSuccessCallback(validationData); }); + afterEach(function () { App.StackServiceComponent.find.restore(); validationUtils.filterNotInstalledComponents.restore(); }); - it('should return modified hosts', function () { - var hosts = Em.A([Em.Object.create({ - warnMessages: "warn", - errorMessages: "error", - anyMessage: true, - checkboxes: Em.A([Em.Object.create({ - hasWarnMessage: true, - hasErrorMessage: true - })]) - })]); - controller.set('hosts', hosts); - var validationData = Em.Object.create({ - resources: Em.A([ - Em.Object.create({ - items: Em.A([ - Em.Object.create({ - "component-name": 'HDFS_CLIENT', - host: "1", - isMaster: true - }) - ]) - }) - ]) - }); - controller.updateValidationsSuccessCallback(validationData); + + it('no generalErrorMessages', function () { expect(controller.get('generalErrorMessages').length).to.equal(0); + }); + + it('no generalWarningMessages', function () { expect(controller.get('generalWarningMessages').length).to.equal(0); - expect(JSON.parse(JSON.stringify(controller.get('hosts')))).to.eql(JSON.parse(JSON.stringify(Em.A([Em.Object.create({ + }); + + it('hosts info is valid', function () { + var cHosts = JSON.parse(JSON.stringify(controller.get('hosts'))); + var expected = [{ warnMessages: [null], errorMessages: [null], anyMessage: true, - checkboxes: Em.A([Em.Object.create({ + checkboxes: [{ hasWarnMessage: true, hasErrorMessage: true - })]) - })])))); + }] + }]; + expect(cHosts).to.eql(expected); }); }); describe('#clearError', function () { + + var headers = Em.A([ + Em.Object.create({name: "c1", label: 't1'}), + Em.Object.create({name: "c2", label: 't2'})]); + + beforeEach(function () { + controller.set('errorMessage', 'error'); + controller.set('headers', headers); + }); + it('both checkboxes are checked', function () { var hosts = Em.A([ Em.Object.create({ @@ -687,12 +714,8 @@ describe('App.WizardStep6Controller', function () { })]) }) ]); - var headers = Em.A([ - Em.Object.create({name: "c1"}), - Em.Object.create({name: "c2"})]); - controller.set('errorMessage', 'error'); + controller.set('hosts', hosts); - controller.set('headers', headers); controller.clearError(); expect(controller.get('errorMessage')).to.equal(''); }); @@ -715,12 +738,8 @@ describe('App.WizardStep6Controller', function () { })]) }) ]); - var headers = Em.A([ - Em.Object.create({name: "c1", label: 't1'}), - Em.Object.create({name: "c2", label: 't2'})]); - controller.set('errorMessage', 'error'); + controller.set('hosts', hosts); - controller.set('headers', headers); controller.set('isAddHostWizard', true); controller.clearError(); expect(controller.get('errorMessage')).to.equal('error'); @@ -921,14 +940,23 @@ describe('App.WizardStep6Controller', function () { } } ]).forEach(function (test) { - it(test.m, function () { - controller.clearStep(); - controller.set('headers', test.headers); - controller.set('hosts', test.hosts); - controller.checkCallback(test.component); - var header = controller.get('headers').findProperty('name', test.component); - expect(header.get('allChecked')).to.equal(test.e.allChecked); - expect(header.get('noChecked')).to.equal(test.e.noChecked); + describe(test.m, function () { + + beforeEach(function () { + controller.clearStep(); + controller.set('headers', test.headers); + controller.set('hosts', test.hosts); + controller.checkCallback(test.component); + this.header = controller.get('headers').findProperty('name', test.component); + }); + + it('allChecked is ' + test.e.allChecked, function () { + expect(this.header.get('allChecked')).to.equal(test.e.allChecked); + }); + + it('noChecked is ' + test.e.noChecked, function () { + expect(this.header.get('noChecked')).to.equal(test.e.noChecked); + }); }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/wizard/step7_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js index ac7b3c3..c6796aa 100644 --- a/ambari-web/test/controllers/wizard/step7_test.js +++ b/ambari-web/test/controllers/wizard/step7_test.js @@ -287,7 +287,8 @@ describe('App.InstallerStep7Controller', function () { }); describe('#checkDatabaseConnectionTest', function () { - it('should return promise in process', function () { + + beforeEach(function () { installerStep7Controller.set('content', { services: Em.A([ Em.Object.create({isSelected: true, isInstalled: false, serviceName: 'OOZIE', ignored: []}), @@ -302,10 +303,13 @@ describe('App.InstallerStep7Controller', function () { }); var obj = Em.Object.create({name:'oozie_database',value:"aa"}); installerStep7Controller.set('stepConfigs',Em.A([Em.Object.create({serviceName: 'OOZIE', configs: Em.A([obj]) })])); - var deffer = installerStep7Controller.checkDatabaseConnectionTest(); - expect(deffer.isResolved()).to.equal(false); - deffer.resolve(true); - deffer.done(function(data) { + this.deffer = installerStep7Controller.checkDatabaseConnectionTest(); + }); + + it('should return promise in process', function () { + expect(this.deffer.isResolved()).to.equal(false); + this.deffer.resolve(true); + this.deffer.done(function(data) { expect(data).to.equal(true); }); }); @@ -684,48 +688,67 @@ describe('App.InstallerStep7Controller', function () { expect(updatedConfig.get('overrides')).to.be.null; }); - it('no overrideToAdd', function () { - var isDefault = true, - name = 'n1', - config = Em.Object.create({overrides: null, name: name, flag: 'flag'}), - overrides = Em.A([ - Em.Object.create({name: name, value: 'v1'}), - Em.Object.create({name: name, value: 'v2'}), - Em.Object.create({name: 'n2', value: 'v3'}) - ]); - installerStep7Controller.reopen({ - overrideToAdd: null, - selectedConfigGroup: Em.Object.create({ - isDefault: isDefault - }) + describe('no overrideToAdd', function () { + var isDefault; + beforeEach(function () { + isDefault = true; + var name = 'n1', + config = Em.Object.create({overrides: null, name: name, flag: 'flag'}), + overrides = Em.A([ + Em.Object.create({name: name, value: 'v1'}), + Em.Object.create({name: name, value: 'v2'}), + Em.Object.create({name: 'n2', value: 'v3'}) + ]); + installerStep7Controller.reopen({ + overrideToAdd: null, + selectedConfigGroup: Em.Object.create({ + isDefault: isDefault + }) + }); + this.updatedConfig = installerStep7Controller._setOverrides(config, overrides); + }); + + it('2 overrides', function () { + expect(this.updatedConfig.get('overrides.length')).to.equal(2); + }); + it('each isEditable is ' + !isDefault, function () { + expect(this.updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true); + }); + it('each parentSCP.flag is `flag`', function () { + expect(this.updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true); }); - var updatedConfig = installerStep7Controller._setOverrides(config, overrides); - expect(updatedConfig.get('overrides.length')).to.equal(2); - expect(updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true); - expect(updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true); }); - it('overrideToAdd exists', function () { - var isDefault = true, - name = 'n1', - config = Em.Object.create({overrides: null, name: name, flag: 'flag'}), - overrides = Em.A([ - Em.Object.create({name: name, value: 'v1'}), - Em.Object.create({name: name, value: 'v2'}), - Em.Object.create({name: 'n2', value: 'v3'}) - ]); - installerStep7Controller.reopen({ - overrideToAdd: Em.Object.create({name: name}), - selectedService: {configGroups: [Em.Object.create({name: 'n', properties: []})]}, - selectedConfigGroup: Em.Object.create({ - isDefault: isDefault, - name: 'n' - }) + describe('overrideToAdd exists', function () { + var isDefault = true; + beforeEach(function () { + var name = 'n1', + config = Em.Object.create({overrides: null, name: name, flag: 'flag'}), + overrides = Em.A([ + Em.Object.create({name: name, value: 'v1'}), + Em.Object.create({name: name, value: 'v2'}), + Em.Object.create({name: 'n2', value: 'v3'}) + ]); + installerStep7Controller.reopen({ + overrideToAdd: Em.Object.create({name: name}), + selectedService: {configGroups: [Em.Object.create({name: 'n', properties: []})]}, + selectedConfigGroup: Em.Object.create({ + isDefault: isDefault, + name: 'n' + }) + }); + this.updatedConfig = installerStep7Controller._setOverrides(config, overrides); + }); + + it('3 overrides', function () { + expect(this.updatedConfig.get('overrides.length')).to.equal(3); + }); + it('each isEditable is ' + !isDefault, function () { + expect(this.updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true); + }); + it('each parentSCP.flag is `flag`', function () { + expect(this.updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true); }); - var updatedConfig = installerStep7Controller._setOverrides(config, overrides); - expect(updatedConfig.get('overrides.length')).to.equal(3); - expect(updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true); - expect(updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true); }); }); @@ -1721,25 +1744,27 @@ describe('App.InstallerStep7Controller', function () { expectedNewValue: dfsNameservices + '/hawq_data' } ]).forEach(function (test) { - it(test.serviceName + ' ' + test.configToUpdate, function () { - var serviceConfigs = [App.ServiceConfig.create({ - serviceName: test.serviceName, + + var serviceConfigs = [App.ServiceConfig.create({ + serviceName: test.serviceName, + configs: [ + Em.Object.create({ + name: test.configToUpdate, + value: test.oldValue + }) + ] + }), + App.ServiceConfig.create({ + serviceName: 'HDFS', configs: [ Em.Object.create({ - name: test.configToUpdate, - value: test.oldValue + name: 'dfs.nameservices', + value: dfsNameservices }) ] - }), - App.ServiceConfig.create({ - serviceName: 'HDFS', - configs: [ - Em.Object.create({ - name: 'dfs.nameservices', - value: dfsNameservices - }) - ] - })]; + })]; + + it(test.serviceName + ' ' + test.configToUpdate, function () { installerStep7Controller.reopen({ selectedServiceNames: [test.serviceName, 'HDFS'] }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/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 576e303..cbf259f 100644 --- a/ambari-web/test/controllers/wizard/step8_test.js +++ b/ambari-web/test/controllers/wizard/step8_test.js @@ -240,7 +240,8 @@ describe('App.WizardStep8Controller', function () { }); describe('#createCoreSiteObj', function () { - it('should return config', function () { + + beforeEach(function () { var content = Em.Object.create({ services: Em.A([ Em.Object.create({ @@ -306,6 +307,9 @@ describe('App.WizardStep8Controller', function () { ]) }) ])); + }); + + it('should return config', function () { var expected = { "type": "core-site", "tag": "version1", @@ -321,6 +325,7 @@ describe('App.WizardStep8Controller', function () { }); describe('#createConfigurationGroups', function () { + var content; beforeEach(function() { sinon.stub(App.router,'get').returns(Em.Object.create({ getDBProperty: function() { @@ -335,12 +340,7 @@ describe('App.WizardStep8Controller', function () { }, createSiteObj: App.MainServiceInfoConfigsController.create({}).createSiteObj.bind(App.MainServiceInfoConfigsController.create({})) })); - }); - afterEach(function() { - App.router.get.restore(); - }); - it('should push group in properties', function () { - var content = Em.Object.create({ + content = Em.Object.create({ configGroups: Em.A([ Em.Object.create({ is_default: true, @@ -398,6 +398,12 @@ describe('App.WizardStep8Controller', function () { installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create()); installerStep8Controller.get('ajaxRequestsQueue').clear(); installerStep8Controller.createConfigurationGroups(); + }); + afterEach(function() { + App.router.get.restore(); + }); + + it('should push group in properties', function () { var expected = [ { "value": "p3", @@ -434,7 +440,8 @@ describe('App.WizardStep8Controller', function () { }); describe('#loadServices', function () { - it('should load services', function () { + + beforeEach(function () { var services = Em.A([ Em.Object.create({ serviceName: 's1', @@ -503,6 +510,9 @@ describe('App.WizardStep8Controller', function () { installerStep8Controller.set('services', Em.A([])); installerStep8Controller.reopen({selectedServices: selectedServices}); installerStep8Controller.loadServices(); + }); + + it('should load services', function () { var expected = [ { "service_name": "s1", @@ -537,7 +547,8 @@ describe('App.WizardStep8Controller', function () { }); describe('#removeClientsFromList', function () { - it('should remove h1', function () { + + beforeEach(function () { installerStep8Controller.set('content', Em.Object.create({ hosts: Em.Object.create({ h1: Em.Object.create({ @@ -552,6 +563,9 @@ describe('App.WizardStep8Controller', function () { }) }) })); + }); + + it('should remove h1', function () { var hostList = Em.A(['h1','h2']); installerStep8Controller.removeClientsFromList('h1', hostList); expect(JSON.parse(JSON.stringify(hostList))).to.eql(["h2"]); @@ -559,7 +573,8 @@ describe('App.WizardStep8Controller', function () { }); describe('#createSlaveAndClientsHostComponents', function () { - it('should return non install object', function () { + + beforeEach(function () { installerStep8Controller.set('content', Em.Object.create({ masterComponentHosts: Em.A([ Em.Object.create({ @@ -615,13 +630,17 @@ describe('App.WizardStep8Controller', function () { })); installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create()); installerStep8Controller.get('ajaxRequestsQueue').clear(); + }); + + it('should return non install object', function () { installerStep8Controller.createSlaveAndClientsHostComponents(); expect(installerStep8Controller.get('content.clients')[0].isInstalled).to.be.false; }); }); describe('#createAdditionalClientComponents', function () { - it('should bes equal to content.cluster.name', function () { + + beforeEach(function () { installerStep8Controller.set('content', Em.Object.create({ masterComponentHosts: Em.A([ Em.Object.create({ @@ -669,6 +688,10 @@ describe('App.WizardStep8Controller', function () { installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create()); installerStep8Controller.get('ajaxRequestsQueue').clear(); installerStep8Controller.createAdditionalClientComponents(); + }); + + it('should bes equal to content.cluster.name', function () { + var result = [ { "hostNames": "name", @@ -1526,60 +1549,82 @@ describe('App.WizardStep8Controller', function () { installerStep8Controller.registerHostsToComponent.restore(); }); - it('should add components with isRequiredOnAllHosts == true (1)', function() { - installerStep8Controller.reopen({ - getRegisteredHosts: function() { - return [{hostName: 'h1'}, {hostName: 'h2'}]; - }, - content: { - services: [ - Em.Object.create({ - serviceName: 'GANGLIA', isSelected: true, isInstalled: false, serviceComponents: [ - Em.Object.create({ - componentName: 'GANGLIA_MONITOR', - isRequiredOnAllHosts: true - }), - Em.Object.create({ - componentName: 'GANGLIA_SERVER', - isRequiredOnAllHosts: false - }) - ] - }) - ] - } + describe('should add components with isRequiredOnAllHosts == true (1)', function() { + + beforeEach(function () { + installerStep8Controller.reopen({ + getRegisteredHosts: function() { + return [{hostName: 'h1'}, {hostName: 'h2'}]; + }, + content: { + services: [ + Em.Object.create({ + serviceName: 'GANGLIA', isSelected: true, isInstalled: false, serviceComponents: [ + Em.Object.create({ + componentName: 'GANGLIA_MONITOR', + isRequiredOnAllHosts: true + }), + Em.Object.create({ + componentName: 'GANGLIA_SERVER', + isRequiredOnAllHosts: false + }) + ] + }) + ] + } + }); + installerStep8Controller.createAdditionalHostComponents(); + }); + + it('registerHostsToComponent is called once', function () { + expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true); + }); + it('hosts are ["h1", "h2"]', function () { + expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']); + }); + it('component is GANGLIA_MONITOR', function () { + expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR'); }); - installerStep8Controller.createAdditionalHostComponents(); - expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true); - expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']); - expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR'); + }); - it('should add components with isRequiredOnAllHosts == true (2)', function() { - installerStep8Controller.reopen({ - getRegisteredHosts: function() { - return [{hostName: 'h1', isInstalled: true}, {hostName: 'h2', isInstalled: false}]; - }, - content: { - services: [ - Em.Object.create({ - serviceName: 'GANGLIA', isSelected: true, isInstalled: true, serviceComponents: [ - Em.Object.create({ - componentName: 'GANGLIA_MONITOR', - isRequiredOnAllHosts: true - }), - Em.Object.create({ - componentName: 'GANGLIA_SERVER', - isRequiredOnAllHosts: false - }) - ] - }) - ] - } + describe('should add components with isRequiredOnAllHosts == true (2)', function() { + + beforeEach(function () { + installerStep8Controller.reopen({ + getRegisteredHosts: function() { + return [{hostName: 'h1', isInstalled: true}, {hostName: 'h2', isInstalled: false}]; + }, + content: { + services: [ + Em.Object.create({ + serviceName: 'GANGLIA', isSelected: true, isInstalled: true, serviceComponents: [ + Em.Object.create({ + componentName: 'GANGLIA_MONITOR', + isRequiredOnAllHosts: true + }), + Em.Object.create({ + componentName: 'GANGLIA_SERVER', + isRequiredOnAllHosts: false + }) + ] + }) + ] + } + }); + installerStep8Controller.createAdditionalHostComponents(); + }); + + it('registerHostsToComponent is called once', function () { + expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true); + }); + it('hosts are ["h2"]', function () { + expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h2']); + }); + it('component is GANGLIA_MONITOR', function () { + expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR'); }); - installerStep8Controller.createAdditionalHostComponents(); - expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true); - expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h2']); - expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR'); + }); var newDatabases = [ @@ -1592,28 +1637,38 @@ describe('App.WizardStep8Controller', function () { ]; newDatabases.forEach(function (db) { - it('should add {0}'.format(db.component), function() { - installerStep8Controller.reopen({ - getRegisteredHosts: function() { - return [{hostName: 'h1'}, {hostName: 'h2'}]; - }, - content: { - masterComponentHosts: [ - {component: 'HIVE_SERVER', hostName: 'h1'}, - {component: 'HIVE_SERVER', hostName: 'h2'} - ], - services: [ - Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false, serviceComponents: []}) - ], - serviceConfigProperties: [ - {name: 'hive_database', value: db.name} - ] - } + describe('should add {0}'.format(db.component), function() { + + beforeEach(function () { + installerStep8Controller.reopen({ + getRegisteredHosts: function() { + return [{hostName: 'h1'}, {hostName: 'h2'}]; + }, + content: { + masterComponentHosts: [ + {component: 'HIVE_SERVER', hostName: 'h1'}, + {component: 'HIVE_SERVER', hostName: 'h2'} + ], + services: [ + Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false, serviceComponents: []}) + ], + serviceConfigProperties: [ + {name: 'hive_database', value: db.name} + ] + } + }); + installerStep8Controller.createAdditionalHostComponents(); + }); + + it('registerHostsToComponent is called once', function () { + expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true); + }); + it('hosts are ["h1", "h2"]', function () { + expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']); + }); + it('component is ' + db.component, function () { + expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal(db.component); }); - installerStep8Controller.createAdditionalHostComponents(); - expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true); - expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']); - expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal(db.component); }); }); @@ -1687,7 +1742,7 @@ describe('App.WizardStep8Controller', function () { hosts: Em.A([ Em.Object.create({hostName: 'h1', isInstalled: false}), Em.Object.create({hostName: 'h2', isInstalled: false}) - ]), + ]) }), Em.Object.create({ componentName: 'CLIENT', @@ -1733,93 +1788,99 @@ describe('App.WizardStep8Controller', function () { }); }); - it('should not add components with isRequiredOnAllHosts == false (2)', function() { - installerStep8Controller.reopen({ - getRegisteredHosts: function() { - return [{hostName: 'h1'}, {hostName: 'h2'}]; - }, - content: { - services: Em.A([ - Em.Object.create({ - serviceName: 'ANYSERVICE', isSelected: true, isInstalled: false, serviceComponents: [ - // set isRequiredOnAllHosts = false for all components - Em.Object.create({ - componentName: 'ANYSERVICE_MASTER', - isMaster: true, - isRequiredOnAllHosts: false - }), - Em.Object.create({ - componentName: 'ANYSERVICE_SLAVE', - isSlave: true, - isRequiredOnAllHosts: false - }), - Em.Object.create({ - componentName: 'ANYSERVICE_SLAVE2', - isSlave: true, - isRequiredOnAllHosts: false - }), - Em.Object.create({ - componentName: 'ANYSERVICE_CLIENT', - isClient: true, - isRequiredOnAllHosts: false - }) - ] - }) - ]), - masterComponentHosts: Em.A([ - Em.Object.create({ - componentName: 'ANYSERVICE_MASTER', - component: 'ANYSERVICE_MASTER', - hosts: Em.A([ - Em.Object.create({hostName: 'h1', isInstalled: true}) - ]) - }) - ]), - slaveComponentHosts: Em.A([ - Em.Object.create({ - componentName: 'ANYSERVICE_SLAVE', - hosts: Em.A([ - Em.Object.create({hostName: 'h1', isInstalled: false}), - Em.Object.create({hostName: 'h2', isInstalled: false}) - ]) - }), - Em.Object.create({ - componentName: 'ANYSERVICE_SLAVE2', - hosts: Em.A([ - Em.Object.create({hostName: 'h1', isInstalled: false}), - Em.Object.create({hostName: 'h2', isInstalled: false}) - ]), - }), - Em.Object.create({ - componentName: 'CLIENT', - hosts: Em.A([ - Em.Object.create({hostName: 'h1', isInstalled: false}), - Em.Object.create({hostName: 'h2', isInstalled: false}) - ]) - }) - ]), - clients: Em.A([ - Em.Object.create({ - component_name: 'ANYSERVICE_CLIENT', - isInstalled: false, - hosts: Em.A([ - Em.Object.create({hostName: 'h1', isInstalled: false}), - Em.Object.create({hostName: 'h2', isInstalled: false}) - ]) - }) - ]) - } + describe('should not add components with isRequiredOnAllHosts == false (2)', function() { + + beforeEach(function () { + installerStep8Controller.reopen({ + getRegisteredHosts: function() { + return [{hostName: 'h1'}, {hostName: 'h2'}]; + }, + content: { + services: Em.A([ + Em.Object.create({ + serviceName: 'ANYSERVICE', isSelected: true, isInstalled: false, serviceComponents: [ + // set isRequiredOnAllHosts = false for all components + Em.Object.create({ + componentName: 'ANYSERVICE_MASTER', + isMaster: true, + isRequiredOnAllHosts: false + }), + Em.Object.create({ + componentName: 'ANYSERVICE_SLAVE', + isSlave: true, + isRequiredOnAllHosts: false + }), + Em.Object.create({ + componentName: 'ANYSERVICE_SLAVE2', + isSlave: true, + isRequiredOnAllHosts: false + }), + Em.Object.create({ + componentName: 'ANYSERVICE_CLIENT', + isClient: true, + isRequiredOnAllHosts: false + }) + ] + }) + ]), + masterComponentHosts: Em.A([ + Em.Object.create({ + componentName: 'ANYSERVICE_MASTER', + component: 'ANYSERVICE_MASTER', + hosts: Em.A([ + Em.Object.create({hostName: 'h1', isInstalled: true}) + ]) + }) + ]), + slaveComponentHosts: Em.A([ + Em.Object.create({ + componentName: 'ANYSERVICE_SLAVE', + hosts: Em.A([ + Em.Object.create({hostName: 'h1', isInstalled: false}), + Em.Object.create({hostName: 'h2', isInstalled: false}) + ]) + }), + Em.Object.create({ + componentName: 'ANYSERVICE_SLAVE2', + hosts: Em.A([ + Em.Object.create({hostName: 'h1', isInstalled: false}), + Em.Object.create({hostName: 'h2', isInstalled: false}) + ]), + }), + Em.Object.create({ + componentName: 'CLIENT', + hosts: Em.A([ + Em.Object.create({hostName: 'h1', isInstalled: false}), + Em.Object.create({hostName: 'h2', isInstalled: false}) + ]) + }) + ]), + clients: Em.A([ + Em.Object.create({ + component_name: 'ANYSERVICE_CLIENT', + isInstalled: false, + hosts: Em.A([ + Em.Object.create({hostName: 'h1', isInstalled: false}), + Em.Object.create({hostName: 'h2', isInstalled: false}) + ]) + }) + ]) + } + }); + installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create()); + installerStep8Controller.get('ajaxRequestsQueue').clear(); + installerStep8Controller.createAdditionalHostComponents(); + }); + + it('registerHostsToComponent is not called', function () { + // isRequiredOnAllHosts = false for all components, implies that + // registerHostsToComponent would be done via + // createMasterHostComponents() or createSlaveAndClientsHostComponents() + // or createAdditionalClientComponents() + // BUT NOT createAdditionalHostComponents() + expect(installerStep8Controller.registerHostsToComponent.callCount).to.equal(0); }); - installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create()); - installerStep8Controller.get('ajaxRequestsQueue').clear(); - installerStep8Controller.createAdditionalHostComponents(); - // isRequiredOnAllHosts = false for all components, implies that - // registerHostsToComponent would be done via - // createMasterHostComponents() or createSlaveAndClientsHostComponents() - // or createAdditionalClientComponents() - // BUT NOT createAdditionalHostComponents() - expect(installerStep8Controller.registerHostsToComponent.callCount).to.equal(0); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/wizard/step9_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step9_test.js b/ambari-web/test/controllers/wizard/step9_test.js index d60b24a..9bfe00d 100644 --- a/ambari-web/test/controllers/wizard/step9_test.js +++ b/ambari-web/test/controllers/wizard/step9_test.js @@ -458,61 +458,74 @@ describe('App.InstallerStep9Controller', function () { }); describe('#setIsServicesInstalled', function () { - it('Should return 100% completed', function () { - var polledData = Em.A([ - Em.Object.create({ - Tasks: Em.Object.create({ - status: 'NONE' - }) - }), - Em.Object.create({ - Tasks: Em.Object.create({ - status: 'NONE' - }) - }) - ]); - c.setProperties({ - status: 'failed', - isPolling: true, - hosts: Em.A([ + + Em.A([ + { + m: 'Should return 100% completed', + c: { + status: 'failed', + isPolling: true, + hosts: Em.A([ + Em.Object.create({ + progress: 0 + }) + ]) + }, + polledData: Em.A([ Em.Object.create({ - progress: 0 - }) - ]) - }); - c.setIsServicesInstalled(polledData); - expect(c.get('progress')).to.equal('100'); - expect(c.get('isPolling')).to.be.false; - }); - it('Should return 34% completed', function () { - var polledData = Em.A([ - Em.Object.create({ - Tasks: Em.Object.create({ - status: 'NONE' + Tasks: Em.Object.create({ + status: 'NONE' + }) + }), + Em.Object.create({ + Tasks: Em.Object.create({ + status: 'NONE' + }) }) - }), - Em.Object.create({ - Tasks: Em.Object.create({ - status: 'NONE' + ]), + e: { + progress: '100', + isPolling: false + } + }, + { + m: 'Should return 34% completed', + c: { + status: '', + isPolling: true, + hosts: Em.A([ + Em.Object.create({ + progress: 0 + }) + ]), + content: Em.Object.create({ + controllerName: 'installerController' }) - }) - ]); - c.setProperties({ - status: '', - isPolling: true, - hosts: Em.A([ + }, + polledData: Em.A([ + Em.Object.create({ + Tasks: Em.Object.create({ + status: 'NONE' + }) + }), Em.Object.create({ - progress: 0 + Tasks: Em.Object.create({ + status: 'NONE' + }) }) ]), - content: Em.Object.create({ - controllerName: 'installerController' - }) + e: { + progress: '34', + isPolling: true + } + } + ]).forEach(function (test) { + it(test.m, function () { + c.setProperties(test.c); + c.setIsServicesInstalled(test.polledData); }); - c.setIsServicesInstalled(polledData); - expect(c.get('progress')).to.equal('34'); - expect(c.get('isPolling')).to.be.true; }); + }); describe('#launchStartServices', function () { @@ -1005,20 +1018,29 @@ describe('App.InstallerStep9Controller', function () { } ]); tests.forEach(function (test) { - it(test.m, function () { - var actions = []; - for (var prop in test.actions) { - if (test.actions.hasOwnProperty(prop) && test.actions[prop]) { - for (var i = 0; i < test.actions[prop]; i++) { - actions.push({Tasks: {status: prop}}); + describe(test.m, function () { + + beforeEach(function () { + var actions = []; + for (var prop in test.actions) { + if (test.actions.hasOwnProperty(prop) && test.actions[prop]) { + for (var i = 0; i < test.actions[prop]; i++) { + actions.push({Tasks: {status: prop}}); + } } } - } - c.reopen({content: {cluster: {status: test.cluster.status}}}); - App.set('supports.skipComponentStartAfterInstall', test.s); - var progress = c.progressPerHost(actions, test.host); - expect(progress).to.equal(test.e.progress); - expect(test.host.progress).to.equal(test.e.progress.toString()); + c.reopen({content: {cluster: {status: test.cluster.status}}}); + App.set('supports.skipComponentStartAfterInstall', test.s); + this.progress = c.progressPerHost(actions, test.host); + }); + + it('progress is ' + test.e.progress, function () { + expect(this.progress).to.equal(test.e.progress); + }); + + it('host progress is ' + test.e.progress.toString(), function () { + expect(test.host.progress).to.equal(test.e.progress.toString()); + }); }); }); }); @@ -1243,8 +1265,9 @@ describe('App.InstallerStep9Controller', function () { it(test.m, function () { c.reopen({hosts: [Em.Object.create({logTasks: test.tasks})]}); c.setLogTasksStatePerHost(test.tasksPerHost, c.get('hosts')[0]); - expect(c.get('hosts')[0].get('logTasks').everyProperty('Tasks.status', test.e.m)).to.equal(true); - expect(c.get('hosts')[0].get('logTasks.length')).to.equal(test.e.l); + var host = c.get('hosts')[0]; + expect(host.get('logTasks').everyProperty('Tasks.status', test.e.m)).to.equal(true); + expect(host.get('logTasks.length')).to.equal(test.e.l); }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/controllers/wizard_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard_test.js b/ambari-web/test/controllers/wizard_test.js index dced13c..08d9d89 100644 --- a/ambari-web/test/controllers/wizard_test.js +++ b/ambari-web/test/controllers/wizard_test.js @@ -1208,8 +1208,7 @@ describe('App.WizardController', function () { describe('#enableStep', function () { - it('should update appropriate value in isStepDisabled', function () { - + beforeEach(function () { c.set('isStepDisabled', [ Em.Object.create({step: 1, value: true}), Em.Object.create({step: 2, value: true}), @@ -1219,10 +1218,14 @@ describe('App.WizardController', function () { Em.Object.create({step: 6, value: true}), Em.Object.create({step: 7, value: true}) ]); + }); + it('should update 1st value in isStepDisabled', function () { c.enableStep(1); expect(c.get('isStepDisabled')[0].get('value')).to.be.false; + }); + it('should update 6th value in isStepDisabled', function () { c.enableStep(7); expect(c.get('isStepDisabled')[6].get('value')).to.be.false; }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/helpers.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/helpers.js b/ambari-web/test/helpers.js index eaa5363..4c2a671 100644 --- a/ambari-web/test/helpers.js +++ b/ambari-web/test/helpers.js @@ -15,6 +15,8 @@ * the License. */ +/*eslint-disable mocha-cleanup/no-assertions-outside-it */ + module.exports = { /** http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/mappers/stack_service_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/stack_service_mapper_test.js b/ambari-web/test/mappers/stack_service_mapper_test.js index 0d13925..4bc36fe 100644 --- a/ambari-web/test/mappers/stack_service_mapper_test.js +++ b/ambari-web/test/mappers/stack_service_mapper_test.js @@ -15,6 +15,8 @@ * the License. */ +/*eslint-disable */ + var App = require('app'); require('mappers/stack_service_mapper'); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/mixins/common/serverValidator_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/common/serverValidator_test.js b/ambari-web/test/mixins/common/serverValidator_test.js index a17698f..e663e7c 100644 --- a/ambari-web/test/mixins/common/serverValidator_test.js +++ b/ambari-web/test/mixins/common/serverValidator_test.js @@ -158,19 +158,28 @@ describe('App.ServerValidatorMixin', function() { e: false } ].forEach(function(test) { - it('controller "name": {0} using "EnhancedConfigsMixin": {1} recommendations called: {2}'.format(test.controllerName, test.injectEnhancedConfigsMixin, test.e), function() { + describe('controller "name": {0} using "EnhancedConfigsMixin": {1} recommendations called: {2}'.format(test.controllerName, test.injectEnhancedConfigsMixin, test.e), function() { var mixed; - if (test.injectEnhancedConfigsMixin) { - mixed = Em.Object.extend(App.EnhancedConfigsMixin, App.ServerValidatorMixin); - } else { - mixed = Em.Object.extend(App.ServerValidatorMixin); - } - // mock controller name in mixed object directly - mixed.create({name: test.controllerName}).loadServerSideConfigsRecommendations(); - expect(App.ajax.send.calledOnce).to.be.eql(test.e); + beforeEach(function () { + if (test.injectEnhancedConfigsMixin) { + mixed = Em.Object.extend(App.EnhancedConfigsMixin, App.ServerValidatorMixin); + } else { + mixed = Em.Object.extend(App.ServerValidatorMixin); + } + // mock controller name in mixed object directly + mixed.create({name: test.controllerName}).loadServerSideConfigsRecommendations(); + }); + + it('request is ' + (test.e ? '' : 'not') + ' sent', function () { + expect(App.ajax.send.calledOnce).to.be.eql(test.e); + }); + if (test.e) { - expect(App.ajax.send.args[0][0].name).to.be.eql('config.recommendations'); + it('request is valid', function () { + expect(App.ajax.send.args[0][0].name).to.be.eql('config.recommendations'); + }); } + }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/models/form_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/form_test.js b/ambari-web/test/models/form_test.js index 3ba7c10..18c86c6 100644 --- a/ambari-web/test/models/form_test.js +++ b/ambari-web/test/models/form_test.js @@ -19,7 +19,7 @@ var App = require('app'); require('models/form'); - +/*eslint-disable mocha-cleanup/no-assertions-outside-it */ var form, field, formField, @@ -75,6 +75,7 @@ var form, formField.validate(); expect(formField.get('errorMessage')).to.equal(message); }; +/*eslint-enable mocha-cleanup/no-assertions-outside-it */ describe('App.Form', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/utils/config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/config_test.js b/ambari-web/test/utils/config_test.js index 84231d7..c88c745 100644 --- a/ambari-web/test/utils/config_test.js +++ b/ambari-web/test/utils/config_test.js @@ -724,25 +724,36 @@ describe('App.config', function () { expect(App.config.createOverride.bind(App.config, null, {}, group)).to.throw(Error, 'serviceConfigProperty can\' be null'); }); - it('updates originalSCP object ', function() { - configProperty.set('overrides', null); - configProperty.set('overrideValues', []); - configProperty.set('overrideIsFinalValues', []); - - var overridenTemplate2 = { - value: "v12", - recommendedValue: "rv12", - savedValue: "sv12", - isFinal: true, - recommendedIsFinal: false, - savedIsFinal: false - }; + describe('updates originalSCP object ', function() { + + var overridenTemplate2; + var override; + + beforeEach(function () { + configProperty.set('overrides', null); + configProperty.set('overrideValues', []); + configProperty.set('overrideIsFinalValues', []); + overridenTemplate2 = { + value: "v12", + recommendedValue: "rv12", + savedValue: "sv12", + isFinal: true, + recommendedIsFinal: false, + savedIsFinal: false + }; + override = App.config.createOverride(configProperty, overridenTemplate2, group); + }); - var override = App.config.createOverride(configProperty, overridenTemplate2, group); + it('overrides.0 is valid', function () { + expect(configProperty.get('overrides')[0]).to.be.eql(override); + }); + it('overrideValues is valid', function () { + expect(configProperty.get('overrideValues')).to.be.eql([overridenTemplate2.value]); + }); + it('overrideIsFinalValues is valid', function () { + expect(configProperty.get('overrideIsFinalValues')).to.be.eql([overridenTemplate2.isFinal]); + }); - expect(configProperty.get('overrides')[0]).to.be.eql(override); - expect(configProperty.get('overrideValues')).to.be.eql([overridenTemplate2.value]); - expect(configProperty.get('overrideIsFinalValues')).to.be.eql([overridenTemplate2.isFinal]); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/utils/configs/config_initializer_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/utils/configs/config_initializer_test.js b/ambari-web/test/utils/configs/config_initializer_test.js index b98581a..f8eb825 100644 --- a/ambari-web/test/utils/configs/config_initializer_test.js +++ b/ambari-web/test/utils/configs/config_initializer_test.js @@ -359,19 +359,29 @@ describe('App.ConfigInitializer', function () { cases['hive_database'].forEach(function (item) { var title = 'hive_database value should be set to {0}'; - it(title.format(item.value), function () { - this.stub - .withArgs('supports.alwaysEnableManagedMySQLForHive').returns(item.alwaysEnableManagedMySQLForHive) - .withArgs('router.currentState.name').returns(item.currentStateName) - .withArgs('isManagedMySQLForHiveEnabled').returns(item.isManagedMySQLForHiveEnabled); - serviceConfigProperty.setProperties({ - name: 'hive_database', - value: item.receivedValue, - options: item.options + describe(title.format(item.value), function () { + + beforeEach(function () { + this.stub + .withArgs('supports.alwaysEnableManagedMySQLForHive').returns(item.alwaysEnableManagedMySQLForHive) + .withArgs('router.currentState.name').returns(item.currentStateName) + .withArgs('isManagedMySQLForHiveEnabled').returns(item.isManagedMySQLForHiveEnabled); + serviceConfigProperty.setProperties({ + name: 'hive_database', + value: item.receivedValue, + options: item.options + }); + App.ConfigInitializer.initialValue(serviceConfigProperty, {}, []); + }); + + it('value is ' + item.value, function () { + expect(serviceConfigProperty.get('value')).to.equal(item.value); }); - App.ConfigInitializer.initialValue(serviceConfigProperty, {}, []); - expect(serviceConfigProperty.get('value')).to.equal(item.value); - expect(serviceConfigProperty.get('options').findProperty('displayName', 'New MySQL Database').hidden).to.equal(item.hidden); + + it('`New MySQL Database` is ' + (item.hidden ? '' : 'not') + ' hidden', function () { + expect(serviceConfigProperty.get('options').findProperty('displayName', 'New MySQL Database').hidden).to.equal(item.hidden); + }); + }); }); @@ -808,19 +818,30 @@ describe('App.ConfigInitializer', function () { expectedValue: 'thrift://h1:9083,thrift://h2:9083' } ]).forEach(function (test) { - it(test.m || test.config, function () { - serviceConfigProperty.setProperties({ - name: test.config, - recommendedValue: test.rValue, - filename: test.filename + describe(test.m || test.config, function () { + + beforeEach(function () { + serviceConfigProperty.setProperties({ + name: test.config, + recommendedValue: test.rValue, + filename: test.filename + }); + App.ConfigInitializer.initialValue(serviceConfigProperty, test.localDB, test.dependencies); + }); + + it('value is ' + test.expectedValue, function () { + expect(serviceConfigProperty.get('value')).to.eql(test.expectedValue); }); - App.ConfigInitializer.initialValue(serviceConfigProperty, test.localDB, test.dependencies); - expect(serviceConfigProperty.get('value')).to.eql(test.expectedValue); + if (Em.isNone(test.expectedRValue)) { - expect(serviceConfigProperty.get('recommendedValue')).to.eql(test.expectedValue); + it('recommendedValue is ' + test.expectedValue, function () { + expect(serviceConfigProperty.get('recommendedValue')).to.eql(test.expectedValue); + }); } else { - expect(serviceConfigProperty.get('recommendedValue')).to.eql(test.expectedRValue); + it('recommendedValue is ' + test.expectedRValue, function () { + expect(serviceConfigProperty.get('recommendedValue')).to.eql(test.expectedRValue); + }); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/views/common/configs/widgets/config_widget_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/configs/widgets/config_widget_view_test.js b/ambari-web/test/views/common/configs/widgets/config_widget_view_test.js index ed43a1b..3fc02a7 100644 --- a/ambari-web/test/views/common/configs/widgets/config_widget_view_test.js +++ b/ambari-web/test/views/common/configs/widgets/config_widget_view_test.js @@ -180,7 +180,7 @@ describe('App.ConfigWidgetView', function () { view = App.ConfigWidgetView.create({ controller: Em.Object.extend(App.EnhancedConfigsMixin, { }).create({ - updateDependentConfigs: function() {}, + updateDependentConfigs: function() {} }), config: Em.Object.create({ name: 'config1'}) }); @@ -215,37 +215,60 @@ describe('App.ConfigWidgetView', function () { }); }); - it('when dependent configs has multiple parents appropriate parent config should be removed', function() { - view.set('controller.recommendations', [ - {name: 'dependent1', parentConfigs: ['config1', 'config2']}, - {name: 'dependent2', parentConfigs: ['config2', 'config1']}, - {name: 'dependent3', parentConfigs: ['config1']} - ]); - view.restoreDependentConfigs(view.get('config')); - expect(view.get('controller.recommendations').findProperty('name', 'dependent1').parentConfigs.toArray()).to.be.eql(["config2"]); - expect(view.get('controller.recommendations').findProperty('name', 'dependent2').parentConfigs.toArray()).to.be.eql(["config2"]); - expect(view.get('controller.recommendations.length')).to.be.eql(2); + describe('when dependent configs has multiple parents appropriate parent config should be removed', function() { + + beforeEach(function () { + view.set('controller.recommendations', [ + {name: 'dependent1', parentConfigs: ['config1', 'config2']}, + {name: 'dependent2', parentConfigs: ['config2', 'config1']}, + {name: 'dependent3', parentConfigs: ['config1']} + ]); + view.restoreDependentConfigs(view.get('config')); + }); + + it('2 recommendations', function () { + expect(view.get('controller.recommendations.length')).to.be.equal(2); + }); + + it('dependent1 parent is ["config2"]', function () { + expect(view.get('controller.recommendations').findProperty('name', 'dependent1').parentConfigs.toArray()).to.be.eql(["config2"]); + }); + it('dependent2 parent is ["config2"]', function () { + expect(view.get('controller.recommendations').findProperty('name', 'dependent2').parentConfigs.toArray()).to.be.eql(["config2"]); + }); + }); - it('dependent config value should be set with inital or saved when it has one parent', function() { - var ctrl = view.get('controller'); - ctrl.set('stepConfigs', [ - Em.Object.create({ - configs: Em.A([ - Em.Object.create({ name: 'dependent3', savedValue: '1', value: 2, filename: 'some-file.xml' }), - Em.Object.create({ name: 'dependent2', savedValue: '4', value: '10', filename: 'some-file.xml' }) - ]) - }) - ]); - view.set('controller.recommendations', [ - {propertyName: 'dependent1', parentConfigs: ['config1', 'config2'], fileName: 'some-file' }, - {propertyName: 'dependent2', parentConfigs: ['config2', 'config1'], fileName: 'some-file'}, - {propertyName: 'dependent3', parentConfigs: ['config1'], fileName: 'some-file' } - ]); - view.restoreDependentConfigs(view.get('config')); - expect(view.get('controller').findConfigProperty('dependent3', 'some-file.xml').get('value')).to.be.eql('1'); - // config with multi dependency should not be updated - expect(view.get('controller').findConfigProperty('dependent2', 'some-file.xml').get('value')).to.be.eql('10'); + describe('dependent config value should be set with inital or saved when it has one parent', function() { + var ctrl; + + beforeEach(function () { + ctrl = view.get('controller'); + ctrl.set('stepConfigs', [ + Em.Object.create({ + configs: Em.A([ + Em.Object.create({ name: 'dependent3', savedValue: '1', value: 2, filename: 'some-file.xml' }), + Em.Object.create({ name: 'dependent2', savedValue: '4', value: '10', filename: 'some-file.xml' }) + ]) + }) + ]); + view.set('controller.recommendations', [ + {propertyName: 'dependent1', parentConfigs: ['config1', 'config2'], fileName: 'some-file' }, + {propertyName: 'dependent2', parentConfigs: ['config2', 'config1'], fileName: 'some-file'}, + {propertyName: 'dependent3', parentConfigs: ['config1'], fileName: 'some-file' } + ]); + view.restoreDependentConfigs(view.get('config')); + }); + + it('dependent3 value is `1`', function () { + expect(view.get('controller').findConfigProperty('dependent3', 'some-file.xml').get('value')).to.be.equal('1'); + }); + + it('dependent2 value is `10`', function () { + // config with multi dependency should not be updated + expect(view.get('controller').findConfigProperty('dependent2', 'some-file.xml').get('value')).to.be.equal('10'); + }); + }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js b/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js index 4e1caa1..47dfc5d 100644 --- a/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js +++ b/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js @@ -136,11 +136,12 @@ describe('App.ListConfigWidgetView', function () { view.sendRequestRorDependentConfigs.restore(); }); it('value updates if some option', function () { - view.toggleOption({context: view.get('options')[2]}); + var options = view.get('options'); + view.toggleOption({context: options[2]}); expect(view.get('config.value')).to.equal('2,1,3'); - view.toggleOption({context: view.get('options')[1]}); + view.toggleOption({context: options[1]}); expect(view.get('config.value')).to.equal('1,3'); - view.toggleOption({context: view.get('options')[1]}); + view.toggleOption({context: options[1]}); expect(view.get('config.value')).to.equal('1,3,2'); }); @@ -161,13 +162,14 @@ describe('App.ListConfigWidgetView', function () { view.sendRequestRorDependentConfigs.restore(); }); it('should restore saved value', function () { - view.toggleOption({context: view.get('options')[0]}); - view.toggleOption({context: view.get('options')[1]}); - view.toggleOption({context: view.get('options')[2]}); + var options = view.get('options'); + view.toggleOption({context: options[0]}); + view.toggleOption({context: options[1]}); + view.toggleOption({context: options[2]}); expect(view.get('config.value')).to.equal('3'); view.restoreValue(); expect(view.get('config.value')).to.equal('2,1'); - expect(view.get('controller.removeCurrentFromDependentList')).to.be.called + expect(view.get('controller.removeCurrentFromDependentList')).to.be.called; }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js b/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js index 3214c5b..a996e69 100644 --- a/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js +++ b/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js @@ -544,28 +544,35 @@ describe('App.SliderConfigWidgetView', function () { ]; tests.forEach(function(test) { - it('should generate ticks: {0} - tick labels: {1}'.format(test.e.ticks, test.e.ticksLabels), function() { + describe('should generate ticks: {0} - tick labels: {1}'.format(test.e.ticks, test.e.ticksLabels), function() { var ticks, ticksLabels; - this.view.reopen(test.viewSetup); - this.view.set('controller', { - isCompareMode: test.viewSetup.isCompareMode - }); - var sliderCopy = window.Slider.prototype; - window.Slider = function(a, b) { - ticks = b.ticks; - ticksLabels = b.ticks_labels; - return { - on: function() { - return this; - } + beforeEach(function () { + this.view.reopen(test.viewSetup); + this.view.set('controller', { + isCompareMode: test.viewSetup.isCompareMode + }); + var sliderCopy = window.Slider.prototype; + window.Slider = function(a, b) { + ticks = b.ticks; + ticksLabels = b.ticks_labels; + return { + on: function() { + return this; + } + }; }; - }; + this.view.willInsertElement(); + this.view.initSlider(); + window.Slider.prototype = sliderCopy; + }); - this.view.willInsertElement(); - this.view.initSlider(); - window.Slider.prototype = sliderCopy; - expect(ticks.toArray()).to.be.eql(test.e.ticks); - expect(ticksLabels.toArray()).to.be.eql(test.e.ticksLabels); + it('ticks are ' + test.e.ticks, function () { + expect(ticks.toArray()).to.be.eql(test.e.ticks); + }); + + it('ticksLabels are ' + test.e.ticksLabels, function () { + expect(ticksLabels.toArray()).to.be.eql(test.e.ticksLabels); + }); }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/views/common/configs/widgets/toggle_config_widget_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/configs/widgets/toggle_config_widget_view_test.js b/ambari-web/test/views/common/configs/widgets/toggle_config_widget_view_test.js index 93a0f01..44d8322 100644 --- a/ambari-web/test/views/common/configs/widgets/toggle_config_widget_view_test.js +++ b/ambari-web/test/views/common/configs/widgets/toggle_config_widget_view_test.js @@ -89,8 +89,8 @@ describe('App.ToggleConfigWidgetView', function () { isValid: true }); expect(this.view.isValueCompatibleWithWidget()).to.be.false; - expect(this.view.get('warnMessage')).to.have.property('length').that.is.least(1); - expect(this.view.get('issueMessage')).to.have.property('length').that.is.least(1); + expect(this.view.get('warnMessage')).to.be.not.empty; + expect(this.view.get('issueMessage')).to.be.not.empty; }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/views/common/controls_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/controls_view_test.js b/ambari-web/test/views/common/controls_view_test.js index cb7a475..a097151 100644 --- a/ambari-web/test/views/common/controls_view_test.js +++ b/ambari-web/test/views/common/controls_view_test.js @@ -295,23 +295,34 @@ describe('App.ServiceConfigRadioButtons', function () { }); cases.forEach(function (item) { - it(item.title, function () { - this.stub.withArgs('currentStackVersion').returns(item.currentStackVersion); - rangerVersion = item.rangerVersion; - view.reopen({controller: item.controller}); - view.setProperties({ - categoryConfigsAll: item.controller.get('selectedService.configs'), - serviceConfig: item.serviceConfig - }); + describe(item.title, function () { + + var additionalView1, additionalView2; + beforeEach(function () { + this.stub.withArgs('currentStackVersion').returns(item.currentStackVersion); + rangerVersion = item.rangerVersion; + view.reopen({controller: item.controller}); + view.setProperties({ + categoryConfigsAll: item.controller.get('selectedService.configs'), + serviceConfig: item.serviceConfig + }); - var additionalView1 = view.get('categoryConfigsAll').findProperty('name', item.propertyAppendTo1).get('additionalView'), + additionalView1 = view.get('categoryConfigsAll').findProperty('name', item.propertyAppendTo1).get('additionalView'); additionalView2 = view.get('categoryConfigsAll').findProperty('name', item.propertyAppendTo2).get('additionalView'); + }); - expect(Em.isNone(additionalView1)).to.equal(item.isAdditionalView1Null); - expect(Em.isNone(additionalView2)).to.equal(item.isAdditionalView2Null); + it('additionalView1 is ' + (item.isAdditionalView1Null ? '' : 'not') + ' null', function () { + expect(Em.isNone(additionalView1)).to.equal(item.isAdditionalView1Null); + }); + + it('additionalView2 is ' + (item.isAdditionalView2Null ? '' : 'not') + ' null', function () { + expect(Em.isNone(additionalView2)).to.equal(item.isAdditionalView2Null); + }); if (!item.isAdditionalView2Null) { - expect(additionalView2.create().get('message')).to.equal(Em.I18n.t('services.service.config.database.msg.jdbcSetup').format(item.dbType, item.driver)); + it('additionalView2.message is valid', function () { + expect(additionalView2.create().get('message')).to.equal(Em.I18n.t('services.service.config.database.msg.jdbcSetup').format(item.dbType, item.driver)); + }); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/views/common/rolling_restart_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/rolling_restart_view_test.js b/ambari-web/test/views/common/rolling_restart_view_test.js index 694f876..2f06f48 100644 --- a/ambari-web/test/views/common/rolling_restart_view_test.js +++ b/ambari-web/test/views/common/rolling_restart_view_test.js @@ -69,15 +69,24 @@ describe('App.RollingRestartView', function () { ]; testCases.forEach(function (test) { - it(test.restartHostComponents.length + ' components to restart', function () { - view.set('batchSize', -1); - view.set('interBatchWaitTimeSeconds', -1); - view.set('tolerateSize', -1); - view.set('hostComponentName', test.hostComponentName); - view.set('restartHostComponents', test.restartHostComponents); - view.initialize(); - expect(view.get('batchSize')).to.equal(test.result.batchSize); - expect(view.get('tolerateSize')).to.equal(test.result.tolerateSize); + describe(test.restartHostComponents.length + ' components to restart', function () { + + beforeEach(function () { + view.set('batchSize', -1); + view.set('interBatchWaitTimeSeconds', -1); + view.set('tolerateSize', -1); + view.set('hostComponentName', test.hostComponentName); + view.set('restartHostComponents', test.restartHostComponents); + view.initialize(); + }); + + it('batchSize is ' + test.result.batchSize, function() { + expect(view.get('batchSize')).to.equal(test.result.batchSize); + }); + + it('tolerateSize is ' + test.result.tolerateSize, function() { + expect(view.get('tolerateSize')).to.equal(test.result.tolerateSize); + }); }) }, this); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js index 94c8fe9..a5b0def 100644 --- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js +++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js @@ -679,16 +679,28 @@ describe('App.upgradeWizardView', function () { }); cases.forEach(function (item) { - it(item.title, function () { - view.set('controller.areSkippedServiceChecksLoaded', item.areSkippedServiceChecksLoaded); - view.reopen({ - isFinalizeItem: item.isFinalizeItem + describe(item.title, function () { + + beforeEach(function () { + view.set('controller.areSkippedServiceChecksLoaded', item.areSkippedServiceChecksLoaded); + view.reopen({ + isFinalizeItem: item.isFinalizeItem + }); + view.propertyDidChange('isFinalizeItem'); + }); + + it('request is sent ' + item.ajaxSendCallCount + ' times', function (){ + expect(App.ajax.send.callCount).to.equal(item.ajaxSendCallCount); }); - view.propertyDidChange('isFinalizeItem'); - expect(App.ajax.send.callCount).to.equal(item.ajaxSendCallCount); - expect(view.get('controller.areSkippedServiceChecksLoaded')).to.equal(item.areSkippedServiceChecksLoadedResult); + + it('areSkippedServiceChecksLoaded is ' + item.areSkippedServiceChecksLoaded, function () { + expect(view.get('controller.areSkippedServiceChecksLoaded')).to.equal(item.areSkippedServiceChecksLoadedResult); + }); + if (item.ajaxSendCallCount) { - expect(App.ajax.send.firstCall.args[0].data.upgradeId).to.equal(1); + it('upgradeId is 1', function () { + expect(App.ajax.send.firstCall.args[0].data.upgradeId).to.equal(1); + }); } }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/views/main/alerts/manage_alert_groups/select_definitions_popup_body_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/alerts/manage_alert_groups/select_definitions_popup_body_view_test.js b/ambari-web/test/views/main/alerts/manage_alert_groups/select_definitions_popup_body_view_test.js index 4ddaf50..d0002a0 100644 --- a/ambari-web/test/views/main/alerts/manage_alert_groups/select_definitions_popup_body_view_test.js +++ b/ambari-web/test/views/main/alerts/manage_alert_groups/select_definitions_popup_body_view_test.js @@ -228,15 +228,25 @@ describe('App.SelectDefinitionsPopupBodyView', function () { } ]; testCases.forEach(function (test) { - it(test.title, function () { - view.set('parentView.availableDefs', test.data.defs); - view.set('showOnlySelectedDefs', test.data.showOnlySelectedDefs); - view.set('filterComponent', test.data.filterComponent); - view.set('filterService', test.data.filterService); + describe(test.title, function () { + + beforeEach(function () { + view.set('parentView.availableDefs', test.data.defs); + view.set('showOnlySelectedDefs', test.data.showOnlySelectedDefs); + view.set('filterComponent', test.data.filterComponent); + view.set('filterService', test.data.filterService); + + view.filterDefs(); + }); + + it('availableDefs.@each.filtered is ' + test.result, function () { + expect(view.get('parentView.availableDefs').mapProperty('filtered')).to.eql(test.result); + }); + + it('startIndex is 1', function () { + expect(view.get('startIndex')).to.equal(1); + }); - view.filterDefs(); - expect(view.get('parentView.availableDefs').mapProperty('filtered')).to.eql(test.result); - expect(view.get('startIndex')).to.equal(1); }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/views/main/dashboard/widget_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/dashboard/widget_test.js b/ambari-web/test/views/main/dashboard/widget_test.js index 39b2a48..e27d0f7 100644 --- a/ambari-web/test/views/main/dashboard/widget_test.js +++ b/ambari-web/test/views/main/dashboard/widget_test.js @@ -335,15 +335,28 @@ describe('App.DashboardWidgetView', function () { } ]; testCases.forEach(function (test) { - it("thresh1 - " + test.data.thresh1 + ', maxValue - ' + test.data.maxValue, function () { - widget.set('isThresh2Error', false); - widget.set('thresh2', test.data.thresh2 || ""); - widget.set('thresh1', test.data.thresh1); - widget.set('maxValue', test.data.maxValue); - widget.observeThresh1Value(); - expect(widget.get('isThresh1Error')).to.equal(test.result.isThresh1Error); - expect(widget.get('errorMessage1')).to.equal(test.result.errorMessage1); - expect(widget.updateSlider.called).to.be.true; + describe("thresh1 - " + test.data.thresh1 + ', maxValue - ' + test.data.maxValue, function () { + + beforeEach(function () { + widget.set('isThresh2Error', false); + widget.set('thresh2', test.data.thresh2 || ""); + widget.set('thresh1', test.data.thresh1); + widget.set('maxValue', test.data.maxValue); + widget.observeThresh1Value(); + }); + + it('isThresh1Error is ' + test.result.isThresh1Error, function () { + expect(widget.get('isThresh1Error')).to.equal(test.result.isThresh1Error); + }); + + it('errorMessage1 is ' + test.result.errorMessage1, function () { + expect(widget.get('errorMessage1')).to.equal(test.result.errorMessage1); + }); + + it('updateSlider is called', function () { + expect(widget.updateSlider.called).to.be.true; + }); + }); }); }); @@ -408,13 +421,25 @@ describe('App.DashboardWidgetView', function () { } ]; testCases.forEach(function (test) { - it("thresh2 - " + test.data.thresh2 + ', maxValue - ' + test.data.maxValue, function () { - widget.set('thresh2', test.data.thresh2 || ""); - widget.set('maxValue', test.data.maxValue); - widget.observeThresh2Value(); - expect(widget.get('isThresh2Error')).to.equal(test.result.isThresh2Error); - expect(widget.get('errorMessage2')).to.equal(test.result.errorMessage2); - expect(widget.updateSlider.called).to.be.true; + describe("thresh2 - " + test.data.thresh2 + ', maxValue - ' + test.data.maxValue, function () { + + beforeEach(function () { + widget.set('thresh2', test.data.thresh2 || ""); + widget.set('maxValue', test.data.maxValue); + widget.observeThresh2Value(); + }); + + it('isThresh2Error is ' + test.result.isThresh2Error, function () { + expect(widget.get('isThresh2Error')).to.equal(test.result.isThresh2Error); + }); + + it('errorMessage2 is ' + JSON.stringify(test.result.errorMessage2), function () { + expect(widget.get('errorMessage2')).to.equal(test.result.errorMessage2); + }); + + it('updateSlider is called', function () { + expect(widget.updateSlider.called).to.be.true; + }); }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/views/main/dashboard/widgets_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/dashboard/widgets_test.js b/ambari-web/test/views/main/dashboard/widgets_test.js index 311bf21..35f0673 100644 --- a/ambari-web/test/views/main/dashboard/widgets_test.js +++ b/ambari-web/test/views/main/dashboard/widgets_test.js @@ -115,14 +115,24 @@ describe('App.MainDashboardWidgetsView', function () { } ]); tests.forEach(function (test) { - it(test.m, function () { - view.set('host_metrics_model', test.models.host_metrics_model); - view.set('hdfs_model', test.models.hdfs_model); - view.set('hbase_model', test.models.hbase_model); - view.set('yarn_model', test.models.yarn_model); - view.setInitPrefObject(); - expect(view.get('initPrefObject.visible.length')).to.equal(test.e.visibleL); - expect(view.get('initPrefObject.hidden.length')).to.equal(test.e.hiddenL); + describe(test.m, function () { + + beforeEach(function () { + view.set('host_metrics_model', test.models.host_metrics_model); + view.set('hdfs_model', test.models.hdfs_model); + view.set('hbase_model', test.models.hbase_model); + view.set('yarn_model', test.models.yarn_model); + view.setInitPrefObject(); + }); + + it('visible.length is ' + test.e.visibleL, function () { + expect(view.get('initPrefObject.visible.length')).to.equal(test.e.visibleL); + }); + + it('hidden.length is ' + test.e.hiddenL, function () { + expect(view.get('initPrefObject.hidden.length')).to.equal(test.e.hiddenL); + }); + }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/views/main/host/details_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/host/details_test.js b/ambari-web/test/views/main/host/details_test.js index 34f4c28..857b644 100644 --- a/ambari-web/test/views/main/host/details_test.js +++ b/ambari-web/test/views/main/host/details_test.js @@ -132,8 +132,11 @@ describe('App.MainHostDetailsView', function () { App.set('services', Em.K); }); - it('should get only clients with configs', function() { + it('should get only clients with configs (1)', function() { expect(view.get('clientsWithConfigs')).to.have.length(1); + }); + + it('should get only clients with configs (2)', function() { view.get('content.hostComponents').pushObject(Em.Object.create({ isClient: true, service: Em.Object.create({ @@ -141,6 +144,9 @@ describe('App.MainHostDetailsView', function () { }) })); expect(view.get('clientsWithConfigs')).to.have.length(1); + }); + + it('should get only clients with configs (3)', function() { view.get('content.hostComponents').pushObject(Em.Object.create({ isClient: true, service: Em.Object.create({ http://git-wip-us.apache.org/repos/asf/ambari/blob/b8aede2a/ambari-web/test/views/wizard/step5_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/wizard/step5_view_test.js b/ambari-web/test/views/wizard/step5_view_test.js index 824d67e..5f3cd0d 100644 --- a/ambari-web/test/views/wizard/step5_view_test.js +++ b/ambari-web/test/views/wizard/step5_view_test.js @@ -105,14 +105,19 @@ describe('App.WizardStep5View', function() { }); describe('#shouldUseInputs', function() { - it('should based on hosts count', function() { - view.set('controller.hosts', d3.range(0, 25).map(function() {return {};})); - expect(view.get('shouldUseInputs')).to.be.false; - view.set('controller.hosts', d3.range(0, 26).map(function() {return {};})); - expect(view.get('shouldUseInputs')).to.be.true; - view.set('controller.hosts', d3.range(0, 24).map(function() {return {};})); - expect(view.get('shouldUseInputs')).to.be.false; + + Em.A([ + {range: 25, e: false}, + {range: 26, e: true}, + {range: 24, e: false} + ]).forEach(function (test) { + it(test.e + ' for ' + test.range + ' hosts', function () { + view.set('controller.hosts', d3.range(0, test.range).map(function() {return {};})); + expect(view.get('shouldUseInputs')).to.be.equal(test.e); + }); + }); + }); });