Ejemplo n.º 1
0
 def get_sedna_config(self):
     """
     To get a object
     :return:the object include a list of nodes and the value of port
     """
     sedna_config_object = SednaConfig()
     sedna_config_object.nodes = self.nodes
     sedna_config_object.port = self.port
     return sedna_config_object
    def test(self):
        expected_services = [Service(name=TEST_SERVICE_NAME, ip="localhost", check_methods=TEST_METHOD)]

        expected_nodes = [Node(services=expected_services, ip="localhost")]

        mocked_sampler = CommunicationTest._MockedNodeSampler()
        mocked_sampler.register_checker(TEST_METHOD, MockedMethodChecker)
        server = NodeSamplerServer(8000, mocked_sampler)

        def start_server():
            server.start()

        server_thread = Thread(target=start_server)
        server_thread.setDaemon(True)
        server_thread.start()

        sedna_config_object = SednaConfig()
        sedna_config_object.port = "8000"
        sedna_config_object.nodes = expected_nodes
        master = Master()
        master.verify_nodes(sedna_config_object)
        self.assertTrue(mocked_sampler.is_sample_called, "The sampler is no called!")
        self.assertSequenceEqual(expected_services, mocked_sampler.actual_services)