Browse Source

AMBARI-7906. Slider apps: It is not possible to correct invalid allocation of resources without wizard close (alexantonenko)

Alex Antonenko 10 years ago
parent
commit
72799ea188

+ 1 - 1
contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step4_controller.js

@@ -98,7 +98,7 @@ App.CreateAppWizardStep4Controller = Ember.ObjectController.extend(App.AjaxError
       });
     }
     return resources;
-  }.property('newApp.components.@each'),
+  }.property('newApp.components.@each.numInstances', 'newApp.components.@each.yarnMemory', 'newApp.components.@each.yarnCPU', 'newApp.components.@each.priority', 'newApp.components.@each.yarnLabelChecked', 'newApp.components.@each.yarnLabel'),
 
   /**
    * Load all required data for step

+ 74 - 0
contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step4_controller_test.js

@@ -56,4 +56,78 @@ test('isSubmitDisabled', function () {
   controller.sendAppDataToServerCompleteCallback();
   equal(controller.get('isSubmitDisabled'), false, 'should be false after sendAppDataToServerCompleteCallback call');
 
+});
+
+test('resourcesFormatted', function () {
+
+  var cases = [
+      {
+        propertyName: 'numInstances',
+        expectedPropertyName: 'instanceCount',
+        value: '1'
+      },
+      {
+        propertyName: 'yarnMemory',
+        expectedPropertyName: 'yarnMemory',
+        value: '256'
+      },
+      {
+        propertyName: 'yarnCPU',
+        expectedPropertyName: 'yarnCpuCores',
+        value: '2'
+      },
+      {
+        propertyName: 'priority',
+        expectedPropertyName: 'priority',
+        value: 2
+      }
+    ],
+    title = '{0} should be {1}',
+    label = 'label';
+
+  var controller = this.subject({
+    newApp: Em.Object.create({
+      components: [
+        Em.Object.create({
+          name: 'c',
+          numInstances: '0',
+          yarnMemory: '512',
+          yarnCPU: '1',
+          priority: 1
+        })
+      ]
+    })
+  });
+
+  cases.forEach(function (item) {
+
+    Em.run(function () {
+      controller.get('newApp.components')[0].set(item.propertyName, item.value);
+    });
+
+    equal(controller.get('resourcesFormatted.components')[0][item.expectedPropertyName], item.value, title.format(item.expectedPropertyName, item.value));
+
+  });
+
+  Em.run(function () {
+    controller.get('newApp.components')[0].setProperties({
+      yarnLabelChecked: false,
+      yarnLabel: label
+    });
+  });
+
+  ok(!controller.get('resourcesFormatted.components')[0].yarnLabel, 'yarnLabel shouldn\'t be set');
+
+  Em.run(function () {
+    controller.get('newApp.components')[0].set('yarnLabelChecked', true);
+  });
+
+  equal(controller.get('resourcesFormatted.components')[0].yarnLabel, label, title.format('yarnLabel', '\'' + label + '\''));
+
+  Em.run(function () {
+    controller.get('newApp.components')[0].set('yarnLabel', ' ' + label + '\n');
+  });
+
+  equal(controller.get('resourcesFormatted.components')[0].yarnLabel, label, 'yarnLabel should be trimmed');
+
 });