Repository: ambari Updated Branches: refs/heads/branch-feature-AMBARI-14714-ui 1578226b3 -> 153477463
http://git-wip-us.apache.org/repos/asf/ambari/blob/15347746/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 b6cae9b..f86fd3d 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -1988,6 +1988,9 @@ var urls = { 'real': '/stacks/{stackName}/versions/{stackVersion}/repository_versions/{id}', 'type': 'DELETE' }, + 'wizard.mpack_service_components': { + 'real': '/stacks/{stackName}/versions/{stackVersion}/services/{serviceName}?fields=StackServices/*,components/*,components/dependencies/Dependencies/scope,components/dependencies/Dependencies/service_name,artifacts/Artifacts/artifact_name' + }, 'wizard.service_components': { 'real': '{stackUrl}/services?fields=StackServices/*,components/*,components/dependencies/Dependencies/scope,components/dependencies/Dependencies/service_name,artifacts/Artifacts/artifact_name', 'mock': '/data/stacks/HDP-2.1/service_components.json' @@ -3065,6 +3068,21 @@ var urls = { }, /** Mpack related APIs */ + 'mpack.download_by_url': { + 'real': '/mpacks', + 'format': function (data) { + return { + type: 'POST', + data: JSON.stringify({ + Body: { + "MpackInfo" : { + "mpack_uri": data.url + } + } + }) + }; + } + }, 'mpack.download': { 'real': '/mpacks', @@ -3082,6 +3100,54 @@ var urls = { }) }; } + }, + + 'mpack.get_registered_mpacks': { + 'real': '/mpacks', + }, + + 'mpack.create_version_definition': { + 'real': '/version_definitions', + 'format': function (data) { + return { + type: 'POST', + data: JSON.stringify({ + Body: { + "VersionDefinition": { + "available": `${data.name}-${data.version}` + } + } + }) + }; + } + }, + + 'mpack.get_version_definition': { + 'real': '/version_definitions/{id}?fields=VersionDefinition/*,operating_systems/repositories/Repositories/*,operating_systems/OperatingSystems/*,VersionDefinition/stack_services,VersionDefinition/repository_version', + }, + + 'mpack.get_version_definitions': { + 'real': '/version_definitions?fields=VersionDefinition/*,operating_systems/repositories/Repositories/*,operating_systems/OperatingSystems/*,VersionDefinition/stack_services,VersionDefinition/repository_version', + }, + + 'registry.mpacks.versions': { + real: '/registries?fields=mpacks/*,mpacks/versions/RegistryMpackVersionInfo/*', + mock: '/data/registry/mpacks_versions.json', + }, + + 'registry.mpacks': { + real: '/registries/{registryId}/mpacks', + mock: '/data/registry/mpacks.json', + }, + + 'registry.mpack': { + real: '/registries/{registryId}/mpacks/{name}', + mock: '/data/registry/mpack.json', + }, + + 'registry.mpack.version': { + real: '/registries/{registryId}/mpacks/{name}/versions/{version}', + mock: '/data/registry/mpack_version.json', } http://git-wip-us.apache.org/repos/asf/ambari/blob/15347746/ambari-web/app/views.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js index 6924d8c..1ef0b62 100644 --- a/ambari-web/app/views.js +++ b/ambari-web/app/views.js @@ -379,6 +379,9 @@ require('views/wizard/step8_view'); require('views/wizard/step9_view'); require('views/wizard/step9/hostLogPopupBody_view'); require('views/wizard/step10_view'); +require('views/wizard/selectMpacks_view'); +require('views/wizard/selectMpacks/mpack_view'); +require('views/wizard/selectMpacks/selectedMpackVersion_view'); require('views/loading'); require('views/experimental'); http://git-wip-us.apache.org/repos/asf/ambari/blob/15347746/ambari-web/app/views/wizard/configureDownload_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/wizard/configureDownload_view.js b/ambari-web/app/views/wizard/configureDownload_view.js index ce436e5..8a02c71 100644 --- a/ambari-web/app/views/wizard/configureDownload_view.js +++ b/ambari-web/app/views/wizard/configureDownload_view.js @@ -23,13 +23,17 @@ App.WizardConfigureDownloadView = Em.View.extend({ templateName: require('templates/wizard/configureDownload'), + didInsertElement: function () { + this.get('controller').loadStep(); + }, + /** * Radio button for use Public repo * * @type {App.RadioButtonView} */ usePublicRepoRadioButton: App.RadioButtonView.extend({ - checked: Em.computed.alias('controller.selectedStack.usePublicRepo'), + checked: Em.computed.alias('controller.content.downloadConfig.usePublicRepo'), change: function () { this.get('controller').usePublicRepo(); } @@ -41,7 +45,7 @@ App.WizardConfigureDownloadView = Em.View.extend({ * @type {App.RadioButtonView} */ useLocalRepoRadioButton: App.RadioButtonView.extend({ - checked: Em.computed.alias('controller.selectedStack.useLocalRepo'), + checked: Em.computed.alias('controller.content.downloadConfig.useLocalRepo'), disabled: true, change: function () { this.get('controller').useLocalRepo(); http://git-wip-us.apache.org/repos/asf/ambari/blob/15347746/ambari-web/app/views/wizard/selectMpacks/mpack_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/wizard/selectMpacks/mpack_view.js b/ambari-web/app/views/wizard/selectMpacks/mpack_view.js new file mode 100644 index 0000000..9c22eb9 --- /dev/null +++ b/ambari-web/app/views/wizard/selectMpacks/mpack_view.js @@ -0,0 +1,31 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); + +App.WizardMpackView = Em.View.extend({ + templateName: require('templates/wizard/selectMpacks/mpack'), + + version: function() { + return this.get('mpack.versions')[0].version; + }.property(), + + services: function () { + return this.get('mpack.versions')[0].services; + }.property() +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/15347746/ambari-web/app/views/wizard/selectMpacks/selectedMpackVersion_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/wizard/selectMpacks/selectedMpackVersion_view.js b/ambari-web/app/views/wizard/selectMpacks/selectedMpackVersion_view.js new file mode 100644 index 0000000..ca503d7 --- /dev/null +++ b/ambari-web/app/views/wizard/selectMpacks/selectedMpackVersion_view.js @@ -0,0 +1,27 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); + +App.WizardSelectedMpackVersionView = Em.View.extend({ + templateName: require('templates/wizard/selectMpacks/selectedMpackVersion'), + + mpack: function () { + return this.get('mpackVersion.mpack.name'); + }.property() +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/15347746/ambari-web/app/views/wizard/selectMpacks_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/wizard/selectMpacks_view.js b/ambari-web/app/views/wizard/selectMpacks_view.js new file mode 100644 index 0000000..3dc4ec0 --- /dev/null +++ b/ambari-web/app/views/wizard/selectMpacks_view.js @@ -0,0 +1,28 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +var App = require('app'); + +App.WizardSelectMpacksView = Em.View.extend({ + templateName: require('templates/wizard/selectMpacks'), + + didInsertElement: function () { + this.get('controller').loadStep(); + }, +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/15347746/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 a33af65..f581d91 100644 --- a/ambari-web/test/controllers/installer_test.js +++ b/ambari-web/test/controllers/installer_test.js @@ -481,60 +481,6 @@ describe('App.InstallerController', function () { }); }); - describe('Should load stacks', function() { - var loadStacks = false; - var checker = { - loadStacks: function() { - return { - done: function(callback) { - callback(true); - } - }; - } - }; - - beforeEach(function () { - sinon.spy(checker, 'loadStacks'); - installerController.loadMap['step1'][0].callback.call(checker); - }); - - afterEach(function() { - checker.loadStacks.restore(); - }); - - it('should call loadStacks, stack info not loaded', function () { - expect(checker.loadStacks.calledOnce).to.be.true; - }); - }); - - describe('Should load stacks async', function() { - var checker = { - loadStacksVersions: Em.K - }; - - beforeEach(function () { - sinon.spy(checker, 'loadStacksVersions'); - }); - - afterEach(function() { - checker.loadStacksVersions.restore(); - }); - - it('stack versions are loaded', function () { - installerController.loadMap['step1'][1].callback.call(checker, true).then(function(data){ - expect(data).to.be.true; - }); - expect(checker.loadStacksVersions.called).to.be.false; - }); - - it('should call loadStacksVersions, stack versions not loaded', function () { - installerController.loadMap['step1'][1].callback.call(checker, false).then(function(data){ - expect(data).to.be.true; - }); - expect(checker.loadStacksVersions.calledOnce).to.be.true; - }); - }); - describe('Should load installOptions', function() { var installOptions = false; var checker = { @@ -569,23 +515,6 @@ describe('App.InstallerController', function () { }); }); - describe('Should load loadServices', function() { - var loadServices = false; - var checker = { - loadServices: function() { - loadServices = true; - } - }; - - beforeEach(function () { - installerController.loadMap['step4'][0].callback.call(checker); - }); - - it('services are loaded', function () { - expect(loadServices).to.be.true; - }); - }); - describe('Should load loadServices (2)', function() { var setSkipSlavesStep = false; var loadMasterComponentHosts = false; http://git-wip-us.apache.org/repos/asf/ambari/blob/15347746/ambari-web/test/controllers/wizard/selectMpacks_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/selectMpacks_test.js b/ambari-web/test/controllers/wizard/selectMpacks_test.js new file mode 100644 index 0000000..73210b4 --- /dev/null +++ b/ambari-web/test/controllers/wizard/selectMpacks_test.js @@ -0,0 +1,42 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var App = require('app'); +require('controllers/wizard/selectMpacks_controller'); +var wizardSelectMpacksController; + +describe('App.WizardSelectMpacksController', function () { + + before(function () { + wizardSelectMpacksController = App.WizardSelectMpacksController.create(); + }); + + describe('#getMPacks', function () { + before(function () { + + }); + + after(function () { + }); + + it('loads mpacks from registry', function () { + }) + + }); + +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/15347746/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 de43a97..fc977b7 100644 --- a/ambari-web/test/controllers/wizard/step8_test.js +++ b/ambari-web/test/controllers/wizard/step8_test.js @@ -116,12 +116,50 @@ var services = Em.A([ }) ]); +var getStacks = function () { + return Em.A([ + Em.Object.create({isSelected: false, hostName: 'h1'}), + Em.Object.create({ + isSelected: true, + hostName: 'h2', + operatingSystems: Em.A([Em.Object.create({ + name:'windows', + isSelected: true, + repositories: Em.A([Em.Object.create({ + baseUrl: "url", + osType: "2", + repoId: "3" + })]) + })]) + }), + Em.Object.create({isSelected: false, hostName: 'h3'}) + ]); +}; + +var getStack = function () { + return Em.Object.create({ + isSelected: true, + hostName: 'h2', + operatingSystems: Em.A([Em.Object.create({ + name:'windows', + isSelected: true, + repositories: Em.A([Em.Object.create({ + baseUrl: "url", + osType: "2", + repoId: "3" + })]) + })]) + }) +}; + function getController() { return App.WizardStep8Controller.create({ configs: configs, - content: {controllerName: ''} + content: {controllerName: ''}, + getSelectedStack: getStack, + downloadConfig: { useRedhatSatellite: false } }); -} +}; describe('App.WizardStep8Controller', function () { @@ -158,9 +196,11 @@ describe('App.WizardStep8Controller', function () { return Em.Object.create({isSelected: true, isInstalled: false, serviceName: serviceName}); }); installerStep8Controller = App.WizardStep8Controller.create({ - content: {controllerName: 'addServiceController', services: mappedServices}, + content: {controllerName: 'addServiceController'}, + selectedServices: mappedServices, configs: configs }); + var serviceData = installerStep8Controller.createSelectedServicesData(); expect(serviceData.mapProperty('ServiceInfo.service_name')).to.eql(test.selectedServices.toArray()); installerStep8Controller.clearStep(); @@ -530,25 +570,7 @@ describe('App.WizardStep8Controller', function () { describe('#loadClusterInfo', function () { beforeEach(function () { - sinon.stub(App.Stack, 'find', function(){ - return Em.A([ - Em.Object.create({isSelected: false, hostName: 'h1'}), - Em.Object.create({ - isSelected: true, - hostName: 'h2', - operatingSystems: Em.A([Em.Object.create({ - name:'windows', - isSelected: true, - repositories: Em.A([Em.Object.create({ - baseUrl: "url", - osType: "2", - repoId: "3" - })]) - })]) - }), - Em.Object.create({isSelected: false, hostName: 'h3'}) - ]); - }); + sinon.stub(App.Stack, 'find', getStacks); }); afterEach(function () { App.Stack.find.restore(); @@ -1163,7 +1185,17 @@ describe('App.WizardStep8Controller', function () { it('App.currentStackVersion should be changed if localRepo selected', function() { App.set('currentStackVersion', 'HDP-2.3'); - installerStep8Controller.reopen({content: {controllerName: 'installerController', installOptions: {localRepo: true}}}); + installerStep8Controller.reopen({ + content: {controllerName: 'installerController', installOptions: { localRepo: true }}, + getSelectedStack: function () { + return Em.Object.create({ + id: "HDP-2.3-2.3.4.4-1234", + isSelected: true, + repositoryVersion: "2.3.4.4-1234", + stackNameVersion: "HDPLocal-2.3" + }); + } + }); var data = { data: JSON.stringify({ "Clusters": {"version": 'HDPLocal-2.3'}}) }; @@ -1173,7 +1205,17 @@ describe('App.WizardStep8Controller', function () { it('App.currentStackVersion shouldn\'t be changed if localRepo ins\'t selected', function() { App.set('currentStackVersion', 'HDP-2.3'); - installerStep8Controller.reopen({content: {controllerName: 'installerController', installOptions: {localRepo: false}}}); + installerStep8Controller.reopen({ + content: {controllerName: 'installerController', installOptions: { localRepo: false }}, + getSelectedStack: function () { + return Em.Object.create({ + id: "HDP-2.3-2.3.4.4-1234", + isSelected: true, + repositoryVersion: "2.3.4.4-1234", + stackNameVersion: "HDP-2.3" + }); + } + }); var data = { data: JSON.stringify({ "Clusters": {"version": 'HDP-2.3'}}) }; http://git-wip-us.apache.org/repos/asf/ambari/blob/15347746/ambari-web/test/mixins/routers/redirections_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/routers/redirections_test.js b/ambari-web/test/mixins/routers/redirections_test.js index 8e6e372..dffbb98 100644 --- a/ambari-web/test/mixins/routers/redirections_test.js +++ b/ambari-web/test/mixins/routers/redirections_test.js @@ -84,16 +84,16 @@ describe('App.RouterRedirections', function () { it('CLUSTER_NOT_CREATED_1. user is on installer', function () { currentClusterStatus.clusterState = 'CLUSTER_NOT_CREATED_1'; - installerController.setCurrentStep('step4'); + installerController.setCurrentStep('selectMpacks'); router.redirectToInstaller(router, currentClusterStatus, true); - expect(router.transitionTo.calledWith('step4')).to.be.true; + expect(router.transitionTo.calledWith('selectMpacks')).to.be.true; }); it('CLUSTER_NOT_CREATED_1. user is not on installer', function () { currentClusterStatus.clusterState = 'CLUSTER_NOT_CREATED_1'; - installerController.setCurrentStep('step4'); + installerController.setCurrentStep('selectMpacks'); router.redirectToInstaller(router, currentClusterStatus, false); - expect(router.transitionTo.calledWith('installer.step4')).to.be.true; + expect(router.transitionTo.calledWith('installer.selectMpacks')).to.be.true; }); it('CLUSTER_DEPLOY_PREP_2. user is on installer', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/15347746/ambari-web/test/views/installer_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/installer_test.js b/ambari-web/test/views/installer_test.js index cfa0325..80493e7 100644 --- a/ambari-web/test/views/installer_test.js +++ b/ambari-web/test/views/installer_test.js @@ -20,13 +20,8 @@ var App = require('app'); require('views/installer'); -var view, - stepsCount = 11, - properties = []; - -for (var i = 0; i < stepsCount; i++ ) { - properties.push('isStep' + i + 'Disabled'); -} +var view; +var steps; describe('App.InstallerView', function () { @@ -34,6 +29,13 @@ describe('App.InstallerView', function () { view = App.InstallerView.create({ controller: App.InstallerController.create() }); + + steps = view.get('controller.steps'); + + for (var i = 0; i < steps.length; i++ ) { + const stepName = steps[i].charAt(0).toUpperCase() + steps[i].slice(1); + properties.push('is' + stepName + 'Disabled'); + } }); properties.forEach(function (item, index) {
