Пример #1
0
    def run_test_server(self, arch=64):
        # run test server
        _capi_server_conf = """
zookeeper 127.0.0.1:2181
cluster_name %s
port 6200
daemonize no
num_conn_per_gw 2
init_timeout_millis 10000
log_level INFO
log_file_prefix "capi_server"
max_fd 4096
conn_reconnect_millis 1000
zk_reconnect_millis 1000
zk_session_timeout_millis 10000
local_proxy_query_timeout_millis 1000
        """ % self.cluster['cluster_name']
        old_cwd = os.path.abspath(os.getcwd())
        os.chdir(util.capi_dir(0))
        f = open('capi_server.conf', 'w')
        f.write(_capi_server_conf)
        f.close()
        os.chdir(old_cwd)

        if arch is 32:
            cmd = "./%s capi_server.conf" % constant.CAPI32_TEST_SERVER
        else:
            cmd = "./%s capi_server.conf" % constant.CAPI_TEST_SERVER

        capi_server = util.exec_proc_async(util.capi_dir(0), cmd, True, None,
                                           subprocess.PIPE, None)

        return capi_server
Пример #2
0
    def run_capi_server(self):
        # run capi test server
        _capi_server_conf = """
zookeeper 127.0.0.1:2181
cluster_name %s
port 6200
daemonize no
num_conn_per_gw 2
init_timeout_millis 10000
log_level INFO
log_file_prefix "capi_server"
max_fd 4096
conn_reconnect_millis 1000
zk_reconnect_millis 1000
zk_session_timeout_millis 10000
local_proxy_query_timeout_millis 10000
        """ % self.cluster['cluster_name']
        old_cwd = os.path.abspath( os.getcwd() )
        os.chdir(util.capi_dir(0))
        f = open('capi_server.conf', 'w')
        f.write(_capi_server_conf)
        f.close()
        os.chdir(old_cwd)

        if self.arch is 32:
            cmd = "./%s capi_server.conf" % constant.CAPI32_TEST_SERVER
        else:
            cmd = "./%s capi_server.conf" % constant.CAPI_TEST_SERVER

        capi_server = util.exec_proc_async(util.capi_dir(0),
                            cmd, True, None, subprocess.PIPE, None)

        # ping check
        while True:
            try:
                t = telnetlib.Telnet('127.0.0.1', 6200)
                break
            except:
                time.sleep(1)
                continue

        t.write("ping\r\n")
        t.read_until('+PONG\r\n')
        t.close()

        return capi_server
Пример #3
0
    def run_capi_server(self, arch=64):
        # run capi test server
        _capi_server_conf = """
zookeeper 127.0.0.1:2181
cluster_name %s
port 6200
daemonize no
num_conn_per_gw 2
init_timeout_millis 10000
log_level INFO
log_file_prefix "capi_server"
max_fd 4096
conn_reconnect_millis 1000
zk_reconnect_millis 1000
zk_session_timeout_millis 10000
local_proxy_query_timeout_millis 10000
        """ % self.cluster['cluster_name']
        old_cwd = os.path.abspath( os.getcwd() )
        os.chdir(util.capi_dir(0))
        f = open('capi_server.conf', 'w')
        f.write(_capi_server_conf)
        f.close()
        os.chdir(old_cwd)

        if arch is 32:
            cmd = "./%s capi_server.conf" % constant.CAPI32_TEST_SERVER
        else:
            cmd = "./%s capi_server.conf" % constant.CAPI_TEST_SERVER

        capi_server = util.exec_proc_async(util.capi_dir(0),
                            cmd, True, None, subprocess.PIPE, None)

        # ping check
        while True:
            try:
                t = telnetlib.Telnet('127.0.0.1', 6200)
                break
            except:
                time.sleep(1)
                continue

        t.write("ping\r\n")
        t.read_until('+PONG\r\n')
        t.close()

        return capi_server
Пример #4
0
    def __test_local_proxy(self, arch=64):
        util.print_frame()

        # Clean server log file
        p = util.exec_proc_async(util.capi_dir(0),
                'rm capi_server-*',
                True, None, subprocess.PIPE, None)

        p.wait()

        # run test server
        _capi_server_conf = """
zookeeper 127.0.0.1:2181
cluster_name %s
port 6200
daemonize no
num_conn_per_gw 2
init_timeout_millis 10000
log_level INFO
log_file_prefix "capi_server"
max_fd 4096
conn_reconnect_millis 1000
zk_reconnect_millis 1000
zk_session_timeout_millis 10000
        """ % self.cluster['cluster_name']
        old_cwd = os.path.abspath( os.getcwd() )
        os.chdir(util.capi_dir(0))
        f = open('capi_server.conf', 'w')
        f.write(_capi_server_conf)
        f.close()
        os.chdir(old_cwd)

        if arch is 32:
            cmd = "./%s capi_server.conf" % constant.CAPI32_TEST_SERVER
        else:
            cmd = "./%s capi_server.conf" % constant.CAPI_TEST_SERVER

        capi_server = util.exec_proc_async(util.capi_dir(0),
                            cmd, True, None, subprocess.PIPE, None)

        # ping check
        while True:
            try:
                t = telnetlib.Telnet('127.0.0.1', 6200)
                break
            except:
                time.sleep(1)
                continue

        t.write("ping\r\n")
        t.read_until('+PONG\r\n')
        t.close()

        # Start load generator
        load_gen_thrd_list = {}
        for i in range(self.max_load_generator):
            load_gen_thrd_list[i] = load_generator.LoadGenerator(i, 'localhost', 6200)
            load_gen_thrd_list[i].start()

        time.sleep(5)

        # Check reconfiguration by SIGHUP
        p = util.exec_proc_async(util.capi_dir(0),
                'grep "Connected to the zookeeper" capi_server-* | wc -l',
                True, None, subprocess.PIPE, None)

        p.wait()
        wc = p.stdout.readline()
        print 'grep "Connected to the zookeeper" result : ' + wc
        self.assertEquals(wc.strip(), '1')

        capi_server.send_signal(signal.SIGHUP)
        time.sleep(5)

        p = util.exec_proc_async(util.capi_dir(0),
                'grep "Connected to the zookeeper" capi_server-* | wc -l',
                True, None, subprocess.PIPE, None)

        p.wait()
        wc = p.stdout.readline()
        print 'grep "Connected to the zookeeper" result : ' + wc
        self.assertEquals(wc.strip(), '2')

        p = util.exec_proc_async(util.capi_dir(0),
                'grep "Graceful shutdown caused by API" capi_server-* | wc -l',
                True, None, subprocess.PIPE, None)

        p.wait()
        wc = p.stdout.readline()
        print 'grep "Graceful shutdown caused by API" result : ' + wc
        self.assertEquals(wc.strip(), '1')

        # Check consistency after sending many SIGHUP signal
        for i in range(50):
            capi_server.send_signal(signal.SIGHUP)
            time.sleep(0.1)

        # check consistency of load_generator
        for i in range(len(load_gen_thrd_list)):
            load_gen_thrd_list[i].quit()
        for i in range(len(load_gen_thrd_list)):
            load_gen_thrd_list[i].join()
            self.assertTrue(load_gen_thrd_list[i].isConsistent(), 'Inconsistent after sending signal')

        # Terminate test server
        capi_server.send_signal(signal.SIGTERM)
        capi_server.wait()
Пример #5
0
    def __test_local_proxy(self, arch=64):
        util.print_frame()

        # Clean server log file
        p = util.exec_proc_async(util.capi_dir(0), 'rm capi_server-*', True,
                                 None, subprocess.PIPE, None)

        p.wait()

        # run test server
        _capi_server_conf = """
zookeeper 127.0.0.1:2181
cluster_name %s
port 6200
daemonize no
num_conn_per_gw 2
init_timeout_millis 10000
log_level INFO
log_file_prefix "capi_server"
max_fd 4096
conn_reconnect_millis 1000
zk_reconnect_millis 1000
zk_session_timeout_millis 10000
        """ % self.cluster['cluster_name']
        old_cwd = os.path.abspath(os.getcwd())
        os.chdir(util.capi_dir(0))
        f = open('capi_server.conf', 'w')
        f.write(_capi_server_conf)
        f.close()
        os.chdir(old_cwd)

        if arch is 32:
            cmd = "./%s capi_server.conf" % constant.CAPI32_TEST_SERVER
        else:
            cmd = "./%s capi_server.conf" % constant.CAPI_TEST_SERVER

        capi_server = util.exec_proc_async(util.capi_dir(0), cmd, True, None,
                                           subprocess.PIPE, None)

        # ping check
        while True:
            try:
                t = telnetlib.Telnet('127.0.0.1', 6200)
                break
            except:
                time.sleep(1)
                continue

        t.write("ping\r\n")
        t.read_until('+PONG\r\n')
        t.close()

        # Start load generator
        load_gen_thrd_list = {}
        for i in range(self.max_load_generator):
            load_gen_thrd_list[i] = load_generator.LoadGenerator(
                i, 'localhost', 6200)
            load_gen_thrd_list[i].start()

        time.sleep(5)

        # Check reconfiguration by SIGHUP
        p = util.exec_proc_async(
            util.capi_dir(0),
            'grep "Connected to the zookeeper" capi_server-* | wc -l', True,
            None, subprocess.PIPE, None)

        p.wait()
        wc = p.stdout.readline()
        print 'grep "Connected to the zookeeper" result : ' + wc
        self.assertEquals(wc.strip(), '1')

        capi_server.send_signal(signal.SIGHUP)
        time.sleep(5)

        p = util.exec_proc_async(
            util.capi_dir(0),
            'grep "Connected to the zookeeper" capi_server-* | wc -l', True,
            None, subprocess.PIPE, None)

        p.wait()
        wc = p.stdout.readline()
        print 'grep "Connected to the zookeeper" result : ' + wc
        self.assertEquals(wc.strip(), '2')

        p = util.exec_proc_async(
            util.capi_dir(0),
            'grep "Graceful shutdown caused by API" capi_server-* | wc -l',
            True, None, subprocess.PIPE, None)

        p.wait()
        wc = p.stdout.readline()
        print 'grep "Graceful shutdown caused by API" result : ' + wc
        self.assertEquals(wc.strip(), '1')

        # Check consistency after sending many SIGHUP signal
        for i in range(50):
            capi_server.send_signal(signal.SIGHUP)
            time.sleep(0.1)

        # check consistency of load_generator
        for i in range(len(load_gen_thrd_list)):
            load_gen_thrd_list[i].quit()
        for i in range(len(load_gen_thrd_list)):
            load_gen_thrd_list[i].join()
            self.assertTrue(load_gen_thrd_list[i].isConsistent(),
                            'Inconsistent after sending signal')

        # Terminate test server
        capi_server.send_signal(signal.SIGTERM)
        capi_server.wait()
Пример #6
0
    def test_local_proxy(self, arch=64):
        util.print_frame()

        # Clean server log file
        p = util.exec_proc_async(util.capi_dir(0), 'rm capi_server-*', True,
                                 None, subprocess.PIPE, None)

        p.wait()

        # run test server
        capi_server = self.run_test_server(arch)

        # ping check
        while True:
            try:
                t = telnetlib.Telnet('127.0.0.1', 6200)
                break
            except:
                time.sleep(1)
                continue

        t.write("ping\r\n")
        t.read_until('+PONG\r\n')
        t.close()

        # Start load generator
        load_gen_thrd_list = {}
        for i in range(self.max_load_generator):
            load_gen_thrd_list[i] = load_generator.LoadGenerator(
                i, 'localhost', 6200)
            load_gen_thrd_list[i].start()

        time.sleep(5)

        # Check reconfiguration by SIGHUP
        p = util.exec_proc_async(
            util.capi_dir(0),
            'grep "Connected to the zookeeper" capi_server-* | wc -l', True,
            None, subprocess.PIPE, None)

        p.wait()
        wc = p.stdout.readline()
        print 'grep "Connected to the zookeeper" result : ' + wc
        self.assertEquals(wc.strip(), '1')

        capi_server.send_signal(signal.SIGHUP)
        time.sleep(5)

        p = util.exec_proc_async(
            util.capi_dir(0),
            'grep "Connected to the zookeeper" capi_server-* | wc -l', True,
            None, subprocess.PIPE, None)

        p.wait()
        wc = p.stdout.readline()
        print 'grep "Connected to the zookeeper" result : ' + wc
        self.assertEquals(wc.strip(), '2')

        p = util.exec_proc_async(
            util.capi_dir(0),
            'grep "Graceful shutdown caused by API" capi_server-* | wc -l',
            True, None, subprocess.PIPE, None)

        p.wait()
        wc = p.stdout.readline()
        print 'grep "Graceful shutdown caused by API" result : ' + wc
        self.assertEquals(wc.strip(), '1')

        # Check consistency after sending many SIGHUP signal
        for i in range(50):
            capi_server.send_signal(signal.SIGHUP)
            time.sleep(0.1)

        # check consistency of load_generator
        for i in range(len(load_gen_thrd_list)):
            load_gen_thrd_list[i].quit()
        for i in range(len(load_gen_thrd_list)):
            load_gen_thrd_list[i].join()
            self.assertTrue(load_gen_thrd_list[i].isConsistent(),
                            'Inconsistent after sending signal')

        # Terminate test server
        self.stop_test_server(capi_server)