Repository: ambari Updated Branches: refs/heads/trunk 9218a8ebf -> ee9abd1b1
AMBARI-8457 Rolling Upgrade process: upgrade progress popup. (atkach) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ee9abd1b Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ee9abd1b Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ee9abd1b Branch: refs/heads/trunk Commit: ee9abd1b105e01bb5b6aad092f1754333368d508 Parents: 9218a8e Author: Andrii Tkach <[email protected]> Authored: Wed Nov 26 19:15:01 2014 +0200 Committer: Andrii Tkach <[email protected]> Committed: Wed Nov 26 19:15:01 2014 +0200 ---------------------------------------------------------------------- .../app/assets/data/stack_versions/upgrade.json | 70 ++++++++++++++++++++ ambari-web/app/assets/test/tests.js | 3 +- .../main/admin/stack_and_upgrade_controller.js | 51 ++++++++++++++ ambari-web/app/messages.js | 6 ++ ambari-web/app/styles/application.less | 26 ++++++++ .../stack_upgrade/stack_upgrade_dialog.hbs | 38 +++++++++++ .../main/admin/stack_upgrade/upgrade_task.hbs | 48 ++++++++++++++ ambari-web/app/utils/ajax/ajax.js | 4 ++ ambari-web/app/views.js | 3 +- .../admin/stack_upgrade/upgrade_task_view.js | 63 ++++++++++++++++++ .../stack_upgrade/upgrade_version_box_view.js | 58 ++++++++++++++++ .../main/admin/upgrade_version_box_view.js | 41 ------------ .../admin/stack_and_upgrade_controller_test.js | 51 ++++++++++++++ .../stack_upgrade/upgrade_task_view_test.js | 59 +++++++++++++++++ .../upgrade_version_box_view_test.js | 62 +++++++++++++++++ .../main/admin/upgrade_version_box_view_test.js | 57 ---------------- 16 files changed, 540 insertions(+), 100 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/ee9abd1b/ambari-web/app/assets/data/stack_versions/upgrade.json ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/data/stack_versions/upgrade.json b/ambari-web/app/assets/data/stack_versions/upgrade.json new file mode 100644 index 0000000..33a97b8 --- /dev/null +++ b/ambari-web/app/assets/data/stack_versions/upgrade.json @@ -0,0 +1,70 @@ +{ + "items": [ + { + "UpgradeItem": { + "upgrade_item_id": 1, + "step_index": 1, + "status": "COMPLETED", + "stage_id": 124321, + "command": "Restart Zookeeper Server on host1", + "type": "auto", + "description": "" + } + }, + { + "UpgradeItem": { + "upgrade_item_id": 2, + "step_index": 2, + "status": "WARNING", + "stage_id": 124321, + "command": "Restart Zookeeper Server on host2", + "type": "auto", + "description": "" + } + }, + { + "UpgradeItem": { + "upgrade_item_id": 3, + "step_index": 3, + "status": "IN_PROGRESS", + "stage_id": 124321, + "command": "Run manual steps", + "type": "manual", + "description": "List of manual steps" + } + }, + { + "UpgradeItem": { + "upgrade_item_id": 4, + "step_index": 4, + "status": "PENDING", + "stage_id": 124321, + "command": "Restart Datanode on 2 hosts", + "type": "auto", + "description": "" + } + }, + { + "UpgradeItem": { + "upgrade_item_id": 5, + "step_index": 5, + "status": "PENDING", + "stage_id": 124321, + "command": "Restart Datanode on 2 hosts", + "type": "auto", + "description": "" + } + }, + { + "UpgradeItem": { + "upgrade_item_id": 6, + "step_index": 6, + "status": "FAILED", + "stage_id": 124321, + "command": "Restart Zookeeper Server on host3", + "type": "auto", + "description": "" + } + } + ] +} http://git-wip-us.apache.org/repos/asf/ambari/blob/ee9abd1b/ambari-web/app/assets/test/tests.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js index da05db2..d165276 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -160,7 +160,8 @@ var files = ['test/init_model_test', 'test/views/main/alerts/manage_alert_groups_view_test', 'test/views/main/alerts/manage_alert_notifications_view_test', 'test/views/main/admin/stack_version/stack_version_details_test', - 'test/views/main/admin/upgrade_version_box_view_test', + 'test/views/main/admin/stack_upgrade/upgrade_version_box_view_test', + 'test/views/main/admin/stack_upgrade/upgrade_task_view_test', 'test/views/main/dashboard/config_history_view_test', 'test/views/main/dashboard/widget_test', 'test/views/main/dashboard/widgets_test', http://git-wip-us.apache.org/repos/asf/ambari/blob/ee9abd1b/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 54f853d..bd48b7b 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 @@ -22,6 +22,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend({ name: 'mainAdminStackAndUpgradeController', serviceToInstall: null, + upgradeTasks: [], /** * version that currently applied to server @@ -78,6 +79,33 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend({ }, /** + * load upgrade tasks by upgrade id + * @return {$.ajax} + */ + loadUpgradeTasks: function () { + //TODO should make call with actual upgrade id + var upgradeId = 1; + return App.ajax.send({ + name: 'admin.upgrade.tasks', + sender: this, + data: { + id: upgradeId + }, + success: 'loadUpgradeTasksSuccessCallback' + }); + }, + + /** + * parse and push upgrade tasks to controller + * @param data + */ + loadUpgradeTasksSuccessCallback: function (data) { + this.set("upgradeTasks", data.items.map(function (item) { + return item.UpgradeItem; + })); + }, + + /** * start cluster downgrade */ downgrade: function () { @@ -88,6 +116,8 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend({ */ upgrade: function () { //TODO start actual upgrade + this.loadUpgradeTasks(); + this.openUpgradeDialog(); }, /** * resume upgrade process @@ -100,5 +130,26 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend({ */ finalize: function () { //TODO start actual finalize + }, + + /** + * show dialog with tasks of upgrade + * @return {App.ModalPopup} + */ + openUpgradeDialog: function () { + var upgradeVersion = 'HDP-2.2.1'; + + return App.ModalPopup.show({ + header: Em.I18n.t('admin.stackUpgrade.dialog.header').format(upgradeVersion), + bodyClass: Em.View.extend({ + controller: this, + templateName: require('templates/main/admin/stack_upgrade/stack_upgrade_dialog'), + tasks: function () { + return this.get('controller.upgradeTasks'); + }.property('controller.upgradeTasks') + }), + primary: null, + secondary: null + }); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/ee9abd1b/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index b9e7a92..a77d74d 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -1264,6 +1264,12 @@ Em.I18n.translations = { 'admin.stackUpgrade.state.finalize': "Finalize", 'admin.stackUpgrade.hosts': "hosts", 'admin.stackUpgrade.host': "host", + 'admin.stackUpgrade.dialog.header': "Upgrade to {0} in progress", + 'admin.stackUpgrade.dialog.operationFailed': "This operation failed.", + 'admin.stackUpgrade.dialog.errorLink': "See error message", + 'admin.stackUpgrade.dialog.stop': "Stop Upgrade", + 'admin.stackUpgrade.dialog.continue': "Ignore and Continue", + 'admin.stackUpgrade.dialog.manualDone': "I have preformed the manual steps above.", 'services.service.start':'Start', 'services.service.stop':'Stop', http://git-wip-us.apache.org/repos/asf/ambari/blob/ee9abd1b/ambari-web/app/styles/application.less ---------------------------------------------------------------------- diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less index 83001cc..b4bb625 100644 --- a/ambari-web/app/styles/application.less +++ b/ambari-web/app/styles/application.less @@ -6547,6 +6547,32 @@ i.icon-asterisks { } } +#stack-upgrade-dialog { + .task-list { + overflow: auto; + .task-details { + padding: 2px 4px; + margin-left: 15px; + .button-row { + text-align: right; + padding: 5px; + } + input[type="checkbox"] { + margin: 0; + } + .message { + line-height: 30px; + } + } + } + .task-list>div { + padding: 5px; + i { + margin-right: 5px; + } + } +} + #config-group-select-create-dialog { .select-create-config-group-div { margin-left: 20px; http://git-wip-us.apache.org/repos/asf/ambari/blob/ee9abd1b/ambari-web/app/templates/main/admin/stack_upgrade/stack_upgrade_dialog.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/admin/stack_upgrade/stack_upgrade_dialog.hbs b/ambari-web/app/templates/main/admin/stack_upgrade/stack_upgrade_dialog.hbs new file mode 100644 index 0000000..bdb650e --- /dev/null +++ b/ambari-web/app/templates/main/admin/stack_upgrade/stack_upgrade_dialog.hbs @@ -0,0 +1,38 @@ +{{! +* 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. +}} + +<div id="stack-upgrade-dialog"> + + <div class="row-fluid"> + <div class="span2">{{t common.progress}}</div> + <div class="span9"> + <div class="progress progress-striped active"> + <div class="bar" style="width: 40%;"></div> + </div> + </div> + <div class="span1"> + 40% + </div> + </div> + + <div class="task-list"> + {{#each task in view.tasks}} + {{view App.upgradeTaskView contentBinding="task"}} + {{/each}} + </div> +</div> http://git-wip-us.apache.org/repos/asf/ambari/blob/ee9abd1b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_task.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_task.hbs b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_task.hbs new file mode 100644 index 0000000..67e373f --- /dev/null +++ b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_task.hbs @@ -0,0 +1,48 @@ +{{! +* 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. +}} + +<i {{bindAttr class="view.iconClass"}}></i><span>{{view.content.command}}</span> +{{#if view.isFailed}} + <div class="box task-details"> + <div> + {{t admin.stackUpgrade.dialog.operationFailed}} + <a href>{{t admin.stackUpgrade.dialog.errorLink}}</a> + </div> + <div class="button-row"> + <button class="btn">{{t admin.stackUpgrade.dialog.continue}}</button> + <button class="btn btn-danger">{{t admin.stackUpgrade.dialog.stop}}</button> + <button class="btn btn-primary">{{t common.retry}}</button> + </div> + </div> +{{/if}} +{{#if view.isManualOpened}} + <div class="task-details"> + <div class="alert alert-info"> + {{view.content.description}} + </div> + <div class="row-fluid"> + <div class="span10 message"> + {{view Em.Checkbox valueBinding="view.isManualDone"}} + {{t admin.stackUpgrade.dialog.manualDone}} + </div> + <div class="span2"> + <button class="btn btn-success pull-right">{{t common.proceed}}</button> + </div> + </div> + </div> +{{/if}} http://git-wip-us.apache.org/repos/asf/ambari/blob/ee9abd1b/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 4c3d74d..e162719 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -1267,6 +1267,10 @@ var urls = { 'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*', 'mock': '/data/wizard/{mock}' }, + 'admin.upgrade.tasks': { + 'real': '/clusters/{clusterName}/upgrades/{id}/upgrade_items', + 'mock': '/data/stack_versions/upgrade.json' + }, 'admin.stack_versions.all': { 'real': '/clusters/{clusterName}/stack_versions?fields=ClusterStackVersions/*&minimal_response=true', 'mock': '/data/stack_versions/stack_version_all.json' http://git-wip-us.apache.org/repos/asf/ambari/blob/ee9abd1b/ambari-web/app/views.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js index a36006f..9e21516 100644 --- a/ambari-web/app/views.js +++ b/ambari-web/app/views.js @@ -104,7 +104,8 @@ require('views/main/admin/highAvailability/resourceManager/step3_view'); require('views/main/admin/highAvailability/resourceManager/step4_view'); require('views/main/admin/serviceAccounts_view'); require('views/main/admin/stack_upgrade'); -require('views/main/admin/upgrade_version_box_view'); +require('views/main/admin/stack_upgrade/upgrade_version_box_view'); +require('views/main/admin/stack_upgrade/upgrade_task_view'); require('views/main/admin/stack_and_upgrade_view'); require('views/main/admin/stack_versions/stack_version_view'); require('views/main/admin/stack_versions/stack_version_details_view'); http://git-wip-us.apache.org/repos/asf/ambari/blob/ee9abd1b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js new file mode 100644 index 0000000..b88219a --- /dev/null +++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js @@ -0,0 +1,63 @@ +/** + * 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.upgradeTaskView = Em.View.extend({ + templateName: require('templates/main/admin/stack_upgrade/upgrade_task'), + + /** + * @type {object|null} + */ + task: null, + + statusIconMap: { + 'COMPLETED': 'icon-ok', + 'WARNING': 'icon-warning-sign', + 'FAILED': 'icon-warning-sign', + 'PENDING': 'icon-cog' + }, + + /** + * @type {boolean} + */ + isManualDone: false, + + /** + * @type {string} + */ + iconClass: function () { + return this.get('statusIconMap')[this.get('content.status')] || 'icon-question-sign'; + }.property('content.status'), + + /** + * @type {boolean} + */ + isFailed: function () { + return this.get('content.status') === 'FAILED'; + }.property('content.status'), + + /** + * @type {boolean} + */ + isManualOpened: function () { + //TODO modify logic according to actual API + return this.get('content.status') === 'IN_PROGRESS' && this.get('content.type') === 'manual' + }.property('content.status', 'content.type') +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ee9abd1b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js new file mode 100644 index 0000000..9689bef --- /dev/null +++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js @@ -0,0 +1,58 @@ +/** + * 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.UpgradeVersionBoxView = Em.View.extend({ + /** + * @type {object|null} + */ + version: null, + + /** + * @type {string} + */ + versionName: function () { + if (Em.isNone(this.get('version'))) return ""; + return this.get('version.stack') + "-" + this.get('version.version'); + }.property('version.stack', 'version.version'), + + /** + * @type {string} + */ + btnClass: 'btn-default', + + /** + * @type {number} + */ + hostsCount: 0, + + /** + * run action by name of method + * @param event + * @return {Boolean} + */ + runAction: function (event) { + if (typeof this.get('controller')[event.context] === 'function') { + this.get('controller')[event.context](); + return true; + } + return false; + } +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ee9abd1b/ambari-web/app/views/main/admin/upgrade_version_box_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/upgrade_version_box_view.js b/ambari-web/app/views/main/admin/upgrade_version_box_view.js deleted file mode 100644 index a071324..0000000 --- a/ambari-web/app/views/main/admin/upgrade_version_box_view.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * 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.UpgradeVersionBoxView = Em.View.extend({ - version: null, - versionName: function () { - return this.get('version.stack') + "-" + this.get('version.version'); - }.property('version.stack', 'version.version'), - btnClass: 'btn-default', - hostsCount: null, - /** - * run action by name of method - * @param event - * @return {Boolean} - */ - runAction: function (event) { - if (typeof this.get('controller')[event.context] === 'function') { - this.get('controller')[event.context](); - return true; - } - return false; - } -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ee9abd1b/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 4e9e1bf..0fb32f4 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 @@ -105,4 +105,55 @@ describe('App.MainAdminStackAndUpgradeController', function() { }]); }); }); + + describe("#loadUpgradeTasks()", function() { + before(function () { + sinon.stub(App.ajax, 'send', Em.K); + }); + after(function () { + App.ajax.send.restore(); + }); + it("make ajax call", function() { + controller.loadUpgradeTasks(); + expect(App.ajax.send.getCall(0).args[0]).to.eql({ + name: 'admin.upgrade.tasks', + sender: controller, + data: { + id: 1 + }, + success: 'loadUpgradeTasksSuccessCallback' + }) + }); + }); + + describe("#loadUpgradeTasksSuccessCallback()", function() { + it("", function() { + var data = {"items": [ + { + "UpgradeItem": { + "id": 1 + } + } + ]}; + controller.loadUpgradeTasksSuccessCallback(data); + expect(controller.get('upgradeTasks')).to.eql([ + { + "id": 1 + } + ]); + }); + }); + + describe("#openUpgradeDialog()", function () { + before(function () { + sinon.stub(App.ModalPopup, 'show', Em.K); + }); + after(function () { + App.ModalPopup.show.restore(); + }); + it("should open dialog", function () { + controller.openUpgradeDialog(); + expect(App.ModalPopup.show.calledOnce).to.be.true; + }); + }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/ee9abd1b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js new file mode 100644 index 0000000..7fcd08c --- /dev/null +++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js @@ -0,0 +1,59 @@ +/** + * 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('views/main/admin/stack_upgrade/upgrade_task_view'); + +describe('App.upgradeTaskView', function () { + var view = App.upgradeTaskView.create({ + content: Em.Object.create() + }); + + describe("#iconClass", function () { + it("status has icon", function () { + view.set('statusIconMap', { + 'S1': 'icon1' + }); + view.set('content.status', 'S1'); + view.propertyDidChange('iconClass'); + expect(view.get('iconClass')).to.equal('icon1'); + }); + it("status undefined", function () { + view.set('statusIconMap', { + 'S1': 'icon1' + }); + view.set('content.status', 'S2'); + view.propertyDidChange('iconClass'); + expect(view.get('iconClass')).to.equal('icon-question-sign'); + }); + }); + + describe("#isFailed", function () { + it("task is not failed", function () { + view.set('content.status', 'COMPLETED'); + view.propertyDidChange('isFailed'); + expect(view.get('isFailed')).to.be.false; + }); + it("task is not failed", function () { + view.set('content.status', 'FAILED'); + view.propertyDidChange('isFailed'); + expect(view.get('isFailed')).to.be.true; + }); + }); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/ee9abd1b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js new file mode 100644 index 0000000..7e277e5 --- /dev/null +++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js @@ -0,0 +1,62 @@ +/** + * 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('views/main/admin/stack_upgrade/upgrade_version_box_view'); + +describe('App.UpgradeVersionBoxView', function () { + var view = App.UpgradeVersionBoxView.create({ + controller: Em.Object.create({ + upgrade: Em.K + }) + }); + + describe("#versionName", function () { + it("version is null", function () { + view.set('version', null); + view.propertyDidChange('versionName'); + expect(view.get('versionName')).to.be.empty; + }); + it("version is loaded", function () { + view.set('version', Em.Object.create({ + stack: 'HDP', + version: '2.2' + })); + view.propertyDidChange('versionName'); + expect(view.get('versionName')).to.equal('HDP-2.2'); + }); + }); + + describe("#runAction()", function () { + beforeEach(function () { + sinon.spy(view.get('controller'), 'upgrade'); + }); + afterEach(function () { + view.get('controller').upgrade.restore(); + }); + it("call upgrade()", function () { + expect(view.runAction({context: 'upgrade'})).to.be.true; + expect(view.get('controller').upgrade.calledOnce).to.be.true; + }); + it("no method should be called", function () { + expect(view.runAction({context: null})).to.be.false; + expect(view.get('controller').upgrade.called).to.be.false; + }); + }); +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/ee9abd1b/ambari-web/test/views/main/admin/upgrade_version_box_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/admin/upgrade_version_box_view_test.js b/ambari-web/test/views/main/admin/upgrade_version_box_view_test.js deleted file mode 100644 index 79436ac..0000000 --- a/ambari-web/test/views/main/admin/upgrade_version_box_view_test.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * 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('views/main/admin/upgrade_version_box_view'); - -describe('App.UpgradeVersionBoxView', function () { - var view = App.UpgradeVersionBoxView.create({ - controller: Em.Object.create({ - upgrade: Em.K - }) - }); - - describe("#versionName", function () { - it("", function () { - view.set('version', Em.Object.create({ - stack: 'HDP', - version: '2.2' - })); - view.propertyDidChange('versionName'); - expect(view.get('versionName')).to.equal('HDP-2.2'); - }); - }); - - describe("#runAction()", function () { - beforeEach(function () { - sinon.spy(view.get('controller'), 'upgrade'); - }); - afterEach(function () { - view.get('controller').upgrade.restore(); - }); - it("call upgrade()", function () { - expect(view.runAction({context: 'upgrade'})).to.be.true; - expect(view.get('controller').upgrade.calledOnce).to.be.true; - }); - it("no method should be called", function () { - expect(view.runAction({context: null})).to.be.false; - expect(view.get('controller').upgrade.called).to.be.false; - }); - }); -}); \ No newline at end of file
