tempesta-tech / tempesta-test

Test suite for Tempesta FW
11 stars 4 forks source link

Access logs curl hang-up fix #270

Closed pale-emperor closed 2 years ago

pale-emperor commented 2 years ago

Old code: tester.wait_while_busy -> client.wait_for_finish() -> client.is_busy() -> self.exit_event

def wait_while_busy(self, *items):
    if items is None:
        return

    for item in items:
        if item.is_running():
            item.wait_for_finish() ->

def wait_for_finish(self):
    # until we explicitly get `self.exit_event` flag set
    while self.is_busy(verbose=False): -> Always True
        pass
    self.returncode = self.proc.exitcode

def is_busy(self, verbose=True):
    busy = not self.exit_event.is_set() -> Always True cause exit_event.set() is unreacheable
    if verbose:
        if busy:
            tf_cfg.dbg(4, "\tClient is running")
        else:
            tf_cfg.dbg(4, "\tClient is not running")
    return busy

client.run_start -> client.run_start() -> client._run_client -> ok

def run_curl(self):
    curl = self.get_client('curl')
    curl.run_start() ->
    curl.proc_results = curl.resq.get(True, 1)
    self.assertEqual(0, curl.returncode,
                     msg=("Curl return code is not 0 (%d)." %
                          (curl.returncode)))

def run_start(self):
    """ Run client """
    tf_cfg.dbg(3, "Running client")
    self.exit_event.clear()
    self.prepare()
    self.proc = multiprocessing.Process(target = _run_client, args=(self, self.exit_event, self.resq)) ->
    self.proc.start()

def _run_client(client, exit_event, resq):
    res = remote.client.run_cmd(client.cmd, timeout=(client.duration + 5)) -> Running ok with Exception 52 errorcode
    tf_cfg.dbg(3, "\tClient exit")
    resq.put(res)
    exit_event.set() -> Code execute correctly, old code was unreacheable

Old problem was

is_busy - False wait_for_finish - True

In _run_client we got Exception and exit_event.set() was never executed and we get infinite wait_while_busy()

nickzaev commented 2 years ago

Have you tried running these tests on current master of tempesta-test? Because with the latest changes to the framework all access_log test section works just fine:

Running functional tests...
----------------------------------------------------------------------

test_frang (access_log.test_access_log.AccessLogFrang) ... ok
test_success_path_http1x (access_log.test_access_log.AccessLogTest) ... ok
test_uri_truncate (access_log.test_access_log.AccessLogTest) ... ok
test_tempesta (access_log.test_access_log_h2.FrangTest) ... ok
test_tempesta (access_log.test_access_log_h2.Response200Test) ... ok
test_tempesta (access_log.test_access_log_h2.Response204Test) ... ok
test_tempesta (access_log.test_access_log_h2.Response302Test) ... ok
test_tempesta (access_log.test_access_log_h2.Response404Test) ... ok
test_tempesta (access_log.test_access_log_h2.Response500Test) ... ok
test_tempesta (access_log.test_access_log_h2.TruncateUriTest) ... ok

----------------------------------------------------------------------
Ran 10 tests in 21.034s

OK