ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject git commit: AMBARI-5337 Add unit tests to Confirm Hosts and Deploy step. (atkach)
Date Thu, 03 Apr 2014 11:00:56 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 28ae1edd3 -> 2e7cb594f


AMBARI-5337 Add unit tests to Confirm Hosts and Deploy step. (atkach)


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

Branch: refs/heads/trunk
Commit: 2e7cb594f7bedd350a10d3d0ccdd899371d1e509
Parents: 28ae1ed
Author: atkach <atkach@hortonworks.com>
Authored: Thu Apr 3 13:57:15 2014 +0300
Committer: atkach <atkach@hortonworks.com>
Committed: Thu Apr 3 13:57:15 2014 +0300

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |   1 +
 ambari-web/app/controllers/wizard.js            |   1 +
 ambari-web/app/data/HDP2/site_properties.js     |   6 +-
 ambari-web/test/views/wizard/step3_view_test.js | 271 +++++++++++++++++++
 ambari-web/test/views/wizard/step9_view_test.js | 195 +++++++++++++
 5 files changed, 471 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2e7cb594/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index d4436d9..98ba280 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -108,6 +108,7 @@ require('test/views/main/host/details/host_component_view_test');
 require('test/views/main/host/details/host_component_views/decommissionable_test');
 require('test/views/main/jobs/hive_job_details_tez_dag_view_test');
 require('test/views/common/configs/services_config_test');
+require('test/views/wizard/step3_view_test');
 require('test/views/wizard/step9_view_test');
 require('test/models/host_test');
 require('test/models/host_component_test');

http://git-wip-us.apache.org/repos/asf/ambari/blob/2e7cb594/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 8cd9f09..848a416 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -18,6 +18,7 @@
 
 
 var App = require('app');
+require('models/host');
 
 App.WizardController = Em.Controller.extend({
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/2e7cb594/ambari-web/app/data/HDP2/site_properties.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/HDP2/site_properties.js b/ambari-web/app/data/HDP2/site_properties.js
index 135a70d..8ee207a 100644
--- a/ambari-web/app/data/HDP2/site_properties.js
+++ b/ambari-web/app/data/HDP2/site_properties.js
@@ -258,7 +258,7 @@ module.exports =
       "displayType": "integer",
       "category": "AppTimelineServer",
       "desription": "Length of time to wait between deletion cycles of leveldb timeline store
in milliseconds.",
-      "value": 300000,
+      //"value": 300000,
       "serviceName": "YARN"
     },
     {
@@ -275,7 +275,7 @@ module.exports =
       "displayType": "checkbox",
       "category": "AppTimelineServer",
       "desription": "Enable age off of timeline store data.",
-      "value": true,
+      //"value": true,
       "serviceName": "YARN"
     },
     {
@@ -285,7 +285,7 @@ module.exports =
       "displayType": "integer",
       "category": "AppTimelineServer",
       "desription": "Time to live for timeline store data in milliseconds.",
-      "value": 2678400000,
+      //"value": 2678400000,
       "serviceName": "YARN"
     },
     {

http://git-wip-us.apache.org/repos/asf/ambari/blob/2e7cb594/ambari-web/test/views/wizard/step3_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step3_view_test.js b/ambari-web/test/views/wizard/step3_view_test.js
new file mode 100644
index 0000000..b38068a
--- /dev/null
+++ b/ambari-web/test/views/wizard/step3_view_test.js
@@ -0,0 +1,271 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+require('views/wizard/step3_view');
+
+describe('App.WizardStep3View', function () {
+  Em.run.next = function(callback){
+    callback()
+  };
+  var view = App.WizardStep3View.create({
+    monitorStatuses: function () {
+    },
+    content: [
+      Em.Object.create({
+        name: 'host1',
+        bootStatus: 'PENDING',
+        isChecked: false
+      }),
+      Em.Object.create({
+        name: 'host2',
+        bootStatus: 'PENDING',
+        isChecked: true
+      }),
+      Em.Object.create({
+        name: 'host3',
+        bootStatus: 'PENDING',
+        isChecked: true
+      })
+    ],
+    pageContent: function () {
+      return this.get('content');
+    }.property('content')
+  });
+
+  describe('watchSelection', function () {
+    it('2 of 3 hosts selected', function () {
+      view.watchSelection();
+      expect(view.get('noHostsSelected')).to.equal(false);
+      expect(view.get('selectedHostsCount')).to.equal(2);
+    });
+    it('all hosts selected', function () {
+      view.selectAll();
+      view.watchSelection();
+      expect(view.get('noHostsSelected')).to.equal(false);
+      expect(view.get('selectedHostsCount')).to.equal(3);
+    });
+    it('none hosts selected', function () {
+      view.unSelectAll();
+      view.watchSelection();
+      expect(view.get('noHostsSelected')).to.equal(true);
+      expect(view.get('selectedHostsCount')).to.equal(0);
+    });
+  });
+
+
+  describe('selectAll', function () {
+    it('select all hosts', function () {
+      view.selectAll();
+      expect(view.get('content').everyProperty('isChecked', true)).to.equal(true);
+    });
+  });
+
+  describe('unSelectAll', function () {
+    it('unselect all hosts', function () {
+      view.unSelectAll();
+      expect(view.get('content').everyProperty('isChecked', false)).to.equal(true);
+    });
+  });
+
+  var testCases = [
+    {
+      title: 'none hosts',
+      content: [],
+      result: {
+        "ALL": 0,
+        "RUNNING": 0,
+        "REGISTERING": 0,
+        "REGISTERED": 0,
+        "FAILED": 0
+      }
+    },
+    {
+      title: 'all hosts RUNNING',
+      content: [
+        Em.Object.create({
+          name: 'host1',
+          bootStatus: 'RUNNING'
+        }),
+        Em.Object.create({
+          name: 'host2',
+          bootStatus: 'RUNNING'
+        }),
+        Em.Object.create({
+          name: 'host3',
+          bootStatus: 'RUNNING'
+        })
+      ],
+      result: {
+        "ALL": 3,
+        "RUNNING": 3,
+        "REGISTERING": 0,
+        "REGISTERED": 0,
+        "FAILED": 0
+      }
+    },
+    {
+      title: 'all hosts REGISTERING',
+      content: [
+        Em.Object.create({
+          name: 'host1',
+          bootStatus: 'REGISTERING'
+        }),
+        Em.Object.create({
+          name: 'host2',
+          bootStatus: 'REGISTERING'
+        }),
+        Em.Object.create({
+          name: 'host3',
+          bootStatus: 'REGISTERING'
+        })
+      ],
+      result: {
+        "ALL": 3,
+        "RUNNING": 0,
+        "REGISTERING": 3,
+        "REGISTERED": 0,
+        "FAILED": 0
+      }
+    },
+    {
+      title: 'all hosts REGISTERED',
+      content: [
+        Em.Object.create({
+          name: 'host1',
+          bootStatus: 'REGISTERED'
+        }),
+        Em.Object.create({
+          name: 'host2',
+          bootStatus: 'REGISTERED'
+        }),
+        Em.Object.create({
+          name: 'host3',
+          bootStatus: 'REGISTERED'
+        })
+      ],
+      result: {
+        "ALL": 3,
+        "RUNNING": 0,
+        "REGISTERING": 0,
+        "REGISTERED": 3,
+        "FAILED": 0
+      }
+    },
+    {
+      title: 'all hosts FAILED',
+      content: [
+        Em.Object.create({
+          name: 'host1',
+          bootStatus: 'FAILED'
+        }),
+        Em.Object.create({
+          name: 'host2',
+          bootStatus: 'FAILED'
+        }),
+        Em.Object.create({
+          name: 'host3',
+          bootStatus: 'FAILED'
+        })
+      ],
+      result: {
+        "ALL": 3,
+        "RUNNING": 0,
+        "REGISTERING": 0,
+        "REGISTERED": 0,
+        "FAILED": 3
+      }
+    },
+    {
+      title: 'first host is FAILED, second is RUNNING, third is REGISTERED',
+      content: [
+        Em.Object.create({
+          name: 'host1',
+          bootStatus: 'FAILED'
+        }),
+        Em.Object.create({
+          name: 'host2',
+          bootStatus: 'RUNNING'
+        }),
+        Em.Object.create({
+          name: 'host3',
+          bootStatus: 'REGISTERED'
+        })
+      ],
+      result: {
+        "ALL": 3,
+        "RUNNING": 1,
+        "REGISTERING": 0,
+        "REGISTERED": 1,
+        "FAILED": 1
+      }
+    },
+    {
+      title: 'two hosts is REGISTERING, one is REGISTERED',
+      content: [
+        Em.Object.create({
+          name: 'host1',
+          bootStatus: 'REGISTERING'
+        }),
+        Em.Object.create({
+          name: 'host2',
+          bootStatus: 'REGISTERING'
+        }),
+        Em.Object.create({
+          name: 'host3',
+          bootStatus: 'REGISTERED'
+        })
+      ],
+      result: {
+        "ALL": 3,
+        "RUNNING": 0,
+        "REGISTERING": 2,
+        "REGISTERED": 1,
+        "FAILED": 0
+      }
+    }
+  ];
+
+  describe('countCategoryHosts', function () {
+    testCases.forEach(function (test) {
+      it(test.title, function () {
+        view.set('content', test.content);
+        view.countCategoryHosts();
+        view.get('categories').forEach(function (category) {
+          expect(category.get('hostsCount')).to.equal(test.result[category.get('hostsBootStatus')])
+        })
+      });
+    }, this);
+  });
+
+  describe('filter', function () {
+    testCases.forEach(function (test) {
+      describe(test.title, function () {
+        view.get('categories').forEach(function (category) {
+          it('. Selected category - ' + category.get('hostsBootStatus'), function () {
+            view.set('content', test.content);
+            view.selectCategory({context: category});
+            view.filter();
+            expect(view.get('filteredContent').length).to.equal(test.result[category.get('hostsBootStatus')])
+          });
+        })
+      });
+    }, this);
+  });
+
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/2e7cb594/ambari-web/test/views/wizard/step9_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step9_view_test.js b/ambari-web/test/views/wizard/step9_view_test.js
index abd6595..9b98019 100644
--- a/ambari-web/test/views/wizard/step9_view_test.js
+++ b/ambari-web/test/views/wizard/step9_view_test.js
@@ -19,6 +19,201 @@
 var App = require('app');
 require('views/wizard/step9_view');
 
+
+describe('App.WizardStep9View', function () {
+  var view = App.WizardStep9View.create({
+    onStatus: function () {},
+    content: [],
+    pageContent: function () {
+      return this.get('content');
+    }.property('content')
+  });
+  var testCases = [
+    {
+      title: 'none hosts',
+      content: [],
+      result: {
+        "all": 0,
+        "inProgress": 0,
+        "warning": 0,
+        "success": 0,
+        "failed": 0
+      }
+    },
+    {
+      title: 'all hosts inProgress',
+      content: [
+        Em.Object.create({
+          name: 'host1',
+          status: 'in_progress'
+        }),
+        Em.Object.create({
+          name: 'host2',
+          status: 'info'
+        }),
+        Em.Object.create({
+          name: 'host3',
+          status: 'pending'
+        })
+      ],
+      result: {
+        "all": 3,
+        "inProgress": 3,
+        "warning": 0,
+        "success": 0,
+        "failed": 0
+      }
+    },
+    {
+      title: 'all hosts warning',
+      content: [
+        Em.Object.create({
+          name: 'host1',
+          status: 'warning'
+        }),
+        Em.Object.create({
+          name: 'host2',
+          status: 'warning'
+        }),
+        Em.Object.create({
+          name: 'host3',
+          status: 'warning'
+        })
+      ],
+      result: {
+        "all": 3,
+        "inProgress": 0,
+        "warning": 3,
+        "success": 0,
+        "failed": 0
+      }
+    },
+    {
+      title: 'all hosts success',
+      content: [
+        Em.Object.create({
+          name: 'host1',
+          status: 'success'
+        }),
+        Em.Object.create({
+          name: 'host2',
+          status: 'success'
+        }),
+        Em.Object.create({
+          name: 'host3',
+          status: 'success'
+        })
+      ],
+      result: {
+        "all": 3,
+        "inProgress": 0,
+        "warning": 0,
+        "success": 3,
+        "failed": 0
+      }
+    },
+    {
+      title: 'all hosts failed',
+      content: [
+        Em.Object.create({
+          name: 'host1',
+          status: 'failed'
+        }),
+        Em.Object.create({
+          name: 'host2',
+          status: 'failed'
+        }),
+        Em.Object.create({
+          name: 'host3',
+          status: 'heartbeat_lost'
+        })
+      ],
+      result: {
+        "all": 3,
+        "inProgress": 0,
+        "warning": 0,
+        "success": 0,
+        "failed": 3
+      }
+    },
+    {
+      title: 'first host is failed, second is warning, third is success',
+      content: [
+        Em.Object.create({
+          name: 'host1',
+          status: 'failed'
+        }),
+        Em.Object.create({
+          name: 'host2',
+          status: 'success'
+        }),
+        Em.Object.create({
+          name: 'host3',
+          status: 'warning'
+        })
+      ],
+      result: {
+        "all": 3,
+        "inProgress": 0,
+        "warning": 1,
+        "success": 1,
+        "failed": 1
+      }
+    },
+    {
+      title: 'two hosts is inProgress, one is success',
+      content: [
+        Em.Object.create({
+          name: 'host1',
+          status: 'pending'
+        }),
+        Em.Object.create({
+          name: 'host2',
+          status: 'in_progress'
+        }),
+        Em.Object.create({
+          name: 'host3',
+          status: 'success'
+        })
+      ],
+      result: {
+        "all": 3,
+        "inProgress": 2,
+        "warning": 0,
+        "success": 1,
+        "failed": 0
+      }
+    }
+  ];
+
+  describe('countCategoryHosts', function () {
+    testCases.forEach(function (test) {
+      it(test.title, function () {
+        view.set('content', test.content);
+        view.countCategoryHosts();
+        view.get('categories').forEach(function (category) {
+          expect(category.get('hostsCount')).to.equal(test.result[category.get('hostStatus')])
+        })
+      });
+    }, this);
+  });
+
+  describe('filter', function () {
+    testCases.forEach(function (test) {
+      describe(test.title, function () {
+        view.get('categories').forEach(function (category) {
+          it('. Selected category - ' + category.get('hostStatus'), function () {
+            view.set('content', test.content);
+            view.selectCategory({context: category});
+            view.filter();
+            expect(view.get('filteredContent').length).to.equal(test.result[category.get('hostStatus')])
+          });
+        })
+      });
+    }, this);
+  });
+});
+
 describe('App.HostStatusView', function () {
   var tests = [
     {


Mime
View raw message