http://git-wip-us.apache.org/repos/asf/ambari/blob/f8213edb/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 0e120a2..576e303 100644 --- a/ambari-web/test/controllers/wizard/step8_test.js +++ b/ambari-web/test/controllers/wizard/step8_test.js @@ -1170,46 +1170,6 @@ describe('App.WizardStep8Controller', function () { }); - describe('#createSelectedServicesData', function() { - it('should reformat provided data', function() { - var selectedServices = [ - Em.Object.create({serviceName: 's1'}), - Em.Object.create({serviceName: 's2'}), - Em.Object.create({serviceName: 's3'}) - ]; - var expected = [ - {"ServiceInfo": { "service_name": 's1' }}, - {"ServiceInfo": { "service_name": 's2' }}, - {"ServiceInfo": { "service_name": 's3' }} - ]; - installerStep8Controller.reopen({selectedServices: selectedServices}); - var createdData = installerStep8Controller.createSelectedServicesData(); - expect(createdData).to.eql(expected); - }); - }); - - describe('#createRegisterHostData', function() { - it('should return empty data if no hosts', function() { - sinon.stub(installerStep8Controller, 'getRegisteredHosts', function() {return [];}); - expect(installerStep8Controller.createRegisterHostData()).to.eql([]); - installerStep8Controller.getRegisteredHosts.restore(); - }); - it('should return computed data', function() { - var data = [ - {isInstalled: false, hostName: 'h1'}, - {isInstalled: true, hostName: 'h2'}, - {isInstalled: false, hostName: 'h3'} - ]; - var expected = [ - {"Hosts": { "host_name": 'h1'}}, - {"Hosts": { "host_name": 'h3'}} - ]; - sinon.stub(installerStep8Controller, 'getRegisteredHosts', function() {return data;}); - expect(installerStep8Controller.createRegisterHostData()).to.eql(expected); - installerStep8Controller.getRegisteredHosts.restore(); - }); - }); - describe('#createStormSiteObj', function() { it('should replace quote \'"\' to "\'" for some properties', function() { var configs = [ @@ -1247,11 +1207,18 @@ describe('App.WizardStep8Controller', function () { }); describe('#ajaxQueueFinished', function() { - it('should call App.router.next', function() { + + beforeEach(function () { sinon.stub(App.router, 'send', Em.K); + }); + + afterEach(function () { + App.router.send.restore(); + }); + + it('should call App.router.next', function() { installerStep8Controller.ajaxQueueFinished(); expect(App.router.send.calledWith('next')).to.equal(true); - App.router.send.restore(); }); }); @@ -1423,43 +1390,60 @@ describe('App.WizardStep8Controller', function () { describe('#createSelectedServices', function() { + var data; + + beforeEach(function () { + sinon.stub(installerStep8Controller, 'createSelectedServicesData', function () { + return data; + }); + }); + + afterEach(function () { + installerStep8Controller.createSelectedServicesData.restore(); + }); + it('shouldn\'t do nothing if no data', function() { - sinon.stub(installerStep8Controller, 'createSelectedServicesData', function() {return [];}); + data = []; installerStep8Controller.createSelectedServices(); expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false); - installerStep8Controller.createSelectedServicesData.restore(); }); it('should call addRequestToAjaxQueue with computed data', function() { - var data = [ + data = [ {"ServiceInfo": { "service_name": 's1' }}, {"ServiceInfo": { "service_name": 's2' }}, {"ServiceInfo": { "service_name": 's3' }} ]; - sinon.stub(installerStep8Controller, 'createSelectedServicesData', function() {return data;}); installerStep8Controller.createSelectedServices(); expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify(data)); - installerStep8Controller.createSelectedServicesData.restore(); }); }); describe('#registerHostsToCluster', function() { + var data; + beforeEach(function () { + sinon.stub(installerStep8Controller, 'createRegisterHostData', function () { + return data; + }); + }); + + afterEach(function () { + installerStep8Controller.createRegisterHostData.restore(); + }); + it('shouldn\'t do nothing if no data', function() { - sinon.stub(installerStep8Controller, 'createRegisterHostData', function() {return [];}); + data = []; installerStep8Controller.registerHostsToCluster(); expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false); - installerStep8Controller.createRegisterHostData.restore(); }); it('should call addRequestToAjaxQueue with computed data', function() { - var data = [ + data = [ {"Hosts": { "host_name": 'h1'}}, {"Hosts": { "host_name": 'h3'}} ]; - sinon.stub(installerStep8Controller, 'createRegisterHostData', function() {return data;}); installerStep8Controller.registerHostsToCluster(); expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify(data)); - installerStep8Controller.createRegisterHostData.restore(); }); }); @@ -1646,98 +1630,107 @@ 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.A([ - Em.Object.create({ - serviceName: 'ANYSERVICE', isSelected: true, isInstalled: false, serviceComponents: [ - // set isRequiredOnAllHosts = true for slave and client - Em.Object.create({ - componentName: 'ANYSERVICE_MASTER', - isMaster: true, - isRequiredOnAllHosts: false - }), - Em.Object.create({ - componentName: 'ANYSERVICE_SLAVE', - isSlave: true, - isRequiredOnAllHosts: true - }), - Em.Object.create({ - componentName: 'ANYSERVICE_SLAVE2', - isSlave: true, - isRequiredOnAllHosts: true - }), - Em.Object.create({ - componentName: 'ANYSERVICE_CLIENT', - isClient: true, - isRequiredOnAllHosts: true - }) - ] - }) - ]), - 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 add components with isRequiredOnAllHosts == true (1)', 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 = true for slave and client + Em.Object.create({ + componentName: 'ANYSERVICE_MASTER', + isMaster: true, + isRequiredOnAllHosts: false + }), + Em.Object.create({ + componentName: 'ANYSERVICE_SLAVE', + isSlave: true, + isRequiredOnAllHosts: true + }), + Em.Object.create({ + componentName: 'ANYSERVICE_SLAVE2', + isSlave: true, + isRequiredOnAllHosts: true + }), + Em.Object.create({ + componentName: 'ANYSERVICE_CLIENT', + isClient: true, + isRequiredOnAllHosts: true + }) + ] + }) + ]), + 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(); }); - installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create()); - installerStep8Controller.get('ajaxRequestsQueue').clear(); - installerStep8Controller.createAdditionalHostComponents(); - // Any component with isRequiredOnAllHosts = true implies that - // registerHostsToComponent would be done via - // createAdditionalHostComponents() BUT NOT - // createMasterHostComponents() or createSlaveAndClientsHostComponents() - // or createAdditionalClientComponents() - expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']); - expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('ANYSERVICE_SLAVE'); - expect(installerStep8Controller.registerHostsToComponent.args[1][0]).to.eql(['h1', 'h2']); - expect(installerStep8Controller.registerHostsToComponent.args[1][1]).to.equal('ANYSERVICE_SLAVE2'); - expect(installerStep8Controller.registerHostsToComponent.args[2][0]).to.eql(['h1', 'h2']); - expect(installerStep8Controller.registerHostsToComponent.args[2][1]).to.equal('ANYSERVICE_CLIENT'); + // Any component with isRequiredOnAllHosts = true implies that + // registerHostsToComponent would be done via + // createAdditionalHostComponents() BUT NOT + // createMasterHostComponents() or createSlaveAndClientsHostComponents() + // or createAdditionalClientComponents() + it('registerHostsToComponent 1st call', function () { + expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']); + expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('ANYSERVICE_SLAVE'); + }); + it('registerHostsToComponent 2nd call', function () { + expect(installerStep8Controller.registerHostsToComponent.args[1][0]).to.eql(['h1', 'h2']); + expect(installerStep8Controller.registerHostsToComponent.args[1][1]).to.equal('ANYSERVICE_SLAVE2'); + }); + it('registerHostsToComponent 3rd call', function () { + expect(installerStep8Controller.registerHostsToComponent.args[2][0]).to.eql(['h1', 'h2']); + expect(installerStep8Controller.registerHostsToComponent.args[2][1]).to.equal('ANYSERVICE_CLIENT'); + }); }); it('should not add components with isRequiredOnAllHosts == false (2)', function() { @@ -1868,22 +1861,49 @@ describe('App.WizardStep8Controller', function () { expect($.ajax.args[0][0].url.contains('overwrite_existing=true')).to.be.true; }); - it('sent data should be valid', function () { + describe('sent data should be valid', function () { + var data; + beforeEach(function () { + installerStep8Controller.createNotification(); + data = installerStep8Controller.get('ajaxRequestsQueue.queue')[0].data.data.AlertTarget; + }); - installerStep8Controller.createNotification(); - var data = installerStep8Controller.get('ajaxRequestsQueue.queue')[0].data.data.AlertTarget; - expect(data.global).to.be.true; - expect(data.notification_type).to.equal('EMAIL'); - expect(data.alert_states).to.eql(['OK', 'WARNING', 'CRITICAL', 'UNKNOWN']); - expect(data.properties['ambari.dispatch.recipients']).to.eql(['to@f.c']); - expect(data.properties['mail.smtp.host']).to.equal('h'); - expect(data.properties['mail.smtp.port']).to.equal('25'); - expect(data.properties['mail.smtp.from']).to.equal('from@f.c'); - expect(data.properties['mail.smtp.starttls.enable']).to.equal(true); - expect(data.properties['mail.smtp.startssl.enable']).to.equal(false); - expect(data.properties['ambari.dispatch.credential.username']).to.equal('usr'); - expect(data.properties['ambari.dispatch.credential.password']).to.equal('pwd'); - expect(data.properties['some_p']).to.equal('some_v'); + it('global is true', function () { + expect(data.global).to.be.true; + }); + it('notification_type is EMAIL', function () { + expect(data.notification_type).to.equal('EMAIL'); + }); + it('alert_states are valid', function () { + expect(data.alert_states).to.eql(['OK', 'WARNING', 'CRITICAL', 'UNKNOWN']); + }); + it('ambari.dispatch.recipients is valid', function () { + expect(data.properties['ambari.dispatch.recipients']).to.eql(['to@f.c']); + }); + it('mail.smtp.host is valid', function () { + expect(data.properties['mail.smtp.host']).to.equal('h'); + }); + it('mail.smtp.port is valid', function () { + expect(data.properties['mail.smtp.port']).to.equal('25'); + }); + it('mail.smtp.from is valid', function () { + expect(data.properties['mail.smtp.from']).to.equal('from@f.c'); + }); + it('mail.smtp.starttls.enable is true', function () { + expect(data.properties['mail.smtp.starttls.enable']).to.equal(true); + }); + it('mail.smtp.startssl.enable is false', function () { + expect(data.properties['mail.smtp.startssl.enable']).to.equal(false); + }); + it('ambari.dispatch.credential.username is valid', function () { + expect(data.properties['ambari.dispatch.credential.username']).to.equal('usr'); + }); + it('ambari.dispatch.credential.password is valid', function () { + expect(data.properties['ambari.dispatch.credential.password']).to.equal('pwd'); + }); + it('custom property is valid', function () { + expect(data.properties['some_p']).to.equal('some_v'); + }); }); @@ -1911,14 +1931,18 @@ describe('App.WizardStep8Controller', function () { installerStep8Controller.startDeploy.restore(); }); - it('no failed requests', function () { - expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1); - expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false; - expect(installerStep8Controller.startDeploy.called).to.be.false; - installerStep8Controller.deleteClusterSuccessCallback(); - expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2); - expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false; - expect(installerStep8Controller.startDeploy.calledOnce).to.be.true; + describe('no failed requests', function () { + it('before Delete Cluster request', function () { + expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1); + expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false; + expect(installerStep8Controller.startDeploy.called).to.be.false; + }); + it('after Delete Cluster request', function () { + installerStep8Controller.deleteClusterSuccessCallback(); + expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2); + expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false; + expect(installerStep8Controller.startDeploy.calledOnce).to.be.true; + }); }); it('one request failed', function () { @@ -1957,20 +1981,34 @@ describe('App.WizardStep8Controller', function () { installerStep8Controller.showDeleteClustersErrorPopup.restore(); }); - it('should show error popup only if all requests are completed', function () { - expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1); - expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false; - installerStep8Controller.deleteClusterErrorCallback(request, ajaxOptions, error, opt); - expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2); - expect(installerStep8Controller.showDeleteClustersErrorPopup.calledOnce).to.be.true; + describe('should show error popup only if all requests are completed', function () { + it('Before Delete Cluster request fail', function () { + expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1); + expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false; + }); + it('After Delete Cluster request is failed', function () { + installerStep8Controller.deleteClusterErrorCallback(request, ajaxOptions, error, opt); + expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2); + expect(installerStep8Controller.showDeleteClustersErrorPopup.calledOnce).to.be.true; + }); }); - it('should create error popup body view', function () { - expect(installerStep8Controller.get('clusterDeleteErrorViews')).to.have.length(1); - expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.url')).to.equal('api/v1/clusters/c0'); - expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.type')).to.equal('DELETE'); - expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.status')).to.equal(500); - expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.message')).to.equal('Internal Server Error'); + describe('should create error popup body view', function () { + it('One failed request', function () { + expect(installerStep8Controller.get('clusterDeleteErrorViews')).to.have.length(1); + }); + it('failed request url is valid', function () { + expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.url')).to.equal('api/v1/clusters/c0'); + }); + it('failed request type is valid', function () { + expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.type')).to.equal('DELETE'); + }); + it('failed request status is valid', function () { + expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.status')).to.equal(500); + }); + it('failed request message is valid', function () { + expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.message')).to.equal('Internal Server Error'); + }); }); }); @@ -2052,22 +2090,29 @@ describe('App.WizardStep8Controller', function () { }); cases.forEach(function (item) { - it(item.title, function () { - sinon.stub(installerStep8Controller, 'get') - .withArgs('ajaxRequestsQueue').returns({ - start: Em.K - }) - .withArgs('ajaxRequestsQueue.queue.length').returns(1) - .withArgs('wizardController').returns({ - getDBProperty: function () { - return item.fileNamesToUpdate; - } - }) - .withArgs('content.controllerName').returns(item.controllerName); - installerStep8Controller.startDeploy(); + describe(item.title, function () { + + beforeEach(function () { + sinon.stub(installerStep8Controller, 'get') + .withArgs('ajaxRequestsQueue').returns({ + start: Em.K + }) + .withArgs('ajaxRequestsQueue.queue.length').returns(1) + .withArgs('wizardController').returns({ + getDBProperty: function () { + return item.fileNamesToUpdate; + } + }) + .withArgs('content.controllerName').returns(item.controllerName); + installerStep8Controller.startDeploy(); + }); + stubbedNames.forEach(function (name) { - expect(installerStep8Controller[name].called).to.equal(!item.notExecuted.contains(name)); + it(name, function () { + expect(installerStep8Controller[name].called).to.equal(!item.notExecuted.contains(name)); + }); }); + }); }); @@ -2305,12 +2350,19 @@ describe('App.WizardStep8Controller', function () { }); describe('#showLoadingIndicator', function() { + + beforeEach(function () { + sinon.spy(App.ModalPopup, 'show'); + }); + + afterEach(function () { + App.ModalPopup.show.restore(); + }); + it('if popup doesn\'t exist should create another', function() { installerStep8Controller.set('isSubmitDisabled', true); - sinon.spy(App.ModalPopup, 'show'); installerStep8Controller.showLoadingIndicator(); expect(App.ModalPopup.show.calledOnce).to.equal(true); - App.ModalPopup.show.restore(); }); });
http://git-wip-us.apache.org/repos/asf/ambari/blob/f8213edb/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 fa57fd5..d60b24a 100644 --- a/ambari-web/test/controllers/wizard/step9_test.js +++ b/ambari-web/test/controllers/wizard/step9_test.js @@ -397,14 +397,12 @@ describe('App.InstallerStep9Controller', function () { var loaded_hosts = c.get('hosts'); expect(loaded_hosts.length).to.equal(2); }); + it('All hosts have progress 0', function () { var loaded_hosts = c.get('hosts'); expect(loaded_hosts.everyProperty('progress', 0)).to.equal(true); }); - it('All hosts have progress 0', function () { - var loaded_hosts = c.get('hosts'); - expect(loaded_hosts.everyProperty('progress', 0)).to.equal(true); - }); + it('All host don\'t have logTasks', function () { var loaded_hosts = c.get('hosts'); expect(loaded_hosts.everyProperty('logTasks.length', 0)).to.equal(true); @@ -1026,12 +1024,22 @@ describe('App.InstallerStep9Controller', function () { }); describe('#clearStep', function () { - it('All to default values', function () { + + beforeEach(function () { c.reopen({hosts: [{},{},{}]}); c.clearStep(); + }); + + it('hosts are empty', function () { expect(c.get('hosts.length')).to.equal(0); + }); + it('status is `info`', function () { expect(c.get('status')).to.equal('info'); + }); + it('progress is 0', function () { expect(c.get('progress')).to.equal('0'); + }); + it('numPolls is 1', function () { expect(c.get('numPolls')).to.equal(1); }); }); @@ -1287,11 +1295,18 @@ describe('App.InstallerStep9Controller', function () { }); describe('#submit', function () { - it('should call App.router.send', function () { + + beforeEach(function () { sinon.stub(App.router, 'send', Em.K); + }); + + afterEach(function () { + App.router.send.restore(); + }); + + it('should call App.router.send', function () { c.submit(); expect(App.router.send.calledWith('next')).to.equal(true); - App.router.send.restore(); }); }); @@ -1336,9 +1351,11 @@ describe('App.InstallerStep9Controller', function () { describe('#startPolling', function () { beforeEach(function () { sinon.stub(c, 'reloadErrorCallback', Em.K); + sinon.stub(c, 'doPolling', Em.K); }); afterEach(function () { c.reloadErrorCallback.restore(); + c.doPolling.restore(); }); it('should set isSubmitDisabled to true', function () { c.set('isSubmitDisabled', false); @@ -1346,10 +1363,8 @@ describe('App.InstallerStep9Controller', function () { expect(c.get('isSubmitDisabled')).to.equal(true); }); it('should call doPolling', function () { - sinon.stub(c, 'doPolling', Em.K); c.startPolling(); expect(c.doPolling.calledOnce).to.equal(true); - c.doPolling.restore(); }); }); @@ -1375,13 +1390,6 @@ describe('App.InstallerStep9Controller', function () { expect(c.getLogsByRequest.calledWith(true, 3)).to.equal(true); }); - it('should set POLL_INTERVAL to 1 if testMode enabled', function () { - sinon.stub(App, 'get', function(k) { if ('testMode' === k) return true; return Em.get(App, k);}); - c.loadLogData(); - expect(c.get('POLL_INTERVAL')).to.equal(1); - App.get.restore(); - }); - }); describe('#loadCurrentTaskLog', function () { @@ -1390,23 +1398,25 @@ describe('App.InstallerStep9Controller', function () { c.set('wizardController', Em.Object.create({ getDBProperty: Em.K })); + sinon.stub(c, 'togglePreviousSteps', Em.K); }); afterEach(function () { c.loadLogData.restore(); + c.togglePreviousSteps.restore(); }); + it('shouldn\'t call App.ajax.send if no currentOpenTaskId', function () { c.set('currentOpenTaskId', null); c.loadCurrentTaskLog(); expect(App.ajax.send.called).to.equal(false); }); + it('should call App.ajax.send with provided data', function () { - sinon.stub(c, 'togglePreviousSteps', Em.K); c.set('currentOpenTaskId', 1); c.set('currentOpenTaskRequestId', 2); c.set('content', {cluster: {name: 3}}); c.loadCurrentTaskLog(); expect(App.ajax.send.args[0][0].data).to.eql({taskId: 1, requestId: 2, clusterName: 3}); - c.togglePreviousSteps.restore(); }); }); @@ -1535,12 +1545,15 @@ describe('App.InstallerStep9Controller', function () { }); describe('#navigateStep', function () { + beforeEach(function () { sinon.stub(c, 'togglePreviousSteps', Em.K); sinon.stub(c, 'loadStep', Em.K); sinon.stub(c, 'loadLogData', Em.K); sinon.stub(c, 'startPolling', Em.K); + sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);}); }); + afterEach(function () { c.togglePreviousSteps.restore(); c.loadStep.restore(); @@ -1548,16 +1561,8 @@ describe('App.InstallerStep9Controller', function () { c.startPolling.restore(); App.get.restore(); }); - it('should set custom data in testMode', function () { - sinon.stub(App, 'get', function(k) {if('testMode' === k) return true; return Em.get(App, k);}); - c.reopen({content: {cluster: {status: 'st', isCompleted: true, requestId: 0}}}); - c.navigateStep(); - expect(c.get('content.cluster.status')).to.equal('PENDING'); - expect(c.get('content.cluster.isCompleted')).to.equal(false); - expect(c.get('content.cluster.requestId')).to.equal(1); - }); + it('isCompleted = true, requestId = 1', function () { - sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);}); c.reopen({content: {cluster: {isCompleted: true, requestId: 1}}}); c.navigateStep(); expect(c.loadStep.calledOnce).to.equal(true); @@ -1565,21 +1570,18 @@ describe('App.InstallerStep9Controller', function () { expect(c.get('progress')).to.equal('100'); }); it('isCompleted = false, requestId = 1, status = INSTALL FAILED', function () { - sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);}); c.reopen({content: {cluster: {status: 'INSTALL FAILED', isCompleted: false, requestId: 1}}}); c.navigateStep(); expect(c.loadStep.calledOnce).to.equal(true); expect(c.loadLogData.calledWith(false)).to.equal(true); }); it('isCompleted = false, requestId = 1, status = START FAILED', function () { - sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);}); c.reopen({content: {cluster: {status: 'START FAILED', isCompleted: false, requestId: 1}}}); c.navigateStep(); expect(c.loadStep.calledOnce).to.equal(true); expect(c.loadLogData.calledWith(false)).to.equal(true); }); it('isCompleted = false, requestId = 1, status = OTHER', function () { - sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);}); c.reopen({content: {cluster: {status: 'STARTED', isCompleted: false, requestId: 1}}}); c.navigateStep(); expect(c.loadStep.calledOnce).to.equal(true); @@ -1633,15 +1635,30 @@ describe('App.InstallerStep9Controller', function () { } } ]).forEach(function (test) { - it(test.m, function () { - c.launchStartServicesSuccessCallback(test.jsonData); - expect(c.hostHasClientsOnly.calledWith(test.e.hostHasClientsOnly)).to.equal(true); - expect(c.saveClusterStatus.calledWith(test.e.clusterStatus)).to.equal(true); + describe(test.m, function () { + + beforeEach(function () { + c.launchStartServicesSuccessCallback(test.jsonData); + }); + + it('hostHasClientsOnly is called with valid arguments', function () { + expect(c.hostHasClientsOnly.calledWith(test.e.hostHasClientsOnly)).to.equal(true); + }); + + it('saveClusterStatus is called with valid arguments', function () { + expect(c.saveClusterStatus.calledWith(test.e.clusterStatus)).to.equal(true); + }); + + if (test.e.status) { - expect(c.get('status')).to.equal(test.e.status); + it('status is valid', function () { + expect(c.get('status')).to.equal(test.e.status); + }); } if (test.e.progress) { - expect(c.get('progress')).to.equal(test.e.progress); + it('progress is valid', function () { + expect(c.get('progress')).to.equal(test.e.progress); + }); } }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f8213edb/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 316ec2d..dced13c 100644 --- a/ambari-web/test/controllers/wizard_test.js +++ b/ambari-web/test/controllers/wizard_test.js @@ -56,21 +56,21 @@ describe('App.WizardController', function () { // isStep0 ... isStep10 tests App.WizardController1 = App.WizardController.extend({currentStep:''}); var tests = []; - for(var i = 0; i < totalSteps; i++) { + for (var i = 0; i < totalSteps; i++) { var n = ruller.slice(0); - n.splice(i,1); - tests.push({i:i,n:n}); + n.splice(i, 1); + tests.push({i: i, n: n}); } - tests.forEach(function(test) { - describe('isStep'+test.i, function() { + tests.forEach(function (test) { + describe('isStep' + test.i, function () { var w = App.WizardController1.create(); w.set('currentStep', test.i); - it('Current Step is ' + test.i + ', so isStep' + test.i + ' is TRUE', function() { - expect(w.get('isStep'+ test.i)).to.equal(true); + it('Current Step is ' + test.i + ', so isStep' + test.i + ' is TRUE', function () { + expect(w.get('isStep' + test.i)).to.equal(true); }); - test.n.forEach(function(indx) { - it('Current Step is ' + test.i + ', so isStep' + indx + ' is FALSE', function() { - expect(w.get('isStep'+ indx)).to.equal(false); + test.n.forEach(function (indx) { + it('Current Step is ' + test.i + ', so isStep' + indx + ' is FALSE', function () { + expect(w.get('isStep' + indx)).to.equal(false); }); }); }); @@ -93,13 +93,19 @@ describe('App.WizardController', function () { }); describe('#launchBootstrapSuccessCallback', function() { + var params = {popup: {finishLoading: function(){}}}; + beforeEach(function () { + sinon.spy(params.popup, "finishLoading"); + }); + + afterEach(function () { + params.popup.finishLoading.restore(); + }); + it('Save bootstrapRequestId', function() { var data = {requestId: 123, status: 'SUCCESS', log: 'ok'}; - var params = {popup: {finishLoading: function(){}}}; - sinon.spy(params.popup, "finishLoading"); wizardController.launchBootstrapSuccessCallback(data, {}, params); expect(params.popup.finishLoading.calledWith(123, null, 'SUCCESS', 'ok')).to.be.true; - params.popup.finishLoading.restore(); }); }); @@ -125,6 +131,7 @@ describe('App.WizardController', function () { sinon.stub(wizardController, 'get') .withArgs('installOptionsTemplate').returns({useSsh: true}) .withArgs('installWindowsOptionsTemplate').returns({useSsh: false}); + this.stub = sinon.stub(App, 'get'); }); afterEach(function () { @@ -134,7 +141,7 @@ describe('App.WizardController', function () { cases.forEach(function (item) { it(title.format(item.expected), function () { - sinon.stub(App, 'get').withArgs('isHadoopWindowsStack').returns(item.isHadoopWindowsStack); + this.stub.withArgs('isHadoopWindowsStack').returns(item.isHadoopWindowsStack); expect(wizardController.getInstallOptions()).to.eql(item.expected); }); }); @@ -156,12 +163,23 @@ describe('App.WizardController', function () { App.get.restore(); }); - it('should clear install options', function () { - wizardController.clearInstallOptions(); - expect(wizardController.get('content.installOptions')).to.eql(wizardController.get('installOptionsTemplate')); - expect(wizardController.get('content.hosts')).to.eql({}); - expect(wizardController.getDBProperty('installOptions')).to.eql(wizardController.get('installOptionsTemplate')); - expect(wizardController.getDBProperty('hosts')).to.eql({}); + describe('should clear install options', function () { + + beforeEach(function () { + wizardController.clearInstallOptions(); + }); + it('content.installOptions', function () { + expect(wizardController.get('content.installOptions')).to.eql(wizardController.get('installOptionsTemplate')); + }); + it('content.hosts', function () { + expect(wizardController.get('content.hosts')).to.eql({}); + }); + it('installOptions', function () { + expect(wizardController.getDBProperty('installOptions')).to.eql(wizardController.get('installOptionsTemplate')); + }); + it('hosts', function () { + expect(wizardController.getDBProperty('hosts')).to.eql({}); + }); }); }); @@ -250,13 +268,21 @@ describe('App.WizardController', function () { afterEach(function(){ App.ModalPopup.show.restore(); }); - it('should set error', function () { - sinon.stub(App.ModalPopup,'show', function (data) { - data.finishLoading.call(c); + + describe('errors', function () { + + beforeEach(function () { + sinon.stub(App.ModalPopup,'show', function (data) { + data.finishLoading.call(c); + }); + }); + + it('should set error', function () { + c.showLaunchBootstrapPopup(Em.K); + expect(c.get('isError')).to.be.true; }); - c.showLaunchBootstrapPopup(Em.K); - expect(c.get('isError')).to.be.true; }); + describe('#finishLoading', function () { var callback = sinon.spy(), stepController = App.get('router.wizardStep3Controller'), @@ -346,18 +372,36 @@ describe('App.WizardController', function () { c.callback.restore(); }); cases.forEach(function (item) { - it(item.title, function () { + describe(item.title, function () { var wizardControllerProperties = Em.keys(item.wizardControllerProperties), stepControllerProperties = Em.keys(item.stepControllerProperties); - sinon.stub(App.ModalPopup,'show', function (data) { - data.finishLoading.call(c, item.requestId, item.serverError, item.status, item.log); + + beforeEach(function () { + sinon.stub(App.ModalPopup,'show', function (data) { + data.finishLoading.call(c, item.requestId, item.serverError, item.status, item.log); + }); + c.showLaunchBootstrapPopup(c.callback); + }); + + it('wizardControllerProperties are valid', function () { + expect(c.getProperties.apply(c, wizardControllerProperties)).to.eql(item.wizardControllerProperties); + }); + + it('stepControllerProperties are valid', function () { + expect(stepController.getProperties.apply(stepController, stepControllerProperties)).to.eql(item.stepControllerProperties); + }); + + it('bootStatus is valid', function () { + expect(stepController.get('hosts').mapProperty('bootStatus').uniq()).to.eql([item.bootStatus]); + }); + + it('callback is called needed number of times', function () { + expect(c.callback.callCount).to.equal(item.callbackCallCount); + }); + + it('hide is called needed number of times', function () { + expect(c.hide.callCount).to.equal(item.hideCallCount); }); - c.showLaunchBootstrapPopup(c.callback); - expect(c.getProperties.apply(c, wizardControllerProperties)).to.eql(item.wizardControllerProperties); - expect(stepController.getProperties.apply(stepController, stepControllerProperties)).to.eql(item.stepControllerProperties); - expect(stepController.get('hosts').mapProperty('bootStatus').uniq()).to.eql([item.bootStatus]); - expect(c.callback.callCount).to.equal(item.callbackCallCount); - expect(c.hide.callCount).to.equal(item.hideCallCount); }); }); }); @@ -584,15 +628,21 @@ describe('App.WizardController', function () { }); describe('#save', function () { - it('should save data', function () { - var res; + var res; + beforeEach(function () { sinon.stub(wizardController,'setDBProperty', function(data){ res = data; }); sinon.stub(wizardController,'toJSInstance').returns('val'); - wizardController.save('name'); + }); + + afterEach(function () { wizardController.setDBProperty.restore(); wizardController.toJSInstance.restore(); + }); + + it('should save data', function () { + wizardController.save('name'); expect(res).to.be.equal('name'); }); }); @@ -1459,6 +1509,7 @@ describe('App.WizardController', function () { serviceName: 's1' }) ])); + this.stub = sinon.stub(App, 'get'); }); afterEach(function () { App.get.restore(); @@ -1468,13 +1519,13 @@ describe('App.WizardController', function () { wizardController.loadConfigThemeForServices.restore(); }); it('Should load config themes', function() { - sinon.stub(App, 'get').returns(true); + this.stub.returns(true); wizardController.loadConfigThemes().then(function(data) { expect().to.be.undefined; }); }); - it('Should load config themes', function() { - sinon.stub(App, 'get').returns(false); + it('Should load config themes (2)', function() { + this.stub.returns(false); wizardController.loadConfigThemes().then(function(data) { expect().to.be.undefined; }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f8213edb/ambari-web/test/data/HDP2.2/site_properties_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/data/HDP2.2/site_properties_test.js b/ambari-web/test/data/HDP2.2/site_properties_test.js index 1cde085..a5e0e18 100644 --- a/ambari-web/test/data/HDP2.2/site_properties_test.js +++ b/ambari-web/test/data/HDP2.2/site_properties_test.js @@ -43,16 +43,12 @@ describe('hdp2SiteProperties', function () { * showLabel * unit */ - it('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Stack driven attributes should be undefined ', function () { - expect(siteProperty.isVisible).to.equal(undefined); - expect(siteProperty.value).to.equal(undefined); - expect(siteProperty.recommendedValue).to.equal(undefined); - expect(siteProperty.description).to.equal(undefined); - expect(siteProperty.isReconfigurable).to.equal(undefined); - expect(siteProperty.isRequired).to.equal(undefined); - expect(siteProperty.displayName).to.equal(undefined); - expect(siteProperty.showLabel).to.equal(undefined); - expect(siteProperty.unit).to.equal(undefined); + describe('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Stack driven attributes should be undefined ', function () { + ['isVisible', 'value', 'recommendedValue', 'description', 'isReconfigurable', 'isRequired', 'displayName', 'showLabel', 'unit'].forEach(function (p) { + it(p, function () { + expect(siteProperty[p]).to.not.exist; + }); + }); }); /** @@ -68,9 +64,13 @@ describe('hdp2SiteProperties', function () { * name * filename */ - it('Check primary attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Attributes that uniquely represent a property should be defined ', function () { - expect(siteProperty.name).to.not.equal(undefined); - expect(siteProperty.filename).to.not.equal(undefined); + describe('Check primary attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Attributes that uniquely represent a property should be defined ', function () { + it('name', function () { + expect(siteProperty.name).to.not.equal(undefined); + }); + it('filename', function () { + expect(siteProperty.filename).to.not.equal(undefined); + }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f8213edb/ambari-web/test/data/HDP2.3/site_properties_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/data/HDP2.3/site_properties_test.js b/ambari-web/test/data/HDP2.3/site_properties_test.js index 263ad6a..b94e0b2 100644 --- a/ambari-web/test/data/HDP2.3/site_properties_test.js +++ b/ambari-web/test/data/HDP2.3/site_properties_test.js @@ -43,16 +43,12 @@ describe('hdp2SiteProperties', function () { * showLabel * unit */ - it('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Stack driven attributes should be undefined ', function () { - expect(siteProperty.isVisible).to.equal(undefined); - expect(siteProperty.value).to.equal(undefined); - expect(siteProperty.recommendedValue).to.equal(undefined); - expect(siteProperty.description).to.equal(undefined); - expect(siteProperty.isReconfigurable).to.equal(undefined); - expect(siteProperty.isRequired).to.equal(undefined); - expect(siteProperty.displayName).to.equal(undefined); - expect(siteProperty.showLabel).to.equal(undefined); - expect(siteProperty.unit).to.equal(undefined); + describe('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Stack driven attributes should be undefined ', function () { + ['isVisible', 'value', 'recommendedValue', 'description', 'isReconfigurable', 'isRequired', 'displayName', 'showLabel', 'unit'].forEach(function (p) { + it(p, function () { + expect(siteProperty[p]).to.not.exist; + }); + }); }); @@ -69,9 +65,13 @@ describe('hdp2SiteProperties', function () { * name * filename */ - it('Check primary attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Attributes that uniquely represent a property should be defined ', function () { - expect(siteProperty.name).to.not.equal(undefined); - expect(siteProperty.filename).to.not.equal(undefined); + describe('Check primary attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Attributes that uniquely represent a property should be defined ', function () { + it('name', function () { + expect(siteProperty.name).to.not.equal(undefined); + }); + it('filename', function () { + expect(siteProperty.filename).to.not.equal(undefined); + }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f8213edb/ambari-web/test/data/HDP2/site_properties_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/data/HDP2/site_properties_test.js b/ambari-web/test/data/HDP2/site_properties_test.js index 89e0ea1..26be9c3 100644 --- a/ambari-web/test/data/HDP2/site_properties_test.js +++ b/ambari-web/test/data/HDP2/site_properties_test.js @@ -43,16 +43,12 @@ describe('hdp2SiteProperties', function () { * showLabel * unit */ - it('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Stack driven attributes should be undefined ', function () { - expect(siteProperty.isVisible).to.equal(undefined); - expect(siteProperty.value).to.equal(undefined); - expect(siteProperty.recommendedValue).to.equal(undefined); - expect(siteProperty.description).to.equal(undefined); - expect(siteProperty.isReconfigurable).to.equal(undefined); - expect(siteProperty.isRequired).to.equal(undefined); - expect(siteProperty.displayName).to.equal(undefined); - expect(siteProperty.showLabel).to.equal(undefined); - expect(siteProperty.unit).to.equal(undefined); + describe('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Stack driven attributes should be undefined ', function () { + ['isVisible', 'value', 'recommendedValue', 'description', 'isReconfigurable', 'isRequired', 'displayName', 'showLabel', 'unit'].forEach(function (p) { + it(p, function () { + expect(siteProperty[p]).to.not.exist; + }); + }); }); /** @@ -68,9 +64,13 @@ describe('hdp2SiteProperties', function () { * name * filename */ - it('Check primary attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Attributes that uniquely represent a property should be defined ', function () { - expect(siteProperty.name).to.not.equal(undefined); - expect(siteProperty.filename).to.not.equal(undefined); + describe('Check primary attributes of "' + siteProperty.filename + '/' + siteProperty.name + '"' + '. Attributes that uniquely represent a property should be defined ', function () { + it('name', function () { + expect(siteProperty.name).to.not.equal(undefined); + }); + it('filename', function () { + expect(siteProperty.filename).to.not.equal(undefined); + }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f8213edb/ambari-web/test/mappers/alert_definition_summary_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/alert_definition_summary_mapper_test.js b/ambari-web/test/mappers/alert_definition_summary_mapper_test.js index 946839a..9208766 100644 --- a/ambari-web/test/mappers/alert_definition_summary_mapper_test.js +++ b/ambari-web/test/mappers/alert_definition_summary_mapper_test.js @@ -21,7 +21,7 @@ require('mappers/alert_definition_summary_mapper'); describe('App.alertDefinitionSummaryMapper', function () { - describe('#map', function() { + describe('#map', function () { var testModels = [ App.AlertDefinition.createRecord({id: 1, enabled: true, type: 'PORT'}), @@ -36,8 +36,18 @@ describe('App.alertDefinitionSummaryMapper', function () { { definition_id: 1, summary: { - OK: {count: 1, original_timestamp: 1, maintenance_count: 0, latest_text : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}, - WARNING: {count: 1, original_timestamp: 2, maintenance_count: 0, latest_text : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}, + OK: { + count: 1, + original_timestamp: 1, + maintenance_count: 0, + latest_text: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000" + }, + WARNING: { + count: 1, + original_timestamp: 2, + maintenance_count: 0, + latest_text: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000" + }, CRITICAL: {count: 0, original_timestamp: 0, maintenance_count: 1}, UNKNOWN: {count: 0, original_timestamp: 0, maintenance_count: 0} } @@ -45,8 +55,18 @@ describe('App.alertDefinitionSummaryMapper', function () { { definition_id: 2, summary: { - OK: {count: 1, original_timestamp: 1, maintenance_count: 0, latest_text : "HTTP 200 response in 0.000 seconds"}, - WARNING: {count: 5, original_timestamp: 2, maintenance_count: 0, latest_text : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}, + OK: { + count: 1, + original_timestamp: 1, + maintenance_count: 0, + latest_text: "HTTP 200 response in 0.000 seconds" + }, + WARNING: { + count: 5, + original_timestamp: 2, + maintenance_count: 0, + latest_text: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000" + }, CRITICAL: {count: 1, original_timestamp: 1, maintenance_count: 0}, UNKNOWN: {count: 1, original_timestamp: 3, maintenance_count: 0} } @@ -54,25 +74,50 @@ describe('App.alertDefinitionSummaryMapper', function () { { definition_id: 3, summary: { - OK: {count: 1, original_timestamp: 1, maintenance_count: 0, latest_text : "HTTP 200 response in 0.000 seconds"}, + OK: { + count: 1, + original_timestamp: 1, + maintenance_count: 0, + latest_text: "HTTP 200 response in 0.000 seconds" + }, WARNING: {count: 2, original_timestamp: 2, maintenance_count: 2}, - CRITICAL: {count: 3, original_timestamp: 4, maintenance_count: 0, latest_text : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}, + CRITICAL: { + count: 3, + original_timestamp: 4, + maintenance_count: 0, + latest_text: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000" + }, UNKNOWN: {count: 4, original_timestamp: 3, maintenance_count: 0} } }, { definition_id: 4, summary: { - OK: {count: 4, original_timestamp: 1, maintenance_count: 0, latest_text : "HTTP 200 response in 0.000 seconds"}, + OK: { + count: 4, + original_timestamp: 1, + maintenance_count: 0, + latest_text: "HTTP 200 response in 0.000 seconds" + }, WARNING: {count: 3, original_timestamp: 2, maintenance_count: 0}, CRITICAL: {count: 2, original_timestamp: 1, maintenance_count: 0}, - UNKNOWN: {count: 1, original_timestamp: 2, maintenance_count: 0, latest_text : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"} + UNKNOWN: { + count: 1, + original_timestamp: 2, + maintenance_count: 0, + latest_text: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000" + } } }, { definition_id: 5, summary: { - OK: {count: 1, original_timestamp: 1, maintenance_count: 0, latest_text : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}, + OK: { + count: 1, + original_timestamp: 1, + maintenance_count: 0, + latest_text: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000" + }, WARNING: {count: 1, original_timestamp: 2, maintenance_count: 0}, CRITICAL: {count: 1, original_timestamp: 3, maintenance_count: 0}, UNKNOWN: {count: 1, original_timestamp: 4, maintenance_count: 0} @@ -81,45 +126,105 @@ describe('App.alertDefinitionSummaryMapper', function () { ] }; - beforeEach(function() { - - sinon.stub(App.AlertDefinition, 'find', function() {return testModels;}); - + beforeEach(function () { + sinon.stub(App.AlertDefinition, 'find').returns(testModels); + App.alertDefinitionSummaryMapper.map(dataToMap); }); - afterEach(function() { - + afterEach(function () { App.AlertDefinition.find.restore(); - }); - it('should map summary info for each alert', function() { - - App.alertDefinitionSummaryMapper.map(dataToMap); + it('should map summary info for 1st alert', function () { expect(App.AlertDefinition.find().findProperty('id', 1).get('lastTriggered')).to.equal(2); - expect(App.AlertDefinition.find().findProperty('id', 1).get('summary')).to.eql({OK: {count: 1, maintenanceCount: 0, latestText : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}, WARNING: {count: 1, maintenanceCount: 0, latestText : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}, CRITICAL: {count: 0, maintenanceCount: 1}, UNKNOWN: {count: 0, maintenanceCount: 0}}); + expect(App.AlertDefinition.find().findProperty('id', 1).get('summary')).to.eql({ + OK: { + count: 1, + maintenanceCount: 0, + latestText: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000" + }, + WARNING: { + count: 1, + maintenanceCount: 0, + latestText: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000" + }, + CRITICAL: {count: 0, maintenanceCount: 1}, + UNKNOWN: {count: 0, maintenanceCount: 0} + }); + }); + it('should map summary info for 2nd alert', function () { expect(App.AlertDefinition.find().findProperty('id', 2).get('lastTriggered')).to.equal(3); - expect(App.AlertDefinition.find().findProperty('id', 2).get('summary')).to.eql({OK: {count: 1, maintenanceCount: 0, latestText : "HTTP 200 response in 0.000 seconds"}, WARNING: {count: 5, maintenanceCount: 0, latestText : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}, CRITICAL: {count: 1, maintenanceCount: 0}, UNKNOWN: {count: 1, maintenanceCount: 0}}); + expect(App.AlertDefinition.find().findProperty('id', 2).get('summary')).to.eql({ + OK: { + count: 1, + maintenanceCount: 0, + latestText: "HTTP 200 response in 0.000 seconds" + }, + WARNING: { + count: 5, + maintenanceCount: 0, + latestText: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000" + }, + CRITICAL: {count: 1, maintenanceCount: 0}, + UNKNOWN: {count: 1, maintenanceCount: 0} + }); + }); + it('should map summary info for 3rd alert', function () { expect(App.AlertDefinition.find().findProperty('id', 3).get('lastTriggered')).to.equal(4); - expect(App.AlertDefinition.find().findProperty('id', 3).get('summary')).to.eql({OK: {count: 1, maintenanceCount: 0, latestText : "HTTP 200 response in 0.000 seconds"}, WARNING: {count: 2, maintenanceCount: 2}, CRITICAL: {count: 3, maintenanceCount: 0, latestText : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}, UNKNOWN: {count: 4, maintenanceCount: 0}}); + expect(App.AlertDefinition.find().findProperty('id', 3).get('summary')).to.eql({ + OK: { + count: 1, + maintenanceCount: 0, + latestText: "HTTP 200 response in 0.000 seconds" + }, + WARNING: {count: 2, maintenanceCount: 2}, + CRITICAL: { + count: 3, + maintenanceCount: 0, + latestText: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000" + }, + UNKNOWN: {count: 4, maintenanceCount: 0} + }); + }); + it('should map summary info for 4th alert', function () { expect(App.AlertDefinition.find().findProperty('id', 4).get('lastTriggered')).to.equal(2); - expect(App.AlertDefinition.find().findProperty('id', 4).get('summary')).to.eql({OK: {count: 4, maintenanceCount: 0, latestText : "HTTP 200 response in 0.000 seconds"}, WARNING: {count: 3, maintenanceCount: 0}, CRITICAL: {count: 2, maintenanceCount: 0}, UNKNOWN: {count: 1, maintenanceCount: 0, latestText : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}}); + expect(App.AlertDefinition.find().findProperty('id', 4).get('summary')).to.eql({ + OK: { + count: 4, + maintenanceCount: 0, + latestText: "HTTP 200 response in 0.000 seconds" + }, + WARNING: {count: 3, maintenanceCount: 0}, + CRITICAL: {count: 2, maintenanceCount: 0}, + UNKNOWN: { + count: 1, + maintenanceCount: 0, + latestText: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000" + } + }); + }); + it('should map summary info for 5th alert', function () { expect(App.AlertDefinition.find().findProperty('id', 5).get('lastTriggered')).to.equal(4); - expect(App.AlertDefinition.find().findProperty('id', 5).get('summary')).to.eql({OK: {count: 1, maintenanceCount: 0, latestText : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}, WARNING: {count: 1, maintenanceCount: 0}, CRITICAL: {count: 1, maintenanceCount: 0}, UNKNOWN: {count: 1, maintenanceCount: 0}}); - + expect(App.AlertDefinition.find().findProperty('id', 5).get('summary')).to.eql({ + OK: { + count: 1, + maintenanceCount: 0, + latestText: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000" + }, + WARNING: {count: 1, maintenanceCount: 0}, + CRITICAL: {count: 1, maintenanceCount: 0}, + UNKNOWN: {count: 1, maintenanceCount: 0} + }); }); it('should clear summary for disabled definitions', function () { - - App.alertDefinitionSummaryMapper.map(dataToMap); expect(App.AlertDefinition.find().findProperty('id', 6).get('summary')).to.eql({}); - }); }); -}); +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/f8213edb/ambari-web/test/mappers/configs/service_config_version_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/configs/service_config_version_mapper_test.js b/ambari-web/test/mappers/configs/service_config_version_mapper_test.js index c118ada..c38c5db 100644 --- a/ambari-web/test/mappers/configs/service_config_version_mapper_test.js +++ b/ambari-web/test/mappers/configs/service_config_version_mapper_test.js @@ -88,30 +88,69 @@ describe.skip('App.serviceConfigVersionsMapper', function () { expect(App.ServiceConfigVersion.find().get('length')).to.equal(0); }); - it('should load data to model', function() { - App.serviceConfigVersionsMapper.map(json); - expect(App.ServiceConfigVersion.find().get('length')).to.equal(2); - expect(App.ServiceConfigVersion.find().mapProperty('id')).to.eql(['SERVICE1_1','SERVICE2_4']); + describe('should load data to model', function() { - //SERVICE1_1 - expect(App.ServiceConfigVersion.find('SERVICE1_1').get('createTime')).to.eql(1425979244738); - expect(App.ServiceConfigVersion.find('SERVICE1_1').get('groupId')).to.eql(-1); - expect(App.ServiceConfigVersion.find('SERVICE1_1').get('hosts')).to.eql(defaultAllHosts); - expect(App.ServiceConfigVersion.find('SERVICE1_1').get('isCurrent')).to.be.true; - expect(App.ServiceConfigVersion.find('SERVICE1_1').get('version')).to.eql(1); - expect(App.ServiceConfigVersion.find('SERVICE1_1').get('notes')).to.eql("Initial configurations for SERVICE1"); - expect(App.ServiceConfigVersion.find('SERVICE1_1').get('serviceName')).to.eql("SERVICE1"); - expect(App.ServiceConfigVersion.find('SERVICE1_1').get('author')).to.eql("admin"); + beforeEach(function () { + App.serviceConfigVersionsMapper.map(json); + }); - //SERVICE1_2 - expect(App.ServiceConfigVersion.find('SERVICE2_4').get('createTime')).to.eql(1426088137115); - expect(App.ServiceConfigVersion.find('SERVICE2_4').get('groupId')).to.eql(2); - expect(App.ServiceConfigVersion.find('SERVICE2_4').get('hosts')).to.eql(["host1"]); - expect(App.ServiceConfigVersion.find('SERVICE2_4').get('isCurrent')).to.be.false; - expect(App.ServiceConfigVersion.find('SERVICE2_4').get('version')).to.eql(4); - expect(App.ServiceConfigVersion.find('SERVICE2_4').get('notes')).to.eql(""); - expect(App.ServiceConfigVersion.find('SERVICE2_4').get('serviceName')).to.eql("SERVICE2"); - expect(App.ServiceConfigVersion.find('SERVICE2_4').get('author')).to.eql("admin"); + it('two versions are mapped', function () { + expect(App.ServiceConfigVersion.find().get('length')).to.equal(2); + }); + + it('services have correct ids', function () { + expect(App.ServiceConfigVersion.find().mapProperty('id')).to.eql(['SERVICE1_1','SERVICE2_4']); + }); + + it('SERVICE1_1 createTime', function () { + expect(App.ServiceConfigVersion.find('SERVICE1_1').get('createTime')).to.equal(1425979244738); + }); + it('SERVICE1_1 groupId', function () { + expect(App.ServiceConfigVersion.find('SERVICE1_1').get('groupId')).to.equal(-1); + }); + it('SERVICE1_1 hosts', function () { + expect(App.ServiceConfigVersion.find('SERVICE1_1').get('hosts')).to.eql(defaultAllHosts); + }); + it('SERVICE1_1 isCurrent', function () { + expect(App.ServiceConfigVersion.find('SERVICE1_1').get('isCurrent')).to.be.true; + }); + it('SERVICE1_1 version', function () { + expect(App.ServiceConfigVersion.find('SERVICE1_1').get('version')).to.equal(1); + }); + it('SERVICE1_1 notes', function () { + expect(App.ServiceConfigVersion.find('SERVICE1_1').get('notes')).to.equal("Initial configurations for SERVICE1"); + }); + it('SERVICE1_1 serviceName', function () { + expect(App.ServiceConfigVersion.find('SERVICE1_1').get('serviceName')).to.equal("SERVICE1"); + }); + it('SERVICE1_1 author', function () { + expect(App.ServiceConfigVersion.find('SERVICE1_1').get('author')).to.equal("admin"); + }); + + it('SERVICE2_4 createTime', function () { + expect(App.ServiceConfigVersion.find('SERVICE2_4').get('createTime')).to.equal(1426088137115); + }); + it('SERVICE2_4 groupId', function () { + expect(App.ServiceConfigVersion.find('SERVICE2_4').get('groupId')).to.equal(2); + }); + it('SERVICE2_4 hosts', function () { + expect(App.ServiceConfigVersion.find('SERVICE2_4').get('hosts')).to.eql(["host1"]); + }); + it('SERVICE2_4 isCurrent', function () { + expect(App.ServiceConfigVersion.find('SERVICE2_4').get('isCurrent')).to.be.false; + }); + it('SERVICE2_4 version', function () { + expect(App.ServiceConfigVersion.find('SERVICE2_4').get('version')).to.equal(4); + }); + it('SERVICE2_4 notes', function () { + expect(App.ServiceConfigVersion.find('SERVICE2_4').get('notes')).to.equal(""); + }); + it('SERVICE2_4 serviceName', function () { + expect(App.ServiceConfigVersion.find('SERVICE2_4').get('serviceName')).to.equal("SERVICE2"); + }); + it('SERVICE2_4 author', function () { + expect(App.ServiceConfigVersion.find('SERVICE2_4').get('author')).to.equal("admin"); + }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/f8213edb/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js b/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js index 3c06724..81341bd 100644 --- a/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js +++ b/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js @@ -21,196 +21,250 @@ require('mappers/configs/stack_config_properties_mapper'); describe.skip('App.stackConfigPropertiesMapper', function () { - describe("#map", function() { - - var json = { items: [ - { - "StackServices" : { - "service_name" : "HBASE", - "stack_name" : "HDP", - "stack_version" : "2.2", - "config_types" : { - "site1" : { - "supports" : { - "adding_forbidden" : "false", - "do_not_extend" : "false", - "final" : "true" + describe("#map", function () { + + var json = { + items: [ + { + "StackServices": { + "service_name": "HBASE", + "stack_name": "HDP", + "stack_version": "2.2", + "config_types": { + "site1": { + "supports": { + "adding_forbidden": "false", + "do_not_extend": "false", + "final": "true" + } } } - } - }, - "configurations" : [ - { - "StackConfigurations" : { - "final" : "false", - "property_description" : "desc1", - "property_name" : "p1", - "property_display_name" : "P1", - "property_type" : [ ], - "property_value" : "v1", - "service_name" : "s1", - "stack_name" : "HDP", - "stack_version" : "2.2", - "type" : "site1.xml", - "property_depends_on": [ + }, + "configurations": [ + { + "StackConfigurations": { + "final": "false", + "property_description": "desc1", + "property_name": "p1", + "property_display_name": "P1", + "property_type": [], + "property_value": "v1", + "service_name": "s1", + "stack_name": "HDP", + "stack_version": "2.2", + "type": "site1.xml", + "property_depends_on": [ + { + "name": "p5", + "type": "site5" + } + ], + "property_value_attributes": { + "type": "int", + "minimum": "512", + "maximum": "10240", + "unit": "MB" + } + }, + "dependencies": [ { - "name": "p5", - "type": "site5" + "StackConfigurationDependency": { + "dependency_name": "p4", + "dependency_type": "site4" + } + } + ] + } + ] + }, + { + "StackServices": { + "service_name": "HDFS", + "stack_name": "HDP", + "stack_version": "2.2", + "config_types": { + "site2": { + "supports": { + "adding_forbidden": "false", + "do_not_extend": "false", + "final": "true" + } + }, + "site3": { + "supports": { + "adding_forbidden": "false", + "do_not_extend": "false", + "final": "true" } - ], - "property_value_attributes": { - "type": "int", - "minimum": "512", - "maximum": "10240", - "unit": "MB" + } + } + }, + "configurations": [ + { + "StackConfigurations": { + "final": "false", + "property_description": "desc3", + "property_name": "p2", + "property_display_name": "P2", + "property_type": [], + "property_value": "v2", + "service_name": "s2", + "stack_name": "HDP", + "stack_version": "2.2", + "type": "site2.xml" } }, - "dependencies": [ - { - "StackConfigurationDependency" : { - "dependency_name" : "p4", - "dependency_type" : "site4" - } + { + "StackConfigurations": { + "final": "false", + "property_description": "desc3", + "property_name": "p3", + "property_display_name": "P3", + "property_type": [], + "property_value": "v3", + "service_name": "s2", + "stack_name": "HDP", + "stack_version": "2.2", + "type": "site3.xml" } - ] - } - ] - }, - { - "StackServices" : { - "service_name" : "HDFS", - "stack_name" : "HDP", - "stack_version" : "2.2", - "config_types" : { - "site2" : { - "supports" : { - "adding_forbidden" : "false", - "do_not_extend" : "false", - "final" : "true" + }, + { + "StackConfigurations": { + "final": "false", + "property_description": "desc4", + "property_name": "p4", + "property_display_name": "P4", + "property_type": ["PASSWORD"], + "property_value": "v4", + "service_name": "s2", + "stack_name": "HDP", + "stack_version": "2.2", + "type": "site3.xml" } }, - "site3" : { - "supports" : { - "adding_forbidden" : "false", - "do_not_extend" : "false", - "final" : "true" + { + "StackConfigurations": { + "final": "false", + "property_description": "desc5", + "property_name": "p5", + "property_display_name": "P5", + "property_type": ["USER"], + "property_value": "v4", + "service_name": "s2", + "stack_name": "HDP", + "stack_version": "2.2", + "type": "site3.xml" } } - } - }, - "configurations" : [ - { - "StackConfigurations" : { - "final" : "false", - "property_description" : "desc3", - "property_name" : "p2", - "property_display_name" : "P2", - "property_type" : [ ], - "property_value" : "v2", - "service_name" : "s2", - "stack_name" : "HDP", - "stack_version" : "2.2", - "type" : "site2.xml" - } - }, - { - "StackConfigurations" : { - "final" : "false", - "property_description" : "desc3", - "property_name" : "p3", - "property_display_name" : "P3", - "property_type" : [ ], - "property_value" : "v3", - "service_name" : "s2", - "stack_name" : "HDP", - "stack_version" : "2.2", - "type" : "site3.xml" - } - }, - { - "StackConfigurations" : { - "final" : "false", - "property_description" : "desc4", - "property_name" : "p4", - "property_display_name" : "P4", - "property_type" : [ "PASSWORD" ], - "property_value" : "v4", - "service_name" : "s2", - "stack_name" : "HDP", - "stack_version" : "2.2", - "type" : "site3.xml" - } - }, - { - "StackConfigurations" : { - "final" : "false", - "property_description" : "desc5", - "property_name" : "p5", - "property_display_name" : "P5", - "property_type" : [ "USER" ], - "property_value" : "v4", - "service_name" : "s2", - "stack_name" : "HDP", - "stack_version" : "2.2", - "type" : "site3.xml" - } - } - ] - } - ]}; + ] + } + ] + }; beforeEach(function () { App.resetDsStoreTypeMap(App.StackConfigProperty); sinon.stub(App.store, 'commit', Em.K); - sinon.stub(App.StackService, 'find', function() { return Em.A()}); + sinon.stub(App.StackService, 'find', function () { + return Em.A() + }); }); - afterEach(function(){ + afterEach(function () { App.store.commit.restore(); App.StackService.find.restore(); }); - it('should not do anything as there is no json', function() { + it('should not do anything as there is no json', function () { App.stackConfigPropertiesMapper.map(null); expect(App.StackConfigProperty.find().get('length')).to.equal(0); }); - it('should load data to model', function() { - App.stackConfigPropertiesMapper.map(json); - expect(App.StackConfigProperty.find().get('length')).to.equal(5); - expect(App.StackConfigProperty.find().mapProperty('id')).to.eql(['p1__site1','p2__site2','p3__site3', 'p4__site3', 'p5__site3']); - - expect(App.StackConfigProperty.find('p1__site1').get('name')).to.eql('p1'); - expect(App.StackConfigProperty.find('p1__site1').get('displayName')).to.eql('P1'); - expect(App.StackConfigProperty.find('p1__site1').get('description')).to.eql('desc1'); - expect(App.StackConfigProperty.find('p1__site1').get('recommendedValue')).to.eql('v1'); - expect(App.StackConfigProperty.find('p1__site1').get('recommendedIsFinal')).to.be.false; - expect(App.StackConfigProperty.find('p1__site1').get('serviceName')).to.eql('s1'); - expect(App.StackConfigProperty.find('p1__site1').get('stackName')).to.eql('HDP'); - expect(App.StackConfigProperty.find('p1__site1').get('stackVersion')).to.eql('2.2'); - expect(App.StackConfigProperty.find('p1__site1').get('type').toArray()).to.eql([]); - expect(App.StackConfigProperty.find('p1__site1').get('fileName')).to.eql('site1.xml'); - expect(App.StackConfigProperty.find('p1__site1').get('propertyDependedBy')).to.eql([ - { - "type": "site4", - "name": "p4" - } - ]); - expect(App.StackConfigProperty.find('p1__site1').get('propertyDependsOn')).to.eql([ - { - "type": "site5", - "name": "p5" - } - ]); - expect(App.StackConfigProperty.find('p1__site1').get('valueAttributes')).to.eql({ - "type": "int", - "minimum": "512", - "maximum": "10240", - "unit": "MB" - }); - expect(App.StackConfigProperty.find('p1__site1').get('supportsFinal')).to.be.true; + describe('should load data to model', function () { + + beforeEach(function () { + App.stackConfigPropertiesMapper.map(json); + }); + + it('5 properties are mapped', function () { + expect(App.StackConfigProperty.find().get('length')).to.equal(5); + }); + + it('ids are valid', function () { + expect(App.StackConfigProperty.find().mapProperty('id')).to.eql(['p1__site1', 'p2__site2', 'p3__site3', 'p4__site3', 'p5__site3']); + }); + + it('name is valid', function () { + expect(App.StackConfigProperty.find('p1__site1').get('name')).to.eql('p1'); + }); + + it('displayName is valid', function () { + expect(App.StackConfigProperty.find('p1__site1').get('displayName')).to.eql('P1'); + }); + + it('description is valid', function () { + expect(App.StackConfigProperty.find('p1__site1').get('description')).to.eql('desc1'); + }); + + it('recommendedValue is valid', function () { + expect(App.StackConfigProperty.find('p1__site1').get('recommendedValue')).to.eql('v1'); + }); + + it('recommendedIsFinal is valid', function () { + expect(App.StackConfigProperty.find('p1__site1').get('recommendedIsFinal')).to.be.false; + }); + + it('serviceName is valid', function () { + expect(App.StackConfigProperty.find('p1__site1').get('serviceName')).to.eql('s1'); + }); + + it('stackName is valid', function () { + expect(App.StackConfigProperty.find('p1__site1').get('stackName')).to.eql('HDP'); + }); + + it('stackVersion is valid', function () { + expect(App.StackConfigProperty.find('p1__site1').get('stackVersion')).to.eql('2.2'); + }); + + it('type is valid', function () { + expect(App.StackConfigProperty.find('p1__site1').get('type').toArray()).to.eql([]); + }); + + it('fileName is valid', function () { + expect(App.StackConfigProperty.find('p1__site1').get('fileName')).to.eql('site1.xml'); + }); + + it('propertyDependedBy is valid', function () { + expect(App.StackConfigProperty.find('p1__site1').get('propertyDependedBy')).to.eql([ + { + "type": "site4", + "name": "p4" + } + ]); + }); + + it('propertyDependsOn is valid', function () { + expect(App.StackConfigProperty.find('p1__site1').get('propertyDependsOn')).to.eql([ + { + "type": "site5", + "name": "p5" + } + ]); + }); + + it('valueAttributes is valid', function () { + expect(App.StackConfigProperty.find('p1__site1').get('valueAttributes')).to.eql({ + "type": "int", + "minimum": "512", + "maximum": "10240", + "unit": "MB" + }); + }); + + it('supportsFinal is valid', function () { + expect(App.StackConfigProperty.find('p1__site1').get('supportsFinal')).to.be.true; + }); }); - it('should set "displayType" by "property_type" attribute', function() { + it('should set "displayType" by "property_type" attribute', function () { App.stackConfigPropertiesMapper.map(json); var prop = App.StackConfigProperty.find().findProperty('name', 'p4'); var prop2 = App.StackConfigProperty.find().findProperty('name', 'p5');