|
@@ -23,64 +23,82 @@ var components = require('data/service_components');
|
|
|
|
|
|
|
|
|
describe('App.WizardStep5Controller', function () {
|
|
|
+ var controller = App.WizardStep5Controller.create();
|
|
|
var cpu = 2, memory = 4;
|
|
|
-
|
|
|
- var methods = ['getKerberosServer', 'getNameNode', 'getSNameNode', 'getJobTracker', 'getResourceManager', 'getHistoryServer', 'getHBaseMaster', 'getOozieServer', 'getHiveServer', 'getHiveMetastore', 'getWebHCatServer'];
|
|
|
-
|
|
|
+ var schemes = [
|
|
|
+ {'description': 'empty condition'},
|
|
|
+ {
|
|
|
+ 'description': 'second host if amount more than 1',
|
|
|
+ "else": 1
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'description': 'first host if amount less than 3, third host if amount less than 6, fourth host if amount more than 5',
|
|
|
+ "3": 0,
|
|
|
+ "6": 2,
|
|
|
+ "else": 3
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'description': 'second host if amount less than 3, second host if amount less than 6, third host if amount less than 31, sixth host if amount more than 30',
|
|
|
+ "3": 1,
|
|
|
+ "6": 1,
|
|
|
+ "31": 2,
|
|
|
+ "else": 5
|
|
|
+ }
|
|
|
+ ];
|
|
|
var test_config = [
|
|
|
{
|
|
|
title: '1 host',
|
|
|
hosts: ['host0'],
|
|
|
- equals: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
|
+ equals: [0, 0, 0, 0]
|
|
|
},
|
|
|
{
|
|
|
title: '2 hosts',
|
|
|
hosts: ['host0', 'host1'],
|
|
|
- equals: [1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]
|
|
|
+ equals: [0, 1, 0, 1]
|
|
|
},
|
|
|
{
|
|
|
title: '3 hosts',
|
|
|
hosts: ['host0', 'host1', 'host2'],
|
|
|
- equals: [1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]
|
|
|
+ equals: [0, 1, 2, 1]
|
|
|
},
|
|
|
{
|
|
|
title: '5 hosts',
|
|
|
hosts: ['host0', 'host1', 'host2', 'host3', 'host4'],
|
|
|
- equals: [1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]
|
|
|
+ equals: [0, 1, 2, 1]
|
|
|
},
|
|
|
{
|
|
|
title: '6 hosts',
|
|
|
hosts: ['host0', 'host1', 'host2', 'host3', 'host4', 'host6'],
|
|
|
- equals: [3, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2]
|
|
|
+ equals: [0, 1, 3, 2]
|
|
|
},
|
|
|
{
|
|
|
title: '10 hosts',
|
|
|
hosts: ['host0', 'host1', 'host2', 'host3', 'host4', 'host5', 'host6', 'host7', 'host8', 'host9'],
|
|
|
- equals: [3, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2]
|
|
|
+ equals: [0, 1, 3, 2]
|
|
|
},
|
|
|
{
|
|
|
title: '31 hosts',
|
|
|
- hosts: ['host0', 'host1', 'host2', 'host3', 'host4', 'host5', 'host6', 'host7', 'host8', 'host9', 'host0', 'host1', 'host2', 'host3', 'host4', 'host5', 'host6', 'host7', 'host8', 'host9', 'host0', 'host1', 'host2', 'host3', 'host4', 'host5', 'host6', 'host7', 'host8', 'host9', 'host0'],
|
|
|
- equals: [5, 0, 1, 2, 2, 2, 3, 3, 4, 4, 4]
|
|
|
+ hosts: ['host0', 'host1', 'host2', 'host3', 'host4', 'host5', 'host6', 'host7', 'host8', 'host9', 'host10', 'host11', 'host12', 'host13', 'host14', 'host15', 'host16', 'host17', 'host18', 'host19', 'host20', 'host21', 'host22', 'host23', 'host24', 'host25', 'host26', 'host27', 'host28', 'host29', 'host30'],
|
|
|
+ equals: [0, 1, 3, 5]
|
|
|
}
|
|
|
];
|
|
|
|
|
|
- test_config.forEach(function(test) {
|
|
|
- describe(test.title, function() {
|
|
|
- var controller = App.WizardStep5Controller.create();
|
|
|
- controller.clearStep();
|
|
|
-
|
|
|
- test.hosts.forEach(function(_host) {
|
|
|
- controller.get('hosts').pushObject(Em.Object.create({
|
|
|
- host_name: _host,
|
|
|
- cpu: cpu,
|
|
|
- memory: memory
|
|
|
- }));
|
|
|
- });
|
|
|
+ schemes.forEach(function(scheme, index) {
|
|
|
+ describe('#getHostForComponent() condition: ' + scheme.description, function() {
|
|
|
+
|
|
|
+ delete scheme['description'];
|
|
|
|
|
|
- methods.forEach(function(method, index) {
|
|
|
- it('#' + method + '()', function() {
|
|
|
- expect(controller[method](test.hosts.length).host_name).to.equal(test.hosts[test.equals[index]]);
|
|
|
+ test_config.forEach(function(test) {
|
|
|
+ it(test.title, function () {
|
|
|
+ controller.get('hosts').clear();
|
|
|
+ test.hosts.forEach(function(_host) {
|
|
|
+ controller.get('hosts').pushObject(Em.Object.create({
|
|
|
+ host_name: _host,
|
|
|
+ cpu: cpu,
|
|
|
+ memory: memory
|
|
|
+ }));
|
|
|
+ });
|
|
|
+ expect(controller.getHostForComponent(test.hosts.length, scheme).host_name).to.equal(test.hosts[test.equals[index]]);
|
|
|
});
|
|
|
});
|
|
|
|
|
@@ -88,19 +106,74 @@ describe('App.WizardStep5Controller', function () {
|
|
|
|
|
|
});
|
|
|
|
|
|
+ describe('#getZooKeeperServer', function() {
|
|
|
+ it('should be array with three host names if hosts number more than three', function() {
|
|
|
+ var hosts = [
|
|
|
+ {host_name: 'host1'},
|
|
|
+ {host_name: 'host2'},
|
|
|
+ {host_name: 'host3'}
|
|
|
+ ];
|
|
|
+
|
|
|
+ controller.set('hosts', hosts);
|
|
|
+ expect(controller.getZooKeeperServer(hosts.length)).to.eql(['host1', 'host2', 'host3']);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should be array with one host names if hosts number less than three', function() {
|
|
|
+ var hosts = [
|
|
|
+ {host_name: 'host1'},
|
|
|
+ {host_name: 'host2'}
|
|
|
+ ];
|
|
|
+
|
|
|
+ controller.set('hosts', hosts);
|
|
|
+ expect(controller.getZooKeeperServer(hosts.length)).to.eql(['host1']);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('#getGangliaServer', function() {
|
|
|
+ it('should be host name if one host ', function() {
|
|
|
+ var hosts = [
|
|
|
+ {host_name: 'host1'}
|
|
|
+ ];
|
|
|
+
|
|
|
+ controller.set('hosts', hosts);
|
|
|
+ expect(controller.getGangliaServer(hosts.length)).to.eql('host1');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should be host name if hosts number more than one', function() {
|
|
|
+ var hosts = [
|
|
|
+ {host_name: 'host1'},
|
|
|
+ {host_name: 'host2'}
|
|
|
+ ];
|
|
|
+
|
|
|
+ controller.set('hosts', hosts);
|
|
|
+ expect(controller.getGangliaServer(hosts.length)).to.eql('host1');
|
|
|
+ });
|
|
|
+
|
|
|
+ it('should be host name different from localhost if hosts number more than one', function() {
|
|
|
+ var hosts = [
|
|
|
+ {host_name: ''},
|
|
|
+ {host_name: 'host2'}
|
|
|
+ ];
|
|
|
+ //first host_name is empty string, because of location.hostname = "" in console,
|
|
|
+ //to implement current test case
|
|
|
+
|
|
|
+ controller.set('hosts', hosts);
|
|
|
+ expect(controller.getGangliaServer(hosts.length)).to.eql('host2');
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
|
|
|
- var controller = App.WizardStep5Controller.create();
|
|
|
controller.set('content', {});
|
|
|
|
|
|
describe('#isReassignWizard', function() {
|
|
|
it('true if content.controllerName is reassignMasterController', function() {
|
|
|
controller.set('content.controllerName', 'reassignMasterController');
|
|
|
expect(controller.get('isReassignWizard')).to.equal(true);
|
|
|
- })
|
|
|
+ });
|
|
|
it('false if content.controllerName is not reassignMasterController', function() {
|
|
|
controller.set('content.controllerName', 'mainController');
|
|
|
expect(controller.get('isReassignWizard')).to.equal(false);
|
|
|
- })
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
});
|