This is an automated email from the ASF dual-hosted git repository.
jonathanhurley pushed a commit to branch branch-feature-AMBARI-14714
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/branch-feature-AMBARI-14714 by
this push:
new 43426ab [AMBARI-23435] Update API calls in the install wizard to use
service groups (#939)
43426ab is described below
commit 43426ab2ac2edf72d7aed912554bbba4edd0f13c
Author: Jason Golieb <[email protected]>
AuthorDate: Wed Apr 11 10:04:02 2018 -0400
[AMBARI-23435] Update API calls in the install wizard to use service groups
(#939)
* Load stack mapper data from mpacks API after registering mpacks.
* First part.
* Second part, including unit test fixes.
---
ambari-web/app/controllers/installer.js | 3 ++
ambari-web/app/controllers/wizard.js | 27 +++++++---
.../app/controllers/wizard/step8_controller.js | 61 +++++++---------------
.../app/controllers/wizard/step9_controller.js | 55 ++++++++++++++-----
ambari-web/app/routes/installer.js | 1 +
ambari-web/app/utils/ajax/ajax.js | 6 +--
ambari-web/test/controllers/installer_test.js | 17 +++++-
ambari-web/test/controllers/wizard/step8_test.js | 16 +-----
ambari-web/test/controllers/wizard/step9_test.js | 11 +++-
ambari-web/test/controllers/wizard_test.js | 12 ++++-
10 files changed, 127 insertions(+), 82 deletions(-)
diff --git a/ambari-web/app/controllers/installer.js
b/ambari-web/app/controllers/installer.js
index c809733..290b75f 100644
--- a/ambari-web/app/controllers/installer.js
+++ b/ambari-web/app/controllers/installer.js
@@ -114,6 +114,7 @@ App.InstallerController =
App.WizardController.extend(App.Persist, {
mpackVersions: [],
mpackServiceVersions: [],
mpackServices: [],
+ serviceGroups: [],
// Tracks which steps have been saved before.
// If you revisit a step, we will know if the step has been saved
previously and we can warn about making changes.
// If a previously saved step is changed, setStepSaved() will "unsave" all
subsequent steps so we don't warn on every screen.
@@ -847,6 +848,7 @@ App.InstallerController =
App.WizardController.extend(App.Persist, {
this.loadConfirmedHosts();
this.loadComponentsFromConfigs();
this.loadRecommendations();
+ this.loadRegisteredMpacks();
}
}
],
@@ -1222,6 +1224,7 @@ App.InstallerController =
App.WizardController.extend(App.Persist, {
this.clearStackServices(!keepStackServices).then(() => {
//get info about services from specific stack versions and save to
StackService model
+ this.set('content.selectedServiceNames',
this.getDBProperty('selectedServiceNames'));
const selectedServices = this.get('content.selectedServices');
const servicePromises = selectedServices.map(service =>
this.loadMpackServiceInfo(service.mpackName, service.mpackVersion,
service.name)
diff --git a/ambari-web/app/controllers/wizard.js
b/ambari-web/app/controllers/wizard.js
index b1ce5d0..ad60107 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -526,13 +526,21 @@ App.WizardController =
Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
};
this.saveClusterStatus(clusterStatus);
- App.ajax.send({
- name: isRetry ? 'common.host_components.update' :
'common.services.update',
- sender: this,
- data: data,
- success: 'installServicesSuccessCallback',
- error: 'installServicesErrorCallback'
- }).then(callback, callback);
+ const serviceGroups = this.get('content.serviceGroups');
+
+ const installPromises = serviceGroups.map(sg => {
+ data.serviceGroup = sg;
+
+ return App.ajax.send({
+ name: isRetry ? 'common.host_components.update' :
'common.services.update',
+ sender: this,
+ data: data,
+ success: 'installServicesSuccessCallback',
+ error: 'installServicesErrorCallback'
+ })
+ })
+
+ $.when(...installPromises).then(callback, callback);
},
installServicesSuccessCallback: function (jsonData) {
@@ -1414,6 +1422,11 @@ App.WizardController =
Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
loadRegisteredMpacks: function () {
this.set('content.registeredMpacks',
this.getDBProperty('registeredMpacks') || []);
const registeredMpacks = this.get('content.registeredMpacks');
+
+ //TODO: mpacks - currently we create a service group for each mpack; this
will be changed in the future
+ const serviceGroups = registeredMpacks.map(rmp =>
rmp.MpackInfo.mpack_name);
+ this.set('content.serviceGroups', serviceGroups);
+
registeredMpacks.forEach(rmp => {
App.stackMapper.map(rmp);
});
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js
b/ambari-web/app/controllers/wizard/step8_controller.js
index 86b0c3f..91a01d1 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -1031,12 +1031,14 @@ App.WizardStep8Controller =
App.WizardStepController.extend(App.AddSecurityConfi
*/
createSelectedServices: function () {
var data = this.createSelectedServicesData();
- if (!data.length) return;
- this.addRequestToAjaxQueue({
- name: 'wizard.step8.create_selected_services',
- data: {
- data: JSON.stringify(data)
- }
+ data.forEach(service => {
+ this.addRequestToAjaxQueue({
+ name: 'wizard.step8.create_selected_services',
+ data: {
+ serviceGroup: service.ServiceInfo.service_group_name,
+ data: JSON.stringify(service)
+ }
+ });
});
},
@@ -1069,13 +1071,15 @@ App.WizardStep8Controller =
App.WizardStepController.extend(App.AddSecurityConfi
var serviceComponents = App.StackServiceComponent.find();
this.get('selectedServices').forEach(function (_service) {
var serviceName = _service.get('serviceName');
+ //TODO - mpacks: when we are supporting user defined service groups,
this must be changed
+ const serviceGroup = _service.get('stackName');
var componentsData = serviceComponents.filterProperty('serviceName',
serviceName).map(function (_component) {
return { "ServiceComponentInfo": { "component_name":
_component.get('componentName') } };
});
// Service must be specified in terms of a query for creating multiple
components at the same time.
// See AMBARI-1018.
- this.addRequestToCreateComponent(componentsData, serviceName);
+ this.addRequestToCreateComponent(componentsData, serviceName,
serviceGroup);
}, this);
if (this.get('isAddHost')) {
@@ -1088,16 +1092,18 @@ App.WizardStep8Controller =
App.WizardStepController.extend(App.AddSecurityConfi
this.get('content.slaveComponentHosts').forEach(function (component) {
if (component.componentName !== 'CLIENT' &&
!allServiceComponents.contains(component.componentName)) {
this.addRequestToCreateComponent(
- [{"ServiceComponentInfo": {"component_name":
component.componentName}}],
- App.StackServiceComponent.find().findProperty('componentName',
component.componentName).get('serviceName')
+ [{"ServiceComponentInfo": {"component_name":
component.componentName}}],
+ App.StackServiceComponent.find().findProperty('componentName',
component.componentName).get('serviceName'),
+ App.StackServiceComponent.find().findProperty('componentName',
component.componentName).get('stackName') //TODO - mpacks: when we are
supporting user defined service groups, this must be changed
);
}
}, this);
this.get('content.clients').forEach(function (component) {
if (!allServiceComponents.contains(component.component_name)) {
this.addRequestToCreateComponent(
- [{"ServiceComponentInfo": {"component_name":
component.component_name}}],
- App.StackServiceComponent.find().findProperty('componentName',
component.component_name).get('serviceName')
+ [{"ServiceComponentInfo": {"component_name":
component.component_name}}],
+ App.StackServiceComponent.find().findProperty('componentName',
component.component_name).get('serviceName'),
+ App.StackServiceComponent.find().findProperty('componentName',
component.componentName).get('stackName') //TODO - mpacks: when we are
supporting user defined service groups, this must be changed
);
}
}, this);
@@ -1109,40 +1115,13 @@ App.WizardStep8Controller =
App.WizardStepController.extend(App.AddSecurityConfi
* @param componentsData
* @param serviceName
*/
- addRequestToCreateComponent: function (componentsData, serviceName) {
+ addRequestToCreateComponent: function (componentsData, serviceName,
serviceGroup) {
this.addRequestToAjaxQueue({
name: 'wizard.step8.create_components',
data: {
data: JSON.stringify(componentsData),
- serviceName: serviceName
- }
- });
- },
-
- /**
- * Error callback for new service component request
- * So, if component doesn't exist we should create it
- * @param {object} request
- * @param {object} ajaxOptions
- * @param {string} error
- * @param {object} opt
- * @param {object} params
- * @method newServiceComponentErrorCallback
- */
- newServiceComponentErrorCallback: function (request, ajaxOptions, error,
opt, params) {
- this.addRequestToAjaxQueue({
- name: 'wizard.step8.create_components',
- data: {
- serviceName: params.serviceName,
- data: JSON.stringify({
- "components": [
- {
- "ServiceComponentInfo": {
- "component_name": params.componentName
- }
- }
- ]
- })
+ serviceName: serviceName,
+ serviceGroup: serviceGroup
}
});
},
diff --git a/ambari-web/app/controllers/wizard/step9_controller.js
b/ambari-web/app/controllers/wizard/step9_controller.js
index cd4dd30..b918a75 100644
--- a/ambari-web/app/controllers/wizard/step9_controller.js
+++ b/ambari-web/app/controllers/wizard/step9_controller.js
@@ -479,9 +479,12 @@ App.WizardStep9Controller =
App.WizardStepController.extend(App.ReloadPopupMixin
* @method launchStartServices
*/
launchStartServices: function (callback) {
- var data = {};
- var name = '';
+ let data;
+ let serviceGroups;
+ let promises;
+
callback = callback || Em.K;
+
switch(this.get('content.controllerName')) {
case 'addHostController':
name = 'common.host_components.update';
@@ -497,39 +500,67 @@ App.WizardStep9Controller =
App.WizardStepController.extend(App.ReloadPopupMixin
"query": "HostRoles/component_name.in(" +
App.get('components.slaves').join(',') +
")&HostRoles/state=INSTALLED&HostRoles/host_name.in(" + hostnames.join(',') +
")",
"HostRoles": { "state": "STARTED"}
};
+
+ return App.ajax.send({
+ name: name,
+ sender: this,
+ data: data,
+ success: 'launchStartServicesSuccessCallback',
+ error: 'launchStartServicesErrorCallback'
+ }).then(callback, callback);
break;
case 'addServiceController':
var servicesList =
this.get('content.services').filterProperty('isSelected').filterProperty('isInstalled',
false).mapProperty('serviceName');
if (servicesList.contains('OOZIE')) {
servicesList = servicesList.concat(['HDFS', 'YARN', 'MAPREDUCE2']);
}
- name = 'common.services.update';
data = {
"context": Em.I18n.t("requestInfo.startAddedServices"),
"ServiceInfo": { "state": "STARTED" },
"urlParams":
"ServiceInfo/state=INSTALLED&ServiceInfo/service_name.in(" +
servicesList.join(",") +
")¶ms/run_smoke_test=true¶ms/reconfigure_client=false"
};
+
+ serviceGroups = this.get('content.serviceGroups');
+ promises = serviceGroups.map(sg => {
+ data.serviceGroup = sg;
+
+ return App.ajax.send({
+ name: 'common.services.update',
+ sender: this,
+ data: data,
+ success: 'launchStartServicesSuccessCallback',
+ error: 'launchStartServicesErrorCallback'
+ })
+ })
+
+ return $.when(...promises).then(callback, callback);
break;
default:
- name = 'common.services.update';
data = {
"context": Em.I18n.t("requestInfo.startServices"),
"ServiceInfo": { "state": "STARTED" },
"urlParams": "ServiceInfo/state=INSTALLED¶ms/run_smoke_test=" +
!this.get('skipServiceChecks') + "¶ms/reconfigure_client=false"
};
+
+ serviceGroups = this.get('content.serviceGroups');
+ promises = serviceGroups.map(sg => {
+ data.serviceGroup = sg;
+
+ return App.ajax.send({
+ name: 'common.services.update',
+ sender: this,
+ data: data,
+ success: 'launchStartServicesSuccessCallback',
+ error: 'launchStartServicesErrorCallback'
+ })
+ })
+
+ return $.when(...promises).then(callback, callback);
}
if (App.get('testMode')) {
this.set('numPolls', 6);
}
-
- return App.ajax.send({
- name: name,
- sender: this,
- data: data,
- success: 'launchStartServicesSuccessCallback',
- error: 'launchStartServicesErrorCallback'
- }).then(callback, callback);
},
/**
diff --git a/ambari-web/app/routes/installer.js
b/ambari-web/app/routes/installer.js
index 89b136d..ac1bb6d 100644
--- a/ambari-web/app/routes/installer.js
+++ b/ambari-web/app/routes/installer.js
@@ -413,6 +413,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
App.set('router.nextBtnClickInProgress', true);
const controller = router.get('installerController');
controller.save('registeredMpacks');
+ controller.save('serviceGroups');
controller.save('selectedStack');
const downloadConfig = controller.get('content.downloadConfig');
if (downloadConfig && downloadConfig.useCustomRepo) {
diff --git a/ambari-web/app/utils/ajax/ajax.js
b/ambari-web/app/utils/ajax/ajax.js
index 3f8bd8b..6f4d8bc 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -57,7 +57,7 @@ var urls = {
},
'common.services.update' : {
- 'real':
'/clusters/{clusterName}/servicegroups/{defaultServiceGroupName}/services?{urlParams}',
+ 'real':
'/clusters/{clusterName}/servicegroups/{serviceGroupName}/services?{urlParams}',
'mock': '/data/wizard/deploy/poll_1.json',
'format': function (data) {
return {
@@ -2096,7 +2096,7 @@ var urls = {
'wizard.step8.create_selected_services': {
'type': 'POST',
- 'real':
'/clusters/{cluster}/servicegroups/{defaultServiceGroupName}/services',
+ 'real': '/clusters/{cluster}/servicegroups/{serviceGroup}/services',
'mock': '/data/stacks/HDP-2.1/recommendations.json',
'format': function (data) {
return {
@@ -2107,7 +2107,7 @@ var urls = {
},
'wizard.step8.create_components': {
- 'real':
'/clusters/{cluster}/servicegroups/{defaultServiceGroupName}/services/{serviceName}/components',
+ 'real':
'/clusters/{cluster}/servicegroups/{serviceGroup}/services/{serviceName}/components',
'mock': '',
'format': function (data) {
return {
diff --git a/ambari-web/test/controllers/installer_test.js
b/ambari-web/test/controllers/installer_test.js
index 948579a..9e65b76 100644
--- a/ambari-web/test/controllers/installer_test.js
+++ b/ambari-web/test/controllers/installer_test.js
@@ -536,10 +536,22 @@ describe('App.InstallerController', function () {
describe('Should load registered mpacks', function () {
it('maps registered mpacks', function () {
- sinon.stub(installerController, 'getDBProperty').returns([{}, {}, {}]);
+ sinon.stub(installerController, 'getDBProperty').returns([
+ {
+ MpackInfo: { mpack_name: "mpack1" }
+ },
+ {
+ MpackInfo: { mpack_name: "mpack2" }
+ },
+ {
+ MpackInfo: { mpack_name: "mpack3" }
+ }
+ ]);
sinon.stub(App.stackMapper, 'map');
installerController.loadRegisteredMpacks();
expect(App.stackMapper.map.calledThrice).to.be.true;
+ const serviceGroups = installerController.get('content.serviceGroups');
+ expect(serviceGroups).to.deep.equal(["mpack1", "mpack2", "mpack3"]);
installerController.getDBProperty.restore();
App.stackMapper.map.restore();
});
@@ -570,7 +582,8 @@ describe('App.InstallerController', function () {
},
getStepIndex: function () {
return 0;
- }
+ },
+ loadRegisteredMpacks: sinon.stub()
};
beforeEach(function () {
diff --git a/ambari-web/test/controllers/wizard/step8_test.js
b/ambari-web/test/controllers/wizard/step8_test.js
index 597265d..089746c 100644
--- a/ambari-web/test/controllers/wizard/step8_test.js
+++ b/ambari-web/test/controllers/wizard/step8_test.js
@@ -1249,7 +1249,8 @@ describe('App.WizardStep8Controller', function () {
{"ServiceInfo": { "service_name": 's3' }}
];
installerStep8Controller.createSelectedServices();
-
expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify(data));
+
expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify({
"ServiceInfo": { "service_name": "s1" } }));
+
expect(installerStep8Controller.addRequestToAjaxQueue.calledThrice).to.be.true;
});
});
@@ -1329,19 +1330,6 @@ describe('App.WizardStep8Controller', function () {
});
});
- describe('#newServiceComponentErrorCallback', function() {
-
- it('should add request for new component', function() {
- var serviceName = 's1',
- componentName = 'c1';
- installerStep8Controller.newServiceComponentErrorCallback({}, {}, '',
{}, {serviceName: serviceName, componentName: componentName});
- var data =
JSON.parse(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data);
-
expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.serviceName).to.equal(serviceName);
-
expect(data.components[0].ServiceComponentInfo.component_name).to.equal(componentName);
- });
-
- });
-
describe('#createAdditionalHostComponents', function() {
beforeEach(function() {
diff --git a/ambari-web/test/controllers/wizard/step9_test.js
b/ambari-web/test/controllers/wizard/step9_test.js
index 83a573e..bc78543 100644
--- a/ambari-web/test/controllers/wizard/step9_test.js
+++ b/ambari-web/test/controllers/wizard/step9_test.js
@@ -595,7 +595,12 @@ describe('App.InstallerStep9Controller', function () {
});
describe('#launchStartServices', function () {
- beforeEach(function() {
+ beforeEach(function () {
+ sinon.stub($, 'when').returns({
+ then: function () {
+ return true;
+ }
+ });
sinon.stub(App, 'get', function(k) {
if (k === 'components.slaves') {
return ["TASKTRACKER", "DATANODE",
@@ -612,6 +617,7 @@ describe('App.InstallerStep9Controller', function () {
});
afterEach(function() {
App.get.restore();
+ $.when.restore();
});
var tests = [
{
@@ -662,7 +668,8 @@ describe('App.InstallerStep9Controller', function () {
it(test.message, function () {
var content = Em.Object.create({
controllerName: test.controllerName,
- services: test.services
+ services: test.services,
+ serviceGroups: []
});
var wizardController = Em.Object.create({
getDBProperty: function() {
diff --git a/ambari-web/test/controllers/wizard_test.js
b/ambari-web/test/controllers/wizard_test.js
index 461ad22..2c24e61 100644
--- a/ambari-web/test/controllers/wizard_test.js
+++ b/ambari-web/test/controllers/wizard_test.js
@@ -747,21 +747,31 @@ describe('App.WizardController', function () {
describe('#installServices', function () {
var res;
+ var when;
beforeEach(function(){
sinon.stub(wizardController,'saveClusterStatus', function(data){
res = JSON.parse(JSON.stringify(data));
});
+ sinon.stub($, 'when').returns({ then: sinon.stub() });
});
afterEach(function(){
wizardController.saveClusterStatus.restore();
+ $.when.restore();
});
it('should call callbeck with data', function () {
wizardController.set('content', Em.Object.create({
cluster: {
oldRequestsId: '1'
- }
+ },
+ serviceGroups: [
+ "mpack1",
+ "mpack2",
+ "mpack3"
+ ]
}));
wizardController.installServices(true);
+ expect(App.ajax.send.calledThrice).to.be.true;
+ expect($.when.calledOnce).to.be.true;
expect(res).to.be.eql({
"status": "PENDING"
});
--
To stop receiving notification emails like this one, please contact
[email protected].