You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2015/08/25 13:04:38 UTC
ambari git commit: AMBARI-12868. Improve calls to the localStorage
(onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/trunk fef858b70 -> e6ad02fe3
AMBARI-12868. Improve calls to the localStorage (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e6ad02fe
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e6ad02fe
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e6ad02fe
Branch: refs/heads/trunk
Commit: e6ad02fe3144124bd640e604f438ee45cde8daf0
Parents: fef858b
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Tue Aug 25 13:54:55 2015 +0300
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Tue Aug 25 14:04:28 2015 +0300
----------------------------------------------------------------------
.../controllers/global/cluster_controller.js | 8 +++--
ambari-web/app/controllers/installer.js | 16 +++++----
.../main/admin/stack_and_upgrade_controller.js | 29 ++++++++-------
.../app/controllers/main/host/add_controller.js | 10 +++---
.../app/controllers/wizard/step7_controller.js | 10 +++---
.../app/controllers/wizard/step8_controller.js | 16 ++++-----
.../app/controllers/wizard/step9_controller.js | 3 +-
.../wizard/wizardProgressPageController.js | 6 ++--
ambari-web/app/routes/add_host_routes.js | 6 ++--
ambari-web/app/routes/add_kerberos_routes.js | 12 ++++---
ambari-web/app/routes/create_widget.js | 16 +++++----
ambari-web/app/routes/installer.js | 30 ++++++++++------
ambari-web/test/controllers/installer_test.js | 38 ++++++++++----------
.../admin/stack_and_upgrade_controller_test.js | 17 ++++-----
.../main/host/add_controller_test.js | 18 +++++++---
.../test/controllers/wizard/step7_test.js | 8 ++---
16 files changed, 141 insertions(+), 102 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/e6ad02fe/ambari-web/app/controllers/global/cluster_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js
index b0ae730..e182719 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -283,9 +283,11 @@ App.ClusterController = Em.Controller.extend({
}
if (lastUpgradeData) {
- upgradeController.setDBProperty('upgradeId', lastUpgradeData.Upgrade.request_id);
- upgradeController.setDBProperty('isDowngrade', lastUpgradeData.Upgrade.direction === 'DOWNGRADE');
- upgradeController.setDBProperty('upgradeState', lastUpgradeData.Upgrade.request_status);
+ upgradeController.setDBProperties({
+ upgradeId: lastUpgradeData.Upgrade.request_id,
+ isDowngrade: lastUpgradeData.Upgrade.direction === 'DOWNGRADE',
+ upgradeState: lastUpgradeData.Upgrade.request_status
+ });
upgradeController.loadRepoVersionsToModel().done(function () {
upgradeController.setDBProperty('upgradeVersion', App.RepositoryVersion.find().findProperty('repositoryVersion', lastUpgradeData.Upgrade.to_version).get('displayName'));
upgradeController.initDBProperties();
http://git-wip-us.apache.org/repos/asf/ambari/blob/e6ad02fe/ambari-web/app/controllers/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/installer.js b/ambari-web/app/controllers/installer.js
index 932da04..d1104a7 100644
--- a/ambari-web/app/controllers/installer.js
+++ b/ambari-web/app/controllers/installer.js
@@ -388,9 +388,11 @@ App.InstallerController = App.WizardController.extend({
});
this.set('content.services', App.StackService.find());
this.set('content.selectedServiceNames', selectedServiceNames);
- this.setDBProperty('selectedServiceNames', selectedServiceNames);
this.set('content.installedServiceNames', installedServiceNames);
- this.setDBProperty('installedServiceNames', installedServiceNames);
+ this.setDBProperties({
+ selectedServiceNames: selectedServiceNames,
+ installedServiceNames: installedServiceNames
+ });
},
/**
@@ -422,8 +424,9 @@ App.InstallerController = App.WizardController.extend({
* Load master component hosts data for using in required step controllers
*/
loadMasterComponentHosts: function () {
- var masterComponentHosts = this.getDBProperty('masterComponentHosts'),
- hosts = this.getDBProperty('hosts'),
+ var props = this.getDBProperties(['masterComponentHosts', 'hosts']);
+ var masterComponentHosts = props.masterComponentHosts,
+ hosts = props.hosts,
host_names = Em.keys(hosts);
if (Em.isNone(masterComponentHosts)) {
masterComponentHosts = [];
@@ -453,8 +456,9 @@ App.InstallerController = App.WizardController.extend({
* Load master component hosts data for using in required step controllers
*/
loadSlaveComponentHosts: function () {
- var slaveComponentHosts = this.getDBProperty('slaveComponentHosts'),
- hosts = this.getDBProperty('hosts'),
+ var props = this.getDBProperties(['slaveComponentHosts', 'hosts']);
+ var slaveComponentHosts = props.slaveComponentHosts,
+ hosts = props.hosts,
host_names = Em.keys(hosts);
if (!Em.isNone(slaveComponentHosts)) {
slaveComponentHosts.forEach(function (component) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e6ad02fe/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
index 95a5ee1..e9829ce 100644
--- a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
+++ b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
@@ -149,10 +149,9 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
* restore data from localStorage
*/
initDBProperties: function () {
- this.get('wizardStorageProperties').forEach(function (property) {
- if (this.getDBProperty(property)) {
- this.set(property, this.getDBProperty(property));
- }
+ var props = this.getDBProperties(this.get('wizardStorageProperties'));
+ Em.keys(props).forEach(function (k) {
+ this.set(k, props[k]);
}, this);
},
@@ -447,10 +446,12 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
this.set('upgradeId', data.resources[0].Upgrade.request_id);
this.set('upgradeVersion', params.label);
this.set('isDowngrade', !!params.isDowngrade);
- this.setDBProperty('upgradeVersion', params.label);
- this.setDBProperty('upgradeId', data.resources[0].Upgrade.request_id);
- this.setDBProperty('upgradeState', 'PENDING');
- this.setDBProperty('isDowngrade', !!params.isDowngrade);
+ this.setDBProperties({
+ upgradeVersion: params.label,
+ upgradeId: data.resources[0].Upgrade.request_id,
+ upgradeState: 'PENDING',
+ isDowngrade: !!params.isDowngrade
+ });
App.set('upgradeState', 'PENDING');
App.clusterStatus.setClusterStatus({
wizardControllerName: this.get('name'),
@@ -782,11 +783,13 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
*/
finish: function () {
if (App.get('upgradeState') === 'COMPLETED') {
- this.setDBProperty('upgradeId', undefined);
- this.setDBProperty('upgradeState', 'INIT');
- this.setDBProperty('upgradeVersion', undefined);
- this.setDBProperty('currentVersion', undefined);
- this.setDBProperty('isDowngrade', undefined);
+ this.setDBProperties({
+ upgradeId: undefined,
+ upgradeState: 'INIT',
+ upgradeVersion: undefined,
+ currentVersion: undefined,
+ isDowngrade: undefined
+ });
App.clusterStatus.setClusterStatus({
localdb: App.db.data
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/e6ad02fe/ambari-web/app/controllers/main/host/add_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/add_controller.js b/ambari-web/app/controllers/main/host/add_controller.js
index 31a8232..d72b146 100644
--- a/ambari-web/app/controllers/main/host/add_controller.js
+++ b/ambari-web/app/controllers/main/host/add_controller.js
@@ -141,9 +141,10 @@ App.AddHostController = App.WizardController.extend({
* TODO move to mixin
*/
loadSlaveComponentHosts: function () {
- var slaveComponentHosts = this.getDBProperty('slaveComponentHosts') || [];
+ var props = this.getDBProperties(['slaveComponentHosts', 'hosts']);
+ var slaveComponentHosts = props.slaveComponentHosts || [];
if (slaveComponentHosts.length) {
- var hosts = this.getDBProperty('hosts'),
+ var hosts = props.hosts,
host_names = Em.keys(hosts);
slaveComponentHosts.forEach(function (component) {
component.hosts.forEach(function (host) {
@@ -407,8 +408,9 @@ App.AddHostController = App.WizardController.extend({
this.set('content.cluster.oldRequestsId', []);
var clusterName = this.get('content.cluster.name');
var hostNames = [];
- for (var hostname in this.getDBProperty('hosts')) {
- if(this.getDBProperty('hosts')[hostname].isInstalled == false){
+ var hosts = this.getDBProperty('hosts');
+ for (var hostname in hosts) {
+ if(!hosts[hostname].isInstalled) {
hostNames.push(hostname);
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e6ad02fe/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index 3e760d5..539fb2e 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -565,16 +565,18 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
* @method resolveStormConfigs
*/
resolveStormConfigs: function (configs) {
- var dependentConfigs, gangliaServerHost, gangliaHostId, hosts;
+ var props = this.get('wizardController').getDBProperties(['masterComponentHosts', 'hosts']);
+ var dependentConfigs, gangliaServerHost, gangliaHostId,
+ masterComponentHosts = props.masterComponentHosts,
+ hosts = props.hosts;
dependentConfigs = ['nimbus.childopts', 'supervisor.childopts', 'worker.childopts'];
// if Ganglia selected or installed, set ganglia host to configs
if (this.get('installedServiceNames').contains('STORM') && this.get('installedServiceNames').contains('GANGLIA')) return;
if (this.get('allSelectedServiceNames').contains('GANGLIA') || this.get('installedServiceNames').contains('GANGLIA')) {
if (this.get('wizardController.name') === 'addServiceController') {
- gangliaServerHost = this.get('wizardController').getDBProperty('masterComponentHosts').findProperty('component', 'GANGLIA_SERVER').hostName;
+ gangliaServerHost = masterComponentHosts.findProperty('component', 'GANGLIA_SERVER').hostName;
} else {
- hosts = this.get('wizardController').getDBProperty('hosts');
- gangliaHostId = this.get('wizardController').getDBProperty('masterComponentHosts').findProperty('component', 'GANGLIA_SERVER').host_id;
+ gangliaHostId = masterComponentHosts.findProperty('component', 'GANGLIA_SERVER').host_id;
for (var hostName in hosts) {
if (hosts[hostName].id == gangliaHostId) gangliaServerHost = hosts[hostName].name;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e6ad02fe/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index 04fa34f..20f6a30 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -624,13 +624,10 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
* @method loadHiveDbValue
*/
loadDbValue: function (serviceName) {
- var dbFull = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', serviceName.toLowerCase() + '_database'),
- db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', serviceName.toLowerCase() + '_ambari_database');
- if (db && dbFull) {
- return db.value + ' (' + dbFull.value + ')';
- } else {
- return '';
- }
+ var serviceConfigProperties = this.get('wizardController').getDBProperty('serviceConfigProperties');
+ var dbFull = serviceConfigProperties.findProperty('name', serviceName.toLowerCase() + '_database'),
+ db = serviceConfigProperties.findProperty('name', serviceName.toLowerCase() + '_ambari_database');
+ return db && dbFull ? db.value + ' (' + dbFull.value + ')' : '';
},
/**
@@ -983,8 +980,9 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
this.updateKerberosDescriptor();
}
}
- if (this.get('wizardController').getDBProperty('fileNamesToUpdate') && this.get('wizardController').getDBProperty('fileNamesToUpdate').length) {
- this.updateConfigurations(this.get('wizardController').getDBProperty('fileNamesToUpdate'));
+ var fileNamesToUpdate = this.get('wizardController').getDBProperty('fileNamesToUpdate');
+ if (fileNamesToUpdate && fileNamesToUpdate.length) {
+ this.updateConfigurations(fileNamesToUpdate);
}
this.createConfigurations();
this.applyConfigurationsToCluster(this.get('serviceConfigTags'));
http://git-wip-us.apache.org/repos/asf/ambari/blob/e6ad02fe/ambari-web/app/controllers/wizard/step9_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step9_controller.js b/ambari-web/app/controllers/wizard/step9_controller.js
index 1dae93b..abfb56a 100644
--- a/ambari-web/app/controllers/wizard/step9_controller.js
+++ b/ambari-web/app/controllers/wizard/step9_controller.js
@@ -471,7 +471,8 @@ App.WizardStep9Controller = Em.Controller.extend(App.ReloadPopupMixin, {
case 'addHostController':
name = 'common.host_components.update';
var hostnames = [];
- for (var hostname in this.get('wizardController').getDBProperty('hosts')) {
+ var hosts = this.get('wizardController').getDBProperty('hosts');
+ for (var hostname in hosts) {
if(this.get('hosts').findProperty('name', hostname)){
hostnames.push(hostname);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/e6ad02fe/ambari-web/app/mixins/wizard/wizardProgressPageController.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/wizard/wizardProgressPageController.js b/ambari-web/app/mixins/wizard/wizardProgressPageController.js
index 226b69a..d290173 100644
--- a/ambari-web/app/mixins/wizard/wizardProgressPageController.js
+++ b/ambari-web/app/mixins/wizard/wizardProgressPageController.js
@@ -110,8 +110,10 @@ App.wizardProgressPageControllerMixin = Em.Mixin.create({
* Clear stages info for single page request.
*/
clearStage: function() {
- this.setDBProperty('tasksRequestIds', null);
- this.setDBProperty('tasksStatuses', null);
+ this.setDBProperties({
+ tasksRequestIds: null,
+ tasksStatuses: null
+ });
this.set('showRetry', false);
this.set('content.tasksRequestIds', null);
this.set('content.tasksStatuses', null);
http://git-wip-us.apache.org/repos/asf/ambari/blob/e6ad02fe/ambari-web/app/routes/add_host_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_host_routes.js b/ambari-web/app/routes/add_host_routes.js
index 10e8b11..5487bce 100644
--- a/ambari-web/app/routes/add_host_routes.js
+++ b/ambari-web/app/routes/add_host_routes.js
@@ -164,8 +164,10 @@ module.exports = App.WizardRoute.extend({
addHostController.saveConfirmedHosts(wizardStep3Controller);
addHostController.saveClients();
- addHostController.setDBProperty('bootStatus', true);
- addHostController.setDBProperty('slaveComponentHosts', undefined);
+ addHostController.setDBProperties({
+ bootStatus: true,
+ slaveComponentHosts: undefined
+ });
wizardStep6Controller.set('isClientsSet', false);
router.transitionTo('step3');
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/e6ad02fe/ambari-web/app/routes/add_kerberos_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_kerberos_routes.js b/ambari-web/app/routes/add_kerberos_routes.js
index 55d1077..1b3e68f 100644
--- a/ambari-web/app/routes/add_kerberos_routes.js
+++ b/ambari-web/app/routes/add_kerberos_routes.js
@@ -288,8 +288,10 @@ module.exports = App.WizardRoute.extend({
var kerberosWizardController = router.get('kerberosWizardController');
var kerberosWizardStep4Controller = router.get('kerberosWizardStep4Controller');
kerberosWizardController.saveServiceConfigProperties(kerberosWizardStep4Controller);
- kerberosWizardController.setDBProperty('tasksStatuses', null);
- kerberosWizardController.setDBProperty('tasksRequestIds', null);
+ kerberosWizardController.setDBProperties({
+ tasksStatuses: null,
+ tasksRequestIds: null
+ });
router.transitionTo('step6');
}
}),
@@ -314,8 +316,10 @@ module.exports = App.WizardRoute.extend({
next: function (router) {
var kerberosWizardController = router.get('kerberosWizardController');
var callback = function () {
- kerberosWizardController.setDBProperty('tasksStatuses', null);
- kerberosWizardController.setDBProperty('tasksRequestIds', null);
+ kerberosWizardController.setDBProperties({
+ tasksStatuses: null,
+ tasksRequestIds: null
+ });
router.transitionTo('step7');
};
if (kerberosWizardController.get('skipClientInstall')) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e6ad02fe/ambari-web/app/routes/create_widget.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/create_widget.js b/ambari-web/app/routes/create_widget.js
index 1557227..609509e 100644
--- a/ambari-web/app/routes/create_widget.js
+++ b/ambari-web/app/routes/create_widget.js
@@ -78,13 +78,15 @@ module.exports = App.WizardRoute.extend({
var widgetWizardController = router.get('widgetWizardController');
var widgetStep1controller = router.get('widgetWizardStep1Controller');
widgetWizardController.save('widgetType', widgetStep1controller.get('widgetType'));
- widgetWizardController.setDBProperty('widgetProperties', {});
- widgetWizardController.setDBProperty('widgetMetrics', []);
- widgetWizardController.setDBProperty('allMetrics', []);
- widgetWizardController.setDBProperty('widgetValues', []);
- widgetWizardController.setDBProperty('expressions', []);
- widgetWizardController.setDBProperty('dataSets', []);
- widgetWizardController.setDBProperty('templateValue', '');
+ widgetWizardController.setDBProperties({
+ widgetProperties: {},
+ widgetMetrics: {},
+ allMetrics: {},
+ widgetValues: {},
+ expressions: {},
+ dataSets: {},
+ templateValue: {}
+ });
router.transitionTo('step2');
}
}),
http://git-wip-us.apache.org/repos/asf/ambari/blob/e6ad02fe/ambari-web/app/routes/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/installer.js b/ambari-web/app/routes/installer.js
index 37153ac..dcd9925 100644
--- a/ambari-web/app/routes/installer.js
+++ b/ambari-web/app/routes/installer.js
@@ -179,9 +179,11 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
var installerController = router.get('installerController');
var wizardStep3Controller = router.get('wizardStep3Controller');
installerController.saveConfirmedHosts(wizardStep3Controller);
- installerController.setDBProperty('bootStatus', true);
- installerController.setDBProperty('selectedServiceNames', undefined);
- installerController.setDBProperty('installedServiceNames', undefined);
+ installerController.setDBProperties({
+ bootStatus: true,
+ selectedServiceNames: undefined,
+ installedServiceNames: undefined
+ });
router.transitionTo('step4');
}
},
@@ -221,8 +223,10 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
controller.saveServices(wizardStep4Controller);
controller.saveClients(wizardStep4Controller);
router.get('wizardStep5Controller').clearRecommendations(); // Force reload recommendation between steps 4 and 5
- controller.setDBProperty('recommendations', undefined);
- controller.setDBProperty('masterComponentHosts', undefined);
+ controller.setDBProperties({
+ recommendations: undefined,
+ masterComponentHosts: undefined
+ });
router.transitionTo('step5');
}
}),
@@ -250,8 +254,10 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
var wizardStep5Controller = router.get('wizardStep5Controller');
var wizardStep6Controller = router.get('wizardStep6Controller');
controller.saveMasterComponentHosts(wizardStep5Controller);
- controller.setDBProperty('slaveComponentHosts', undefined);
- controller.setDBProperty('recommendations', wizardStep5Controller.get('content.recommendations'));
+ controller.setDBProperties({
+ slaveComponentHosts: undefined,
+ recommendations: wizardStep5Controller.get('content.recommendations')
+ });
wizardStep6Controller.set('isClientsSet', false);
router.transitionTo('step6');
}
@@ -281,10 +287,12 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
router.set('transitionInProgress', true);
controller.saveSlaveComponentHosts(wizardStep6Controller);
controller.get('content').set('serviceConfigProperties', null);
- controller.setDBProperty('serviceConfigProperties', null);
- controller.setDBProperty('serviceConfigGroups', null);
- controller.setDBProperty('recommendationsHostGroups', wizardStep6Controller.get('content.recommendationsHostGroups'));
- controller.setDBProperty('recommendationsConfigs', null);
+ controller.setDBProperties({
+ serviceConfigProperties: null,
+ serviceConfigGroups: null,
+ recommendationsHostGroups: wizardStep6Controller.get('content.recommendationsHostGroups'),
+ recommendationsConfigs: null
+ });
router.transitionTo('step7');
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/e6ad02fe/ambari-web/test/controllers/installer_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/installer_test.js b/ambari-web/test/controllers/installer_test.js
index 49a8852..df5c8f4 100644
--- a/ambari-web/test/controllers/installer_test.js
+++ b/ambari-web/test/controllers/installer_test.js
@@ -851,9 +851,15 @@ describe('App.InstallerController', function () {
describe('#loadMasterComponentHosts', function() {
beforeEach(function () {
- sinon.stub(installerController, 'getDBProperty', function(key) {
- if (key == 'hosts') {
- return {
+ sinon.stub(installerController, 'getDBProperties', function(key) {
+ return {
+ masterComponentHosts: Em.A([
+ {
+ hostName: '',
+ host_id: 11
+ }
+ ]),
+ hosts: {
'h1': {
id: 11
},
@@ -864,18 +870,11 @@ describe('App.InstallerController', function () {
id: 12
}
}
- } else {
- return Em.A([
- {
- hostName: '',
- host_id: 11
- }
- ]);
}
});
});
afterEach(function () {
- installerController.getDBProperty.restore();
+ installerController.getDBProperties.restore();
});
it ('Should load hosts', function() {
installerController.loadMasterComponentHosts();
@@ -890,9 +889,9 @@ describe('App.InstallerController', function () {
describe('#loadSlaveComponentHosts', function() {
beforeEach(function () {
- sinon.stub(installerController, 'getDBProperty', function(key) {
- if (key == 'hosts') {
- return {
+ sinon.stub(installerController, 'getDBProperties', function() {
+ return {
+ hosts: {
'h1': {
id: 11
},
@@ -902,9 +901,8 @@ describe('App.InstallerController', function () {
'h2': {
id: 12
}
- }
- } else {
- return Em.A([
+ },
+ slaveComponentHosts: Em.A([
{
hosts: Em.A([
{
@@ -913,12 +911,12 @@ describe('App.InstallerController', function () {
}
])
}
- ]);
- }
+ ])
+ };
});
});
afterEach(function () {
- installerController.getDBProperty.restore();
+ installerController.getDBProperties.restore();
});
it ('Should load slave hosts', function() {
installerController.loadSlaveComponentHosts();
http://git-wip-us.apache.org/repos/asf/ambari/blob/e6ad02fe/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
index e92d49c..73327f5 100644
--- a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
@@ -424,12 +424,16 @@ describe('App.MainAdminStackAndUpgradeController', function() {
describe("#initDBProperties()", function() {
before(function () {
- sinon.stub(controller, 'getDBProperty', function (prop) {
- return prop;
+ sinon.stub(controller, 'getDBProperties', function (prop) {
+ var ret = {};
+ prop.forEach(function (k) {
+ ret[k] = k;
+ });
+ return ret;
});
});
after(function () {
- controller.getDBProperty.restore();
+ controller.getDBProperties.restore();
});
it("set properties", function () {
controller.set('wizardStorageProperties', ['prop1']);
@@ -483,13 +487,13 @@ describe('App.MainAdminStackAndUpgradeController', function() {
before(function () {
sinon.stub(App.clusterStatus, 'setClusterStatus', Em.K);
sinon.stub(controller, 'openUpgradeDialog', Em.K);
- sinon.stub(controller, 'setDBProperty', Em.K);
+ sinon.stub(controller, 'setDBProperties', Em.K);
sinon.stub(controller, 'load', Em.K);
});
after(function () {
App.clusterStatus.setClusterStatus.restore();
controller.openUpgradeDialog.restore();
- controller.setDBProperty.restore();
+ controller.setDBProperties.restore();
controller.load.restore();
});
it("open upgrade dialog", function() {
@@ -503,9 +507,6 @@ describe('App.MainAdminStackAndUpgradeController', function() {
]
};
controller.upgradeSuccessCallback(data, {}, {label: 'HDP-2.2.1', isDowngrade: true});
- expect(controller.setDBProperty.calledWith('upgradeId', 1)).to.be.true;
- expect(controller.setDBProperty.calledWith('upgradeVersion', 'HDP-2.2.1')).to.be.true;
- expect(controller.setDBProperty.calledWith('isDowngrade', true)).to.be.true;
expect(controller.load.calledOnce).to.be.true;
expect(controller.get('upgradeVersion')).to.equal('HDP-2.2.1');
expect(controller.get('upgradeData')).to.be.null;
http://git-wip-us.apache.org/repos/asf/ambari/blob/e6ad02fe/ambari-web/test/controllers/main/host/add_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/add_controller_test.js b/ambari-web/test/controllers/main/host/add_controller_test.js
index 2fe4341..09375bd 100644
--- a/ambari-web/test/controllers/main/host/add_controller_test.js
+++ b/ambari-web/test/controllers/main/host/add_controller_test.js
@@ -538,29 +538,37 @@ describe('App.AddHostController', function () {
});
describe("#loadSlaveComponentHosts()", function () {
+
var mock = {
hosts: null,
slaveComponentHosts: null
};
+
beforeEach(function () {
- sinon.stub(controller, 'getDBProperty', function (arg) {
- if (arg === 'hosts') return mock.hosts;
- if (arg === 'slaveComponentHosts') return mock.slaveComponentHosts;
+ sinon.stub(controller, 'getDBProperties', function (propsList) {
+ var ret = {};
+ propsList.forEach(function(k) {
+ ret[k] = mock[k];
+ });
+ return ret;
});
});
+
afterEach(function () {
- controller.getDBProperty.restore();
+ controller.getDBProperties.restore();
});
it("No slaveComponentHosts in db, null", function () {
controller.loadSlaveComponentHosts();
expect(controller.get('content.slaveComponentHosts')).to.be.empty;
});
+
it("No slaveComponentHosts in db", function () {
mock.slaveComponentHosts = [];
controller.loadSlaveComponentHosts();
expect(controller.get('content.slaveComponentHosts')).to.be.empty;
});
+
it("One slaveComponent without hosts", function () {
mock.slaveComponentHosts = [
{hosts: []}
@@ -571,6 +579,7 @@ describe('App.AddHostController', function () {
{hosts: []}
]);
});
+
it("One slaveComponent with host", function () {
mock.slaveComponentHosts = [
{hosts: [
@@ -588,6 +597,7 @@ describe('App.AddHostController', function () {
]}
]);
});
+
});
describe("#saveClients()", function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e6ad02fe/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index 80433ab..f1770a4 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -694,8 +694,8 @@ describe('App.InstallerStep7Controller', function () {
hosts: {'h1': {name: 'host1', id: 'h1'}},
masterComponentHosts: [{component: 'GANGLIA_SERVER', host_id: 'h1'}],
- getDBProperty: function (k) {
- return this.get(k);
+ getDBProperties: function (keys) {
+ return this.getProperties(keys);
}
})
});
@@ -773,8 +773,8 @@ describe('App.InstallerStep7Controller', function () {
wizardController: Em.Object.create({
name: 'addServiceController',
masterComponentHosts: [{component: 'GANGLIA_SERVER', hostName: 'realhost1'}],
- getDBProperty: function (k) {
- return this.get(k);
+ getDBProperties: function (keys) {
+ return this.getProperties(keys);
}
})
});