def test_scaling_down_existing_mult_node_group(self, ng, context): ng.side_effect = my_node_group_update context.side_effect = my_get_context cluster = TestCluster() cluster.node_groups.append( TestNodeGroup( ["GANGLIA_MONITOR", "AMBARI_AGENT", "DATANODE", "TASKTRACKER"], name="TEST1", id=1)) cluster.node_groups.append( TestNodeGroup([ "GANGLIA_SERVER", "AMBARI_SERVER", "AMBARI_AGENT", "NAMENODE", "JOBTRACKER" ], count=1, name="TEST2", id=2)) test_node_group = TestNodeGroup( ["GANGLIA_MONITOR", "AMBARI_AGENT", "DATANODE", "TASKTRACKER"], count=0, name="TEST3", id=3) cluster.node_groups.append(test_node_group) additional = {3: 1} existing = {2: 0} validator = v.Validator() with self.assertRaises(v.NotSingleAmbariServerException): validator.validate_scaling(cluster, existing, additional) self.assertEqual(3, len(cluster.node_groups)) self.assertEqual(1, cluster.node_groups[0].count) self.assertEqual(1, cluster.node_groups[1].count)
def test_missing_ambari_agent(self): cluster = TestCluster() cluster.node_groups.append( TestNodeGroup(["GANGLIA_SERVER", "NAMENODE", "AMBARI_SERVER"])) cluster.node_groups.append( TestNodeGroup(["GANGLIA_MONITOR", "AMBARI_AGENT"])) validator = v.Validator() with self.assertRaises(v.AmbariAgentNumberException): validator.validate(cluster)
def test_no_ambari_server(self): cluster = TestCluster() cluster.node_groups.append( TestNodeGroup(["GANGLIA_SERVER", "NAMENODE", "AMBARI_AGENT"])) cluster.node_groups.append( TestNodeGroup(["GANGLIA_MONITOR", "AMBARI_AGENT"])) validator = v.Validator() with self.assertRaises(v.NotSingleAmbariServerException): validator.validate(cluster)
def test_no_namenode(self): cluster = TestCluster() cluster.node_groups.append( TestNodeGroup(["GANGLIA_SERVER", "AMBARI_SERVER", "AMBARI_AGENT"])) cluster.node_groups.append( TestNodeGroup(["GANGLIA_MONITOR", "AMBARI_AGENT"])) validator = v.Validator() with self.assertRaises(ex.NotSingleNameNodeException): validator.validate(cluster)
def test_with_namenode(self): cluster = TestCluster() cluster.node_groups.append( TestNodeGroup([ "GANGLIA_SERVER", "AMBARI_SERVER", "AMBARI_AGENT", "NAMENODE" ])) cluster.node_groups.append( TestNodeGroup(["GANGLIA_MONITOR", "AMBARI_AGENT"])) validator = v.Validator() validator.validate(cluster)
def test_with_jobtracker(self): cluster = TestCluster() cluster.node_groups.append( TestNodeGroup([ "GANGLIA_SERVER", "AMBARI_SERVER", "AMBARI_AGENT", "NAMENODE", "JOBTRACKER" ])) cluster.node_groups.append( TestNodeGroup(["GANGLIA_MONITOR", "AMBARI_AGENT", "TASKTRACKER"])) validator = v.Validator() validator.validate(cluster)
def test_no_jobtracker(self): cluster = TestCluster() cluster.node_groups.append( TestNodeGroup([ "GANGLIA_SERVER", "AMBARI_SERVER", "AMBARI_AGENT", "NAMENODE" ])) cluster.node_groups.append( TestNodeGroup(["GANGLIA_MONITOR", "AMBARI_AGENT", "TASKTRACKER"])) validator = v.Validator() with self.assertRaises(ex.TaskTrackersWithoutJobTracker): validator.validate(cluster)
def test_scaling_an_existing_ambari_server_node_group(self, ng, context): ng.side_effect = my_node_group_update context.side_effect = my_get_context cluster = TestCluster() cluster.node_groups.append( TestNodeGroup([ "GANGLIA_SERVER", "AMBARI_SERVER", "AMBARI_AGENT", "NAMENODE", "JOBTRACKER" ], id=1, count=1)) existing = {1: 2} additional = {} validator = v.Validator() with self.assertRaises(v.NotSingleAmbariServerException): validator.validate_scaling(cluster, existing, additional) self.assertEqual(1, len(cluster.node_groups)) self.assertEqual(1, cluster.node_groups[0].count)
def test_scaling_with_jobtracker(self, ng, context): ng.side_effect = my_node_group_update context.side_effect = my_get_context cluster = TestCluster() cluster.node_groups.append( TestNodeGroup([ "GANGLIA_SERVER", "AMBARI_SERVER", "AMBARI_AGENT", "NAMENODE", "JOBTRACKER" ], id=1)) add_node_group = TestNodeGroup( ["GANGLIA_MONITOR", "AMBARI_AGENT", "TASKTRACKER"], count=0, id=2) cluster.node_groups.append(add_node_group) additional = {2: 1} existing = {} validator = v.Validator() validator.validate_scaling(cluster, existing, additional) self.assertEqual(2, len(cluster.node_groups)) self.assertEqual(0, cluster.node_groups[1].count)
def test_scaling_with_additional_ambari_server(self, ng, context): ng.side_effect = my_node_group_update context.side_effect = my_get_context cluster = TestCluster() cluster.node_groups.append( TestNodeGroup([ "GANGLIA_SERVER", "AMBARI_SERVER", "AMBARI_AGENT", "NAMENODE", "JOBTRACKER" ], id=1)) test_node_group = TestNodeGroup([ "GANGLIA_MONITOR", "AMBARI_AGENT", "TASKTRACKER", "AMBARI_SERVER" ], count=0, id=2) cluster.node_groups.append(test_node_group) additional = {2: 1} existing = {} validator = v.Validator() with self.assertRaises(v.NotSingleAmbariServerException): validator.validate_scaling(cluster, existing, additional) self.assertEqual(2, len(cluster.node_groups)) self.assertEqual(0, cluster.node_groups[1].count)
def validate(self, cluster): validator = v.Validator() validator.validate(cluster)
def validate_scaling(self, cluster, existing, additional): # see if additional servers are slated for "MASTER" group validator = v.Validator() validator.validate_scaling(cluster, existing, additional)