You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/04/19 01:41:02 UTC

svn commit: r1469637 - in /incubator/ambari/trunk: CHANGES.txt ambari-web/app/controllers/wizard/step2_controller.js ambari-web/test/installer/step2_test.js

Author: yusaku
Date: Thu Apr 18 23:41:01 2013
New Revision: 1469637

URL: http://svn.apache.org/r1469637
Log:
AMBARI-1988. Hostname pattern expression is broken. (yusaku)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-web/app/controllers/wizard/step2_controller.js
    incubator/ambari/trunk/ambari-web/test/installer/step2_test.js

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1469637&r1=1469636&r2=1469637&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Thu Apr 18 23:41:01 2013
@@ -768,6 +768,8 @@ Trunk (unreleased changes):
 
  BUG FIXES
 
+ AMBARI-1988. Hostname pattern expression is broken. (yusaku)
+
  AMBARI-1986. HDFS General section has disappeared from Customize Services 
  step of the Install Wizard. (yusaku)
 

Modified: incubator/ambari/trunk/ambari-web/app/controllers/wizard/step2_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/wizard/step2_controller.js?rev=1469637&r1=1469636&r2=1469637&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/wizard/step2_controller.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/wizard/step2_controller.js Thu Apr 18 23:41:01 2013
@@ -199,15 +199,15 @@ App.WizardStep2Controller = Em.Controlle
         start=start[0].substr(1);
         end=end[0].substr(1);
 
-        if(parseInt(start) <= parseInt(end) && parseInt(start) >= 0){
+        if(parseInt(start) <= parseInt(end, 10) && parseInt(start, 10) >= 0){
           self.isPattern = true;
 
           if(start[0] == "0" && start.length > 1) {
             extra = start.match(/0*/);
           }
 
-          for (var i = parseInt(start); i < parseInt(end) + 1; i++) {
-            hostNames.push(a.replace(/\[\d*\-\d*\]/,extra[0].substring(1,1+extra[0].length-i.toString().length)+i))
+          for (var i = parseInt(start, 10); i < parseInt(end, 10) + 1; i++) {
+            hostNames.push(a.replace(/\[\d*\-\d*\]/,extra[0].substring(0,start.length-i.toString().length)+i))
           }
 
         }else{

Modified: incubator/ambari/trunk/ambari-web/test/installer/step2_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/installer/step2_test.js?rev=1469637&r1=1469636&r2=1469637&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/installer/step2_test.js (original)
+++ incubator/ambari/trunk/ambari-web/test/installer/step2_test.js Thu Apr 18 23:41:01 2013
@@ -193,17 +193,18 @@ describe('App.WizardStep2Controller', fu
 
     it('should parse hosts from pattern expression to hostNameArr', function () {
       var controller = App.WizardStep2Controller.create({
-        hostNames: 'hots[0-10]'
+        hostNameArr: ['host[001-011]']
       });
       controller.patternExpression();
       var result = true;
       var hosts = controller.get('hostNameArr');
-      for (var i = 0; i<11; i++) {
-        if (hosts[i] !== 'host'+i) {
+      for (var i = 1; i<12; i++) {
+        var extra = (i.toString().length == 1) ? 0 : '';
+        if (hosts[i-1] !== 'host0' + extra + i) {
           result = false;
         }
       }
-      expect(result).to.equal(false);
+      expect(result).to.equal(true);
     })
   })