示例#1
0
def main():
    sedna_config_path = SednaConfigPath()
    config_dir = sedna_config_path.get_config_path()
    config = Config(config_dir)
    sedna_config_value = config.get_sedna_config()
    master = Master()
    results = master.verify_nodes(sedna_config_value)
    formated_result = FormatedResult()
    formated_result.format_output_log(results)
示例#2
0
 def test_get_port(self):
     config = Config(self.absolute_fake_sedna_config_path)
     sedna_config_object = config.get_sedna_config()
     self.assertEquals(sedna_config_object.port,
                       "8000",
                       'Fail when get port.')
示例#3
0
class GetConfigTest(unittest2.TestCase):
    """
    The test cases to test Config class
    when config file is configured correctly.
    """

    def setUp(self):
        self.fake_config_file = FakeSednaConfigFile()
        fake_relative_path = self.fake_config_file.set_up()
        config = SednaConfigParser()
        self.fake_sedna_config = config.get_config_parser(fake_relative_path)

        fake_sedna_config_path = SednaConfigPath()
        absolute_fake_sedna_config_path =\
            fake_sedna_config_path.get_config_path("./tests/fake_sedna.conf")
        self.config = Config(absolute_fake_sedna_config_path)
        self.sedna_config_object = self.config.get_sedna_config()

    def test_get_port(self):
        self.assertEquals(self.sedna_config_object.port,
                          self.fake_sedna_config.get("sampler", "port"),
                          'Fail when get port.')

    def test_get_nodes(self):
        nodes_num = 0
        for option in self.fake_sedna_config.options("groups"):
            group_addresses =\
                self.fake_sedna_config.get("groups", option).split(", ")
            nodes_num += len(group_addresses)

        node_list = self.sedna_config_object.nodes

        self.assertEquals(len(node_list), nodes_num,
                          'Fail when test_get_nodes information')

    def test_get_nodes_content_stdout(self):
        node_list = self.sedna_config_object.nodes
        print node_list[3].group
        print node_list[3].ip
        for service in node_list[3].services:
            print service.name
            print service.ip
            print service.check_methods

    def test_get_nodes_content(self):
        expected_service_a_1 =\
            Service(name="service_a", ip="192.168.0.1",
                    check_methods="systemd")
        expected_service_a_2 = \
            Service(name="service_a", ip="192.168.0.2",
                    check_methods="systemd")
        expected_service_a_3 = \
            Service(name="service_a", ip="192.168.0.3",
                    check_methods="systemd")
        expected_service_b_1 =\
            Service(name="service_b", ip="192.168.0.1",
                    check_methods="pacemaker")
        expected_service_b_2 = \
            Service(name="service_b", ip="192.168.0.2",
                    check_methods="pacemaker")
        expected_service_b_3 = \
            Service(name="service_b", ip="192.168.0.3",
                    check_methods="pacemaker")
        expected_service_c_4 = \
            Service(name="service_c", ip="192.168.0.4",
                    check_methods="init.d")
        expected_service_c_5 = \
            Service(name="service_c", ip="192.168.0.5",
                    check_methods="init.d")
        expected_service_d_4 = \
            Service(name="service_d", ip="192.168.0.4",
                    check_methods="$$unknown_method$$")
        expected_service_d_5 = \
            Service(name="service_d", ip="192.168.0.5",
                    check_methods="$$unknown_method$$")

        expected_service_list_1 = [expected_service_a_1, expected_service_b_1]
        expected_service_list_2 = [expected_service_a_2, expected_service_b_2]
        expected_service_list_3 = [expected_service_a_3, expected_service_b_3]
        expected_service_list_4 = [expected_service_c_4, expected_service_d_4]
        expected_service_list_5 = [expected_service_c_5, expected_service_d_5]

        expected_node_1 =\
            Node(group="test_group_a", ip="192.168.0.1",
                 services=expected_service_list_1)
        expected_node_2 =\
            Node(group="test_group_a", ip="192.168.0.2",
                 services=expected_service_list_2)
        expected_node_3 =\
            Node(group="test_group_a", ip="192.168.0.3",
                 services=expected_service_list_3)
        expected_node_4 =\
            Node(group="test_group_b", ip="192.168.0.4",
                 services=expected_service_list_4)
        expected_node_5 =\
            Node(group="test_group_b", ip="192.168.0.5",
                 services=expected_service_list_5)

        expected_nodes =\
            [expected_node_1, expected_node_2, expected_node_3,
             expected_node_4, expected_node_5]

        node_list = self.sedna_config_object.nodes

        self.assertEquals(node_list, expected_nodes,
                          'Fail when test_get_nodes information')

    def tearDown(self):
        self.fake_config_file.tear_down()