Esempio n. 1
0
    def setUp(self):

        # set test server size
        self.TOTAL_SERVERS = 5

        # initialize server list
        self.server_list = []

        # generate the host numbers and ports of server connections
        for i in range(9000, 9000 + 2 * self.TOTAL_SERVERS, 2):
            server_entry = dict()

            server_entry["host"] = "localhost"
            server_entry["internal_port"] = i + 1
            server_entry["client_port"] = i

            self.server_list.append(server_entry)

        # bring up each server
        self.servers = []

        # iterate through address list and instantiate servers
        for i in range(0, len(self.server_list)):
            # instantiate new servers
            new_server = server.PAXOS_member(i, self.server_list)
            self.servers.append(new_server)

        assert (len(self.servers) == len(self.server_list))
        assert (len(self.servers) == self.TOTAL_SERVERS)

        # initialize new servers
        for i in range(0, len(self.servers)):
            s = self.server_list[i]
            assert s
            self.servers[i].initialize_paxos()
Esempio n. 2
0
    def setUp(self):
        """
            Bring up just enough infrastructure to set up a test
            acceptor and send it messages
        """
        # Instantiate a server instance
        self.server_list = [{
            "host": "localhost",
            "internal_port": 9001,
            "client_port": 9002
        }, {
            "host": "localhost",
            "internal_port": 9003,
            "client_port": 9004
        }]
        self.paxos_server = server.PAXOS_member(0, self.server_list)

        # Insert a wait for the server to come online
        time.sleep(1)

        # create a dummy server of test
        self.dummy_server_id = 1

        # start a test remote inter-server socket on 9003
        try:
            self.dummy_server_socket = socket.socket(socket.AF_INET,
                                                     socket.SOCK_STREAM)
            self.dummy_server_socket.setsockopt(socket.SOL_SOCKET,
                                                socket.SO_REUSEADDR, 1)
            self.dummy_server_socket.bind(('localhost', 9003))
            self.dummy_server_socket.listen(5)
        except Exception, e:
            os.system("lsof -n -i")
            os.system("ps -a")
            self.dummy_server_socket.close()
            emsg = "[Info] Failed to bind socket for dummy server: " + str(e)
            raise ValueError(emsg)
Esempio n. 3
0
    def test_message_drops(self):
        """
            Test paxos group with message drop
        """
        print "\n\n##########[MESSAGE DROP TEST]##########\n\n"

        # set test server size
        self.TOTAL_SERVERS = 3
        self.client_files = None

        # initialize server list
        self.server_list = []

        # generate the host numbers and ports of server connections
        for i in range(9000, 9000 + 2 * self.TOTAL_SERVERS, 2):
            server_entry = dict()

            server_entry["host"] = "localhost"
            server_entry["internal_port"] = i + 1
            server_entry["client_port"] = i
            server_entry["drop_rate"] = 0.001  # this is a percentage

            self.server_list.append(server_entry)

        # bring up each server
        self.servers = []

        # iterate through address list and instantiate servers
        for i, server_config in enumerate(self.server_list):
            # instantiate new servers
            new_server = server.PAXOS_member(i, self.server_config)
            self.servers.append(new_server)

        assert len(self.servers) == len(self.server_list)
        assert len(self.servers) == self.TOTAL_SERVERS

        # initialize new servers
        for i in range(0, len(self.servers)):
            s = self.server_list[i]
            assert s
            self.servers[i].initialize_paxos()
            time.sleep(.5)  # allow the system to recover

        # LOCKS = 1

        # generate the lock files
        for i in range(0, len(self.server_list)):
            filename = "client_" + str(i) + ".txt"
            make_simple_file(LOCKS, filename)

        # for i in range(0, len(self.server_list)):
        #    filename = "client_" + str(i) + ".txt"
        #    make_simple_file(LOCKS, filename)
        #
        client_files = []

        # instantiate a client to each server
        client_list = []
        for i in range(0, len(self.server_list)):
            port = self.server_list[i]["client_port"]
            host = self.server_list[i]["host"]
            assert ((int(port) % 2) == 0)

            cli = client.client("client_" + str(i) + ".txt", host, port, i)
            print "up client {}".format(len(client_list))
            client_list.append(cli)
            client_files.append("client_" + str(i) + ".txt")

        self.client_files = client_files

        # join each client
        failed = False
        for c in client_list:
            try:
                c.c_process.join()
            except Exception, e:
                c.terminate()
                failed = True
Esempio n. 4
0
    def test_message_duplication(self):
        """
            Test Functionality at 50 percent Message Duplication Rate
        """
        print "\n\n##########[MESSAGE DUUPLICATION TEST]##########\n\n"

        # set test server size
        self.TOTAL_SERVERS = 5

        # initialize server list
        self.server_list = []

        self.client_files = []

        # generate the host numbers and ports of server connections
        for i in range(9000, 9000 + 2 * self.TOTAL_SERVERS, 2):
            server_entry = dict()

            server_entry["host"] = "localhost"
            server_entry["internal_port"] = i + 1
            server_entry["client_port"] = i

            server_entry["dup_rate"] = 0.5

            self.server_list.append(server_entry)

        # bring up each server
        self.servers = []

        # iterate through address list and instantiate servers
        for i in range(0, len(self.server_list)):
            # instantiate new servers
            new_server = server.PAXOS_member(i, self.server_list)
            self.servers.append(new_server)

        assert (len(self.servers) == len(self.server_list))
        assert (len(self.servers) == self.TOTAL_SERVERS)

        # initialize new servers
        for i in range(0, len(self.servers)):
            s = self.server_list[i]
            assert s
            self.servers[i].initialize_paxos()
            time.sleep(.5)  # allow the system to recover

        LOCKS = 100

        # generate the lock files
        for i in range(0, len(self.server_list)):
            filename = "client_" + str(i) + ".txt"
            make_simple_file(LOCKS, filename)

        # instantiate a client to each server
        client_list = []
        client_files = []
        for i in range(0, len(self.server_list)):
            port = self.server_list[i]["client_port"]
            host = self.server_list[i]["host"]
            assert ((int(port) % 2) == 0)

            cli = client.client("client_" + str(i) + ".txt", host, port,
                                len(client_list))
            client_list.append(cli)
            client_list.append(cli)
            client_list.append(cli)
            client_files.append("client_" + str(i) + ".txt")

        self.client_files = client_files

        # join each client
        failed = False
        for c in client_list:
            try:
                c.c_process.join()
            except Exception, e:
                c.terminate()
                failed = True