You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2015/03/06 02:49:42 UTC
[2/2] ambari git commit: AMBARI-9949. Add Service: Choose Services
page,
selected service issue during navigation to wizard from Stack Versions page.
(alexantonenko)
AMBARI-9949. Add Service: Choose Services page, selected service issue during navigation to wizard from Stack Versions page. (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/21c67f93
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/21c67f93
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/21c67f93
Branch: refs/heads/branch-2.0.0
Commit: 21c67f93ba87750f418ac1e08da4ce4d9430a35c
Parents: b1e4100
Author: Alex Antonenko <hi...@gmail.com>
Authored: Thu Mar 5 21:42:25 2015 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Fri Mar 6 03:49:31 2015 +0200
----------------------------------------------------------------------
.../controllers/main/service/add_controller.js | 5 +-
.../main/service/add_controller_test.js | 84 ++++++++++++++++++++
2 files changed, 87 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/21c67f93/ambari-web/app/controllers/main/service/add_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/add_controller.js b/ambari-web/app/controllers/main/service/add_controller.js
index b340e68..c1682a9 100644
--- a/ambari-web/app/controllers/main/service/add_controller.js
+++ b/ambari-web/app/controllers/main/service/add_controller.js
@@ -30,7 +30,7 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs, {
hideBackButton: true,
/**
- * @type {object}
+ * @type {string}
* @default null
*/
serviceToInstall: null,
@@ -201,7 +201,7 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs, {
};
App.StackService.find().forEach(function (item) {
var isInstalled = App.Service.find().someProperty('id', item.get('serviceName'));
- var isSelected = item.get('serviceName') == this.get('serviceToInstall');
+ var isSelected = (item.get('serviceName') == this.get('serviceToInstall')) || item.get('coSelectedServices').contains(this.get('serviceToInstall'));
item.set('isSelected', isInstalled || isSelected);
item.set('isInstalled', isInstalled);
if (isInstalled) {
@@ -227,6 +227,7 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs, {
this.get('isStepDisabled').findProperty('step', 3).set('value', this.get('content.skipSlavesStep'));
}
}
+ this.set('serviceToInstall', null);
this.set('content.services', App.StackService.find());
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/21c67f93/ambari-web/test/controllers/main/service/add_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/add_controller_test.js b/ambari-web/test/controllers/main/service/add_controller_test.js
index 2054cc1..79b0f21 100644
--- a/ambari-web/test/controllers/main/service/add_controller_test.js
+++ b/ambari-web/test/controllers/main/service/add_controller_test.js
@@ -339,4 +339,88 @@ describe('App.AddServiceController', function() {
});
});
+
+ describe('#loadServices', function() {
+ beforeEach(function() {
+ this.controller = App.AddServiceController.create({});
+ this.db = {};
+ sinon.stub(this.controller, 'getDBProperty');
+ sinon.stub(this.controller, 'setDBProperty', function(key, value) {
+ this.db = value;
+ }.bind(this));
+ });
+
+ afterEach(function() {
+ this.controller.getDBProperty.restore();
+ this.controller.setDBProperty.restore();
+ });
+
+ var tests = [
+ {
+ appStackService: [
+ Em.Object.create({ id: 'HDFS', serviceName: 'HDFS', coSelectedServices: []}),
+ Em.Object.create({ id: 'YARN', serviceName: 'YARN', coSelectedServices: ['MAPREDUCE2']}),
+ Em.Object.create({ id: 'MAPREDUCE2', serviceName: 'MAPREDUCE2', coSelectedServices: []}),
+ Em.Object.create({ id: 'FALCON', serviceName: 'FALCON', coSelectedServices: []}),
+ Em.Object.create({ id: 'STORM', serviceName: 'STORM', coSelectedServices: []})
+ ],
+ appService: [
+ Em.Object.create({ id: 'HDFS', serviceName: 'HDFS'}),
+ Em.Object.create({ id: 'STORM', serviceName: 'STORM'})
+ ],
+ servicesFromDB: false,
+ serviceToInstall: 'MAPREDUCE2',
+ e: {
+ selectedServices: ['HDFS', 'YARN', 'MAPREDUCE2', 'STORM'],
+ installedServices: ['HDFS', 'STORM']
+ },
+ m: 'MapReduce selected on Admin -> Stack Versions Page, Yarn service should be selected because it coselected'
+ },
+ {
+ appStackService: [
+ Em.Object.create({ id: 'HDFS', serviceName: 'HDFS', coSelectedServices: []}),
+ Em.Object.create({ id: 'YARN', serviceName: 'YARN', coSelectedServices: ['MAPREDUCE2']}),
+ Em.Object.create({ id: 'HBASE', serviceName: 'HBASE', coSelectedServices: []}),
+ Em.Object.create({ id: 'STORM', serviceName: 'STORM', coSelectedServices: []})
+ ],
+ appService: [
+ Em.Object.create({ id: 'HDFS', serviceName: 'HDFS'}),
+ Em.Object.create({ id: 'STORM', serviceName: 'STORM'})
+ ],
+ servicesFromDB: {
+ selectedServices: ['HBASE'],
+ installedServices: ['HDFS', 'STORM']
+ },
+ serviceToInstall: null,
+ e: {
+ selectedServices: ['HDFS', 'HBASE', 'STORM'],
+ installedServices: ['HDFS', 'STORM']
+ },
+ m: 'HDFS and STORM are installed. Select HBASE'
+ }
+ ];
+
+ tests.forEach(function(test) {
+ it(test.m, function() {
+ sinon.stub(App.StackService, 'find').returns(test.appStackService);
+ sinon.stub(App.Service, 'find').returns(test.appService);
+ this.controller.getDBProperty.withArgs('services').returns(test.servicesFromDB);
+ this.controller.set('serviceToInstall', test.serviceToInstall);
+ this.controller.loadServices();
+ App.StackService.find.restore();
+ App.Service.find.restore();
+ if (!test.servicesFromDB) {
+ // verify saving to local db on first enter to the wizard
+ expect(this.db.selectedServices).to.be.eql(test.e.selectedServices);
+ expect(this.db.installedServices).to.be.eql(test.e.installedServices);
+ } else {
+ // verify values for App.StackService
+ expect(test.appStackService.filterProperty('isSelected', true).mapProperty('serviceName')).to.be.eql(test.e.selectedServices);
+ expect(test.appStackService.filterProperty('isInstalled', true).mapProperty('serviceName')).to.be.eql(test.e.installedServices);
+ }
+ expect(this.controller.get('serviceToInstall')).to.be.null;
+ });
+ }, this);
+ });
+
});