|
@@ -23,6 +23,7 @@ require('models/service');
|
|
|
require('models/host_component');
|
|
|
require('models/host_stack_version');
|
|
|
var batchUtils = require('utils/batch_scheduled_requests');
|
|
|
+var componentsUtils = require('utils/components');
|
|
|
var hostsManagement = require('utils/hosts');
|
|
|
var controller;
|
|
|
|
|
@@ -34,7 +35,7 @@ describe('App.MainHostDetailsController', function () {
|
|
|
then: Em.K,
|
|
|
complete: Em.K
|
|
|
});
|
|
|
- controller = App.MainHostDetailsController.create(App.InstallComponent, {
|
|
|
+ controller = App.MainHostDetailsController.create({
|
|
|
content: Em.Object.create({
|
|
|
hostComponents: []
|
|
|
})
|
|
@@ -225,11 +226,11 @@ describe('App.MainHostDetailsController', function () {
|
|
|
});
|
|
|
|
|
|
describe('#ajaxErrorCallback()', function () {
|
|
|
- it('call mainServiceItemController.ajaxErrorCallback', function () {
|
|
|
- sinon.stub(controller, 'ajaxErrorCallback', Em.K);
|
|
|
+ it('call componentsUtils.ajaxErrorCallback', function () {
|
|
|
+ sinon.stub(componentsUtils, 'ajaxErrorCallback', Em.K);
|
|
|
controller.ajaxErrorCallback('request', 'ajaxOptions', 'error', 'opt', 'params');
|
|
|
- expect(controller.ajaxErrorCallback.calledWith('request', 'ajaxOptions', 'error', 'opt', 'params')).to.be.true;
|
|
|
- controller.ajaxErrorCallback.restore();
|
|
|
+ expect(componentsUtils.ajaxErrorCallback.calledWith('request', 'ajaxOptions', 'error', 'opt', 'params')).to.be.true;
|
|
|
+ componentsUtils.ajaxErrorCallback.restore();
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -477,23 +478,18 @@ describe('App.MainHostDetailsController', function () {
|
|
|
beforeEach(function () {
|
|
|
sinon.spy(App, "showConfirmationPopup");
|
|
|
sinon.stub(controller, "addClientComponent", Em.K);
|
|
|
- sinon.stub(controller, "installHostComponentCall", Em.K);
|
|
|
- sinon.stub(controller, "checkComponentDependencies", Em.K);
|
|
|
- controller.set('content', {
|
|
|
- hostComponents: [Em.Object.create({
|
|
|
- componentName: "HDFS_CLIENT"
|
|
|
- })]
|
|
|
- });
|
|
|
- controller.reopen({
|
|
|
- securityEnabled: false
|
|
|
- });
|
|
|
+ sinon.stub(controller, "primary", Em.K);
|
|
|
+ controller.set('content', {hostComponents: [Em.Object.create({
|
|
|
+ componentName: "HDFS_CLIENT"
|
|
|
+ })]});
|
|
|
+ sinon.stub(componentsUtils, 'checkComponentDependencies', Em.K);
|
|
|
});
|
|
|
|
|
|
afterEach(function () {
|
|
|
App.showConfirmationPopup.restore();
|
|
|
controller.addClientComponent.restore();
|
|
|
- controller.installHostComponentCall.restore();
|
|
|
- controller.checkComponentDependencies.restore();
|
|
|
+ controller.primary.restore();
|
|
|
+ componentsUtils.checkComponentDependencies.restore();
|
|
|
});
|
|
|
|
|
|
it('add ZOOKEEPER_SERVER', function () {
|
|
@@ -502,8 +498,12 @@ describe('App.MainHostDetailsController', function () {
|
|
|
componentName: 'ZOOKEEPER_SERVER'
|
|
|
})
|
|
|
};
|
|
|
- controller.addComponent(event);
|
|
|
+ var popup = controller.addComponent(event);
|
|
|
expect(App.showConfirmationPopup.calledOnce).to.be.true;
|
|
|
+ popup.onPrimary();
|
|
|
+ expect(controller.primary.calledWith(Em.Object.create({
|
|
|
+ componentName: 'ZOOKEEPER_SERVER'
|
|
|
+ }))).to.be.true;
|
|
|
});
|
|
|
it('add slave component', function () {
|
|
|
var event = {
|
|
@@ -591,16 +591,60 @@ describe('App.MainHostDetailsController', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
sinon.spy(App.ModalPopup, 'show');
|
|
|
+ sinon.stub(controller, 'primary', Em.K);
|
|
|
});
|
|
|
|
|
|
afterEach(function () {
|
|
|
App.ModalPopup.show.restore();
|
|
|
+ controller.primary.restore();
|
|
|
});
|
|
|
|
|
|
it('should display add component confirmation', function () {
|
|
|
- var popup = controller.showAddComponentPopup(message, false, Em.K);
|
|
|
+ var popup = controller.showAddComponentPopup(message, false, function () {
|
|
|
+ controller.primary(component);
|
|
|
+ });
|
|
|
expect(App.ModalPopup.show.calledOnce).to.be.true;
|
|
|
expect(popup.get('addComponentMsg')).to.eql(Em.I18n.t('hosts.host.addComponent.msg').format(message));
|
|
|
+ popup.onPrimary();
|
|
|
+ expect(controller.primary.calledWith(component)).to.be.true;
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('#primary()', function () {
|
|
|
+ beforeEach(function () {
|
|
|
+ sinon.stub(App.StackServiceComponent, 'find', function () {
|
|
|
+ return [
|
|
|
+ Em.Object.create({
|
|
|
+ componentName: 'COMP1',
|
|
|
+ serviceName: 's1'
|
|
|
+ })
|
|
|
+ ]
|
|
|
+ });
|
|
|
+
|
|
|
+ sinon.stub(App.router, 'get', function () {
|
|
|
+ return Em.Object.create({
|
|
|
+ updateComponentsState: function (callback) {
|
|
|
+ return callback();
|
|
|
+ },
|
|
|
+ updateServiceMetric: function (callback) {
|
|
|
+ return callback();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
+ });
|
|
|
+ afterEach(function () {
|
|
|
+ App.router.get.restore();
|
|
|
+ App.StackServiceComponent.find.restore();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('Query should be sent', function () {
|
|
|
+ var component = Em.Object.create({
|
|
|
+ componentName: 'COMP1',
|
|
|
+ displayName: 'comp1'
|
|
|
+ });
|
|
|
+ App.serviceComponents = ['COMP1'];
|
|
|
+ controller.primary(component);
|
|
|
+ expect(App.ajax.send.calledOnce).to.be.true;
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -2049,16 +2093,16 @@ describe('App.MainHostDetailsController', function () {
|
|
|
}))).to.equal(0);
|
|
|
});
|
|
|
});
|
|
|
- describe('#downloadClientConfigsCall', function () {
|
|
|
+ describe('#downloadClientConfigs()', function () {
|
|
|
|
|
|
beforeEach(function () {
|
|
|
- sinon.stub(controller, 'downloadClientConfigsCall', Em.K);
|
|
|
+ sinon.stub(componentsUtils, 'downloadClientConfigs', Em.K);
|
|
|
});
|
|
|
afterEach(function () {
|
|
|
- controller.downloadClientConfigsCall.restore();
|
|
|
+ componentsUtils.downloadClientConfigs.restore();
|
|
|
});
|
|
|
|
|
|
- it('should launch controller.downloadClientConfigsCall method', function () {
|
|
|
+ it('should launch componentsUtils.downloadClientConfigs method', function () {
|
|
|
controller.downloadClientConfigs({
|
|
|
context: Em.Object.create({
|
|
|
componentName: 'name',
|
|
@@ -2066,7 +2110,7 @@ describe('App.MainHostDetailsController', function () {
|
|
|
displayName: 'dName'
|
|
|
})
|
|
|
});
|
|
|
- expect(controller.downloadClientConfigsCall.calledWith({
|
|
|
+ expect(componentsUtils.downloadClientConfigs.calledWith({
|
|
|
componentName: 'name',
|
|
|
hostName: 'host1',
|
|
|
displayName: 'dName'
|
|
@@ -2434,7 +2478,8 @@ describe('App.MainHostDetailsController', function () {
|
|
|
showAlertPopupCalled: false,
|
|
|
title: 'Clients to add have mutual dependencies'
|
|
|
}
|
|
|
- ];
|
|
|
+ ],
|
|
|
+ componentsUtils = require('utils/components');
|
|
|
|
|
|
beforeEach(function () {
|
|
|
sinon.stub(controller, 'sendComponentCommand', Em.K);
|
|
@@ -2460,12 +2505,12 @@ describe('App.MainHostDetailsController', function () {
|
|
|
App.get('router.mainAdminKerberosController').getSecurityType.restore();
|
|
|
App.showAlertPopup.restore();
|
|
|
App.StackServiceComponent.find.restore();
|
|
|
- controller.checkComponentDependencies.restore();
|
|
|
+ componentsUtils.checkComponentDependencies.restore();
|
|
|
});
|
|
|
|
|
|
cases.forEach(function (item) {
|
|
|
it(item.title, function () {
|
|
|
- sinon.stub(controller, 'checkComponentDependencies', function (componentName, params) {
|
|
|
+ sinon.stub(componentsUtils, 'checkComponentDependencies', function (componentName, params) {
|
|
|
return item.dependencies[componentName];
|
|
|
});
|
|
|
controller.installClients({
|