From dfb2555370ecae60a17f5433727830049c6c9dd8 Mon Sep 17 00:00:00 2001 From: Santiago Petrone Date: Fri, 30 Sep 2016 12:21:23 +0200 Subject: [PATCH 1/7] Basic Service Integration --- ...rade7-nodes-repositories-checks.controller.js | 16 ++++++++++++---- .../upgrade7/nodes-repositories-checks-page.jade | 14 +++++++++++--- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js b/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js index 92d6e924..31bf2434 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js +++ b/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js @@ -19,7 +19,7 @@ completed: false, valid: false, checks: { - 'SLES_12_SP2': { + 'os': { status: false, label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLES_12_SP2' }, @@ -52,13 +52,16 @@ label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE_Enterprise_Storage_4_Updates' } }, - runRepoChecks: runRepoChecks + runRepoChecks: runRepoChecks, + running: false, + spinnerVisible: false }; /** * Validate Nodes Repositories required for Cloud 7 Upgrade */ function runRepoChecks() { + vm.repoChecks.running = true; upgradeRepositoriesChecksFactory.getNodesRepoChecks() .then( @@ -66,14 +69,17 @@ function (repoChecksResponse) { _.forEach(repoChecksResponse.data, function(value, key) { - vm.repoChecks.checks[key].status = value; + // Validate we're updating a valid check from the service + if (vm.repoChecks.checks.hasOwnProperty(key)) { + vm.repoChecks.checks[key].status = value.available; + } }); var repoChecksResult = true; // Update prechecks status _.forEach(vm.repoChecks.checks, function (repoStatus) { - + if (false === repoStatus.status) { repoChecksResult = false; return false; @@ -92,6 +98,8 @@ .finally(function () { // Either on sucess or failure, the repoChecks has been completed. vm.repoChecks.completed = true; + // And the spinner must be stopped and hidden + vm.repoChecks.running = false; }); } } diff --git a/assets/app/features/upgrade/templates/upgrade7/nodes-repositories-checks-page.jade b/assets/app/features/upgrade/templates/upgrade7/nodes-repositories-checks-page.jade index 24cb4e4a..7ba76d6d 100644 --- a/assets/app/features/upgrade/templates/upgrade7/nodes-repositories-checks-page.jade +++ b/assets/app/features/upgrade/templates/upgrade7/nodes-repositories-checks-page.jade @@ -5,6 +5,14 @@ div.checks-container crowbar-checklist(checklist='upgradeNodesRepoChecksVm.repoChecks.checks', completed='upgradeNodesRepoChecksVm.repoChecks.completed') - button.btn.btn-success.pull-left(translate='', - ng-class="{disabled: upgradeNodesRepoChecksVm.repoChecks.completed && upgradeNodesRepoChecksVm.repoChecks.valid}", - ng-click="upgradeNodesRepoChecksVm.repoChecks.runRepoChecks()") upgrade7.steps.nodes-repository-checks.form.check-again + button.btn.btn-success.pull-left( + ng-click="upgradeNodesRepoChecksVm.repoChecks.runRepoChecks()" + ng-disabled="(upgradeNodesRepoChecksVm.repoChecks.completed && upgradeNodesRepoChecksVm.repoChecks.valid) || upgradeNodesRepoChecksVm.repoChecks.running", + ng-class="{\ + 'spinner-visible': upgradeNodesRepoChecksVm.repoChecks.spinnerVisible,\ + active: upgradeNodesRepoChecksVm.repoChecks.running\ + }", + ) + suse-lazy-spinner(delay="2000", active="upgradeNodesRepoChecksVm.repoChecks.running", + visible="upgradeNodesRepoChecksVm.repoChecks.spinnerVisible") + span(translate='') upgrade7.steps.nodes-repository-checks.form.check-again \ No newline at end of file From d9e5b3469a08c89a849c4158fc74fd5d4d0bb1c9 Mon Sep 17 00:00:00 2001 From: Santiago Petrone Date: Wed, 5 Oct 2016 19:40:15 +0200 Subject: [PATCH 2/7] Integrate with /api/upgrade/repocheck real endpoint --- app.js | 4 +- .../upgrade/repositories-checks.factory.js | 2 +- .../repositories-checks.factory.spec.js | 2 +- ...e7-nodes-repositories-checks.controller.js | 133 ++++++++++++------ assets/app/features/upgrade/i18n/en.json | 16 +-- .../app/features/upgrade/upgrade.constants.js | 11 ++ assets/index.jade | 1 + routes/api/upgrade/repocheck.js | 26 ++++ routes/api/upgrade7/nodes-repo-checks.js | 18 --- 9 files changed, 142 insertions(+), 71 deletions(-) create mode 100644 assets/app/features/upgrade/upgrade.constants.js create mode 100644 routes/api/upgrade/repocheck.js delete mode 100644 routes/api/upgrade7/nodes-repo-checks.js diff --git a/app.js b/app.js index de4e813f..02672716 100644 --- a/app.js +++ b/app.js @@ -12,7 +12,7 @@ var express = require('express'), upgrade7Backup = require('./routes/api/upgrade7/backup'), upgrade7AdminRepoChecks = require('./routes/api/upgrade7/admin-repo-checks'), upgrade7AdminUpgrade = require('./routes/api/upgrade7/admin-upgrade'), - upgrade7NodesRepoChecks = require('./routes/api/upgrade7/nodes-repo-checks'), + upgrade7NodesRepoChecks = require('./routes/api/upgrade/repocheck'), app = express(); @@ -31,7 +31,7 @@ app.use('/api/upgrade7/prechecks', upgrade7Prechecks); app.use('/api/upgrade7/backup', upgrade7Backup); app.use('/api/upgrade7/admin-repo-checks', upgrade7AdminRepoChecks); app.use('/api/upgrade7/admin-upgrade', upgrade7AdminUpgrade); -app.use('/api/upgrade7/nodes-repo-checks', upgrade7NodesRepoChecks); +app.use('/api/upgrade/repocheck', upgrade7NodesRepoChecks); // catch 404 and forward to error handler app.use(function(req, res, next) { diff --git a/assets/app/data/services/upgrade/repositories-checks.factory.js b/assets/app/data/services/upgrade/repositories-checks.factory.js index 515a187d..9350e88e 100644 --- a/assets/app/data/services/upgrade/repositories-checks.factory.js +++ b/assets/app/data/services/upgrade/repositories-checks.factory.js @@ -29,7 +29,7 @@ var requestOptions = { method: 'GET', - url: '/api/upgrade7/nodes-repo-checks', + url: '/api/upgrade/repocheck', headers: COMMON_API_V2_HEADERS }; diff --git a/assets/app/data/services/upgrade/repositories-checks.factory.spec.js b/assets/app/data/services/upgrade/repositories-checks.factory.spec.js index dc7fb36a..0208820f 100644 --- a/assets/app/data/services/upgrade/repositories-checks.factory.spec.js +++ b/assets/app/data/services/upgrade/repositories-checks.factory.spec.js @@ -73,7 +73,7 @@ describe('Upgrade Repo Checks Factory', function () { beforeEach(function () { - $httpBackend.expect('GET', '/api/upgrade7/nodes-repo-checks') + $httpBackend.expect('GET', '/api/upgrade/repocheck') .respond(200, mockedNodesRepoChecksData); nodesRepoChecksPromise = upgradeRepositoriesChecksFactory.getNodesRepoChecks(); }); diff --git a/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js b/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js index 31bf2434..a0b3393d 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js +++ b/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js @@ -11,45 +11,53 @@ angular.module('crowbarApp') .controller('Upgrade7NodesRepositoriesCheckController', Upgrade7NodesRepositoriesCheckController); - Upgrade7NodesRepositoriesCheckController.$inject = ['$translate', 'upgradeRepositoriesChecksFactory']; + Upgrade7NodesRepositoriesCheckController.$inject = [ + '$translate', + 'upgradeRepositoriesChecksFactory', + 'NODES_PRODUCTS_REPO_CHECKS_MAP' + ]; // @ngInject - function Upgrade7NodesRepositoriesCheckController($translate, upgradeRepositoriesChecksFactory) { + function Upgrade7NodesRepositoriesCheckController( + $translate, + upgradeRepositoriesChecksFactory, + NODES_PRODUCTS_REPO_CHECKS_MAP + ) { var vm = this; vm.repoChecks = { completed: false, valid: false, checks: { - 'os': { + 'SLES12-SP2-Pool': { status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLES_12_SP2' + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLES12-SP2-Pool' }, - 'SLES_12_SP2_Updates': { + 'SLES12-SP2-Updates': { status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLES_12_SP2_Updates' + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLES12-SP2-Updates' }, - 'SLES_OpenStack_Cloud_7': { + 'SUSE-OpenStack-Cloud-7-Pool': { status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLES_OpenStack_Cloud_7' + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE-OpenStack-Cloud-7-Pool' }, - 'SLES_OpenStack_Cloud_7_Updates': { + 'SUSE-OpenStack-Cloud-7-Updates': { status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLES_OpenStack_Cloud_7_Updates' + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE-OpenStack-Cloud-7-Updates' }, - 'SLE_HA_12_SP2': { + 'SLE12-SP2-HA-Pool': { status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLE_HA_12_SP2' + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLE12-SP2-HA-Pool' }, - 'SLE_HA_12_SP2_Updates': { + 'SLE12-SP2-HA-Updates': { status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLE_HA_12_SP2_Updates' + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLE12-SP2-HA-Updates' }, - 'SUSE_Enterprise_Storage_4': { + 'SUSE-Enterprise-Storage-4-Pool': { status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE_Enterprise_Storage_4' + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE-Enterprise-Storage-4-Pool' }, - 'SUSE_Enterprise_Storage_4_Updates': { + 'SUSE-Enterprise-Storage-4-Updates': { status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE_Enterprise_Storage_4_Updates' + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE-Enterprise-Storage-4-Updates' } }, runRepoChecks: runRepoChecks, @@ -66,29 +74,7 @@ upgradeRepositoriesChecksFactory.getNodesRepoChecks() .then( // In case of success - function (repoChecksResponse) { - - _.forEach(repoChecksResponse.data, function(value, key) { - // Validate we're updating a valid check from the service - if (vm.repoChecks.checks.hasOwnProperty(key)) { - vm.repoChecks.checks[key].status = value.available; - } - }); - - var repoChecksResult = true; - // Update prechecks status - - _.forEach(vm.repoChecks.checks, function (repoStatus) { - - if (false === repoStatus.status) { - repoChecksResult = false; - return false; - } - }); - - // Update prechecks validity - vm.repoChecks.valid = repoChecksResult; - }, + onSuccessGetNodesRepoChecks, // In case of failure function (errorRepoChecksResponse) { // Expose the error list to repoChecks object @@ -102,5 +88,70 @@ vm.repoChecks.running = false; }); } + + function onSuccessGetNodesRepoChecks (repoChecksResponse) { + + var failingRepositories = [], + repoChecksResult = true; + + // Iterate over each product check returned from the service + _.forEach(repoChecksResponse.data, function(productValue, productKey) { + + // Validate a valid check from the service is being updated + if (NODES_PRODUCTS_REPO_CHECKS_MAP.hasOwnProperty(productKey)) { + + // Iterate through the repositories list for the product + _.forEach(NODES_PRODUCTS_REPO_CHECKS_MAP[productKey], function (repoName) { + + // If the product is available, then its related repositories should be displayed as passing + if (productValue.available) { + vm.repoChecks.checks[repoName].status = true; + + // If not, each/all failing repositories must be identified and marked as failing + } else { + + /* + * If an empty repos details are provided by the service, + * add all related repositories as to the failing repositories collection. + */ + if (_.isEmpty(productValue.repos)) { + + failingRepositories.push(repoName); + + /* + * If the repos details are provided by the service, + * iterate through the repository problems, repository architectures and repositories list + */ + } else { + _.forEach(productValue.repos, function (repoProblemType) { + _.forEach(repoProblemType, function (repoArchitectureType) { + _.forEach(repoArchitectureType, function (unavailableRepository) { + + // Add the unavailable repository, to the failing repositories collection. + if (!_.includes(failingRepositories, unavailableRepository)) { + failingRepositories.push(unavailableRepository); + } + }); + }); + }); + } + } + }); + } + }); + + // Go through the complete repository list and update their status + _.forEach(vm.repoChecks.checks, function (repositoryValue, repositoryKey) { + + // If the repository is included in the failing repositories collection, mark its status as false + repositoryValue.status = !_.includes(failingRepositories, repositoryKey); + + // Validate if there is any failing repository check + repoChecksResult = repoChecksResult && repositoryValue.status; + }); + + // Update the vm valid attribute (Used by the view to enable/disable the check button) + vm.repoChecks.valid = repoChecksResult; + } } })(); diff --git a/assets/app/features/upgrade/i18n/en.json b/assets/app/features/upgrade/i18n/en.json index 0280c7e2..8ba453c4 100644 --- a/assets/app/features/upgrade/i18n/en.json +++ b/assets/app/features/upgrade/i18n/en.json @@ -162,14 +162,14 @@ "description": "Please update the repository information on the CEPH and HA add-on products as well as the SUSE OpenStack Cloud 7 and SLES12 SP2 repositories used by the compute plane.", "repositories": { "codes": { - "SLES_12_SP2": "SUSE Linux Enterprise Server 12 SP2", - "SLES_12_SP2_Updates": "SUSE Linux Enterprise Server 12 SP2 Updates", - "SLES_OpenStack_Cloud_7": "SUSE Linux OpenStack Cloud 7", - "SLES_OpenStack_Cloud_7_Updates": "SUSE Linux OpenStack Cloud 7 Updates", - "SLE_HA_12_SP2": "SUSE Linux Enterprise 12 SP2 High Availability", - "SLE_HA_12_SP2_Updates": "SUSE Linux Enterprise 12 SP2 High Availability Updates", - "SUSE_Enterprise_Storage_4": "SUSE Linux Enterprise Storage 4", - "SUSE_Enterprise_Storage_4_Updates": "SUSE Linux Enterprise Storage 4 Updates" + "SLES12-SP2-Pool": "SUSE Linux Enterprise Server 12 SP2", + "SLES12-SP2-Updates": "SUSE Linux Enterprise Server 12 SP2 Updates", + "SUSE-OpenStack-Cloud-7-Pool": "SUSE Linux OpenStack Cloud 7", + "SUSE-OpenStack-Cloud-7-Updates": "SUSE Linux OpenStack Cloud 7 Updates", + "SLE12-SP2-HA-Pool": "SUSE Linux Enterprise 12 SP2 High Availability", + "SLE12-SP2-HA-Updates": "SUSE Linux Enterprise 12 SP2 High Availability Updates", + "SUSE-Enterprise-Storage-4-Pool": "SUSE Linux Enterprise Storage 4", + "SUSE-Enterprise-Storage-4-Updates": "SUSE Linux Enterprise Storage 4 Updates" } }, "form": { diff --git a/assets/app/features/upgrade/upgrade.constants.js b/assets/app/features/upgrade/upgrade.constants.js new file mode 100644 index 00000000..e376469e --- /dev/null +++ b/assets/app/features/upgrade/upgrade.constants.js @@ -0,0 +1,11 @@ +(function() { + + angular + .module('crowbarApp.upgrade') + .constant('NODES_PRODUCTS_REPO_CHECKS_MAP', { + 'os': ['SLES12-SP2-Pool', 'SLES12-SP2-Updates'], + 'ha': ['SLE12-SP2-HA-Pool', 'SLE12-SP2-HA-Updates'], + 'openstack': ['SUSE-OpenStack-Cloud-7-Pool', 'SUSE-OpenStack-Cloud-7-Updates'], + 'ceph': ['SUSE-Enterprise-Storage-4-Pool', 'SUSE-Enterprise-Storage-4-Updates'] + }); +})(); diff --git a/assets/index.jade b/assets/index.jade index 7cfb0006..c9697c7d 100644 --- a/assets/index.jade +++ b/assets/index.jade @@ -46,6 +46,7 @@ html(ng-app='crowbarApp') // Upgrade State script(src='app/features/upgrade/upgrade.module.js') script(src='app/features/upgrade/upgrade.config.js') + script(src='app/features/upgrade/upgrade.constants.js') script(src='app/features/upgrade/upgrade.controller.js') // Upgrade 7 script(src='app/features/upgrade/upgrade7.controller.js') diff --git a/routes/api/upgrade/repocheck.js b/routes/api/upgrade/repocheck.js new file mode 100644 index 00000000..28bc3b5e --- /dev/null +++ b/routes/api/upgrade/repocheck.js @@ -0,0 +1,26 @@ +var express = require('express'), + router = express.Router(); + +/* GET Nodes Repo Checks. */ +router.get('/', function(req, res) { + res.status(200).json({ + 'ceph': { + 'available': true, + 'repos': {} + }, + 'ha': { + 'available': true, + 'repos': {} + }, + 'os': { + 'available': true, + 'repos': {} + }, + 'openstack': { + 'available': true, + 'repos': {} + } + }); +}); + +module.exports = router; diff --git a/routes/api/upgrade7/nodes-repo-checks.js b/routes/api/upgrade7/nodes-repo-checks.js deleted file mode 100644 index 633a4716..00000000 --- a/routes/api/upgrade7/nodes-repo-checks.js +++ /dev/null @@ -1,18 +0,0 @@ -var express = require('express'), - router = express.Router(); - -/* GET Nodes Repo Checks. */ -router.get('/', function(req, res) { - res.status(200).json({ - 'SLES_12_SP2': true, - 'SLES_12_SP2_Updates': true, - 'SLES_OpenStack_Cloud_7': true, - 'SLES_OpenStack_Cloud_7_Updates': true, - 'SLE_HA_12_SP2': true, - 'SLE_HA_12_SP2_Updates': true, - 'SUSE_Enterprise_Storage_4': true, - 'SUSE_Enterprise_Storage_4_Updates': true - }); -}); - -module.exports = router; From 6b189f3ba13c91bd70087e58720d44e3338b4287 Mon Sep 17 00:00:00 2001 From: Santiago Petrone Date: Wed, 5 Oct 2016 19:40:15 +0200 Subject: [PATCH 3/7] Integrate with /api/upgrade/repocheck real endpoint --- app.js | 4 +- .../upgrade/repositories-checks.factory.js | 2 +- .../repositories-checks.factory.spec.js | 2 +- ...e7-nodes-repositories-checks.controller.js | 133 ++++++++++++------ assets/app/features/upgrade/i18n/en.json | 16 +-- .../nodes-repositories-checks-page.jade | 2 +- .../app/features/upgrade/upgrade.constants.js | 11 ++ assets/index.jade | 1 + routes/api/upgrade/repocheck.js | 26 ++++ routes/api/upgrade7/nodes-repo-checks.js | 18 --- 10 files changed, 143 insertions(+), 72 deletions(-) create mode 100644 assets/app/features/upgrade/upgrade.constants.js create mode 100644 routes/api/upgrade/repocheck.js delete mode 100644 routes/api/upgrade7/nodes-repo-checks.js diff --git a/app.js b/app.js index de4e813f..02672716 100644 --- a/app.js +++ b/app.js @@ -12,7 +12,7 @@ var express = require('express'), upgrade7Backup = require('./routes/api/upgrade7/backup'), upgrade7AdminRepoChecks = require('./routes/api/upgrade7/admin-repo-checks'), upgrade7AdminUpgrade = require('./routes/api/upgrade7/admin-upgrade'), - upgrade7NodesRepoChecks = require('./routes/api/upgrade7/nodes-repo-checks'), + upgrade7NodesRepoChecks = require('./routes/api/upgrade/repocheck'), app = express(); @@ -31,7 +31,7 @@ app.use('/api/upgrade7/prechecks', upgrade7Prechecks); app.use('/api/upgrade7/backup', upgrade7Backup); app.use('/api/upgrade7/admin-repo-checks', upgrade7AdminRepoChecks); app.use('/api/upgrade7/admin-upgrade', upgrade7AdminUpgrade); -app.use('/api/upgrade7/nodes-repo-checks', upgrade7NodesRepoChecks); +app.use('/api/upgrade/repocheck', upgrade7NodesRepoChecks); // catch 404 and forward to error handler app.use(function(req, res, next) { diff --git a/assets/app/data/services/upgrade/repositories-checks.factory.js b/assets/app/data/services/upgrade/repositories-checks.factory.js index 515a187d..9350e88e 100644 --- a/assets/app/data/services/upgrade/repositories-checks.factory.js +++ b/assets/app/data/services/upgrade/repositories-checks.factory.js @@ -29,7 +29,7 @@ var requestOptions = { method: 'GET', - url: '/api/upgrade7/nodes-repo-checks', + url: '/api/upgrade/repocheck', headers: COMMON_API_V2_HEADERS }; diff --git a/assets/app/data/services/upgrade/repositories-checks.factory.spec.js b/assets/app/data/services/upgrade/repositories-checks.factory.spec.js index dc7fb36a..0208820f 100644 --- a/assets/app/data/services/upgrade/repositories-checks.factory.spec.js +++ b/assets/app/data/services/upgrade/repositories-checks.factory.spec.js @@ -73,7 +73,7 @@ describe('Upgrade Repo Checks Factory', function () { beforeEach(function () { - $httpBackend.expect('GET', '/api/upgrade7/nodes-repo-checks') + $httpBackend.expect('GET', '/api/upgrade/repocheck') .respond(200, mockedNodesRepoChecksData); nodesRepoChecksPromise = upgradeRepositoriesChecksFactory.getNodesRepoChecks(); }); diff --git a/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js b/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js index 31bf2434..a0b3393d 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js +++ b/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js @@ -11,45 +11,53 @@ angular.module('crowbarApp') .controller('Upgrade7NodesRepositoriesCheckController', Upgrade7NodesRepositoriesCheckController); - Upgrade7NodesRepositoriesCheckController.$inject = ['$translate', 'upgradeRepositoriesChecksFactory']; + Upgrade7NodesRepositoriesCheckController.$inject = [ + '$translate', + 'upgradeRepositoriesChecksFactory', + 'NODES_PRODUCTS_REPO_CHECKS_MAP' + ]; // @ngInject - function Upgrade7NodesRepositoriesCheckController($translate, upgradeRepositoriesChecksFactory) { + function Upgrade7NodesRepositoriesCheckController( + $translate, + upgradeRepositoriesChecksFactory, + NODES_PRODUCTS_REPO_CHECKS_MAP + ) { var vm = this; vm.repoChecks = { completed: false, valid: false, checks: { - 'os': { + 'SLES12-SP2-Pool': { status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLES_12_SP2' + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLES12-SP2-Pool' }, - 'SLES_12_SP2_Updates': { + 'SLES12-SP2-Updates': { status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLES_12_SP2_Updates' + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLES12-SP2-Updates' }, - 'SLES_OpenStack_Cloud_7': { + 'SUSE-OpenStack-Cloud-7-Pool': { status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLES_OpenStack_Cloud_7' + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE-OpenStack-Cloud-7-Pool' }, - 'SLES_OpenStack_Cloud_7_Updates': { + 'SUSE-OpenStack-Cloud-7-Updates': { status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLES_OpenStack_Cloud_7_Updates' + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE-OpenStack-Cloud-7-Updates' }, - 'SLE_HA_12_SP2': { + 'SLE12-SP2-HA-Pool': { status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLE_HA_12_SP2' + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLE12-SP2-HA-Pool' }, - 'SLE_HA_12_SP2_Updates': { + 'SLE12-SP2-HA-Updates': { status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLE_HA_12_SP2_Updates' + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLE12-SP2-HA-Updates' }, - 'SUSE_Enterprise_Storage_4': { + 'SUSE-Enterprise-Storage-4-Pool': { status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE_Enterprise_Storage_4' + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE-Enterprise-Storage-4-Pool' }, - 'SUSE_Enterprise_Storage_4_Updates': { + 'SUSE-Enterprise-Storage-4-Updates': { status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE_Enterprise_Storage_4_Updates' + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE-Enterprise-Storage-4-Updates' } }, runRepoChecks: runRepoChecks, @@ -66,29 +74,7 @@ upgradeRepositoriesChecksFactory.getNodesRepoChecks() .then( // In case of success - function (repoChecksResponse) { - - _.forEach(repoChecksResponse.data, function(value, key) { - // Validate we're updating a valid check from the service - if (vm.repoChecks.checks.hasOwnProperty(key)) { - vm.repoChecks.checks[key].status = value.available; - } - }); - - var repoChecksResult = true; - // Update prechecks status - - _.forEach(vm.repoChecks.checks, function (repoStatus) { - - if (false === repoStatus.status) { - repoChecksResult = false; - return false; - } - }); - - // Update prechecks validity - vm.repoChecks.valid = repoChecksResult; - }, + onSuccessGetNodesRepoChecks, // In case of failure function (errorRepoChecksResponse) { // Expose the error list to repoChecks object @@ -102,5 +88,70 @@ vm.repoChecks.running = false; }); } + + function onSuccessGetNodesRepoChecks (repoChecksResponse) { + + var failingRepositories = [], + repoChecksResult = true; + + // Iterate over each product check returned from the service + _.forEach(repoChecksResponse.data, function(productValue, productKey) { + + // Validate a valid check from the service is being updated + if (NODES_PRODUCTS_REPO_CHECKS_MAP.hasOwnProperty(productKey)) { + + // Iterate through the repositories list for the product + _.forEach(NODES_PRODUCTS_REPO_CHECKS_MAP[productKey], function (repoName) { + + // If the product is available, then its related repositories should be displayed as passing + if (productValue.available) { + vm.repoChecks.checks[repoName].status = true; + + // If not, each/all failing repositories must be identified and marked as failing + } else { + + /* + * If an empty repos details are provided by the service, + * add all related repositories as to the failing repositories collection. + */ + if (_.isEmpty(productValue.repos)) { + + failingRepositories.push(repoName); + + /* + * If the repos details are provided by the service, + * iterate through the repository problems, repository architectures and repositories list + */ + } else { + _.forEach(productValue.repos, function (repoProblemType) { + _.forEach(repoProblemType, function (repoArchitectureType) { + _.forEach(repoArchitectureType, function (unavailableRepository) { + + // Add the unavailable repository, to the failing repositories collection. + if (!_.includes(failingRepositories, unavailableRepository)) { + failingRepositories.push(unavailableRepository); + } + }); + }); + }); + } + } + }); + } + }); + + // Go through the complete repository list and update their status + _.forEach(vm.repoChecks.checks, function (repositoryValue, repositoryKey) { + + // If the repository is included in the failing repositories collection, mark its status as false + repositoryValue.status = !_.includes(failingRepositories, repositoryKey); + + // Validate if there is any failing repository check + repoChecksResult = repoChecksResult && repositoryValue.status; + }); + + // Update the vm valid attribute (Used by the view to enable/disable the check button) + vm.repoChecks.valid = repoChecksResult; + } } })(); diff --git a/assets/app/features/upgrade/i18n/en.json b/assets/app/features/upgrade/i18n/en.json index 0280c7e2..8ba453c4 100644 --- a/assets/app/features/upgrade/i18n/en.json +++ b/assets/app/features/upgrade/i18n/en.json @@ -162,14 +162,14 @@ "description": "Please update the repository information on the CEPH and HA add-on products as well as the SUSE OpenStack Cloud 7 and SLES12 SP2 repositories used by the compute plane.", "repositories": { "codes": { - "SLES_12_SP2": "SUSE Linux Enterprise Server 12 SP2", - "SLES_12_SP2_Updates": "SUSE Linux Enterprise Server 12 SP2 Updates", - "SLES_OpenStack_Cloud_7": "SUSE Linux OpenStack Cloud 7", - "SLES_OpenStack_Cloud_7_Updates": "SUSE Linux OpenStack Cloud 7 Updates", - "SLE_HA_12_SP2": "SUSE Linux Enterprise 12 SP2 High Availability", - "SLE_HA_12_SP2_Updates": "SUSE Linux Enterprise 12 SP2 High Availability Updates", - "SUSE_Enterprise_Storage_4": "SUSE Linux Enterprise Storage 4", - "SUSE_Enterprise_Storage_4_Updates": "SUSE Linux Enterprise Storage 4 Updates" + "SLES12-SP2-Pool": "SUSE Linux Enterprise Server 12 SP2", + "SLES12-SP2-Updates": "SUSE Linux Enterprise Server 12 SP2 Updates", + "SUSE-OpenStack-Cloud-7-Pool": "SUSE Linux OpenStack Cloud 7", + "SUSE-OpenStack-Cloud-7-Updates": "SUSE Linux OpenStack Cloud 7 Updates", + "SLE12-SP2-HA-Pool": "SUSE Linux Enterprise 12 SP2 High Availability", + "SLE12-SP2-HA-Updates": "SUSE Linux Enterprise 12 SP2 High Availability Updates", + "SUSE-Enterprise-Storage-4-Pool": "SUSE Linux Enterprise Storage 4", + "SUSE-Enterprise-Storage-4-Updates": "SUSE Linux Enterprise Storage 4 Updates" } }, "form": { diff --git a/assets/app/features/upgrade/templates/upgrade7/nodes-repositories-checks-page.jade b/assets/app/features/upgrade/templates/upgrade7/nodes-repositories-checks-page.jade index 7ba76d6d..99f73d05 100644 --- a/assets/app/features/upgrade/templates/upgrade7/nodes-repositories-checks-page.jade +++ b/assets/app/features/upgrade/templates/upgrade7/nodes-repositories-checks-page.jade @@ -15,4 +15,4 @@ ) suse-lazy-spinner(delay="2000", active="upgradeNodesRepoChecksVm.repoChecks.running", visible="upgradeNodesRepoChecksVm.repoChecks.spinnerVisible") - span(translate='') upgrade7.steps.nodes-repository-checks.form.check-again \ No newline at end of file + span(translate='') upgrade7.steps.nodes-repository-checks.form.check-again diff --git a/assets/app/features/upgrade/upgrade.constants.js b/assets/app/features/upgrade/upgrade.constants.js new file mode 100644 index 00000000..e376469e --- /dev/null +++ b/assets/app/features/upgrade/upgrade.constants.js @@ -0,0 +1,11 @@ +(function() { + + angular + .module('crowbarApp.upgrade') + .constant('NODES_PRODUCTS_REPO_CHECKS_MAP', { + 'os': ['SLES12-SP2-Pool', 'SLES12-SP2-Updates'], + 'ha': ['SLE12-SP2-HA-Pool', 'SLE12-SP2-HA-Updates'], + 'openstack': ['SUSE-OpenStack-Cloud-7-Pool', 'SUSE-OpenStack-Cloud-7-Updates'], + 'ceph': ['SUSE-Enterprise-Storage-4-Pool', 'SUSE-Enterprise-Storage-4-Updates'] + }); +})(); diff --git a/assets/index.jade b/assets/index.jade index 7cfb0006..c9697c7d 100644 --- a/assets/index.jade +++ b/assets/index.jade @@ -46,6 +46,7 @@ html(ng-app='crowbarApp') // Upgrade State script(src='app/features/upgrade/upgrade.module.js') script(src='app/features/upgrade/upgrade.config.js') + script(src='app/features/upgrade/upgrade.constants.js') script(src='app/features/upgrade/upgrade.controller.js') // Upgrade 7 script(src='app/features/upgrade/upgrade7.controller.js') diff --git a/routes/api/upgrade/repocheck.js b/routes/api/upgrade/repocheck.js new file mode 100644 index 00000000..28bc3b5e --- /dev/null +++ b/routes/api/upgrade/repocheck.js @@ -0,0 +1,26 @@ +var express = require('express'), + router = express.Router(); + +/* GET Nodes Repo Checks. */ +router.get('/', function(req, res) { + res.status(200).json({ + 'ceph': { + 'available': true, + 'repos': {} + }, + 'ha': { + 'available': true, + 'repos': {} + }, + 'os': { + 'available': true, + 'repos': {} + }, + 'openstack': { + 'available': true, + 'repos': {} + } + }); +}); + +module.exports = router; diff --git a/routes/api/upgrade7/nodes-repo-checks.js b/routes/api/upgrade7/nodes-repo-checks.js deleted file mode 100644 index 633a4716..00000000 --- a/routes/api/upgrade7/nodes-repo-checks.js +++ /dev/null @@ -1,18 +0,0 @@ -var express = require('express'), - router = express.Router(); - -/* GET Nodes Repo Checks. */ -router.get('/', function(req, res) { - res.status(200).json({ - 'SLES_12_SP2': true, - 'SLES_12_SP2_Updates': true, - 'SLES_OpenStack_Cloud_7': true, - 'SLES_OpenStack_Cloud_7_Updates': true, - 'SLE_HA_12_SP2': true, - 'SLE_HA_12_SP2_Updates': true, - 'SUSE_Enterprise_Storage_4': true, - 'SUSE_Enterprise_Storage_4_Updates': true - }); -}); - -module.exports = router; From 56b4bc5d346ea5934faf8ec5ac4bb23c13e9f4af Mon Sep 17 00:00:00 2001 From: Santiago Petrone Date: Mon, 10 Oct 2016 00:03:53 +0200 Subject: [PATCH 4/7] Refactor Data module, Update static responses, Test Nodes Repository Checks --- app.js | 38 +-- assets/app/crowbar-app.module.js | 2 +- assets/app/data/crowbar-data.module.js | 5 - .../common-api-v2.constants.js | 2 +- assets/app/data/crowbar/crowbar.module.js | 5 + .../services/crowbar-backup.factory.js} | 23 +- .../services/crowbar-backup.factory.spec.js} | 24 +- .../data/crowbar/services/crowbar.factory.js | 84 +++++ .../crowbar/services/crowbar.factory.spec.js | 159 ++++++++++ .../crowbar/services/openstack.factory.js | 49 +++ .../services/openstack.factory.spec.js | 83 +++++ .../data/crowbar/services/upgrade.factory.js | 68 ++++ .../crowbar/services/upgrade.factory.spec.js | 124 ++++++++ .../upgrade => crowbar}/steps.factory.js | 2 +- assets/app/data/services/steps.factory.js | 97 ------ .../services/upgrade/crowbar-data.module.js | 5 - .../upgrade/openstack-services.factory.js | 37 --- .../openstack-services.factory.spec.js | 83 ----- .../services/upgrade/prechecks.factory.js | 27 -- .../upgrade/prechecks.factory.spec.js | 59 ---- .../upgrade/repositories-checks.factory.js | 39 --- .../repositories-checks.factory.spec.js | 103 ------ .../upgrade-administration-server.factory.js | 35 --- ...rade-administration-server.factory.spec.js | 84 ----- assets/app/data/suse-data.module.js | 5 + ...stration-repositories-checks.controller.js | 6 +- ...ion-repositories-checks.controller.spec.js | 20 +- .../controllers/upgrade7-backup.controller.js | 8 +- .../upgrade7-backup.controller.spec.js | 31 +- .../upgrade7-landing.controller.js | 8 +- .../upgrade7-landing.controller.spec.js | 20 +- ...e7-nodes-repositories-checks.controller.js | 6 +- ...des-repositories-checks.controller.spec.js | 12 +- .../upgrade7-openstack-services.controller.js | 28 +- ...ade7-openstack-services.controller.spec.js | 292 +++++++++--------- ...pgrade-administration-server.controller.js | 8 +- ...e-administration-server.controller.spec.js | 24 +- .../upgrade7/openstack-services.jade | 2 +- assets/index.jade | 23 +- .../backups/1.zip} | Bin routes/api/crowbar/backups/create.js | 17 + .../backup.js => crowbar/backups/download.js} | 4 +- routes/api/crowbar/entity.js | 15 + .../repocheck.js} | 0 .../admin-upgrade.js => crowbar/upgrade.js} | 0 .../backup.js} | 4 +- .../services.js} | 4 +- routes/api/steps.js | 82 ----- routes/api/{upgrade7 => upgrade}/prechecks.js | 0 routes/api/upgrade7/steps.js | 61 ---- 50 files changed, 914 insertions(+), 1003 deletions(-) delete mode 100644 assets/app/data/crowbar-data.module.js rename assets/app/data/{services/upgrade => crowbar}/common-api-v2.constants.js (79%) create mode 100644 assets/app/data/crowbar/crowbar.module.js rename assets/app/data/{services/upgrade/backup.factory.js => crowbar/services/crowbar-backup.factory.js} (64%) rename assets/app/data/{services/upgrade/backup.factory.spec.js => crowbar/services/crowbar-backup.factory.spec.js} (82%) create mode 100644 assets/app/data/crowbar/services/crowbar.factory.js create mode 100644 assets/app/data/crowbar/services/crowbar.factory.spec.js create mode 100644 assets/app/data/crowbar/services/openstack.factory.js create mode 100644 assets/app/data/crowbar/services/openstack.factory.spec.js create mode 100644 assets/app/data/crowbar/services/upgrade.factory.js create mode 100644 assets/app/data/crowbar/services/upgrade.factory.spec.js rename assets/app/data/{services/upgrade => crowbar}/steps.factory.js (98%) delete mode 100644 assets/app/data/services/steps.factory.js delete mode 100644 assets/app/data/services/upgrade/crowbar-data.module.js delete mode 100644 assets/app/data/services/upgrade/openstack-services.factory.js delete mode 100644 assets/app/data/services/upgrade/openstack-services.factory.spec.js delete mode 100644 assets/app/data/services/upgrade/prechecks.factory.js delete mode 100644 assets/app/data/services/upgrade/prechecks.factory.spec.js delete mode 100644 assets/app/data/services/upgrade/repositories-checks.factory.js delete mode 100644 assets/app/data/services/upgrade/repositories-checks.factory.spec.js delete mode 100644 assets/app/data/services/upgrade/upgrade-administration-server.factory.js delete mode 100644 assets/app/data/services/upgrade/upgrade-administration-server.factory.spec.js create mode 100644 assets/app/data/suse-data.module.js rename routes/api/{upgrade7/S33z8qFX.jpg.zip => crowbar/backups/1.zip} (100%) create mode 100644 routes/api/crowbar/backups/create.js rename routes/api/{upgrade7/backup.js => crowbar/backups/download.js} (84%) create mode 100644 routes/api/crowbar/entity.js rename routes/api/{upgrade7/admin-repo-checks.js => crowbar/repocheck.js} (100%) rename routes/api/{upgrade7/admin-upgrade.js => crowbar/upgrade.js} (100%) rename routes/api/{upgrade7/openstack-services-backup.js => openstack/backup.js} (66%) rename routes/api/{upgrade7/stop-openstack-services.js => openstack/services.js} (67%) delete mode 100644 routes/api/steps.js rename routes/api/{upgrade7 => upgrade}/prechecks.js (100%) delete mode 100644 routes/api/upgrade7/steps.js diff --git a/app.js b/app.js index f204ef63..e218b62c 100644 --- a/app.js +++ b/app.js @@ -6,15 +6,15 @@ var express = require('express'), //Routes index = require('./routes/index'), - steps = require('./routes/api/steps'), - upgrade7Steps = require('./routes/api/upgrade7/steps'), - upgrade7Prechecks = require('./routes/api/upgrade7/prechecks'), - upgrade7Backup = require('./routes/api/upgrade7/backup'), - upgrade7AdminRepoChecks = require('./routes/api/upgrade7/admin-repo-checks'), - upgrade7AdminUpgrade = require('./routes/api/upgrade7/admin-upgrade'), - upgrade7NodesRepoChecks = require('./routes/api/upgrade/repocheck'), - upgrade7StopOpenStackServices = require('./routes/api/upgrade7/stop-openstack-services'), - upgrade7OpenStackServicesBackup = require('./routes/api/upgrade7/openstack-services-backup'), + crowbarEntity = require('./routes/api/crowbar/entity'), + crowbarBackupCreate = require('./routes/api/crowbar/backups/create'), + crowbarBackupDownload = require('./routes/api/crowbar/backups/download'), + crowbarRepocheck = require('./routes/api/crowbar/repocheck'), + crowbarUpgrade = require('./routes/api/crowbar/upgrade'), + upgradeRepocheck = require('./routes/api/upgrade/repocheck'), + upgradePrechecks = require('./routes/api/upgrade/prechecks'), + openstackServices = require('./routes/api/openstack/services'), + openstackBackup = require('./routes/api/openstack/backup'), app = express(); @@ -27,15 +27,17 @@ app.use(cookieParser()); app.use(express.static(path.join(__dirname, 'public'))); app.use('/', index); -app.use('/api/steps', steps); -app.use('/api/upgrade7/steps', upgrade7Steps); -app.use('/api/upgrade7/prechecks', upgrade7Prechecks); -app.use('/api/upgrade7/backup', upgrade7Backup); -app.use('/api/upgrade7/admin-repo-checks', upgrade7AdminRepoChecks); -app.use('/api/upgrade7/admin-upgrade', upgrade7AdminUpgrade); -app.use('/api/upgrade7/repocheck', upgrade7NodesRepoChecks); -app.use('/api/upgrade7/openstack-services/stop', upgrade7StopOpenStackServices); -app.use('/api/upgrade7/openstack-services/backup', upgrade7OpenStackServicesBackup); +app.use('/api/crowbar', crowbarEntity); +app.use('/api/crowbar/backups', crowbarBackupCreate); +app.use('/api/crowbar/backups/\*/download', crowbarBackupDownload); +app.use('/api/crowbar/repocheck', crowbarRepocheck); +app.use('/api/crowbar/upgrade', crowbarUpgrade); +app.use('/api/upgrade/prechecks', upgradePrechecks); +app.use('/api/upgrade/repocheck', upgradeRepocheck); +app.use('/api/openstack/services', openstackServices); +app.use('/api/openstack/backup', openstackBackup); + + // catch 404 and forward to error handler app.use(function(req, res, next) { diff --git a/assets/app/crowbar-app.module.js b/assets/app/crowbar-app.module.js index d4ca3158..659c56ef 100644 --- a/assets/app/crowbar-app.module.js +++ b/assets/app/crowbar-app.module.js @@ -12,7 +12,7 @@ angular .module('crowbarApp', [ 'crowbarCore', - 'crowbarData', + 'suseData', 'crowbarWidgets', /* diff --git a/assets/app/data/crowbar-data.module.js b/assets/app/data/crowbar-data.module.js deleted file mode 100644 index 9e5ecc66..00000000 --- a/assets/app/data/crowbar-data.module.js +++ /dev/null @@ -1,5 +0,0 @@ -(function () { - 'use strict'; - - angular.module('crowbarData', ['crowbarData.upgrade']); -})(); diff --git a/assets/app/data/services/upgrade/common-api-v2.constants.js b/assets/app/data/crowbar/common-api-v2.constants.js similarity index 79% rename from assets/app/data/services/upgrade/common-api-v2.constants.js rename to assets/app/data/crowbar/common-api-v2.constants.js index 7e0d23d9..1619ed9a 100644 --- a/assets/app/data/services/upgrade/common-api-v2.constants.js +++ b/assets/app/data/crowbar/common-api-v2.constants.js @@ -1,7 +1,7 @@ (function() { angular - .module('crowbarData.upgrade') + .module('suseData.crowbar') .constant('COMMON_API_V2_HEADERS', { 'Accept': 'application/vnd.crowbar.v2.0+json' }); diff --git a/assets/app/data/crowbar/crowbar.module.js b/assets/app/data/crowbar/crowbar.module.js new file mode 100644 index 00000000..4c00129b --- /dev/null +++ b/assets/app/data/crowbar/crowbar.module.js @@ -0,0 +1,5 @@ +(function () { + 'use strict'; + + angular.module('suseData.crowbar', []); +})(); diff --git a/assets/app/data/services/upgrade/backup.factory.js b/assets/app/data/crowbar/services/crowbar-backup.factory.js similarity index 64% rename from assets/app/data/services/upgrade/backup.factory.js rename to assets/app/data/crowbar/services/crowbar-backup.factory.js index afe84d48..3810fcac 100644 --- a/assets/app/data/services/upgrade/backup.factory.js +++ b/assets/app/data/crowbar/services/crowbar-backup.factory.js @@ -1,19 +1,24 @@ (function() { angular - .module('crowbarData.upgrade') - .factory('upgradeBackupFactory', upgradeBackupFactory); + .module('suseData.crowbar') + .factory('crowbarBackupFactory', crowbarBackupFactory); - upgradeBackupFactory.$inject = ['$q', '$http', '$filter', 'COMMON_API_V2_HEADERS']; + crowbarBackupFactory.$inject = ['$q', '$http', '$filter', 'COMMON_API_V2_HEADERS']; /* @ngInject */ - function upgradeBackupFactory($q, $http, $filter, COMMON_API_V2_HEADERS) { + function crowbarBackupFactory($q, $http, $filter, COMMON_API_V2_HEADERS) { var factory = { create: createBackup, - download: downloadBackup + getBackup: getBackup }; return factory; + /** + * Create a new backup of the Administration Node + * + * @return {Promise} + */ function createBackup() { var requestOptions = { @@ -26,7 +31,13 @@ return $http(requestOptions); } - function downloadBackup(id) { + /** + * Download a specific backup based on its Id + * + * @param {Number} Backup Id to be downloaded + * @return {Promise} + */ + function getBackup(id) { // this should never happen, caller should make sure 'id' is set if (angular.isUndefined(id)) { throw Error('downloadBackup() called without id.'); diff --git a/assets/app/data/services/upgrade/backup.factory.spec.js b/assets/app/data/crowbar/services/crowbar-backup.factory.spec.js similarity index 82% rename from assets/app/data/services/upgrade/backup.factory.spec.js rename to assets/app/data/crowbar/services/crowbar-backup.factory.spec.js index e47c41b9..17214304 100644 --- a/assets/app/data/services/upgrade/backup.factory.spec.js +++ b/assets/app/data/crowbar/services/crowbar-backup.factory.spec.js @@ -1,5 +1,5 @@ -/*global bard $httpBackend should expect upgradeBackupFactory assert */ -describe('Upgrade Backup Factory', function () { +/*global bard $httpBackend should expect crowbarBackupFactory assert */ +describe('Crowbar Backup Factory', function () { var mockedBackupFile = '--mockedBackupFile--', mockedCreateResponse = { @@ -9,8 +9,8 @@ describe('Upgrade Backup Factory', function () { beforeEach(function () { //Setup the module and dependencies to be used. - bard.appModule('crowbarData.upgrade'); - bard.inject('upgradeBackupFactory', '$q', '$httpBackend'); + bard.appModule('suseData.crowbar'); + bard.inject('crowbarBackupFactory', '$q', '$httpBackend', 'COMMON_API_V2_HEADERS'); }); afterEach(function() { @@ -22,23 +22,23 @@ describe('Upgrade Backup Factory', function () { describe('when executed', function () { it('returns an object', function () { - should.exist(upgradeBackupFactory); + should.exist(crowbarBackupFactory); }); it('returns an object with create function defined', function () { - expect(upgradeBackupFactory.create).toEqual(jasmine.any(Function)); + expect(crowbarBackupFactory.create).toEqual(jasmine.any(Function)); }); - it('returns an object with download function defined', function () { - expect(upgradeBackupFactory.download).toEqual(jasmine.any(Function)); + it('returns an object with getBackup function defined', function () { + expect(crowbarBackupFactory.getBackup).toEqual(jasmine.any(Function)); }); describe('when create method is executed', function () { beforeEach(function () { - $httpBackend.expect('POST', '/api/crowbar/backups') + $httpBackend.expect('POST', '/api/crowbar/backups', undefined) .respond(200, mockedCreateResponse); - backupPromise = upgradeBackupFactory.create(); + backupPromise = crowbarBackupFactory.create(); $httpBackend.flush(); }); @@ -65,7 +65,7 @@ describe('Upgrade Backup Factory', function () { beforeEach(function () { $httpBackend.expect('GET', '/api/crowbar/backups/42/download') .respond(200, mockedBackupFile); - backupPromise = upgradeBackupFactory.download(42); + backupPromise = crowbarBackupFactory.getBackup(42); $httpBackend.flush(); }); @@ -92,7 +92,7 @@ describe('Upgrade Backup Factory', function () { describe('when download method is executed without parameter', function () { it('throws an exception', function () { - expect(upgradeBackupFactory.download).toThrow(); + expect(crowbarBackupFactory.getBackup).toThrow(); }); }); }); diff --git a/assets/app/data/crowbar/services/crowbar.factory.js b/assets/app/data/crowbar/services/crowbar.factory.js new file mode 100644 index 00000000..57bf6249 --- /dev/null +++ b/assets/app/data/crowbar/services/crowbar.factory.js @@ -0,0 +1,84 @@ +(function() { + + angular + .module('suseData.crowbar') + .factory('crowbarFactory', crowbarFactory); + + crowbarFactory.$inject = ['$q', '$http', 'COMMON_API_V2_HEADERS']; + /* @ngInject */ + function crowbarFactory($q, $http, COMMON_API_V2_HEADERS) { + var factory = { + getEntity: getEntity, + getRepositoriesChecks: getRepositoriesChecks, + upgrade: upgrade, + getUpgradeStatus: getUpgradeStatus + }; + + return factory; + + /** + * Get Crowbar Entity + * + * @return {Promise} + */ + function getEntity() { + + var requestOptions = { + method: 'GET', + url: '/api/crowbar', + headers: COMMON_API_V2_HEADERS + }; + + return $http(requestOptions); + } + + /** + * Get Administration repositories checks (Operative System and Open Stack) + * + * @return {Promise} + */ + function getRepositoriesChecks() { + + var requestOptions = { + method: 'GET', + url: '/api/crowbar/repocheck', + headers: COMMON_API_V2_HEADERS + }; + + return $http(requestOptions); + + } + + /** + * Trigger the Upgrade process on the Adinistration Node (Crowbar) from Cloud6 to Cloud7 + * + * @return {Promise} + */ + function upgrade() { + + var requestOptions = { + method: 'POST', + url: '/api/crowbar/upgrade', + headers: COMMON_API_V2_HEADERS + }; + + return $http(requestOptions); + } + + /** + * Get the upgrade status of the Administration Node (Crowbar) + * + * @return {Promise} + */ + function getUpgradeStatus() { + + var requestOptions = { + method: 'GET', + url: '/api/crowbar/upgrade', + headers: COMMON_API_V2_HEADERS + }; + + return $http(requestOptions); + } + } +})(); diff --git a/assets/app/data/crowbar/services/crowbar.factory.spec.js b/assets/app/data/crowbar/services/crowbar.factory.spec.js new file mode 100644 index 00000000..a4a29384 --- /dev/null +++ b/assets/app/data/crowbar/services/crowbar.factory.spec.js @@ -0,0 +1,159 @@ +/*global bard $httpBackend should expect crowbarFactory COMMON_API_V2_HEADERS */ +describe('Crowbar Factory', function () { + + var mockedCrowbarEntityData = '--mockedCrowbarEntityData--', + mockedRepositoriesChecksData = '--mockedRepositoriesChecksData--', + mockedUpgradeData = '--mockedUpgradeData--', + mockedUpgradeStatusData = '--mockedUpgradeStatusData--', + crowbarEntityPromise, + repositoriesChecksPromise, + upgradePromise, + upgradeStatusPromise; + + beforeEach(function () { + //Setup the module and dependencies to be used. + bard.appModule('suseData.crowbar'); + bard.inject('crowbarFactory', '$q', '$httpBackend', 'COMMON_API_V2_HEADERS'); + }); + + describe('when executed', function () { + + it('returns an object', function () { + should.exist(crowbarFactory); + }); + + it('returns an object with getEntity function is defined', function () { + expect(crowbarFactory.getEntity).toEqual(jasmine.any(Function)); + }); + + it('returns an object with getRepositoriesChecks function is defined', function () { + expect(crowbarFactory.getRepositoriesChecks).toEqual(jasmine.any(Function)); + }); + + it('returns an object with upgrade function is defined', function () { + expect(crowbarFactory.upgrade).toEqual(jasmine.any(Function)); + }); + + it('returns an object with getUpgradeStatus function is defined', function () { + expect(crowbarFactory.getUpgradeStatus).toEqual(jasmine.any(Function)); + }); + + describe('when getEntity method is executed', function () { + + beforeEach(function () { + + $httpBackend.expectGET('/api/crowbar', COMMON_API_V2_HEADERS) + .respond(200, mockedCrowbarEntityData); + crowbarEntityPromise = crowbarFactory.getEntity(); + }); + + it('returns a promise', function () { + expect(crowbarEntityPromise).toEqual(jasmine.any(Object)); + expect(crowbarEntityPromise['then']).toEqual(jasmine.any(Function)); + expect(crowbarEntityPromise['catch']).toEqual(jasmine.any(Function)); + expect(crowbarEntityPromise['finally']).toEqual(jasmine.any(Function)); + expect(crowbarEntityPromise['error']).toEqual(jasmine.any(Function)); + expect(crowbarEntityPromise['success']).toEqual(jasmine.any(Function)); + }); + + // getEntity success, partially passing and/or failing are handled in the controller. + it('when resolved, it returns the crowbar entity response', function () { + crowbarEntityPromise.then(function (getEntityResponse) { + expect(getEntityResponse.status).toEqual(200); + expect(getEntityResponse.data).toEqual(mockedCrowbarEntityData); + }); + $httpBackend.flush(); + }); + + }); + + describe('when getRepositoriesChecks method is executed', function () { + + beforeEach(function () { + + $httpBackend.expectGET('/api/crowbar/repocheck', COMMON_API_V2_HEADERS) + .respond(200, mockedRepositoriesChecksData); + repositoriesChecksPromise = crowbarFactory.getRepositoriesChecks(); + }); + + it('returns a promise', function () { + expect(repositoriesChecksPromise).toEqual(jasmine.any(Object)); + expect(repositoriesChecksPromise['then']).toEqual(jasmine.any(Function)); + expect(repositoriesChecksPromise['catch']).toEqual(jasmine.any(Function)); + expect(repositoriesChecksPromise['finally']).toEqual(jasmine.any(Function)); + expect(repositoriesChecksPromise['error']).toEqual(jasmine.any(Function)); + expect(repositoriesChecksPromise['success']).toEqual(jasmine.any(Function)); + }); + + // getRepositoriesChecks success, partially passing and/or failing are handled in the controller. + it('when resolved, it returns the Repositories Checks response', function () { + repositoriesChecksPromise.then(function (repositoriesChecksResponse) { + expect(repositoriesChecksResponse.status).toEqual(200); + expect(repositoriesChecksResponse.data).toEqual(mockedRepositoriesChecksData); + }); + $httpBackend.flush(); + }); + + }); + + describe('when upgrade method is executed', function () { + + beforeEach(function () { + + $httpBackend.expectPOST('/api/crowbar/upgrade', null, COMMON_API_V2_HEADERS) + .respond(200, mockedUpgradeData); + upgradePromise = crowbarFactory.upgrade(); + }); + + it('returns a promise', function () { + expect(upgradePromise).toEqual(jasmine.any(Object)); + expect(upgradePromise['then']).toEqual(jasmine.any(Function)); + expect(upgradePromise['catch']).toEqual(jasmine.any(Function)); + expect(upgradePromise['finally']).toEqual(jasmine.any(Function)); + expect(upgradePromise['error']).toEqual(jasmine.any(Function)); + expect(upgradePromise['success']).toEqual(jasmine.any(Function)); + }); + + // upgrade success, partially passing and/or failing are handled in the controller. + it('when resolved, it returns the crowbar upgrade response', function () { + upgradePromise.then(function (upgradeResponse) { + expect(upgradeResponse.status).toEqual(200); + expect(upgradeResponse.data).toEqual(mockedUpgradeData); + }); + $httpBackend.flush(); + }); + + }); + + describe('when getUpgradeStatus method is executed', function () { + + beforeEach(function () { + + $httpBackend.expectGET('/api/crowbar/upgrade', COMMON_API_V2_HEADERS) + .respond(200, mockedUpgradeStatusData); + upgradeStatusPromise = crowbarFactory.getUpgradeStatus(); + }); + + it('returns a promise', function () { + expect(upgradeStatusPromise).toEqual(jasmine.any(Object)); + expect(upgradeStatusPromise['then']).toEqual(jasmine.any(Function)); + expect(upgradeStatusPromise['catch']).toEqual(jasmine.any(Function)); + expect(upgradeStatusPromise['finally']).toEqual(jasmine.any(Function)); + expect(upgradeStatusPromise['error']).toEqual(jasmine.any(Function)); + expect(upgradeStatusPromise['success']).toEqual(jasmine.any(Function)); + }); + + // getUpgradeStatus success, partially passing and/or failing are handled in the controller. + it('when resolved, it returns the upgrade crowbar status response', function () { + upgradeStatusPromise.then(function (getUpgradeStatusResponse) { + expect(getUpgradeStatusResponse.status).toEqual(200); + expect(getUpgradeStatusResponse.data).toEqual(mockedUpgradeStatusData); + }); + $httpBackend.flush(); + }); + + }); + + }); + +}); diff --git a/assets/app/data/crowbar/services/openstack.factory.js b/assets/app/data/crowbar/services/openstack.factory.js new file mode 100644 index 00000000..aa056666 --- /dev/null +++ b/assets/app/data/crowbar/services/openstack.factory.js @@ -0,0 +1,49 @@ +(function() { + + angular + .module('suseData.crowbar') + .factory('openstackFactory', openstackFactory); + + openstackFactory.$inject = ['$q', '$http', 'COMMON_API_V2_HEADERS']; + /* @ngInject */ + function openstackFactory($q, $http, COMMON_API_V2_HEADERS) { + var factory = { + stopServices: stopServices, + createBackup: createBackup + }; + + return factory; + + /** + * Stop all openstack services + * + * @return {Promise} + */ + function stopServices() { + + var requestOptions = { + method: 'POST', + url: '/api/openstack/services', + headers: COMMON_API_V2_HEADERS + }; + + return $http(requestOptions); + } + + /** + * Create Openstack Database Backup + * + * @return {Promise} + */ + function createBackup() { + + var requestOptions = { + method: 'POST', + url: '/api/openstack/backup', + headers: COMMON_API_V2_HEADERS + }; + + return $http(requestOptions); + } + } +})(); diff --git a/assets/app/data/crowbar/services/openstack.factory.spec.js b/assets/app/data/crowbar/services/openstack.factory.spec.js new file mode 100644 index 00000000..dd5bca84 --- /dev/null +++ b/assets/app/data/crowbar/services/openstack.factory.spec.js @@ -0,0 +1,83 @@ +/*global bard $httpBackend should expect openstackFactory COMMON_API_V2_HEADERS */ +describe('OpenStack Factory', function () { + var mockedStopServicesPromise = { + 'services': true, + }, + mockedCreateBackupPromise = { + 'services': true, + }, + stopServicesPromise, + createBackupPromise; + + beforeEach(function () { + //Setup the module and dependencies to be used. + bard.appModule('suseData.crowbar'); + bard.inject('openstackFactory', '$q', '$httpBackend', 'COMMON_API_V2_HEADERS'); + }); + + describe('when executed', function () { + + it('returns an object', function () { + should.exist(openstackFactory); + }); + + it('returns an object with stopServices function is defined', function () { + expect(openstackFactory.stopServices).toEqual(jasmine.any(Function)); + }); + + it('returns an object with createBackup function is defined', function () { + expect(openstackFactory.createBackup).toEqual(jasmine.any(Function)); + }); + + describe('when stopServices method is executed', function () { + beforeEach(function () { + $httpBackend.expectPOST('/api/openstack/services', null, COMMON_API_V2_HEADERS) + .respond(200, mockedStopServicesPromise); + stopServicesPromise = openstackFactory.stopServices(); + }); + + it('returns a promise', function () { + expect(stopServicesPromise).toEqual(jasmine.any(Object)); + expect(stopServicesPromise['then']).toEqual(jasmine.any(Function)); + expect(stopServicesPromise['catch']).toEqual(jasmine.any(Function)); + expect(stopServicesPromise['finally']).toEqual(jasmine.any(Function)); + expect(stopServicesPromise['error']).toEqual(jasmine.any(Function)); + expect(stopServicesPromise['success']).toEqual(jasmine.any(Function)); + }); + + // stopOpenStackServices success, partially passing and/or failing are handled in the controller. + it('when resolved, it returns the stopOpenStackServices response', function () { + stopServicesPromise.then(function (stopServicesResponse) { + expect(stopServicesResponse.status).toEqual(200); + expect(stopServicesResponse.data).toEqual(mockedStopServicesPromise); + }); + $httpBackend.flush(); + }); + }); + + describe('when createBackup method is executed', function () { + beforeEach(function () { + $httpBackend.expectPOST('/api/openstack/backup', null, COMMON_API_V2_HEADERS) + .respond(200, mockedCreateBackupPromise); + createBackupPromise = openstackFactory.createBackup(); + }); + + it('returns a promise', function () { + expect(createBackupPromise).toEqual(jasmine.any(Object)); + expect(createBackupPromise['then']).toEqual(jasmine.any(Function)); + expect(createBackupPromise['catch']).toEqual(jasmine.any(Function)); + expect(createBackupPromise['finally']).toEqual(jasmine.any(Function)); + expect(createBackupPromise['error']).toEqual(jasmine.any(Function)); + expect(createBackupPromise['success']).toEqual(jasmine.any(Function)); + }); + + it('when resolved, it returns the createBackupServices response', function () { + createBackupPromise.then(function (createBackupResponse) { + expect(createBackupResponse.status).toEqual(200); + expect(createBackupResponse.data).toEqual(mockedCreateBackupPromise); + }); + $httpBackend.flush(); + }); + }); + }); +}); diff --git a/assets/app/data/crowbar/services/upgrade.factory.js b/assets/app/data/crowbar/services/upgrade.factory.js new file mode 100644 index 00000000..ac1b83f6 --- /dev/null +++ b/assets/app/data/crowbar/services/upgrade.factory.js @@ -0,0 +1,68 @@ +(function() { + + angular + .module('suseData.crowbar') + .factory('upgradeFactory', upgradeFactory); + + upgradeFactory.$inject = ['$q', '$http', 'COMMON_API_V2_HEADERS']; + /* @ngInject */ + function upgradeFactory($q, $http, COMMON_API_V2_HEADERS) { + var factory = { + getPreliminaryChecks: getPreliminaryChecks, + prepareNodes: prepareNodes, + getNodesRepoChecks: getNodesRepoChecks + }; + + return factory; + + /** + * Get the preliminary checks required to start the upgrade process + * + * @return {Promise} + */ + function getPreliminaryChecks() { + + var requestOptions = { + method: 'GET', + url: '/api/upgrade/prechecks', + headers: COMMON_API_V2_HEADERS + }; + + return $http(requestOptions); + } + + /** + * Prepare nodes for upgrade. This will change the Nodes status to 'upgrade', so no further changes + * can be applied to them until the upgrade is either completed or canceled. + * + * @return {Promise} + */ + function prepareNodes() { + + var requestOptions = { + method: 'POST', + url: '/api/upgrade/prepare', + headers: COMMON_API_V2_HEADERS + }; + + return $http(requestOptions); + } + + /** + * Get the Repositories checks for the Nodes to be upgraded. + * (These results doesn't include Administration Server repositories) + * + * @return {Promise} + */ + function getNodesRepoChecks() { + + var requestOptions = { + method: 'GET', + url: '/api/upgrade/repocheck', + headers: COMMON_API_V2_HEADERS + }; + + return $http(requestOptions); + } + } +})(); diff --git a/assets/app/data/crowbar/services/upgrade.factory.spec.js b/assets/app/data/crowbar/services/upgrade.factory.spec.js new file mode 100644 index 00000000..d926d052 --- /dev/null +++ b/assets/app/data/crowbar/services/upgrade.factory.spec.js @@ -0,0 +1,124 @@ +/*global bard $httpBackend should expect upgradeFactory COMMON_API_V2_HEADERS */ +describe('Upgrade Factory', function () { + + var mockedPreliminaryChecksData = '--mockedNodesRepoChecksData--', + mockedPrepareNodesData = '--mockedNodesRepoChecksData--', + mockedNodesRepoChecksData = '--mockedNodesRepoChecksData--', + preliminaryChecksPromise, + prepareNodesPromise, + nodesRepoChecksPromise; + + beforeEach(function () { + //Setup the module and dependencies to be used. + bard.appModule('suseData.crowbar'); + bard.inject('upgradeFactory', '$q', '$httpBackend', 'COMMON_API_V2_HEADERS'); + }); + + describe('when executed', function () { + + it('returns an object', function () { + should.exist(upgradeFactory); + }); + + it('returns an object with getPreliminaryChecks function defined', function () { + expect(upgradeFactory.getPreliminaryChecks).toEqual(jasmine.any(Function)); + }); + + it('returns an object with prepareNodes function defined', function () { + expect(upgradeFactory.prepareNodes).toEqual(jasmine.any(Function)); + }); + + it('returns an object with getNodesRepoChecks function defined', function () { + expect(upgradeFactory.getNodesRepoChecks).toEqual(jasmine.any(Function)); + }); + + describe('when getPreliminaryChecks method is executed', function () { + + beforeEach(function () { + + $httpBackend.expectGET('/api/upgrade/prechecks', COMMON_API_V2_HEADERS) + .respond(200, mockedPreliminaryChecksData); + preliminaryChecksPromise = upgradeFactory.getPreliminaryChecks(); + }); + + it('returns a promise', function () { + expect(preliminaryChecksPromise).toEqual(jasmine.any(Object)); + expect(preliminaryChecksPromise['then']).toEqual(jasmine.any(Function)); + expect(preliminaryChecksPromise['catch']).toEqual(jasmine.any(Function)); + expect(preliminaryChecksPromise['finally']).toEqual(jasmine.any(Function)); + expect(preliminaryChecksPromise['error']).toEqual(jasmine.any(Function)); + expect(preliminaryChecksPromise['success']).toEqual(jasmine.any(Function)); + }); + + // repoChecks success, partially passing and/or failing are handled in the controller. + it('when resolved, it returns the repoChecks response', function () { + preliminaryChecksPromise.then(function (preChecksResponse) { + expect(preChecksResponse.status).toEqual(200); + expect(preChecksResponse.data).toEqual(mockedPreliminaryChecksData); + }); + $httpBackend.flush(); + }); + + }); + + describe('when prepareNodes method is executed', function () { + + beforeEach(function () { + + $httpBackend.expectPOST('/api/upgrade/prepare', null, COMMON_API_V2_HEADERS) + .respond(200, mockedPrepareNodesData); + prepareNodesPromise = upgradeFactory.prepareNodes(); + }); + + it('returns a promise', function () { + expect(prepareNodesPromise).toEqual(jasmine.any(Object)); + expect(prepareNodesPromise['then']).toEqual(jasmine.any(Function)); + expect(prepareNodesPromise['catch']).toEqual(jasmine.any(Function)); + expect(prepareNodesPromise['finally']).toEqual(jasmine.any(Function)); + expect(prepareNodesPromise['error']).toEqual(jasmine.any(Function)); + expect(prepareNodesPromise['success']).toEqual(jasmine.any(Function)); + }); + + // prepareNodes success, partially passing and/or failing are handled in the controller. + it('when resolved, it returns the prepareNodes response', function () { + prepareNodesPromise.then(function (prepareNodesResponse) { + expect(prepareNodesResponse.status).toEqual(200); + expect(prepareNodesResponse.data).toEqual(mockedPrepareNodesData); + }); + $httpBackend.flush(); + }); + + }); + + describe('when getNodesRepoChecks method is executed', function () { + + beforeEach(function () { + + $httpBackend.expectGET('/api/upgrade/repocheck', COMMON_API_V2_HEADERS) + .respond(200, mockedNodesRepoChecksData); + nodesRepoChecksPromise = upgradeFactory.getNodesRepoChecks(); + }); + + it('returns a promise', function () { + expect(nodesRepoChecksPromise).toEqual(jasmine.any(Object)); + expect(nodesRepoChecksPromise['then']).toEqual(jasmine.any(Function)); + expect(nodesRepoChecksPromise['catch']).toEqual(jasmine.any(Function)); + expect(nodesRepoChecksPromise['finally']).toEqual(jasmine.any(Function)); + expect(nodesRepoChecksPromise['error']).toEqual(jasmine.any(Function)); + expect(nodesRepoChecksPromise['success']).toEqual(jasmine.any(Function)); + }); + + // repoChecks success, partially passing and/or failing are handled in the controller. + it('when resolved, it returns the repoChecks response', function () { + nodesRepoChecksPromise.then(function (repoChecksResponse) { + expect(repoChecksResponse.status).toEqual(200); + expect(repoChecksResponse.data).toEqual(mockedNodesRepoChecksData); + }); + $httpBackend.flush(); + }); + + }); + + }); + +}); diff --git a/assets/app/data/services/upgrade/steps.factory.js b/assets/app/data/crowbar/steps.factory.js similarity index 98% rename from assets/app/data/services/upgrade/steps.factory.js rename to assets/app/data/crowbar/steps.factory.js index af07c763..629c4857 100644 --- a/assets/app/data/services/upgrade/steps.factory.js +++ b/assets/app/data/crowbar/steps.factory.js @@ -1,7 +1,7 @@ (function() { angular - .module('crowbarData.upgrade') + .module('suseData.crowbar') .factory('upgradeStepsFactory', upgradeStepsFactory); upgradeStepsFactory.$inject = []; diff --git a/assets/app/data/services/steps.factory.js b/assets/app/data/services/steps.factory.js deleted file mode 100644 index 0f520f5c..00000000 --- a/assets/app/data/services/steps.factory.js +++ /dev/null @@ -1,97 +0,0 @@ -(function() { - - angular - .module('crowbarData') - .factory('stepsFactory', stepsFactory); - - stepsFactory.$inject = ['$q', '$http']; - /* @ngInject */ - function stepsFactory($q, $http) { - var factory = { - getAll: getStepsFactory, - getAllStatic: function() { - return [ - { - id: 0, - title: 'Prepare Client Node', - state: 'upgrade.prepare', - active: true, - enabled: true - }, - { - id: 1, - title: 'Download Upgrade Data', - state: 'upgrade.backup', - active: false, - enabled: false - }, - { - id: 2, - title: 'Reinstall Admin Server', - state: 'upgrade.reinstall-admin', - active: false, - enabled: false - }, - { - id: 3, - title: 'Continue Upgrade', - state: 'upgrade.continue-upgrade', - active: false, - enabled: false - }, - { - id: 4, - title: 'Restore', - state: 'upgrade.restore-admin', - active: false, - enabled: false - }, - { - id: 5, - title: 'Verify Repositories', - state: 'upgrade.verify-repos', - active: false, - enabled: false - }, - { - id: 6, - title: 'Stop OpenStack Services', - state: 'upgrade.stop-openstack-services', - active: false, - enabled: false - }, - { - id: 7, - title: 'Data Backup', - state: 'upgrade.openstack-backup', - active: false, - enabled: false - }, - { - id: 8, - title: 'Upgrading Nodes OS', - state: 'upgrade.upgrade-nodes-os', - active: false, - enabled: false - }, - { - id: 9, - title: 'Finishing Upgrade', - state: 'upgrade.finishing-upgrade', - active: false, - enabled: false - } - ]; - } - }; - - return factory; - function getStepsFactory() { - - return $http({ - method: 'GET', - url: '/api/steps' - }); - } - } -})(); diff --git a/assets/app/data/services/upgrade/crowbar-data.module.js b/assets/app/data/services/upgrade/crowbar-data.module.js deleted file mode 100644 index 71e0193c..00000000 --- a/assets/app/data/services/upgrade/crowbar-data.module.js +++ /dev/null @@ -1,5 +0,0 @@ -(function () { - 'use strict'; - - angular.module('crowbarData.upgrade', []); -})(); diff --git a/assets/app/data/services/upgrade/openstack-services.factory.js b/assets/app/data/services/upgrade/openstack-services.factory.js deleted file mode 100644 index f58f49e4..00000000 --- a/assets/app/data/services/upgrade/openstack-services.factory.js +++ /dev/null @@ -1,37 +0,0 @@ -(function() { - - angular - .module('crowbarData.upgrade') - .factory('openStackFactory', openStackFactory); - - openStackFactory.$inject = ['$q', '$http']; - /* @ngInject */ - function openStackFactory($q, $http) { - var factory = { - stopOpenstackServices: stopOpenstackServices, - createOpenstackBackup: createOpenstackBackup - }; - - return factory; - - function stopOpenstackServices() { - - var requestOptions = { - method: 'GET', - url: '/api/upgrade7/openstack-services/stop' - }; - - return $http(requestOptions); - } - - function createOpenstackBackup() { - - var requestOptions = { - method: 'GET', - url: '/api/upgrade7/openstack-services/backup' - }; - - return $http(requestOptions); - } - } -})(); diff --git a/assets/app/data/services/upgrade/openstack-services.factory.spec.js b/assets/app/data/services/upgrade/openstack-services.factory.spec.js deleted file mode 100644 index 4df14941..00000000 --- a/assets/app/data/services/upgrade/openstack-services.factory.spec.js +++ /dev/null @@ -1,83 +0,0 @@ -/*global bard $httpBackend should expect openStackFactory */ -describe('OpenStack Services Factory', function () { - var mockedStopOpenStackServicesPromise = { - 'services': true, - }, - mockedCreateOpenstackBackupPromise = { - 'services': true, - }, - stopOpenStackServicesPromise, - createOpenstackBackupPromise; - - beforeEach(function () { - //Setup the module and dependencies to be used. - bard.appModule('crowbarData.upgrade'); - bard.inject('openStackFactory', '$q', '$httpBackend'); - }); - - describe('when executed', function () { - - it('returns an object', function () { - should.exist(openStackFactory); - }); - - it('returns an object with stopOpenstackServices function is defined', function () { - expect(openStackFactory.stopOpenstackServices).toEqual(jasmine.any(Function)); - }); - - it('returns an object with createOpenstackBackup function is defined', function () { - expect(openStackFactory.createOpenstackBackup).toEqual(jasmine.any(Function)); - }); - - describe('when stopOpenstackServices method is executed', function () { - beforeEach(function () { - $httpBackend.expect('GET', '/api/upgrade7/openstack-services/stop') - .respond(200, mockedStopOpenStackServicesPromise); - stopOpenStackServicesPromise = openStackFactory.stopOpenstackServices(); - }); - - it('returns a promise', function () { - expect(stopOpenStackServicesPromise).toEqual(jasmine.any(Object)); - expect(stopOpenStackServicesPromise['then']).toEqual(jasmine.any(Function)); - expect(stopOpenStackServicesPromise['catch']).toEqual(jasmine.any(Function)); - expect(stopOpenStackServicesPromise['finally']).toEqual(jasmine.any(Function)); - expect(stopOpenStackServicesPromise['error']).toEqual(jasmine.any(Function)); - expect(stopOpenStackServicesPromise['success']).toEqual(jasmine.any(Function)); - }); - - // stopOpenStackServices success, partially passing and/or failing are handled in the controller. - it('when resolved, it returns the stopOpenStackServices response', function () { - stopOpenStackServicesPromise.then(function (stopOpenstackServicesResponse) { - expect(stopOpenstackServicesResponse.status).toEqual(200); - expect(stopOpenstackServicesResponse.data).toEqual(mockedStopOpenStackServicesPromise); - }); - $httpBackend.flush(); - }); - }); - - describe('when createOpenstackBackup method is executed', function () { - beforeEach(function () { - $httpBackend.expect('GET', '/api/upgrade7/openstack-services/backup') - .respond(200, mockedCreateOpenstackBackupPromise); - createOpenstackBackupPromise = openStackFactory.createOpenstackBackup(); - }); - - it('returns a promise', function () { - expect(createOpenstackBackupPromise).toEqual(jasmine.any(Object)); - expect(createOpenstackBackupPromise['then']).toEqual(jasmine.any(Function)); - expect(createOpenstackBackupPromise['catch']).toEqual(jasmine.any(Function)); - expect(createOpenstackBackupPromise['finally']).toEqual(jasmine.any(Function)); - expect(createOpenstackBackupPromise['error']).toEqual(jasmine.any(Function)); - expect(createOpenstackBackupPromise['success']).toEqual(jasmine.any(Function)); - }); - - it('when resolved, it returns the createOpenstackBackupServices response', function () { - createOpenstackBackupPromise.then(function (createOpenstackBackupResponse) { - expect(createOpenstackBackupResponse.status).toEqual(200); - expect(createOpenstackBackupResponse.data).toEqual(mockedCreateOpenstackBackupPromise); - }); - $httpBackend.flush(); - }); - }); - }); -}); diff --git a/assets/app/data/services/upgrade/prechecks.factory.js b/assets/app/data/services/upgrade/prechecks.factory.js deleted file mode 100644 index 1c434733..00000000 --- a/assets/app/data/services/upgrade/prechecks.factory.js +++ /dev/null @@ -1,27 +0,0 @@ -(function() { - - angular - .module('crowbarData.upgrade') - .factory('upgradePrechecksFactory', upgradePrechecksFactory); - - upgradePrechecksFactory.$inject = ['$q', '$http', 'COMMON_API_V2_HEADERS']; - /* @ngInject */ - function upgradePrechecksFactory($q, $http, COMMON_API_V2_HEADERS) { - var factory = { - getAll: getPrechecks - }; - - return factory; - - function getPrechecks() { - - var requestOptions = { - method: 'GET', - url: '/api/upgrade7/prechecks', - headers: COMMON_API_V2_HEADERS - }; - - return $http(requestOptions); - } - } -})(); diff --git a/assets/app/data/services/upgrade/prechecks.factory.spec.js b/assets/app/data/services/upgrade/prechecks.factory.spec.js deleted file mode 100644 index 12c13083..00000000 --- a/assets/app/data/services/upgrade/prechecks.factory.spec.js +++ /dev/null @@ -1,59 +0,0 @@ -/*global bard $httpBackend should expect upgradePrechecksFactory */ -describe('Upgrade Prechecks Factory', function () { - - var mockedprechecksPromise = { - 'updates_installed': true, - 'network_sanity': true, - 'high_availability': true, - 'free_node_available': true - }, - prechecksPromise; - - beforeEach(function () { - //Setup the module and dependencies to be used. - bard.appModule('crowbarData.upgrade'); - bard.inject('upgradePrechecksFactory', '$q', '$httpBackend'); - }); - - describe('when executed', function () { - - it('returns an object', function () { - should.exist(upgradePrechecksFactory); - }); - - it('returns an object with getAll function is defined', function () { - expect(upgradePrechecksFactory.getAll).toEqual(jasmine.any(Function)); - }); - - describe('when getAll method is executed', function () { - - beforeEach(function () { - - $httpBackend.expect('GET', '/api/upgrade7/prechecks') - .respond(200, mockedprechecksPromise); - prechecksPromise = upgradePrechecksFactory.getAll(); - }); - - it('returns a promise', function () { - expect(prechecksPromise).toEqual(jasmine.any(Object)); - expect(prechecksPromise['then']).toEqual(jasmine.any(Function)); - expect(prechecksPromise['catch']).toEqual(jasmine.any(Function)); - expect(prechecksPromise['finally']).toEqual(jasmine.any(Function)); - expect(prechecksPromise['error']).toEqual(jasmine.any(Function)); - expect(prechecksPromise['success']).toEqual(jasmine.any(Function)); - }); - - // Prechecks success, partially passing and/or failing are handled in the controller. - it('when resolved, it returns the prechecks response', function () { - prechecksPromise.then(function (prechecksResponse) { - expect(prechecksResponse.status).toEqual(200); - expect(prechecksResponse.data).toEqual(mockedprechecksPromise); - }); - $httpBackend.flush(); - }); - - }); - - }); - -}); diff --git a/assets/app/data/services/upgrade/repositories-checks.factory.js b/assets/app/data/services/upgrade/repositories-checks.factory.js deleted file mode 100644 index 9350e88e..00000000 --- a/assets/app/data/services/upgrade/repositories-checks.factory.js +++ /dev/null @@ -1,39 +0,0 @@ -(function() { - - angular - .module('crowbarData.upgrade') - .factory('upgradeRepositoriesChecksFactory', upgradeRepositoriesChecksFactory); - - upgradeRepositoriesChecksFactory.$inject = ['$q', '$http', 'COMMON_API_V2_HEADERS']; - /* @ngInject */ - function upgradeRepositoriesChecksFactory($q, $http, COMMON_API_V2_HEADERS) { - var factory = { - getAdminRepoChecks: getAdminRepoChecks, - getNodesRepoChecks: getNodesRepoChecks - }; - - return factory; - - function getAdminRepoChecks() { - - var requestOptions = { - method: 'GET', - url: '/api/upgrade7/admin-repo-checks', - headers: COMMON_API_V2_HEADERS - }; - - return $http(requestOptions); - } - - function getNodesRepoChecks() { - - var requestOptions = { - method: 'GET', - url: '/api/upgrade/repocheck', - headers: COMMON_API_V2_HEADERS - }; - - return $http(requestOptions); - } - } -})(); diff --git a/assets/app/data/services/upgrade/repositories-checks.factory.spec.js b/assets/app/data/services/upgrade/repositories-checks.factory.spec.js deleted file mode 100644 index 0208820f..00000000 --- a/assets/app/data/services/upgrade/repositories-checks.factory.spec.js +++ /dev/null @@ -1,103 +0,0 @@ -/*global bard $httpBackend should expect upgradeRepositoriesChecksFactory */ -describe('Upgrade Repo Checks Factory', function () { - - var mockedAdminRepoChecksData = { - 'SLES_12_SP2': false, - 'SLES_12_SP2_Updates': false, - 'SLES_OpenStack_Cloud_7': false, - 'SLES_OpenStack_Cloud_7_Updates': false - }, - adminRepoChecksPromise, - mockedNodesRepoChecksData = { - 'SLES_12_SP2': false, - 'SLES_12_SP2_Updates': false, - 'SLES_OpenStack_Cloud_7': false, - 'SLES_OpenStack_Cloud_7_Updates': false, - 'SLE_HA_12_SP2': false, - 'SLE_HA_12_SP2_Updates': false, - 'SUSE_Enterprise_Storage_4': false, - 'SUSE_Enterprise_Storage_4_Updates': false - }, - nodesRepoChecksPromise; - - beforeEach(function () { - //Setup the module and dependencies to be used. - bard.appModule('crowbarData.upgrade'); - bard.inject('upgradeRepositoriesChecksFactory', '$q', '$httpBackend'); - }); - - describe('when executed', function () { - - it('returns an object', function () { - should.exist(upgradeRepositoriesChecksFactory); - }); - - it('returns an object with getAdminRepoChecks function is defined', function () { - expect(upgradeRepositoriesChecksFactory.getAdminRepoChecks).toEqual(jasmine.any(Function)); - }); - - it('returns an object with getNodesRepoChecks function is defined', function () { - expect(upgradeRepositoriesChecksFactory.getNodesRepoChecks).toEqual(jasmine.any(Function)); - }); - - describe('when getAdminRepoChecks method is executed', function () { - - beforeEach(function () { - - $httpBackend.expect('GET', '/api/upgrade7/admin-repo-checks') - .respond(200, mockedAdminRepoChecksData); - adminRepoChecksPromise = upgradeRepositoriesChecksFactory.getAdminRepoChecks(); - }); - - it('returns a promise', function () { - expect(adminRepoChecksPromise).toEqual(jasmine.any(Object)); - expect(adminRepoChecksPromise['then']).toEqual(jasmine.any(Function)); - expect(adminRepoChecksPromise['catch']).toEqual(jasmine.any(Function)); - expect(adminRepoChecksPromise['finally']).toEqual(jasmine.any(Function)); - expect(adminRepoChecksPromise['error']).toEqual(jasmine.any(Function)); - expect(adminRepoChecksPromise['success']).toEqual(jasmine.any(Function)); - }); - - // repoChecks success, partially passing and/or failing are handled in the controller. - it('when resolved, it returns the repoChecks response', function () { - adminRepoChecksPromise.then(function (repoChecksResponse) { - expect(repoChecksResponse.status).toEqual(200); - expect(repoChecksResponse.data).toEqual(mockedAdminRepoChecksData); - }); - $httpBackend.flush(); - }); - - }); - - describe('when getNodesRepoChecks method is executed', function () { - - beforeEach(function () { - - $httpBackend.expect('GET', '/api/upgrade/repocheck') - .respond(200, mockedNodesRepoChecksData); - nodesRepoChecksPromise = upgradeRepositoriesChecksFactory.getNodesRepoChecks(); - }); - - it('returns a promise', function () { - expect(nodesRepoChecksPromise).toEqual(jasmine.any(Object)); - expect(nodesRepoChecksPromise['then']).toEqual(jasmine.any(Function)); - expect(nodesRepoChecksPromise['catch']).toEqual(jasmine.any(Function)); - expect(nodesRepoChecksPromise['finally']).toEqual(jasmine.any(Function)); - expect(nodesRepoChecksPromise['error']).toEqual(jasmine.any(Function)); - expect(nodesRepoChecksPromise['success']).toEqual(jasmine.any(Function)); - }); - - // repoChecks success, partially passing and/or failing are handled in the controller. - it('when resolved, it returns the repoChecks response', function () { - nodesRepoChecksPromise.then(function (repoChecksResponse) { - expect(repoChecksResponse.status).toEqual(200); - expect(repoChecksResponse.data).toEqual(mockedNodesRepoChecksData); - }); - $httpBackend.flush(); - }); - - }); - - }); - -}); diff --git a/assets/app/data/services/upgrade/upgrade-administration-server.factory.js b/assets/app/data/services/upgrade/upgrade-administration-server.factory.js deleted file mode 100644 index 5caaec75..00000000 --- a/assets/app/data/services/upgrade/upgrade-administration-server.factory.js +++ /dev/null @@ -1,35 +0,0 @@ -(function() { - - angular - .module('crowbarData.upgrade') - .factory('upgradeUpgradeAdministrationServerFactory', upgradeUpgradeAdministrationServerFactory); - - upgradeUpgradeAdministrationServerFactory.$inject = ['$q', '$http', 'COMMON_API_V2_HEADERS']; - /* @ngInject */ - function upgradeUpgradeAdministrationServerFactory($q, $http, COMMON_API_V2_HEADERS) { - return { - getAdminUpgrade: getAdminUpgrade, - getAdminUpgradeStatus: getAdminUpgradeStatus - }; - - function getAdminUpgrade() { - var requestOptions = { - method: 'POST', - url: '/api/upgrade7/admin-upgrade', - headers: COMMON_API_V2_HEADERS - }; - - return $http(requestOptions); - } - - function getAdminUpgradeStatus() { - var requestOptions = { - method: 'GET', - url: '/api/upgrade7/admin-upgrade', - headers: COMMON_API_V2_HEADERS - }; - - return $http(requestOptions); - } - } -})(); diff --git a/assets/app/data/services/upgrade/upgrade-administration-server.factory.spec.js b/assets/app/data/services/upgrade/upgrade-administration-server.factory.spec.js deleted file mode 100644 index 7f37185e..00000000 --- a/assets/app/data/services/upgrade/upgrade-administration-server.factory.spec.js +++ /dev/null @@ -1,84 +0,0 @@ -/*global bard should expect upgradeUpgradeAdministrationServerFactory $httpBackend */ -describe('Upgrade Upgrade Admin Factory', function () { - var mockedStatusResponse = { - 'some_stuff': 'abc', - 'completed': false - }, - testPromise; - - beforeEach(function () { - //Setup the module and dependencies to be used. - bard.appModule('crowbarData.upgrade'); - bard.inject('upgradeUpgradeAdministrationServerFactory', '$q', '$httpBackend'); - }); - - describe('when executed', function () { - - it('returns an object', function () { - should.exist(upgradeUpgradeAdministrationServerFactory); - }); - - it('returns an object with getAdminUpgrade function defined', function () { - expect(upgradeUpgradeAdministrationServerFactory.getAdminUpgrade).toEqual(jasmine.any(Function)); - }); - - describe('when getAdminUpgrade method is executed', function () { - beforeEach(function () { - $httpBackend.expect('POST', '/api/upgrade7/admin-upgrade') - .respond(200, mockedStatusResponse); - testPromise = upgradeUpgradeAdministrationServerFactory.getAdminUpgrade(); - }); - - it('returns a promise', function () { - expect(testPromise).toEqual(jasmine.any(Object)); - expect(testPromise['then']).toEqual(jasmine.any(Function)); - expect(testPromise['catch']).toEqual(jasmine.any(Function)); - expect(testPromise['finally']).toEqual(jasmine.any(Function)); - expect(testPromise['error']).toEqual(jasmine.any(Function)); - expect(testPromise['success']).toEqual(jasmine.any(Function)); - }); - - // admin upgrade starting status is handled in the controller. - it('when resolved, it returns the test response', function () { - testPromise.then(function (testResponse) { - expect(testResponse.status).toEqual(200); - expect(testResponse.data).toEqual(mockedStatusResponse); - }); - $httpBackend.flush(); - }); - }); - - - it('returns an object with getAdminUpgradeStatus function defined', function () { - expect(upgradeUpgradeAdministrationServerFactory.getAdminUpgradeStatus).toEqual(jasmine.any(Function)); - }); - - describe('when getAdminUpgradeStatus method is executed', function () { - beforeEach(function () { - $httpBackend.expect('GET', '/api/upgrade7/admin-upgrade') - .respond(200, mockedStatusResponse); - testPromise = upgradeUpgradeAdministrationServerFactory.getAdminUpgradeStatus(); - }); - - it('returns a promise', function () { - expect(testPromise).toEqual(jasmine.any(Object)); - expect(testPromise['then']).toEqual(jasmine.any(Function)); - expect(testPromise['catch']).toEqual(jasmine.any(Function)); - expect(testPromise['finally']).toEqual(jasmine.any(Function)); - expect(testPromise['error']).toEqual(jasmine.any(Function)); - expect(testPromise['success']).toEqual(jasmine.any(Function)); - }); - - // admin upgrade status response is handled in the controller. - it('when resolved, it returns the test response', function () { - testPromise.then(function (testResponse) { - expect(testResponse.status).toEqual(200); - expect(testResponse.data).toEqual(mockedStatusResponse); - }); - $httpBackend.flush(); - }); - }); - - }); - -}); diff --git a/assets/app/data/suse-data.module.js b/assets/app/data/suse-data.module.js new file mode 100644 index 00000000..32ec76c8 --- /dev/null +++ b/assets/app/data/suse-data.module.js @@ -0,0 +1,5 @@ +(function () { + 'use strict'; + + angular.module('suseData', ['suseData.crowbar']); +})(); diff --git a/assets/app/features/upgrade/controllers/upgrade7-administration-repositories-checks.controller.js b/assets/app/features/upgrade/controllers/upgrade7-administration-repositories-checks.controller.js index 21eb404c..23881afc 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-administration-repositories-checks.controller.js +++ b/assets/app/features/upgrade/controllers/upgrade7-administration-repositories-checks.controller.js @@ -12,9 +12,9 @@ .controller('Upgrade7AdministrationRepositoriesCheckController', Upgrade7AdministrationRepositoriesCheckController); - Upgrade7AdministrationRepositoriesCheckController.$inject = ['$translate', 'upgradeRepositoriesChecksFactory']; + Upgrade7AdministrationRepositoriesCheckController.$inject = ['$translate', 'crowbarFactory']; // @ngInject - function Upgrade7AdministrationRepositoriesCheckController($translate, upgradeRepositoriesChecksFactory) { + function Upgrade7AdministrationRepositoriesCheckController($translate, crowbarFactory) { var vm = this; vm.repoChecks = { running: false, @@ -48,7 +48,7 @@ function runRepoChecks() { vm.repoChecks.running = true; - upgradeRepositoriesChecksFactory.getAdminRepoChecks() + crowbarFactory.getRepositoriesChecks() .then( // In case of success function (repoChecksResponse) { diff --git a/assets/app/features/upgrade/controllers/upgrade7-administration-repositories-checks.controller.spec.js b/assets/app/features/upgrade/controllers/upgrade7-administration-repositories-checks.controller.spec.js index f0eca85e..13e5f6fd 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-administration-repositories-checks.controller.spec.js +++ b/assets/app/features/upgrade/controllers/upgrade7-administration-repositories-checks.controller.spec.js @@ -1,4 +1,4 @@ -/*global bard $controller $httpBackend should assert upgradeRepositoriesChecksFactory $q $rootScope */ +/*global bard $controller $httpBackend should assert crowbarFactory $q $rootScope */ describe('Upgrade Flow - Admin Repositories Checks Controller', function () { var controller, passingRepoChecks = { @@ -40,7 +40,7 @@ describe('Upgrade Flow - Admin Repositories Checks Controller', function () { beforeEach(function() { //Setup the module and dependencies to be used. bard.appModule('crowbarApp'); - bard.inject('$controller', 'upgradeRepositoriesChecksFactory', '$q', '$httpBackend', '$rootScope'); + bard.inject('$controller', 'crowbarFactory', '$q', '$httpBackend', '$rootScope'); //Create the controller controller = $controller('Upgrade7AdministrationRepositoriesCheckController'); @@ -93,8 +93,8 @@ describe('Upgrade Flow - Admin Repositories Checks Controller', function () { describe('when successfull', function () { beforeEach(function () { - bard.mockService(upgradeRepositoriesChecksFactory, { - getAdminRepoChecks: $q.when(passingReposChecksResponse) + bard.mockService(crowbarFactory, { + getRepositoriesChecks: $q.when(passingReposChecksResponse) }); controller.repoChecks.runRepoChecks(); $rootScope.$digest(); @@ -118,8 +118,8 @@ describe('Upgrade Flow - Admin Repositories Checks Controller', function () { describe('when checks fails', function () { beforeEach(function () { - bard.mockService(upgradeRepositoriesChecksFactory, { - getAdminRepoChecks: $q.when(failingReposChecksResponse) + bard.mockService(crowbarFactory, { + getRepositoriesChecks: $q.when(failingReposChecksResponse) }); controller.repoChecks.runRepoChecks(); $rootScope.$digest(); @@ -142,8 +142,8 @@ describe('Upgrade Flow - Admin Repositories Checks Controller', function () { describe('when checks partially fails', function () { beforeEach(function () { - bard.mockService(upgradeRepositoriesChecksFactory, { - getAdminRepoChecks: $q.when(partiallyFailingChecksResponse) + bard.mockService(crowbarFactory, { + getRepositoriesChecks: $q.when(partiallyFailingChecksResponse) }); controller.repoChecks.runRepoChecks(); $rootScope.$digest(); @@ -167,8 +167,8 @@ describe('Upgrade Flow - Admin Repositories Checks Controller', function () { describe('when service call fails', function () { beforeEach(function () { - bard.mockService(upgradeRepositoriesChecksFactory, { - getAdminRepoChecks: $q.reject(failingReposResponse) + bard.mockService(crowbarFactory, { + getRepositoriesChecks: $q.reject(failingReposResponse) }); controller.repoChecks.runRepoChecks(); $rootScope.$digest(); diff --git a/assets/app/features/upgrade/controllers/upgrade7-backup.controller.js b/assets/app/features/upgrade/controllers/upgrade7-backup.controller.js index c1a50938..9b92f249 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-backup.controller.js +++ b/assets/app/features/upgrade/controllers/upgrade7-backup.controller.js @@ -12,9 +12,9 @@ function() { angular.module('crowbarApp') .controller('Upgrade7BackupController', Upgrade7BackupController); - Upgrade7BackupController.$inject = ['$translate', '$state', 'upgradeBackupFactory', '$document']; + Upgrade7BackupController.$inject = ['$translate', '$state', 'crowbarBackupFactory', '$document']; // @ngInject - function Upgrade7BackupController($translate, $state, upgradeBackupFactory, $document) { + function Upgrade7BackupController($translate, $state, crowbarBackupFactory, $document) { var vm = this; vm.backup = { running: false, @@ -27,7 +27,7 @@ function() { function createBackup() { vm.backup.running = true; - upgradeBackupFactory.create() + crowbarBackupFactory.create() .then( function (response) { // the ID should always be returned in a successfull response @@ -56,7 +56,7 @@ function() { } function downloadBackup(backupId) { - upgradeBackupFactory.download(backupId) + crowbarBackupFactory.getBackup(backupId) .then( // When Backup Data has been created successfully function (response) { diff --git a/assets/app/features/upgrade/controllers/upgrade7-backup.controller.spec.js b/assets/app/features/upgrade/controllers/upgrade7-backup.controller.spec.js index f256678b..82b67d6a 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-backup.controller.spec.js +++ b/assets/app/features/upgrade/controllers/upgrade7-backup.controller.spec.js @@ -1,5 +1,5 @@ /* jshint -W117, -W030 */ -/*global bard $controller $httpBackend should assert upgradeBackupFactory $q $rootScope $document */ +/*global bard $controller $httpBackend should assert crowbarBackupFactory $q $rootScope $document */ describe('Upgrade Flow - Backup Controller', function() { var controller, mockedErrorList = [ 1, 2, 3], @@ -26,7 +26,7 @@ describe('Upgrade Flow - Backup Controller', function() { beforeEach(function() { //Setup the module and dependencies to be used. bard.appModule('crowbarApp'); - bard.inject('$controller', '$rootScope', '$q', '$httpBackend', '$document', 'upgradeBackupFactory'); + bard.inject('$controller', '$rootScope', '$q', '$httpBackend', '$document', 'crowbarBackupFactory'); //Create the controller controller = $controller('Upgrade7BackupController'); @@ -65,7 +65,7 @@ describe('Upgrade Flow - Backup Controller', function() { beforeEach(function () { spyOn(controller.backup, 'download'); - bard.mockService(upgradeBackupFactory, { + bard.mockService(crowbarBackupFactory, { create: $q.when(mockedCreateResponse) }); controller.backup.create(); @@ -85,8 +85,8 @@ describe('Upgrade Flow - Backup Controller', function() { beforeEach(function () { spyOn(controller.backup, 'download'); - bard.mockService(upgradeBackupFactory, { - create: $q.reject(mockedErrorResponse) + bard.mockService(crowbarBackupFactory, { + create: $q.reject(mockedErrorResponse), }); controller.backup.create(); $rootScope.$digest(); @@ -132,23 +132,26 @@ describe('Upgrade Flow - Backup Controller', function() { spyOn(mockedDownloadResponse, 'headers') .and.returnValue(mockedDownloadResponseHeaders); - // Mock the download() method of the upgradeBackupFactory, + // Mock the download() method of the crowbarBackupFactory, // and return a custom promise instead - bard.mockService(upgradeBackupFactory, { - download: $q.when(mockedDownloadResponse) + bard.mockService(crowbarBackupFactory, { + getBackup: $q.when(mockedDownloadResponse) }); - // Run the backup download + // Run the backup getBackup function controller.backup.download(42); $rootScope.$digest(); }); it('click() method should have been triggered to download the backup', function () { - assert.isTrue(upgradeBackupFactory.download.calledOnce); expect($document[0].createElement).toHaveBeenCalledWith('a'); expect(downloadBackupMock.click).toHaveBeenCalled(); }) + it('crowbarBackupFactory.getBackup() has been called once', function () { + assert.isTrue(crowbarBackupFactory.getBackup.calledOnce); + }); + it('changes the completed status', function() { assert.isTrue(controller.backup.completed); }); @@ -161,14 +164,18 @@ describe('Upgrade Flow - Backup Controller', function() { describe('on failure', function () { beforeEach(function () { - bard.mockService(upgradeBackupFactory, { - download: $q.reject(mockedErrorResponse) + bard.mockService(crowbarBackupFactory, { + getBackup: $q.reject(mockedErrorResponse) }); controller.backup.download(42); $rootScope.$digest(); }); + it('crowbarBackupFactory.getBackup() has been called once', function () { + assert.isTrue(crowbarBackupFactory.getBackup.calledOnce); + }); + it('changes the completed status', function() { assert.isTrue(controller.backup.completed); }); diff --git a/assets/app/features/upgrade/controllers/upgrade7-landing.controller.js b/assets/app/features/upgrade/controllers/upgrade7-landing.controller.js index 2f111865..f7a7bc65 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-landing.controller.js +++ b/assets/app/features/upgrade/controllers/upgrade7-landing.controller.js @@ -11,9 +11,9 @@ angular.module('crowbarApp') .controller('Upgrade7LandingController', Upgrade7LandingController); - Upgrade7LandingController.$inject = ['$translate', '$state', 'upgradePrechecksFactory']; + Upgrade7LandingController.$inject = ['$translate', '$state', 'upgradeFactory']; // @ngInject - function Upgrade7LandingController($translate, $state, upgradePrechecksFactory) { + function Upgrade7LandingController($translate, $state, upgradeFactory) { var vm = this; vm.beginUpgrade = beginUpgrade; @@ -61,8 +61,8 @@ function runPrechecks() { vm.prechecks.running = true; - upgradePrechecksFactory - .getAll() + upgradeFactory + .getPreliminaryChecks() .then( //Success handler. Al precheck passed successfully: function(prechecksResponse) { diff --git a/assets/app/features/upgrade/controllers/upgrade7-landing.controller.spec.js b/assets/app/features/upgrade/controllers/upgrade7-landing.controller.spec.js index 31a6f483..7f9ae689 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-landing.controller.spec.js +++ b/assets/app/features/upgrade/controllers/upgrade7-landing.controller.spec.js @@ -1,5 +1,5 @@ /* jshint -W117, -W030 */ -/*global bard $controller $httpBackend should assert upgradePrechecksFactory $q $rootScope module $state */ +/*global bard $controller $httpBackend should assert upgradeFactory $q $rootScope module $state */ describe('Upgrade Landing Controller', function() { var controller, passingChecks = { @@ -41,7 +41,7 @@ describe('Upgrade Landing Controller', function() { beforeEach(function() { //Setup the module and dependencies to be used. bard.appModule('crowbarApp'); - bard.inject('$controller', '$rootScope', 'upgradePrechecksFactory', '$q', '$httpBackend'); + bard.inject('$controller', '$rootScope', 'upgradeFactory', '$q', '$httpBackend'); //Create the controller controller = $controller('Upgrade7LandingController'); @@ -101,8 +101,8 @@ describe('Upgrade Landing Controller', function() { describe('when checks pass successfully', function () { beforeEach(function () { - bard.mockService(upgradePrechecksFactory, { - getAll: $q.when(passingChecksResponse) + bard.mockService(upgradeFactory, { + getPreliminaryChecks: $q.when(passingChecksResponse) }); controller.prechecks.runPrechecks(); $rootScope.$digest(); @@ -126,8 +126,8 @@ describe('Upgrade Landing Controller', function() { describe('when checks fails', function () { beforeEach(function () { - bard.mockService(upgradePrechecksFactory, { - getAll: $q.when(failingChecksResponse) + bard.mockService(upgradeFactory, { + getPreliminaryChecks: $q.when(failingChecksResponse) }); controller.prechecks.runPrechecks(); $rootScope.$digest(); @@ -151,8 +151,8 @@ describe('Upgrade Landing Controller', function() { describe('when checks partially fails', function () { beforeEach(function () { - bard.mockService(upgradePrechecksFactory, { - getAll: $q.when(partiallyFailingChecksResponse) + bard.mockService(upgradeFactory, { + getPreliminaryChecks: $q.when(partiallyFailingChecksResponse) }); controller.prechecks.runPrechecks(); $rootScope.$digest(); @@ -176,8 +176,8 @@ describe('Upgrade Landing Controller', function() { describe('when service call fails', function () { beforeEach(function () { - bard.mockService(upgradePrechecksFactory, { - getAll: $q.reject(failingResponse) + bard.mockService(upgradeFactory, { + getPreliminaryChecks: $q.reject(failingResponse) }); controller.prechecks.runPrechecks(); $rootScope.$digest(); diff --git a/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js b/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js index a0b3393d..50c55016 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js +++ b/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js @@ -13,13 +13,13 @@ Upgrade7NodesRepositoriesCheckController.$inject = [ '$translate', - 'upgradeRepositoriesChecksFactory', + 'upgradeFactory', 'NODES_PRODUCTS_REPO_CHECKS_MAP' ]; // @ngInject function Upgrade7NodesRepositoriesCheckController( $translate, - upgradeRepositoriesChecksFactory, + upgradeFactory, NODES_PRODUCTS_REPO_CHECKS_MAP ) { var vm = this; @@ -71,7 +71,7 @@ function runRepoChecks() { vm.repoChecks.running = true; - upgradeRepositoriesChecksFactory.getNodesRepoChecks() + upgradeFactory.getNodesRepoChecks() .then( // In case of success onSuccessGetNodesRepoChecks, diff --git a/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.spec.js b/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.spec.js index 0c711333..d65a5947 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.spec.js +++ b/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.spec.js @@ -1,4 +1,4 @@ -/*global bard $controller $httpBackend should assert upgradeRepositoriesChecksFactory $q $rootScope */ +/*global bard $controller $httpBackend should assert upgradeFactory $q $rootScope */ describe('Upgrade Flow - Nodes Repositories Checks Controller', function () { var controller, failingRepoChecks = { @@ -165,7 +165,7 @@ describe('Upgrade Flow - Nodes Repositories Checks Controller', function () { bard.appModule('crowbarApp'); bard.inject( '$controller', - 'upgradeRepositoriesChecksFactory', + 'upgradeFactory', '$q', '$httpBackend', '$rootScope', @@ -223,7 +223,7 @@ describe('Upgrade Flow - Nodes Repositories Checks Controller', function () { describe('when checks pass successfull', function () { beforeEach(function () { - bard.mockService(upgradeRepositoriesChecksFactory, { + bard.mockService(upgradeFactory, { getNodesRepoChecks: $q.when(passingReposChecksResponse) }); controller.repoChecks.runRepoChecks(); @@ -249,7 +249,7 @@ describe('Upgrade Flow - Nodes Repositories Checks Controller', function () { describe('when checks fails', function () { beforeEach(function () { - bard.mockService(upgradeRepositoriesChecksFactory, { + bard.mockService(upgradeFactory, { getNodesRepoChecks: $q.when(failingReposChecksResponse) }); controller.repoChecks.runRepoChecks(); @@ -274,7 +274,7 @@ describe('Upgrade Flow - Nodes Repositories Checks Controller', function () { describe('when checks partially fails', function () { beforeEach(function () { - bard.mockService(upgradeRepositoriesChecksFactory, { + bard.mockService(upgradeFactory, { getNodesRepoChecks: $q.when(partiallyFailingReposChecksResponse) }); controller.repoChecks.runRepoChecks(); @@ -334,7 +334,7 @@ describe('Upgrade Flow - Nodes Repositories Checks Controller', function () { describe('when service call fails', function () { beforeEach(function () { - bard.mockService(upgradeRepositoriesChecksFactory, { + bard.mockService(upgradeFactory, { getNodesRepoChecks: $q.reject(failingResponse) }); controller.repoChecks.runRepoChecks(); diff --git a/assets/app/features/upgrade/controllers/upgrade7-openstack-services.controller.js b/assets/app/features/upgrade/controllers/upgrade7-openstack-services.controller.js index 42fa55d6..ff29e043 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-openstack-services.controller.js +++ b/assets/app/features/upgrade/controllers/upgrade7-openstack-services.controller.js @@ -11,9 +11,9 @@ angular.module('crowbarApp') .controller('Upgrade7OpenStackServicesController', Upgrade7OpenStackServicesController); - Upgrade7OpenStackServicesController.$inject = ['$translate', 'openStackFactory']; + Upgrade7OpenStackServicesController.$inject = ['$translate', 'openstackFactory']; // @ngInject - function Upgrade7OpenStackServicesController($translate, openStackFactory) { + function Upgrade7OpenStackServicesController($translate, openstackFactory) { var vm = this; @@ -32,37 +32,37 @@ label: 'upgrade7.steps.openstack-services.codes.backup' } }, - stopOpenStackServices: stopOpenStackServices + stopServices: stopServices }; /** * Validate OpenStackServices required for Cloud 7 Upgrade */ - function stopOpenStackServices() { + function stopServices() { vm.openStackServices.running = true; - openStackFactory.stopOpenstackServices() + openstackFactory.stopServices() .then( //Success handler. Stop all OpenStackServices successfully: - stopOpenstackServicesSuccess, + stopServicesSuccess, //Failure handler: - stopOpenstackServicesError + stopServicesError ); - function stopOpenstackServicesSuccess (openStackServicesResponse) { + function stopServicesSuccess (openStackServicesResponse) { vm.openStackServices.checks.services.status = vm.openStackServices.valid = openStackServicesResponse.data.services; if (vm.openStackServices.checks.services.status) { - openStackFactory.createOpenstackBackup() + openstackFactory.createBackup() .then( //Success handler. Backup OpenStackServices successfully: - createOpenstackBackupSuccess, + createBackupSuccess, //Failure handler: - createOpenstackBackupError + createBackupError ).finally(function() { vm.openStackServices.completed = true; // Update openStackServices validity @@ -77,19 +77,19 @@ } } - function stopOpenstackServicesError (errorOpenStackServicesResponse) { + function stopServicesError (errorOpenStackServicesResponse) { vm.openStackServices.completed = true; vm.openStackServices.running = false; // Expose the error list to openStackServices object vm.openStackServices.errors = errorOpenStackServicesResponse.data.errors; } - function createOpenstackBackupSuccess (openStackBackupResponse) { + function createBackupSuccess (openStackBackupResponse) { vm.openStackServices.checks.backup.status = openStackBackupResponse.data.backup; } - function createOpenstackBackupError (errorOpenStackServicesResponse) { + function createBackupError (errorOpenStackServicesResponse) { // Expose the error list to openStackServices object vm.openStackServices.errors = errorOpenStackServicesResponse.data.errors; diff --git a/assets/app/features/upgrade/controllers/upgrade7-openstack-services.controller.spec.js b/assets/app/features/upgrade/controllers/upgrade7-openstack-services.controller.spec.js index 826314d5..04a75467 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-openstack-services.controller.spec.js +++ b/assets/app/features/upgrade/controllers/upgrade7-openstack-services.controller.spec.js @@ -1,4 +1,4 @@ -/*global bard $controller $httpBackend should assert openStackFactory $q $rootScope */ +/*global bard $controller $httpBackend should assert openstackFactory $q $rootScope */ describe('openStack Services Controller', function() { var controller, passingOpenStackServices = { @@ -16,16 +16,16 @@ describe('openStack Services Controller', function() { failingErrors = { error_message: 'Authentication failure' }, - passingOpenStackServicesResponse = { + passingServicesResponse = { data: passingOpenStackServices }, failingOpenStackServicesResponse = { data: failingOpenStackServices }, - passingOpenStackBackupResponse = { + passingBackupResponse = { data: passingOpenStackBackup }, - failingOpenStackBackupResponse = { + failingBackupResponse = { data: failingOpenStackBackup }, failingResponse = { @@ -37,7 +37,7 @@ describe('openStack Services Controller', function() { beforeEach(function() { //Setup the module and dependencies to be used. bard.appModule('crowbarApp'); - bard.inject('$controller', '$rootScope', 'openStackFactory', '$q', '$httpBackend'); + bard.inject('$controller', '$rootScope', 'openstackFactory', '$q', '$httpBackend'); //Create the controller controller = $controller('Upgrade7OpenStackServicesController'); @@ -92,201 +92,201 @@ describe('openStack Services Controller', function() { }); }); }); - }); - describe('stopOpenStackServices function', function () { - it('should be defined', function () { - should.exist(controller.openStackServices.stopOpenStackServices); - }); + describe('stopServices function', function () { + it('should be defined', function () { + should.exist(controller.openStackServices.stopServices); + }); - describe('when services check and backup check pass successfull', function () { - beforeEach(function () { - bard.mockService(openStackFactory, { - stopOpenstackServices: $q.when(passingOpenStackServicesResponse), - createOpenstackBackup: $q.when(passingOpenStackBackupResponse) + describe('when services check and backup check pass successfully', function () { + beforeEach(function () { + bard.mockService(openstackFactory, { + stopServices: $q.when(passingServicesResponse), + createBackup: $q.when(passingBackupResponse) + }); + controller.openStackServices.stopServices(); + $rootScope.$digest(); }); - controller.openStackServices.stopOpenStackServices(); - $rootScope.$digest(); - }); - it('should set openStackServices.completed status to true', function () { - assert.isTrue(controller.openStackServices.completed); - }); + it('should set openStackServices.completed status to true', function () { + assert.isTrue(controller.openStackServices.completed); + }); - it('should update valid attribute of checks model to true', function () { - assert.isTrue(controller.openStackServices.valid); - }); + it('should update valid attribute of checks model to true', function () { + assert.isTrue(controller.openStackServices.valid); + }); - it('should set running to false', function () { - assert.isFalse(controller.openStackServices.running); - }); + it('should set running to false', function () { + assert.isFalse(controller.openStackServices.running); + }); - it('should call stopOpenstack service', function () { - assert.isTrue(openStackFactory.stopOpenstackServices.calledOnce); - }); + it('should call stopOpenstack service', function () { + assert.isTrue(openstackFactory.stopServices.calledOnce); + }); - it('should update services check value to true', function () { - assert.isTrue(controller.openStackServices.checks.services.status); - }); + it('should update services check value to true', function () { + assert.isTrue(controller.openStackServices.checks.services.status); + }); - it('should call backup service', function () { - assert.isTrue(openStackFactory.createOpenstackBackup.calledOnce); - }); + it('should call backup service', function () { + assert.isTrue(openstackFactory.createBackup.calledOnce); + }); + + it('should update backup check value to true', function () { + assert.isTrue(controller.openStackServices.checks.backup.status); + }); - it('should update backup check value to true', function () { - assert.isTrue(controller.openStackServices.checks.backup.status); }); - }); + describe('when services check pass successfull and backup check fails', function () { + beforeEach(function () { + bard.mockService(openstackFactory, { + stopServices: $q.when(passingServicesResponse), + createBackup: $q.when(failingBackupResponse) + }); + controller.openStackServices.stopServices(); + $rootScope.$digest(); + }); - describe('when services check pass successfull and backup check fails', function () { - beforeEach(function () { - bard.mockService(openStackFactory, { - stopOpenstackServices: $q.when(passingOpenStackServicesResponse), - createOpenstackBackup: $q.when(failingOpenStackBackupResponse) + it('should set openStackServices.completed status to true', function () { + assert.isTrue(controller.openStackServices.completed); }); - controller.openStackServices.stopOpenStackServices(); - $rootScope.$digest(); - }); - it('should set openStackServices.completed status to true', function () { - assert.isTrue(controller.openStackServices.completed); - }); + it('should update valid attribute of checks model to false', function () { + assert.isFalse(controller.openStackServices.valid); + }); - it('should update valid attribute of checks model to false', function () { - assert.isFalse(controller.openStackServices.valid); - }); + it('should set running to false', function () { + assert.isFalse(controller.openStackServices.running); + }); - it('should set running to false', function () { - assert.isFalse(controller.openStackServices.running); - }); + it('should call stopOpenstack service', function () { + assert.isTrue(openstackFactory.stopServices.calledOnce); + }); - it('should call stopOpenstack service', function () { - assert.isTrue(openStackFactory.stopOpenstackServices.calledOnce); - }); + it('should update services check value to true', function () { + assert.isTrue(controller.openStackServices.checks.services.status); + }); - it('should update services check value to true', function () { - assert.isTrue(controller.openStackServices.checks.services.status); - }); + it('should call backup service', function () { + assert.isTrue(openstackFactory.createBackup.calledOnce); + }); - it('should call backup service', function () { - assert.isTrue(openStackFactory.createOpenstackBackup.calledOnce); - }); + it('should update backup check value to false', function () { + assert.isFalse(controller.openStackServices.checks.backup.status); + }); - it('should update backup check value to false', function () { - assert.isFalse(controller.openStackServices.checks.backup.status); }); - }); + describe('when services check pass successfull and backup service call fails', function () { + beforeEach(function () { + bard.mockService(openstackFactory, { + stopServices: $q.when(passingServicesResponse), + createBackup: $q.reject(failingResponse) + }); + controller.openStackServices.stopServices(); + $rootScope.$digest(); + }); - describe('when services check pass successfull and backup service call fails', function () { - beforeEach(function () { - bard.mockService(openStackFactory, { - stopOpenstackServices: $q.when(passingOpenStackServicesResponse), - createOpenstackBackup: $q.reject(failingResponse) + it('should set openStackServices.completed status to true', function () { + assert.isTrue(controller.openStackServices.completed); }); - controller.openStackServices.stopOpenStackServices(); - $rootScope.$digest(); - }); - it('should set openStackServices.completed status to true', function () { - assert.isTrue(controller.openStackServices.completed); - }); + it('should update valid attribute of checks model to false', function () { + assert.isFalse(controller.openStackServices.valid); + }); - it('should update valid attribute of checks model to false', function () { - assert.isFalse(controller.openStackServices.valid); - }); + it('should set running to false', function () { + assert.isFalse(controller.openStackServices.running); + }); - it('should set running to false', function () { - assert.isFalse(controller.openStackServices.running); - }); + it('should call stopOpenstack service', function () { + assert.isTrue(openstackFactory.stopServices.calledOnce); + }); - it('should call stopOpenstack service', function () { - assert.isTrue(openStackFactory.stopOpenstackServices.calledOnce); - }); + it('should update services check value to true', function () { + assert.isTrue(controller.openStackServices.checks.services.status); + }); - it('should update services check value to true', function () { - assert.isTrue(controller.openStackServices.checks.services.status); - }); + it('should call backup service', function () { + assert.isTrue(openstackFactory.createBackup.calledOnce); + }); - it('should call backup service', function () { - assert.isTrue(openStackFactory.createOpenstackBackup.calledOnce); - }); + it('should expose the errors through vm.openStackServices.errors object', function () { + expect(controller.openStackServices.errors).toEqual(failingResponse.data.errors); + }); - it('should expose the errors through vm.openStackServices.errors object', function () { - expect(controller.openStackServices.errors).toEqual(failingResponse.data.errors); }); - }); + describe('when services check fails', function () { + beforeEach(function () { + spyOn(openstackFactory, 'createBackup'); - describe('when services check fails', function () { - beforeEach(function () { - spyOn(openStackFactory, 'createOpenstackBackup'); + bard.mockService(openstackFactory, { + stopServices: $q.when(failingOpenStackServicesResponse) + }); + controller.openStackServices.stopServices(); + $rootScope.$digest(); - bard.mockService(openStackFactory, { - stopOpenstackServices: $q.when(failingOpenStackServicesResponse) }); - controller.openStackServices.stopOpenStackServices(); - $rootScope.$digest(); - }); + it('should set openStackServices.completed status to true', function () { + assert.isTrue(controller.openStackServices.completed); + }); - it('should set openStackServices.completed status to true', function () { - assert.isTrue(controller.openStackServices.completed); - }); + it('should update valid attribute of checks model to false', function () { + assert.isFalse(controller.openStackServices.valid); + }); - it('should update valid attribute of checks model to false', function () { - assert.isFalse(controller.openStackServices.valid); - }); + it('should set running to false', function () { + assert.isFalse(controller.openStackServices.running); + }); - it('should set running to false', function () { - assert.isFalse(controller.openStackServices.running); - }); + it('should call stopOpenstack service', function () { + assert.isTrue(openstackFactory.stopServices.calledOnce); + }); - it('should call stopOpenstack service', function () { - assert.isTrue(openStackFactory.stopOpenstackServices.calledOnce); - }); + it('should update services checks values to false', function () { + assert.isFalse(controller.openStackServices.checks.services.status); + }); - it('should update services checks values to false', function () { - assert.isFalse(controller.openStackServices.checks.services.status); - }); + it('should not call backup service', function () { + expect(openstackFactory.createBackup).not.toHaveBeenCalled(); + }); - it('should not call backup service', function () { - expect(openStackFactory.createOpenstackBackup).not.toHaveBeenCalled(); }); - }); + describe('when stopOpenstack service call fails', function () { + beforeEach(function () { + spyOn(openstackFactory, 'createBackup'); + bard.mockService(openstackFactory, { + stopServices: $q.reject(failingResponse) + }); + controller.openStackServices.stopServices(); + $rootScope.$digest(); + }); - describe('when stopOpenstack service call fails', function () { - beforeEach(function () { - spyOn(openStackFactory, 'createOpenstackBackup'); - bard.mockService(openStackFactory, { - stopOpenstackServices: $q.reject(failingResponse) + it('should set openStackServices.completed status to true', function () { + assert.isTrue(controller.openStackServices.completed); }); - controller.openStackServices.stopOpenStackServices(); - $rootScope.$digest(); - }); - it('should set openStackServices.completed status to true', function () { - assert.isTrue(controller.openStackServices.completed); - }); + it('should update valid attribute of checks model to false', function () { + assert.isFalse(controller.openStackServices.valid); + }); - it('should update valid attribute of checks model to false', function () { - assert.isFalse(controller.openStackServices.valid); - }); + it('should set running to false', function () { + assert.isFalse(controller.openStackServices.running); + }); - it('should set running to false', function () { - assert.isFalse(controller.openStackServices.running); - }); + it('should not call backup service', function () { + expect(openstackFactory.createBackup).not.toHaveBeenCalled(); + }); - it('should not call backup service', function () { - expect(openStackFactory.createOpenstackBackup).not.toHaveBeenCalled(); - }); + it('should expose the errors through vm.openStackServices.errors object', function () { + expect(controller.openStackServices.errors).toEqual(failingResponse.data.errors); + }); - it('should expose the errors through vm.openStackServices.errors object', function () { - expect(controller.openStackServices.errors).toEqual(failingResponse.data.errors); }); - }); }); diff --git a/assets/app/features/upgrade/controllers/upgrade7-upgrade-administration-server.controller.js b/assets/app/features/upgrade/controllers/upgrade7-upgrade-administration-server.controller.js index e11a2b66..0bc27280 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-upgrade-administration-server.controller.js +++ b/assets/app/features/upgrade/controllers/upgrade7-upgrade-administration-server.controller.js @@ -11,9 +11,9 @@ angular.module('crowbarApp') .controller('Upgrade7UpgradeAdministrationServerController', Upgrade7UpgradeAdministrationServerController); - Upgrade7UpgradeAdministrationServerController.$inject = ['$timeout', 'upgradeUpgradeAdministrationServerFactory']; + Upgrade7UpgradeAdministrationServerController.$inject = ['$timeout', 'crowbarFactory']; // @ngInject - function Upgrade7UpgradeAdministrationServerController($timeout, upgradeUpgradeAdministrationServerFactory) { + function Upgrade7UpgradeAdministrationServerController($timeout, crowbarFactory) { var vm = this; vm.adminUpgrade = { completed: false, @@ -27,7 +27,7 @@ function beginAdminUpgrade() { vm.adminUpgrade.running = true; - upgradeUpgradeAdministrationServerFactory.getAdminUpgrade() + crowbarFactory.upgrade() .then( // In case of success function (/*response*/) { @@ -44,7 +44,7 @@ } function checkAdminUpgrade() { - upgradeUpgradeAdministrationServerFactory.getAdminUpgradeStatus() + crowbarFactory.getUpgradeStatus() .then( // In case of success function (response) { diff --git a/assets/app/features/upgrade/controllers/upgrade7-upgrade-administration-server.controller.spec.js b/assets/app/features/upgrade/controllers/upgrade7-upgrade-administration-server.controller.spec.js index d2a195f5..4ee65d84 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-upgrade-administration-server.controller.spec.js +++ b/assets/app/features/upgrade/controllers/upgrade7-upgrade-administration-server.controller.spec.js @@ -1,4 +1,4 @@ -/*global bard $controller should $httpBackend upgradeUpgradeAdministrationServerFactory assert $q $rootScope */ +/*global bard $controller should $httpBackend crowbarFactory assert $q $rootScope */ describe('Upgrade Flow - Upgrade Administration Server Controller', function () { var controller, completedUpgradeResponse = { @@ -16,7 +16,7 @@ describe('Upgrade Flow - Upgrade Administration Server Controller', function () beforeEach(function() { //Setup the module and dependencies to be used. bard.appModule('crowbarApp'); - bard.inject('$controller', '$q', '$httpBackend', '$rootScope', 'upgradeUpgradeAdministrationServerFactory'); + bard.inject('$controller', '$q', '$httpBackend', '$rootScope', 'crowbarFactory'); mockedTimeout = jasmine.createSpy('$timeout'); @@ -58,8 +58,8 @@ describe('Upgrade Flow - Upgrade Administration Server Controller', function () beforeEach(function () { spyOn(controller.adminUpgrade, 'checkAdminUpgrade'); - bard.mockService(upgradeUpgradeAdministrationServerFactory, { - getAdminUpgrade: $q.when(incompleteUpgradeResponse) + bard.mockService(crowbarFactory, { + upgrade: $q.when(incompleteUpgradeResponse) }); controller.adminUpgrade.beginAdminUpgrade(); $rootScope.$digest(); @@ -78,8 +78,8 @@ describe('Upgrade Flow - Upgrade Administration Server Controller', function () beforeEach(function () { spyOn(controller.adminUpgrade, 'checkAdminUpgrade'); - bard.mockService(upgradeUpgradeAdministrationServerFactory, { - getAdminUpgrade: $q.reject(errorResponse) + bard.mockService(crowbarFactory, { + upgrade: $q.reject(errorResponse) }); controller.adminUpgrade.beginAdminUpgrade(); $rootScope.$digest(); @@ -109,8 +109,8 @@ describe('Upgrade Flow - Upgrade Administration Server Controller', function () describe('when got upgrade status from api successfully', function () { describe('when received status is completed', function () { beforeEach(function () { - bard.mockService(upgradeUpgradeAdministrationServerFactory, { - getAdminUpgradeStatus: $q.when(completedUpgradeResponse) + bard.mockService(crowbarFactory, { + getUpgradeStatus: $q.when(completedUpgradeResponse) }); controller.adminUpgrade.checkAdminUpgrade(); $rootScope.$digest(); @@ -129,8 +129,8 @@ describe('Upgrade Flow - Upgrade Administration Server Controller', function () describe('when received status is not completed', function () { beforeEach(function () { - bard.mockService(upgradeUpgradeAdministrationServerFactory, { - getAdminUpgradeStatus: $q.when(incompleteUpgradeResponse) + bard.mockService(crowbarFactory, { + getUpgradeStatus: $q.when(incompleteUpgradeResponse) }); controller.adminUpgrade.running = true; controller.adminUpgrade.checkAdminUpgrade(); @@ -151,8 +151,8 @@ describe('Upgrade Flow - Upgrade Administration Server Controller', function () describe('when got error from api', function () { beforeEach(function () { - bard.mockService(upgradeUpgradeAdministrationServerFactory, { - getAdminUpgradeStatus: $q.reject(errorResponse) + bard.mockService(crowbarFactory, { + getUpgradeStatus: $q.reject(errorResponse) }); controller.adminUpgrade.checkAdminUpgrade(); $rootScope.$digest(); diff --git a/assets/app/features/upgrade/templates/upgrade7/openstack-services.jade b/assets/app/features/upgrade/templates/upgrade7/openstack-services.jade index a42f6e75..e1dbd416 100644 --- a/assets/app/features/upgrade/templates/upgrade7/openstack-services.jade +++ b/assets/app/features/upgrade/templates/upgrade7/openstack-services.jade @@ -2,7 +2,7 @@ h2(translate='') upgrade7.steps.openstack-services.title p(translate='') upgrade7.steps.openstack-services.description button.btn.btn-success.center-block( - ng-click='upgradeOpenStackServicesVm.openStackServices.stopOpenStackServices()', + ng-click='upgradeOpenStackServicesVm.openStackServices.stopServices()', ng-disabled='(upgradeOpenStackServicesVm.openStackServices.completed && upgradeOpenStackServicesVm.openStackServices.valid) || upgradeOpenStackServicesVm.openStackServices.running', ng-class='{\ "spinner-visible": upgradeOpenStackServicesVm.openStackServices.spinnerVisible,\ diff --git a/assets/index.jade b/assets/index.jade index 56939986..9c686f5f 100644 --- a/assets/index.jade +++ b/assets/index.jade @@ -22,18 +22,17 @@ html(ng-app='crowbarApp') // Crowbar Core script(src='app/core/crowbar-core.module.js') - // Crowbar Data - script(src='app/data/crowbar-data.module.js') - script(src='app/data/services/steps.factory.js') - // Crowbar Data - Upgrade - script(src='app/data/services/upgrade/crowbar-data.module.js') - script(src='app/data/services/upgrade/common-api-v2.constants.js') - script(src='app/data/services/upgrade/steps.factory.js') - script(src='app/data/services/upgrade/prechecks.factory.js') - script(src='app/data/services/upgrade/backup.factory.js') - script(src='app/data/services/upgrade/repositories-checks.factory.js') - script(src='app/data/services/upgrade/upgrade-administration-server.factory.js') - script(src='app/data/services/upgrade/openstack-services.factory.js') + // Suse Data + script(src='app/data/suse-data.module.js') + + // Suse Data - Crowbar + script(src='app/data/crowbar/crowbar.module.js') + script(src='app/data/crowbar/common-api-v2.constants.js') + script(src='app/data/crowbar/steps.factory.js') + script(src='app/data/crowbar/services/crowbar.factory.js') + script(src='app/data/crowbar/services/crowbar-backup.factory.js') + script(src='app/data/crowbar/services/upgrade.factory.js') + script(src='app/data/crowbar/services/openstack.factory.js') // Crowbar Widgets script(src='app/widgets/crowbar-widgets.module.js') diff --git a/routes/api/upgrade7/S33z8qFX.jpg.zip b/routes/api/crowbar/backups/1.zip similarity index 100% rename from routes/api/upgrade7/S33z8qFX.jpg.zip rename to routes/api/crowbar/backups/1.zip diff --git a/routes/api/crowbar/backups/create.js b/routes/api/crowbar/backups/create.js new file mode 100644 index 00000000..2c81c41d --- /dev/null +++ b/routes/api/crowbar/backups/create.js @@ -0,0 +1,17 @@ +var express = require('express'), + router = express.Router(); + +/* GET Admin Repo Checks. */ +router.post('/', function(req, res) { + res.status(200).json({ + 'id': 1, + 'name': 'testbackup', + 'version': '4.0', + 'size': 76815, + 'created_at': '2016-09-27T06:05:10.208Z', + 'updated_at': '2016-09-27T06:05:10.208Z', + 'migration_level': 20160819142156 + }); +}); + +module.exports = router; diff --git a/routes/api/upgrade7/backup.js b/routes/api/crowbar/backups/download.js similarity index 84% rename from routes/api/upgrade7/backup.js rename to routes/api/crowbar/backups/download.js index 77cb29fb..1bb66cc1 100644 --- a/routes/api/upgrade7/backup.js +++ b/routes/api/crowbar/backups/download.js @@ -4,9 +4,9 @@ var express = require('express'), mime = require('mime'), fs = require('fs'); -router.post('/', function(req, res) { +router.get('/', function(req, res) { - var file = __dirname + '/S33z8qFX.jpg.zip', + var file = __dirname + '/1.zip', filename = path.basename(file), mimetype = mime.lookup(file), filestream = fs.createReadStream(file); diff --git a/routes/api/crowbar/entity.js b/routes/api/crowbar/entity.js new file mode 100644 index 00000000..511c4306 --- /dev/null +++ b/routes/api/crowbar/entity.js @@ -0,0 +1,15 @@ +var express = require('express'), + router = express.Router(); + +/* GET crowbar entity. */ +router.get('/', function(req, res) { + res.status(200).json({ + 'version': '4.0', + 'addons': [ + 'ceph', + 'ha' + ] + }); +}); + +module.exports = router; diff --git a/routes/api/upgrade7/admin-repo-checks.js b/routes/api/crowbar/repocheck.js similarity index 100% rename from routes/api/upgrade7/admin-repo-checks.js rename to routes/api/crowbar/repocheck.js diff --git a/routes/api/upgrade7/admin-upgrade.js b/routes/api/crowbar/upgrade.js similarity index 100% rename from routes/api/upgrade7/admin-upgrade.js rename to routes/api/crowbar/upgrade.js diff --git a/routes/api/upgrade7/openstack-services-backup.js b/routes/api/openstack/backup.js similarity index 66% rename from routes/api/upgrade7/openstack-services-backup.js rename to routes/api/openstack/backup.js index 4a2d9196..6bf59652 100644 --- a/routes/api/upgrade7/openstack-services-backup.js +++ b/routes/api/openstack/backup.js @@ -1,8 +1,8 @@ var express = require('express'), router = express.Router(); -/* GET openStack services Checks. */ -router.get('/', function(req, res) { +/* POST openStack services Checks. */ +router.post('/', function(req, res) { res.status(200).json({ 'backup': true }); diff --git a/routes/api/upgrade7/stop-openstack-services.js b/routes/api/openstack/services.js similarity index 67% rename from routes/api/upgrade7/stop-openstack-services.js rename to routes/api/openstack/services.js index 157a562e..5440717d 100644 --- a/routes/api/upgrade7/stop-openstack-services.js +++ b/routes/api/openstack/services.js @@ -2,8 +2,8 @@ var express = require('express'), router = express.Router(); -/* GET openStack services Checks. */ -router.get('/', function(req, res) { +/* POST openStack services Checks. */ +router.post('/', function(req, res) { res.status(200).json({ 'services': true }); diff --git a/routes/api/steps.js b/routes/api/steps.js deleted file mode 100644 index 79c3a2dc..00000000 --- a/routes/api/steps.js +++ /dev/null @@ -1,82 +0,0 @@ -var express = require('express'), - router = express.Router(); - -var steps = [ - { - id: 0, - title: 'Prepare Client Node', - state: 'upgrade.prepare', - active: true, - enabled: true - }, - { - id: 1, - title: 'Download Upgrade Data', - state: 'upgrade.backup', - active: false, - enabled: false - }, - { - id: 2, - title: 'Reinstall Admin Server', - state: 'upgrade.reinstall-admin', - active: false, - enabled: false - }, - { - id: 3, - title: 'Continue Upgrade', - state: 'upgrade.continue-upgrade', - active: false, - enabled: false - }, - { - id: 4, - title: 'Restore', - state: 'upgrade.restore-admin', - active: false, - enabled: false - }, - { - id: 5, - title: 'Verify Repositories', - state: 'upgrade.verify-repos', - active: false, - enabled: false - }, - { - id: 6, - title: 'Stop OpenStack Services', - state: 'upgrade.stop-openstack-services', - active: false, - enabled: false - }, - { - id: 7, - title: 'Data Backup', - state: 'upgrade.openstack-backup', - active: false, - enabled: false - }, - { - id: 8, - title: 'Upgrading Nodes OS', - state: 'upgrade.upgrade-nodes-os', - active: false, - enabled: false - }, - { - id: 9, - title: 'Finishing Upgrade', - state: 'upgrade.finishing-upgrade', - active: false, - enabled: false - } -]; - -/* GET users listing. */ -router.get('/', function(req, res) { - res.status(200).json(steps); -}); - -module.exports = router; diff --git a/routes/api/upgrade7/prechecks.js b/routes/api/upgrade/prechecks.js similarity index 100% rename from routes/api/upgrade7/prechecks.js rename to routes/api/upgrade/prechecks.js diff --git a/routes/api/upgrade7/steps.js b/routes/api/upgrade7/steps.js deleted file mode 100644 index 46cc0926..00000000 --- a/routes/api/upgrade7/steps.js +++ /dev/null @@ -1,61 +0,0 @@ -var express = require('express'), - router = express.Router(); - -var steps = [ - { - id: 0, - title: 'Download Backup of Administration Server', - state: 'upgrade7.backup', - active: true, - enabled: true - }, - { - id: 1, - title: 'Check Administration Server Repositories', - state: 'upgrade7.administration-repository-checks', - active: false, - enabled: false - }, - { - id: 2, - title: 'Upgrade Administration Server', - state: 'upgrade7.upgrade-administration-server', - active: false, - enabled: false - }, - { - id: 3, - title: 'Connect or Create OpenStack Database', - state: 'upgrade7.database-configuration', - active: false, - enabled: false - }, - { - id: 4, - title: 'Check Add-On & Node Repositories', - state: 'upgrade7.nodes-repositories-checks', - active: false, - enabled: false - }, - { - id: 5, - title: 'Migrate OpenStack Database', - state: 'upgrade7.migrate-openstack-database', - active: false, - enabled: false - }, - { - id: 6, - title: 'Upgrade Nodes & Reapply Barclamps', - state: 'upgrade7.finish-upgrade', - active: false, - enabled: false - } -]; - -/* GET users listing. */ -router.get('/', function(req, res) { - res.status(200).json(steps); -}); - -module.exports = router; From cc48972a47f0ec8c124b3cf9fc0a2735330b5dd1 Mon Sep 17 00:00:00 2001 From: Santiago Petrone Date: Tue, 11 Oct 2016 14:40:11 +0200 Subject: [PATCH 5/7] Address comments from PR --- assets/app/data/crowbar/services/crowbar-backup.factory.js | 2 +- .../upgrade/controllers/upgrade7-backup.controller.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/app/data/crowbar/services/crowbar-backup.factory.js b/assets/app/data/crowbar/services/crowbar-backup.factory.js index 3810fcac..52976210 100644 --- a/assets/app/data/crowbar/services/crowbar-backup.factory.js +++ b/assets/app/data/crowbar/services/crowbar-backup.factory.js @@ -40,7 +40,7 @@ function getBackup(id) { // this should never happen, caller should make sure 'id' is set if (angular.isUndefined(id)) { - throw Error('downloadBackup() called without id.'); + throw Error('getBackup() called without id.'); } var requestOptions = { diff --git a/assets/app/features/upgrade/controllers/upgrade7-backup.controller.spec.js b/assets/app/features/upgrade/controllers/upgrade7-backup.controller.spec.js index 82b67d6a..c62900eb 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-backup.controller.spec.js +++ b/assets/app/features/upgrade/controllers/upgrade7-backup.controller.spec.js @@ -86,7 +86,7 @@ describe('Upgrade Flow - Backup Controller', function() { spyOn(controller.backup, 'download'); bard.mockService(crowbarBackupFactory, { - create: $q.reject(mockedErrorResponse), + create: $q.reject(mockedErrorResponse) }); controller.backup.create(); $rootScope.$digest(); From 272b9de8d4cadb91ec0df3122f920d5d1892488d Mon Sep 17 00:00:00 2001 From: Santiago Petrone Date: Tue, 11 Oct 2016 16:17:14 +0200 Subject: [PATCH 6/7] Show repositories for AddOn products only if they're available --- ...e7-nodes-repositories-checks.controller.js | 55 +++++++++++++------ ...des-repositories-checks.controller.spec.js | 16 +++++- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js b/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js index 50c55016..23494414 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js +++ b/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.js @@ -14,15 +14,35 @@ Upgrade7NodesRepositoriesCheckController.$inject = [ '$translate', 'upgradeFactory', + 'crowbarFactory', 'NODES_PRODUCTS_REPO_CHECKS_MAP' ]; // @ngInject function Upgrade7NodesRepositoriesCheckController( $translate, upgradeFactory, + crowbarFactory, NODES_PRODUCTS_REPO_CHECKS_MAP ) { - var vm = this; + var vm = this, + addonsRepos = { + 'SLE12-SP2-HA-Pool': { + status: false, + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLE12-SP2-HA-Pool' + }, + 'SLE12-SP2-HA-Updates': { + status: false, + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLE12-SP2-HA-Updates' + }, + 'SUSE-Enterprise-Storage-4-Pool': { + status: false, + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE-Enterprise-Storage-4-Pool' + }, + 'SUSE-Enterprise-Storage-4-Updates': { + status: false, + label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE-Enterprise-Storage-4-Updates' + } + }; vm.repoChecks = { completed: false, valid: false, @@ -42,22 +62,6 @@ 'SUSE-OpenStack-Cloud-7-Updates': { status: false, label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE-OpenStack-Cloud-7-Updates' - }, - 'SLE12-SP2-HA-Pool': { - status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLE12-SP2-HA-Pool' - }, - 'SLE12-SP2-HA-Updates': { - status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SLE12-SP2-HA-Updates' - }, - 'SUSE-Enterprise-Storage-4-Pool': { - status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE-Enterprise-Storage-4-Pool' - }, - 'SUSE-Enterprise-Storage-4-Updates': { - status: false, - label: 'upgrade7.steps.nodes-repository-checks.repositories.codes.SUSE-Enterprise-Storage-4-Updates' } }, runRepoChecks: runRepoChecks, @@ -65,6 +69,23 @@ spinnerVisible: false }; + activate(); + + /** + * Activation of the Nodes and AddOns Repository checks page + */ + function activate() { + crowbarFactory.getEntity().then(function (entityResponse) { + if (! _.isEmpty(entityResponse.data.addons)) { + _.forEach(entityResponse.data.addons, function (addon) { + _.forEach(NODES_PRODUCTS_REPO_CHECKS_MAP[addon], function (addonRepository) { + _.set(vm.repoChecks.checks, addonRepository, addonsRepos[addonRepository]); + }); + + }); + } + }); + } /** * Validate Nodes Repositories required for Cloud 7 Upgrade */ diff --git a/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.spec.js b/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.spec.js index d65a5947..1aea280e 100644 --- a/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.spec.js +++ b/assets/app/features/upgrade/controllers/upgrade7-nodes-repositories-checks.controller.spec.js @@ -1,4 +1,4 @@ -/*global bard $controller $httpBackend should assert upgradeFactory $q $rootScope */ +/*global bard $controller $httpBackend should assert upgradeFactory $q $rootScope crowbarFactory */ describe('Upgrade Flow - Nodes Repositories Checks Controller', function () { var controller, failingRepoChecks = { @@ -145,6 +145,15 @@ describe('Upgrade Flow - Nodes Repositories Checks Controller', function () { failingErrors = { error_message: 'Authentication failure' }, + entityResponse = { + data: { + 'version': '4.0', + 'addons': [ + 'ceph', + 'ha' + ] + } + }, passingReposChecksResponse = { data: passingRepoChecks }, @@ -166,12 +175,17 @@ describe('Upgrade Flow - Nodes Repositories Checks Controller', function () { bard.inject( '$controller', 'upgradeFactory', + 'crowbarFactory', '$q', '$httpBackend', '$rootScope', 'NODES_PRODUCTS_REPO_CHECKS_MAP' ); + bard.mockService(crowbarFactory, { + getEntity: $q.when(entityResponse) + }); + //Create the controller controller = $controller('Upgrade7NodesRepositoriesCheckController'); From 409d6cb7ae1b30b530e30a9db687cedee724b644 Mon Sep 17 00:00:00 2001 From: Santiago Petrone Date: Wed, 12 Oct 2016 14:53:54 +0200 Subject: [PATCH 7/7] Align name of Backup factory methods --- .../app/data/crowbar/services/crowbar-backup.factory.js | 2 +- .../data/crowbar/services/crowbar-backup.factory.spec.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/assets/app/data/crowbar/services/crowbar-backup.factory.js b/assets/app/data/crowbar/services/crowbar-backup.factory.js index 52976210..4724400e 100644 --- a/assets/app/data/crowbar/services/crowbar-backup.factory.js +++ b/assets/app/data/crowbar/services/crowbar-backup.factory.js @@ -9,7 +9,7 @@ function crowbarBackupFactory($q, $http, $filter, COMMON_API_V2_HEADERS) { var factory = { create: createBackup, - getBackup: getBackup + get: getBackup }; return factory; diff --git a/assets/app/data/crowbar/services/crowbar-backup.factory.spec.js b/assets/app/data/crowbar/services/crowbar-backup.factory.spec.js index 17214304..bc1c90a1 100644 --- a/assets/app/data/crowbar/services/crowbar-backup.factory.spec.js +++ b/assets/app/data/crowbar/services/crowbar-backup.factory.spec.js @@ -29,8 +29,8 @@ describe('Crowbar Backup Factory', function () { expect(crowbarBackupFactory.create).toEqual(jasmine.any(Function)); }); - it('returns an object with getBackup function defined', function () { - expect(crowbarBackupFactory.getBackup).toEqual(jasmine.any(Function)); + it('returns an object with get function defined', function () { + expect(crowbarBackupFactory.get).toEqual(jasmine.any(Function)); }); describe('when create method is executed', function () { @@ -65,7 +65,7 @@ describe('Crowbar Backup Factory', function () { beforeEach(function () { $httpBackend.expect('GET', '/api/crowbar/backups/42/download') .respond(200, mockedBackupFile); - backupPromise = crowbarBackupFactory.getBackup(42); + backupPromise = crowbarBackupFactory.get(42); $httpBackend.flush(); }); @@ -92,7 +92,7 @@ describe('Crowbar Backup Factory', function () { describe('when download method is executed without parameter', function () { it('throws an exception', function () { - expect(crowbarBackupFactory.getBackup).toThrow(); + expect(crowbarBackupFactory.get).toThrow(); }); }); });