Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EEF6F1887D for ; Thu, 25 Jun 2015 09:32:11 +0000 (UTC) Received: (qmail 38869 invoked by uid 500); 25 Jun 2015 09:32:11 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 38843 invoked by uid 500); 25 Jun 2015 09:32:11 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 38834 invoked by uid 99); 25 Jun 2015 09:32:11 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Jun 2015 09:32:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 635B8E3674; Thu, 25 Jun 2015 09:32:11 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: onechiporenko@apache.org To: commits@ambari.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: ambari git commit: AMBARI-11658. Add Service Wizard resets local hdp repo to public repo (onechiporenko) Date: Thu, 25 Jun 2015 09:32:11 +0000 (UTC) Repository: ambari Updated Branches: refs/heads/branch-2.0.maint 21ae5c1f1 -> 716ac9858 AMBARI-11658. Add Service Wizard resets local hdp repo to public repo (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/716ac985 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/716ac985 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/716ac985 Branch: refs/heads/branch-2.0.maint Commit: 716ac98580c1d7068e74cd83ea56f07e8a9b192a Parents: 21ae5c1 Author: Oleg Nechiporenko Authored: Thu Jun 25 12:31:58 2015 +0300 Committer: Oleg Nechiporenko Committed: Thu Jun 25 12:31:58 2015 +0300 ---------------------------------------------------------------------- .../app/controllers/wizard/step8_controller.js | 16 ++-- ambari-web/app/utils/ajax/ajax.js | 4 + .../test/controllers/wizard/step8_test.js | 90 +++++++++++++++++--- 3 files changed, 90 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/716ac985/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 9f9ee88..9560f02 100644 --- a/ambari-web/app/controllers/wizard/step8_controller.js +++ b/ambari-web/app/controllers/wizard/step8_controller.js @@ -598,13 +598,16 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz * @method loadRepoInfo */ loadRepoInfo: function () { - var nameVersionCombo = App.get('currentStackVersion').split('-'); + + var currentRepoVersion = App.StackVersion.find().findProperty('state', 'CURRENT').get('repositoryVersion.repositoryVersion'); + var stackName = App.get('currentStackName'); + return App.ajax.send({ - name: 'cluster.load_repositories', + name: 'cluster.load_repo_version', sender: this, data: { - stackName: nameVersionCombo[0], - stackVersion: nameVersionCombo[1] + stackName: stackName, + repositoryVersion: currentRepoVersion }, success: 'loadRepoInfoSuccessCallback', error: 'loadRepoInfoErrorCallback' @@ -618,7 +621,8 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz */ loadRepoInfoSuccessCallback: function (data) { var allRepos = []; - data.items.forEach(function (os) { + Em.assert('Current repo-version may be only one', data.items.length === 1); + data.items[0].repository_versions[0].operating_systems.forEach(function (os) { os.repositories.forEach(function (repository) { allRepos.push(Em.Object.create({ base_url: repository.Repositories.base_url, @@ -626,7 +630,7 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz repo_id: repository.Repositories.repo_id })); }); - }, this); + }); allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName")); this.get('clusterInfo').set('repoInfo', allRepos); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/716ac985/ambari-web/app/utils/ajax/ajax.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js index bfda3a3..235cec6 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -1117,6 +1117,10 @@ var urls = { }; } }, + 'cluster.load_repo_version': { + 'real': '/stacks/{stackName}/versions?fields=repository_versions/operating_systems/repositories/*,repository_versions/RepositoryVersions/display_name&repository_versions/RepositoryVersions/repository_version={repositoryVersion}', + 'mock': '' + }, 'cluster.load_detailed_repo_version': { 'real': '/clusters/{clusterName}/stack_versions?ClusterStackVersions/state=CURRENT&fields=repository_versions/RepositoryVersions/repository_version&minimal_response=true', 'mock': '/data/stack_versions/stack_version_all.json' http://git-wip-us.apache.org/repos/asf/ambari/blob/716ac985/ambari-web/test/controllers/wizard/step8_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js index fa1d1a3..26384a3 100644 --- a/ambari-web/test/controllers/wizard/step8_test.js +++ b/ambari-web/test/controllers/wizard/step8_test.js @@ -438,15 +438,26 @@ describe('App.WizardStep8Controller', function () { }); describe('#loadRepoInfo', function() { - it('should use App.currentStackVersion', function() { - var version = 'HDP-1.1.1'; - sinon.stub(App, 'get', function() {return version;}); + + beforeEach(function () { + sinon.stub(App, 'get').withArgs('currentStackName').returns('HDP'); sinon.stub(App.ajax, 'send', Em.K); - installerStep8Controller.loadRepoInfo(); - var data = App.ajax.send.args[0][0].data; - expect(data).to.eql({stackName: 'HDP', stackVersion: '1.1.1'}); + sinon.stub(App.StackVersion, 'find', function() { + return [ + Em.Object.create({state: 'CURRENT', repositoryVersion: {repositoryVersion: '2.3.0.0-2208'}}) + ]; + }); + }); + + afterEach(function () { App.ajax.send.restore(); App.get.restore(); + App.StackVersion.find.restore(); + }); + it('should use current StackVersion', function() { + installerStep8Controller.loadRepoInfo(); + var data = App.ajax.send.args[0][0].data; + expect(data).to.eql({stackName: 'HDP', repositoryVersion: '2.3.0.0-2208'}); }); }); @@ -454,15 +465,66 @@ describe('App.WizardStep8Controller', function () { beforeEach(function () { installerStep8Controller.set('clusterInfo', Em.Object.create({})); }); + + it('should assert error if no data returned from server', function () { + expect(function () { + installerStep8Controller.loadRepoInfoSuccessCallback({items: []}); + }).to.throw(Error); + }); + Em.A([ - { - items: [], - m: 'no data', - e: { - base_url: [], - os_type: [] - } + { + m: 'Normal JSON', + e: { + base_url: ['baseurl1', 'baseurl2'], + os_type: ['redhat6', 'suse11'], + repo_id: ['HDP-2.3', 'HDP-UTILS-1.1.0.20'] }, + items: [ + { + repository_versions: [ + { + operating_systems: [ + { + repositories: [ + { + Repositories: { + base_url: 'baseurl1', + os_type: 'redhat6', + repo_id: 'HDP-2.3' + } + } + ] + }, + { + repositories: [ + { + Repositories: { + base_url: 'baseurl2', + os_type: 'suse11', + repo_id: 'HDP-UTILS-1.1.0.20' + } + } + ] + } + ] + } + ] + } + ] + } + ]).forEach(function (test) { + + it(test.m, function () { + installerStep8Controller.loadRepoInfoSuccessCallback({items: test.items}); + expect(installerStep8Controller.get('clusterInfo.repoInfo').mapProperty('base_url')).to.eql(test.e.base_url); + expect(installerStep8Controller.get('clusterInfo.repoInfo').mapProperty('os_type')).to.eql(test.e.os_type); + expect(installerStep8Controller.get('clusterInfo.repoInfo').mapProperty('repo_id')).to.eql(test.e.repo_id); + }); + + }); + + /*Em.A([ { items: [ { @@ -574,7 +636,7 @@ describe('App.WizardStep8Controller', function () { expect(installerStep8Controller.get('clusterInfo.repoInfo').mapProperty('base_url')).to.eql(test.e.base_url); expect(installerStep8Controller.get('clusterInfo.repoInfo').mapProperty('os_type')).to.eql(test.e.os_type); }); - }); + });*/ }); describe('#loadRepoInfoErrorCallback', function() {