This is an automated email from the ASF dual-hosted git repository.
atkach pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new 8c870c3 AMBARI-22808 Ambari-Web: Fix randomly failing unit tests
8c870c3 is described below
commit 8c870c39f7dd175989b24a01abb28fb8ab37e2a4
Author: Andrii Tkach <[email protected]>
AuthorDate: Thu Jan 18 14:21:19 2018 +0200
AMBARI-22808 Ambari-Web: Fix randomly failing unit tests
---
.../nameNode/step3_controller_test.js | 23 +++---
.../test/views/common/chart/linear_time_test.js | 10 +--
ambari-web/test/views/common/controls_view_test.js | 18 ++---
.../common/host_progress_popup_body_view_test.js | 90 +++++++++++-----------
4 files changed, 69 insertions(+), 72 deletions(-)
diff --git
a/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js
b/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js
index 6bc8821..527b74d 100644
---
a/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js
+++
b/ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js
@@ -539,10 +539,12 @@ describe('App.HighAvailabilityWizardStep3Controller',
function() {
displayName: 's1',
configCategories: [
{
- name: 'C1'
+ name: 'C1',
+ errorCount: 0
},
{
- name: 'C2'
+ name: 'C2',
+ errorCount: 0
}
]
};
@@ -562,15 +564,14 @@ describe('App.HighAvailabilityWizardStep3Controller',
function() {
});
it('selectedService should be set', function() {
-
expect(JSON.stringify(controller.get('selectedService'))).to.be.equal(JSON.stringify(App.ServiceConfig.create({
- serviceName: 'S1',
- displayName: 's1',
- configCategories: [{
- name: 'C1'
- }],
- showConfig: true,
- configs: []
- })));
+
expect(JSON.stringify(controller.get('selectedService.configCategories'))).to.be.equal(JSON.stringify([{
+ name: 'C1',
+ errorCount: 0
+ }]));
+ expect(controller.get('selectedService.serviceName')).to.be.equal('S1');
+ expect(controller.get('selectedService.displayName')).to.be.equal('s1');
+ expect(controller.get('selectedService.showConfig')).to.be.true;
+ expect(controller.get('selectedService.configs')).to.be.empty;
});
it('once should be true', function() {
diff --git a/ambari-web/test/views/common/chart/linear_time_test.js
b/ambari-web/test/views/common/chart/linear_time_test.js
index 3aa425c..7173a2a 100644
--- a/ambari-web/test/views/common/chart/linear_time_test.js
+++ b/ambari-web/test/views/common/chart/linear_time_test.js
@@ -25,6 +25,11 @@ describe('App.ChartLinearTimeView', function () {
beforeEach(function() {
chartLinearTimeView = App.ChartLinearTimeView.create();
+ sinon.stub(App.ajax, 'abortRequests', Em.K);
+ });
+
+ afterEach(function () {
+ App.ajax.abortRequests.restore();
});
describe("#isRequestRunning", function () {
@@ -397,16 +402,11 @@ describe('App.ChartLinearTimeView', function () {
describe(item.title, function () {
beforeEach(function () {
- sinon.stub(App.ajax, 'abortRequests', Em.K);
view.set('inWidget', item.inWidget);
view.set('parentView.isClusterMetricsWidget',
item.isClusterMetricsWidget);
view.propertyDidChange('parentView.currentTimeRangeIndex');
});
- afterEach(function () {
- App.ajax.abortRequests.restore();
- });
-
it('parentView.isLoaded', function () {
expect(view.get('parentView.isLoaded')).to.eql(item.parentViewIsLoaded);
});
diff --git a/ambari-web/test/views/common/controls_view_test.js
b/ambari-web/test/views/common/controls_view_test.js
index b6f19ef..2e7f83f 100644
--- a/ambari-web/test/views/common/controls_view_test.js
+++ b/ambari-web/test/views/common/controls_view_test.js
@@ -198,14 +198,15 @@ describe('App.ServiceConfigRadioButtons', function () {
];
var rangerVersion = '';
- before(function () {
- sinon.stub(Em.run, 'next', function (arg) {
- arg();
- });
- });
-
beforeEach(function () {
sinon.stub(view, 'sendRequestRorDependentConfigs', Em.K);
+ sinon.stub(Em.run, 'next', function (arg1, arg2) {
+ if (typeof arg1 === 'function') {
+ arg1();
+ } else if (typeof arg1 === 'object' && typeof arg2 === 'function') {
+ arg2();
+ }
+ });
this.stub = sinon.stub(App, 'get');
this.stub.withArgs('currentStackName').returns('HDP');
sinon.stub(App.StackService, 'find', function() {
@@ -217,15 +218,12 @@ describe('App.ServiceConfigRadioButtons', function () {
});
afterEach(function () {
+ Em.run.next.restore();
App.get.restore();
App.StackService.find.restore();
view.sendRequestRorDependentConfigs.restore();
});
- after(function () {
- Em.run.next.restore();
- });
-
cases.forEach(function (item) {
describe(item.title, function () {
diff --git a/ambari-web/test/views/common/host_progress_popup_body_view_test.js
b/ambari-web/test/views/common/host_progress_popup_body_view_test.js
index 93e8efb..19af580 100644
--- a/ambari-web/test/views/common/host_progress_popup_body_view_test.js
+++ b/ambari-web/test/views/common/host_progress_popup_body_view_test.js
@@ -19,34 +19,34 @@
var App = require('app');
require("utils/host_progress_popup");
-require("views/common/modal_popup")
+require("views/common/modal_popup");
describe('App.HostProgressPopupBodyView', function () {
- var controller;
+ var view;
beforeEach(function () {
- controller = Em.Object.create({
- setSelectCount: Em.K,
- dataSourceController: Em.Object.create({
- levelInfo: {},
- requestMostRecent: Em.K
+ view = App.HostProgressPopupBodyView.create({
+ updateSelectView: sinon.spy(),
+ controller: Em.Object.create({
+ setSelectCount: Em.K,
+ dataSourceController: Em.Object.create({
+ levelInfo: {},
+ requestMostRecent: Em.K
+ }),
+ refreshRequestScheduleInfo: Em.K,
+ setBackgroundOperationHeader: Em.K,
+ onHostUpdate: Em.K,
+ hosts: [],
+ breadcrumbs: null,
+ rootBreadcrumb: { label: "rootBreadcrumb" },
+ serviceName: "serviceName",
+ currentHostName: "currentHostName"
}),
- refreshRequestScheduleInfo: Em.K,
- setBackgroundOperationHeader: Em.K,
- onHostUpdate: Em.K,
- hosts: []
+ parentView: App.HostPopup.initPopup("serviceName", controller, false, 1)
});
});
describe('when not isBackgroundOperations', function() {
- var view;
-
- beforeEach(function () {
- view = App.HostProgressPopupBodyView.create({
- controller: controller,
- parentView: App.HostPopup.initPopup("serviceName", controller, false,
1)
- });
- });
describe('#switchLevel when isBackgroundOperations is false', function () {
var map =
App.HostProgressPopupBodyView.create().get('customControllersSwitchLevelMap');
@@ -274,22 +274,41 @@ describe('App.HostProgressPopupBodyView', function () {
sinon.stub(view.get('controller'), 'setBackgroundOperationHeader');
sinon.stub(view, 'setOnStart');
sinon.stub(view, 'rerender');
- sinon.stub(view, 'updateSelectView');
});
afterEach(function() {
view.get('controller').setBackgroundOperationHeader.restore();
view.setOnStart.restore();
view.rerender.restore();
- view.updateSelectView.restore();
});
- it("should set properties of parentView", function() {
+ it("parentView.isOpen should be true", function() {
view.set('parentView.isOpen', true);
+ view.resetState();
expect(view.get('parentView.isOpen')).to.be.true;
+ });
+
+ it("parentView.isLogWrapHidden should be true", function() {
+ view.set('parentView.isOpen', true);
+ view.resetState();
expect(view.get('parentView.isLogWrapHidden')).to.be.true;
+ });
+
+ it("parentView.isTaskListHidden should be true", function() {
+ view.set('parentView.isOpen', true);
+ view.resetState();
expect(view.get('parentView.isTaskListHidden')).to.be.true;
+ });
+
+ it("parentView.isHostListHidden should be true", function() {
+ view.set('parentView.isOpen', true);
+ view.resetState();
expect(view.get('parentView.isHostListHidden')).to.be.true;
+ });
+
+ it("parentView.isServiceListHidden should be false", function() {
+ view.set('parentView.isOpen', true);
+ view.resetState();
expect(view.get('parentView.isServiceListHidden')).to.be.false;
});
@@ -353,11 +372,9 @@ describe('App.HostProgressPopupBodyView', function () {
});
describe('when isBackgroundOperations', function() {
- var view;
beforeEach(function () {
- view = App.HostProgressPopupBodyView.create({
- controller: controller,
+ view.reopen({
parentView: App.HostPopup.initPopup("", controller, true)
});
@@ -412,29 +429,10 @@ describe('App.HostProgressPopupBodyView', function () {
});
describe("#changeLevel", function() {
- var view;
- var controller;
beforeEach(function () {
- controller = Em.Object.create({
- setSelectCount: Em.K,
- dataSourceController: Em.Object.create({
- levelInfo: {},
- requestMostRecent: Em.K
- }),
- refreshRequestScheduleInfo: Em.K,
- setBackgroundOperationHeader: Em.K,
- onHostUpdate: Em.K,
- hosts: [],
- breadcrumbs: null,
- rootBreadcrumb: { label: "rootBreadcrumb" },
- serviceName: "serviceName",
- currentHostName: "currentHostName"
- });
-
- view = App.HostProgressPopupBodyView.create({
- controller: controller,
- parentView: Em.Object.create({ isOpen: true })
+ view.reopen({
+ parentView: Em.Object.create({isOpen: true})
});
});
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].