Pārlūkot izejas kodu

AMBARI-22047. Cannot upgrade stack due to 'Version XXXXX does not contain services that are installed' (alexantonenko)

Alex Antonenko 8 gadi atpakaļ
vecāks
revīzija
06d21bb385

+ 1 - 1
ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js

@@ -1513,7 +1513,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
     var availableServices = repo.get('stackServices').filter(function(service) {
       return App.Service.find(service.get('name')).get('isLoaded') && service.get('isAvailable') && service.get('isUpgradable');
     }, this);
-    if (!availableServices.length){
+    if (!availableServices.length && !repo.get('isStandard')){
       return App.showAlertPopup( Em.I18n.t('admin.stackVersions.upgrade.installPackage.fail.title'), Em.I18n.t('admin.stackVersions.upgrade.installPackage.fail.noAvailableServices').format(repo.get('displayName')) );
     }
     var self = this;

+ 21 - 3
ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js

@@ -1170,18 +1170,36 @@ describe('App.MainAdminStackAndUpgradeController', function() {
   describe("#installRepoVersionPopup()", function () {
     before(function () {
       sinon.stub(controller, 'installRepoVersion', Em.K);
-      sinon.stub(App.Service, 'find').returns({});
+      sinon.stub(App.Service, 'find').returns(Em.Object.create({
+        isLoaded: true
+      }));
     });
     after(function () {
       controller.installRepoVersion.restore();
       App.Service.find.restore();
     });
-    it("show popup", function () {
-      var repo = Em.Object.create({'displayName': 'HDP-2.2', stackServices: []});
+    it("show confirmation popup for non standart and available services", function () {
+      var repo = Em.Object.create({'displayName': 'HDP-2.2', isStandard: false, stackServices: [Em.Object.create({
+        name: 'HDFS',
+        isUpgradable: true,
+        isAvailable: true
+      })]});
+      var popup = controller.installRepoVersionPopup(repo);
+      popup.onPrimary();
+      expect(controller.installRepoVersion.calledWith(repo)).to.be.true;
+    });
+    it("show pre-check popup for non standard and empty available services", function () {
+      var repo = Em.Object.create({'displayName': 'HDP-2.2', isStandard: false, stackServices: []});
       var popup = controller.installRepoVersionPopup(repo);
       popup.onPrimary();
       expect(controller.installRepoVersion.calledWith(repo)).to.be.false;
     });
+    it("show confirmation popup for standart", function () {
+      var repo = Em.Object.create({'displayName': 'HDP-2.2', isStandard: true, stackServices: []});
+      var popup = controller.installRepoVersionPopup(repo);
+      popup.onPrimary();
+      expect(controller.installRepoVersion.calledWith(repo)).to.be.true;
+    });
   });
 
   describe("#installRepoVersion()", function () {