ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akovale...@apache.org
Subject ambari git commit: AMBARI-21102. To/From Version Information is Incorrect When Looking at Prior Upgrades (alexantonenko)
Date Fri, 21 Jul 2017 14:47:36 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-21450 3510647bc -> 804e21183


AMBARI-21102. To/From Version Information is Incorrect When Looking at Prior Upgrades (alexantonenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/804e2118
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/804e2118
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/804e2118

Branch: refs/heads/branch-feature-AMBARI-21450
Commit: 804e211830c89ae76d0722cdf2176fdfedff83ca
Parents: 3510647
Author: Alex Antonenko <aantonenko@hortonworks.com>
Authored: Fri Jul 21 17:47:07 2017 +0300
Committer: Alex Antonenko <aantonenko@hortonworks.com>
Committed: Fri Jul 21 17:47:07 2017 +0300

----------------------------------------------------------------------
 .../stack_version/stack_upgrade_history.js      |  19 +--
 .../admin/stack_upgrade/upgrade_history.hbs     | 164 ++++++++++---------
 ambari-web/app/utils/array_utils.js             |   6 +-
 .../admin/stack_upgrade/upgrade_history_view.js |  37 +++--
 .../stack_upgrade/upgrade_history_view_test.js  |  83 ++++++++--
 5 files changed, 184 insertions(+), 125 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/804e2118/ambari-web/app/models/stack_version/stack_upgrade_history.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/stack_version/stack_upgrade_history.js b/ambari-web/app/models/stack_version/stack_upgrade_history.js
index a0f5f3a..1973381 100644
--- a/ambari-web/app/models/stack_version/stack_upgrade_history.js
+++ b/ambari-web/app/models/stack_version/stack_upgrade_history.js
@@ -31,21 +31,10 @@ App.StackUpgradeHistory = DS.Model.extend({
   endTime: DS.attr('number'),
   startTime: DS.attr('number'),
   createTime: DS.attr('number'),
-
-  displayFromVersion: function() {
-    var stackName = App.RepositoryVersion.find()
-      .findProperty('repositoryVersion', this.get('fromVersion'))
-      .get('stackVersionType');
-    return stackName + '-' + this.get('fromVersion');
-  }.property('fromVersion'),
-
-  displayToVersion: function() {
-    var stackName = App.RepositoryVersion.find()
-      .findProperty('repositoryVersion', this.get('toVersion'))
-      .get('stackVersionType');
-    return stackName + '-' + this.get('toVersion');
-  }.property('toVersion')
-
+  versions: DS.attr('object'),
+  displayStatus: function() {
+    return stringUtils.upperUnderscoreToText(this.get('requestStatus'));
+  }.property('requestStatus')
 });
 
 App.StackUpgradeHistory.FIXTURES = [];

http://git-wip-us.apache.org/repos/asf/ambari/blob/804e2118/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_history.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_history.hbs b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_history.hbs
index ef03cec..c4832c0 100644
--- a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_history.hbs
+++ b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_history.hbs
@@ -21,85 +21,87 @@
     {{view App.SpinnerView}}
   </div>
   <div {{bindAttr class="view.isReady::hidden"}}>
-	  <div class="btn-group display-inline-block">
-	    <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
-	      <span class="filters-label">{{t common.filter}}: </span>
-	        <span>
-	          {{view.selectedCategory.label}}
-	          <span class="caret"></span>
-	        </span>
-	    </a>
-	    <ul class="dropdown-menu">
-	      {{#each category in view.categories}}
-	        <li>
-	          <a {{action selectCategory category target="view"}} href="#">
-	            {{category.label}}
-	          </a>
-	        </li>
-	      {{/each}}
-	    </ul>
-	  </div>
-	  <br/>
-	  <br/>
-	  <table class="table advanced-header-table table-striped" id="upgrade-summary-table">
-	    <thead>
-	      <th>{{t common.direction}}</th>
-	      <th>{{t common.type}}</th>
-	      <th>{{t common.from.version}}</th>
-	      <th>{{t common.to.version}}</th>
-	      <th>{{t common.start.time}}</th>
-	      <th>{{t common.duration}}</th>
-	      <th>{{t common.end.time}}</th>
-	      <th>{{t common.status}}</th>
-	    </thead>
-	    <tbody>
-		    {{#if view.pageContent}}
-		      {{#each item in view.pageContent}}
-		        <tr>
-		          <td class='name'>
-		            <span class="trim_hostname">
-		              <a href="#" class="black" {{action "showUpgradeHistoryRecord" item target="view"}}>
-		                {{unbound item.directionLabel}}
-		              </a>
-		            </span>
-		          </td>
-		          <td>
-		            <span>{{item.upgradeTypeLabel}}</span>
-		          </td>
-		          <td>
-		            <span>{{item.displayFromVersion}}</span>
-		          </td>
-		          <td>
-		            <span>{{item.displayToVersion}}</span>
-		          </td>
-		          <td>
-		            <span>{{item.startTimeLabel}}</span>
-		          </td>
-		          <td>
-	              <span>{{item.duration}}</span>
-	            </td>
-		          <td>
-		            <span>{{item.endTimeLabel}}</span>
-		          </td>
-		          <td>
-		            <span>{{item.requestStatus}}</span>
-		          </td>
-		        </tr>
-		      {{/each}}
-		    {{/if}}
-	    </tbody>
-	  </table>
-	  <div class="page-bar">
-	    <div class="items-on-page">
-	      <label>{{t common.show}}: {{view view.rowsPerPageSelectView selectionBinding="view.displayLength"}}</label>
-	    </div>
-	    <div class="info">{{view.paginationInfo}}</div>
-	    <div class="paging_two_button">
-	      <a {{bindAttr class="view.paginationLeftClass"}}{{action previousPage target="view"}}><i
-	              class="icon-arrow-left"></i></a>
-	      <a {{bindAttr class="view.paginationRightClass"}}{{action nextPage target="view"}}><i
-	              class="icon-arrow-right"></i></a>
-	    </div>
-	  </div>
+    <div class="row">
+      <h2 class="table-title col-sm-3">{{t common.upgrade.history}}</h2>
+      <div class="table-controls row span9 pull-right">
+        <div class="span12">
+          <div class="btn-group pull-right">
+            <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#">
+              <span class="filters-label">{{t common.filter}}: </span>
+              <span>
+                {{view.selectedCategory.label}}
+                <span class="caret"></span>
+              </span>
+            </a>
+            <ul class="dropdown-menu">
+              {{#each category in view.categories}}
+                <li>
+                  <a {{action selectCategory category target="view"}} href="#">
+                    {{category.label}}
+                  </a>
+                </li>
+              {{/each}}
+            </ul>
+          </div>
+        </div>
+      </div>
+    </div>
+    <table class="table advanced-header-table table-hover" id="upgrade-summary-table">
+      <thead>
+      <tr>
+        <th>{{t common.direction}}</th>
+        <th>{{t common.type}}</th>
+        <th>{{t common.service}}</th>
+        <th>{{t common.version}}</th>
+        <th>{{t common.start.time}}</th>
+        <th>{{t common.duration}}</th>
+        <th>{{t common.end.time}}</th>
+        <th>{{t common.status}}</th>
+      </tr>
+      </thead>
+      <tbody>
+        {{#if view.pageContent}}
+          {{#each item in view.pageContent}}
+            <tr>
+              <td class='name'>
+                <span class="trim_hostname">
+                  <a href="#" class="black" {{action "showUpgradeHistoryRecord" item.stackUpgradeHistoryItem
target="view"}}>
+                    {{unbound item.directionLabel}}
+                  </a>
+                </span>
+              </td>
+              <td>
+                <span>{{item.upgradeTypeLabel}}</span>
+              </td>
+              <td>
+                <span>{{item.serviceName}}</span>
+              </td>
+              <td>
+                <span>{{item.version}}</span>
+              </td>
+              <td>
+                <span>{{item.startTimeLabel}}</span>
+              </td>
+              <td>
+                <span>{{item.duration}}</span>
+              </td>
+              <td>
+                <span>{{item.endTimeLabel}}</span>
+              </td>
+              <td>
+                <span>{{item.displayStatus}}</span>
+              </td>
+            </tr>
+          {{/each}}
+        {{/if}}
+      </tbody>
+      <tfoot>
+        <tr>
+          <td colspan="8">
+            {{view App.PaginationView}}
+          </td>
+        </tr>
+        </tfoot>
+    </table>
   </div>
-</div>
\ No newline at end of file
+</div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/804e2118/ambari-web/app/utils/array_utils.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/array_utils.js b/ambari-web/app/utils/array_utils.js
index 76914c4..75d5096 100644
--- a/ambari-web/app/utils/array_utils.js
+++ b/ambari-web/app/utils/array_utils.js
@@ -20,6 +20,8 @@ function _parseId(id) {
   return id.replace(/[^\d|\.]/g, '').split('.').map(function (i) {return parseInt(i, 10);});
 }
 
+var flatten = function(list) {return list.reduce(function(a, b) {return a.concat(Array.isArray(b)
? flatten(b) : b)}, [])};
+
 module.exports = {
   /**
    *
@@ -83,6 +85,8 @@ module.exports = {
       return 0
     }
     return lId1 > lId2 ? 1 : -1;
-  }
+  },
+
+  flatten: flatten
 
 };

http://git-wip-us.apache.org/repos/asf/ambari/blob/804e2118/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_view.js
index 79a4a25..3bcccdf 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_history_view.js
@@ -16,9 +16,9 @@
  * limitations under the License.
  */
 
-
 var App = require('app');
 var date = require('utils/date/date');
+var arrayUtils = require('utils/array_utils');
 
 App.MainAdminStackUpgradeHistoryView = App.TableView.extend(App.TableServerViewMixin, {
 
@@ -98,8 +98,7 @@ App.MainAdminStackUpgradeHistoryView = App.TableView.extend(App.TableServerViewM
   selectedCategory: Em.computed.findBy('categories', 'isSelected', true),
 
   filteredCount: function () {
-    var filteredContent = this.get('filteredContent').toArray();
-    return filteredContent.length;
+    return this.get('filteredContent').map(function(item) {return Object.keys(item.get('versions')
|| {}).length}).reduce(Em.sum, 0);
   }.property('filteredContent'),
 
   /**
@@ -115,7 +114,7 @@ App.MainAdminStackUpgradeHistoryView = App.TableView.extend(App.TableServerViewM
   }.property('selectedCategory'),
 
   /**
-   * sort and slice recieved content by pagination parameters
+   * sort and slice received content by pagination parameters
    */
   pageContent: function () {
     var content = this.get('filteredContent').toArray();
@@ -125,21 +124,23 @@ App.MainAdminStackUpgradeHistoryView = App.TableView.extend(App.TableServerViewM
   }.property('filteredContent', 'startIndex', 'endIndex'),
 
   processForDisplay: function (content) {
-    var processedContent = [];
-
-    content.forEach(function (item) {
-      var direction = item.get('direction') === 'UPGRADE' ? Em.I18n.t('common.upgrade') :
Em.I18n.t('common.downgrade');
+    return arrayUtils.flatten(content.map(function(item) {
+      var versions = item.get('versions');
       var method = this.get('upgradeMethods').findProperty('type', item.get('upgradeType'));
-      item.setProperties({
-        directionLabel: direction,
-        upgradeTypeLabel: method ? method.get('displayName') : method,
-        startTimeLabel: date.startTime(App.dateTimeWithTimeZone(item.get('startTime'))),
-        endTimeLabel: date.endTime(App.dateTimeWithTimeZone(item.get('endTime'))),
-        duration: date.durationSummary(item.get('startTime'), item.get('endTime'))
+      return Object.keys(versions).map(function(serviceName) {
+        return {
+          version: versions[serviceName].to_repository_version,
+          serviceName: App.format.role(serviceName),
+          directionLabel: item.get('direction') === 'UPGRADE' ? Em.I18n.t('common.upgrade')
: Em.I18n.t('common.downgrade'),
+          upgradeTypeLabel: method ? method.get('displayName') : method,
+          startTimeLabel: date.startTime(App.dateTimeWithTimeZone(item.get('startTime'))),
+          endTimeLabel: date.endTime(App.dateTimeWithTimeZone(item.get('endTime'))),
+          duration: date.durationSummary(item.get('startTime'), item.get('endTime')),
+          displayStatus: item.get('displayStatus'),
+          stackUpgradeHistoryItem: item
+        };
       });
-      processedContent.push(item);
-    }, this);
-    return processedContent;
+    }));
   },
 
   paginationLeftClass: function () {
@@ -293,7 +294,7 @@ App.MainAdminStackUpgradeHistoryView = App.TableView.extend(App.TableServerViewM
     var associatedVersion = record.get('associatedVersion');
     var type = this.get('upgradeMethods').findProperty('type', record.get('upgradeType'));
     var displayName = type ? type.get('displayName') : App.format.normalizeName(record.get('upgradeType'));
-    var i18nKeySuffix = direction === 'UPGRADE' ? 'upgrade' : 'downgrade';
+    var i18nKeySuffix = direction.toLowerCase() === 'upgrade' ? 'upgrade' : 'downgrade';
 
     this.get('controller').set('currentUpgradeRecord', record);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/804e2118/ambari-web/test/views/main/admin/stack_upgrade/upgrade_history_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_history_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_history_view_test.js
index 2e4838c..9780470 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_history_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_history_view_test.js
@@ -135,13 +135,13 @@ describe('App.MainAdminStackUpgradeHistoryView', function () {
       event = {
         context: Em.Object.create({
           isSelected: false,
-          value: 'ALL',
+          value: 'ALL'
         })
       };
       view.set('categories', [
         Em.Object.create({
           isSelected: true,
-          value: 'UPGRADE_COMPLETED',
+          value: 'UPGRADE_COMPLETED'
         }),
         event.context
       ]);
@@ -170,6 +170,61 @@ describe('App.MainAdminStackUpgradeHistoryView', function () {
     });
   });
 
+  describe('#filteredCount', function () {
+
+    [
+      {
+        filteredContent: [
+          Em.Object.create({
+            versions: {s1: {}}
+          })
+        ],
+        m: '1 version',
+        e: 1
+      },
+      {
+        filteredContent: [
+          Em.Object.create({
+            versions: {s1: {}, s2: {}}
+          })
+        ],
+        m: '2 versions',
+        e: 2
+      },
+      {
+        filteredContent: [
+          Em.Object.create({
+            versions: {s1: {}, s2: {}}
+          }),
+          Em.Object.create({
+            versions: {s1: {}, s2: {}, s3: {}}
+          })
+        ],
+        m: '5 versions',
+        e: 5
+      }
+    ].forEach(function (test) {
+      describe(test.m, function () {
+        beforeEach(function () {
+          sinon.stub(view, 'get', function (key) {
+            if (key === 'filteredContent') {
+              return test.filteredContent;
+            }
+            return Em.get(this, key);
+          });
+        });
+        afterEach(function () {
+          view.get.restore();
+        });
+        it('should map versions', function () {
+          view.set('filteredContent', test.filteredContent);
+          expect(view.get('filteredCount')).to.be.equal(test.e);
+        });
+      });
+    });
+
+  });
+
   describe('#processForDisplay', function () {
 
     var timestamp = 1484698121448;
@@ -179,13 +234,15 @@ describe('App.MainAdminStackUpgradeHistoryView', function () {
         direction: 'UPGRADE',
         upgradeType: 'ROLLING',
         startTime: timestamp,
-        endTime: timestamp + 3600 * 1000
+        endTime: timestamp + 3600 * 1000,
+        versions: {s1: {}}
       }),
       Em.Object.create({
         direction: 'DOWNGRADE',
         upgradeType: 'HOST_ORDERED',
         startTime: timestamp,
-        endTime: timestamp + 3600 * 1000 * 2
+        endTime: timestamp + 3600 * 1000 * 2,
+        versions: {s1: {}}
       })
     ];
 
@@ -193,16 +250,18 @@ describe('App.MainAdminStackUpgradeHistoryView', function () {
       Em.Object.create({
         directionLabel: Em.I18n.t('common.upgrade'),
         upgradeTypeLabel: Em.I18n.t('common.rolling'),
-        duration: '1.00 hours'
+        duration: '1.00 hours',
+        serviceName: 'S1'
       }),
       Em.Object.create({
         directionLabel: Em.I18n.t('common.downgrade'),
         upgradeTypeLabel: Em.I18n.t('common.hostOrdered'),
-        duration: '2.00 hours'
+        duration: '2.00 hours',
+        serviceName: 'S1'
       })
     ];
 
-    var fields = ['directionLabel', 'upgradeTypeLabel', 'duration'];
+    var fields = ['directionLabel', 'upgradeTypeLabel', 'duration', 'serviceName'];
 
     var processedContent;
 
@@ -217,13 +276,17 @@ describe('App.MainAdminStackUpgradeHistoryView', function () {
       App.dateTimeWithTimeZone.restore();
     });
 
+    it('2 items mapped', function () {
+      expect(processedContent.length).to.be.equal(2);
+    })
+
     expected.forEach(function (item, index) {
 
       describe('test #' + (index + 1), function () {
 
         fields.forEach(function (field) {
           it('#' + field, function () {
-            expect(processedContent[index].get(field)).to.be.equal(item.get(field));
+            expect(processedContent[index][field]).to.be.equal(item.get(field));
           });
         });
 
@@ -233,8 +296,8 @@ describe('App.MainAdminStackUpgradeHistoryView', function () {
 
 
     it('End Time for upgrade in progress is `Not finished`', function () {
-      processedContent = view.processForDisplay([Em.Object.create({endTime: -1})]);
-      expect(processedContent[0].get('endTimeLabel')).to.be.equal('Not finished');
+      processedContent = view.processForDisplay([Em.Object.create({endTime: -1, versions:
{s1:{}}})]);
+      expect(processedContent[0].endTimeLabel).to.be.equal('Not finished');
     });
   });
 


Mime
View raw message