incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject svn commit: r1497323 - in /incubator/ambari/trunk/ambari-web/test/models: ./ host_component_test.js host_test.js rack_test.js
Date Thu, 27 Jun 2013 12:30:39 GMT
Author: yusaku
Date: Thu Jun 27 12:30:39 2013
New Revision: 1497323

URL: http://svn.apache.org/r1497323
Log:
AMBARI-2375. Unit Tests: Added tests to models. Committing missed files. (Andrii Tkach via
yusaku)

Added:
    incubator/ambari/trunk/ambari-web/test/models/
    incubator/ambari/trunk/ambari-web/test/models/host_component_test.js
    incubator/ambari/trunk/ambari-web/test/models/host_test.js
    incubator/ambari/trunk/ambari-web/test/models/rack_test.js

Added: incubator/ambari/trunk/ambari-web/test/models/host_component_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/models/host_component_test.js?rev=1497323&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/models/host_component_test.js (added)
+++ incubator/ambari/trunk/ambari-web/test/models/host_component_test.js Thu Jun 27 12:30:39
2013
@@ -0,0 +1,79 @@
+/**
+ * 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('models/host_component');
+require('models/host');
+require('router');
+require('models/service/hdfs');
+require('controllers/main/service');
+
+
+describe('App.HostComponent', function () {
+
+
+  var hostComponentData = [
+    {
+      id: 'component1',
+      component_name: 'DATANODE',
+      host_id: 'host1'
+    },
+    {
+      id: 'component2',
+      component_name: 'DATANODE',
+      host_id: 'host3'
+    },
+    {
+      id: 'component3',
+      component_name: 'TASKTRACKER',
+      host_id: 'host2'
+    }
+  ];
+
+  var hdfsData = {
+    id: 'HDFS',
+    service_name: 'HDFS',
+    decommission_data_nodes: ['host1', 'host2']
+  };
+
+
+  //3 hosts are loaded to the model (host1, host2, host3) in models/host_test
+  App.store.load(App.HDFSService, hdfsData);
+  App.store.loadMany(App.HostComponent, hostComponentData);
+
+
+
+  describe('#isDecommissioning', function () {
+
+    it('component1 is DATANODE and on decommissioned host', function () {
+      var hostComponent = App.HostComponent.find().findProperty('id', 'component1');
+      expect(hostComponent.get('isDecommissioning')).to.equal(true);
+    });
+    it('component2 is DATANODE but not on decommissioned host', function () {
+      var hostComponent = App.HostComponent.find().findProperty('id', 'component2');
+      expect(hostComponent.get('isDecommissioning')).to.equal(false);
+    });
+    it('component3 isn\'t DATANODE', function () {
+      var hostComponent = App.HostComponent.find().findProperty('id', 'component3');
+      expect(hostComponent.get('isDecommissioning')).to.equal(false);
+    });
+  });
+
+
+});

Added: incubator/ambari/trunk/ambari-web/test/models/host_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/models/host_test.js?rev=1497323&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/models/host_test.js (added)
+++ incubator/ambari/trunk/ambari-web/test/models/host_test.js Thu Jun 27 12:30:39 2013
@@ -0,0 +1,134 @@
+/**
+ * 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('models/host');
+
+describe('App.Host', function () {
+
+  var data = [
+    {
+      id: 'host1',
+      host_name: 'host1',
+      memory: 200000,
+      disk_total: 100.555,
+      disk_free: 90.555,
+      health_status: 'HEALTHY',
+      last_heart_beat_time: (new Date()).getTime() - 18100000
+    },
+    {
+      id: 'host2',
+      host_name: 'host2',
+      memory: 99999,
+      disk_total: 90,
+      disk_free: 90,
+      health_status: 'HEALTHY',
+      last_heart_beat_time: (new Date()).getTime() - 170000
+    },
+    {
+      id: 'host3',
+      host_name: 'host3',
+      memory: 99999,
+      disk_total: 99.999,
+      disk_free: 0,
+      health_status: 'UNKNOWN',
+      last_heart_beat_time: (new Date()).getTime()
+    }
+  ];
+  App.set('testMode', false);
+  App.store.loadMany(App.Host, data);
+
+  describe('#diskUsedFormatted', function () {
+
+    it('host1 - 10GB ', function () {
+      var host = App.Host.find().findProperty('hostName', 'host1');
+      expect(host.get('diskUsedFormatted')).to.equal('10GB');
+    });
+    it('host2 - 0GB', function () {
+      var host = App.Host.find().findProperty('hostName', 'host2');
+      expect(host.get('diskUsedFormatted')).to.equal('0GB');
+    });
+    it('host3 - 100GB', function () {
+      var host = App.Host.find().findProperty('hostName', 'host3');
+      expect(host.get('diskUsedFormatted')).to.equal('100GB');
+    });
+  });
+
+  describe('#diskTotalFormatted', function () {
+
+    it('host1 - 100.56GB ', function () {
+      var host = App.Host.find().findProperty('hostName', 'host1');
+      expect(host.get('diskTotalFormatted')).to.equal('100.56GB');
+    });
+    it('host2 - 90GB', function () {
+      var host = App.Host.find().findProperty('hostName', 'host2');
+      expect(host.get('diskTotalFormatted')).to.equal('90GB');
+    });
+    it('host3 - 100GB', function () {
+      var host = App.Host.find().findProperty('hostName', 'host3');
+      expect(host.get('diskTotalFormatted')).to.equal('100GB');
+    });
+  });
+
+  describe('#diskUsageFormatted', function () {
+
+    it('host1 - 9.94% ', function () {
+      var host = App.Host.find().findProperty('hostName', 'host1');
+      expect(host.get('diskUsageFormatted')).to.equal('9.94%');
+    });
+    it('host2 - 0%', function () {
+      var host = App.Host.find().findProperty('hostName', 'host2');
+      expect(host.get('diskUsageFormatted')).to.equal('0%');
+    });
+    it('host3 - 100%', function () {
+      var host = App.Host.find().findProperty('hostName', 'host3');
+      expect(host.get('diskUsageFormatted')).to.equal('100%');
+    });
+  });
+
+  describe('#isNotHeartBeating', function () {
+
+    it('host1 - true ', function () {
+      var host = App.Host.find().findProperty('hostName', 'host1');
+      expect(host.get('isNotHeartBeating')).to.equal(true);
+    });
+    it('host2 - false', function () {
+      var host = App.Host.find().findProperty('hostName', 'host2');
+      expect(host.get('isNotHeartBeating')).to.equal(false);
+    });
+    it('host3 - false', function () {
+      var host = App.Host.find().findProperty('hostName', 'host3');
+      expect(host.get('isNotHeartBeating')).to.equal(false);
+    });
+  });
+
+  describe('#updateHealthClass', function () {
+
+    it('host1 has status health-status-DEAD-YELLOW', function () {
+      var host = App.Host.find().findProperty('hostName', 'host1');
+      host.updateHealthClass();
+      expect(host.get('healthClass')).to.equal('health-status-DEAD-YELLOW');
+    });
+    it('host3 has status health-status-DEAD-YELLOW', function () {
+      var host = App.Host.find().findProperty('hostName', 'host3');
+      host.updateHealthClass();
+      expect(host.get('healthClass')).to.equal('health-status-DEAD-YELLOW');
+    });
+  });
+});

Added: incubator/ambari/trunk/ambari-web/test/models/rack_test.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/test/models/rack_test.js?rev=1497323&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/test/models/rack_test.js (added)
+++ incubator/ambari/trunk/ambari-web/test/models/rack_test.js Thu Jun 27 12:30:39 2013
@@ -0,0 +1,53 @@
+/**
+ * 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('models/host');
+require('models/rack');
+
+describe('App.Rack', function () {
+
+  var data = {
+    id: 'rack1',
+    name: 'rack1'
+  };
+
+  App.store.load(App.Rack, data);
+
+  describe('#liveHostsCount', function () {
+
+    it('rack1 has two live hosts', function () {
+      var rack = App.Rack.find().findProperty('name', 'rack1');
+      expect(rack.get('liveHostsCount')).to.equal(2);
+    });
+
+    it('rack1 has three live hosts', function () {
+      App.store.load(App.Host, {
+        id: 'host3',
+        host_name: 'host3',
+        health_status: 'HEALTHY'
+      });
+      var rack = App.Rack.find().findProperty('name', 'rack1');
+      rack.set('name', 'rack1');
+      expect(rack.get('liveHostsCount')).to.equal(3);
+    });
+  });
+
+
+});



Mime
View raw message