[Notes] [Git][BuildStream/buildstream][Qinusty/531-fetch-retries-on-terminate] Enable stdout-stderr on ci



Title: GitLab

Qinusty pushed to branch Qinusty/531-fetch-retries-on-terminate at BuildStream / buildstream

Commits:

6 changed files:

Changes:

  • tests/frontend/delayedproj/__init__.py

  • tests/frontend/interruptions/elements/delaymock.bsttests/frontend/delayedproj/elements/delaymock.bst

  • tests/frontend/delayedproj/plugins/__init__.py

  • tests/frontend/interruptions/plugins/delayed.pytests/frontend/delayedproj/plugins/delayed.py
    ... ... @@ -27,6 +27,7 @@ class DelayedMockSource(Source):
    27 27
     
    
    28 28
             def prog_percent(prog):
    
    29 29
                 return "{}%".format((float(i) / float(LOOP_FOR)) * 100)
    
    30
    +
    
    30 31
             for i in range(LOOP_FOR):
    
    31 32
                 time.sleep(0.5)
    
    32 33
                 self.status("Mock Source progress {}".format(prog_percent(i)))
    

  • tests/frontend/interruptions/project.conftests/frontend/delayedproj/project.conf

  • tests/frontend/interruptions.py
    ... ... @@ -6,6 +6,7 @@ import time
    6 6
     import multiprocessing as mp
    
    7 7
     from multiprocessing import Process
    
    8 8
     from multiprocessing.queues import Queue
    
    9
    +import subprocess
    
    9 10
     
    
    10 11
     from buildstream import _yaml
    
    11 12
     from tests.testutils import cli
    
    ... ... @@ -13,45 +14,37 @@ from tests.testutils import cli
    13 14
     
    
    14 15
     DATA_DIR = os.path.join(
    
    15 16
         os.path.dirname(os.path.realpath(__file__)),
    
    16
    -    "interruptions",
    
    17
    +    "delayedproj",
    
    17 18
     )
    
    18 19
     
    
    19 20
     
    
    20
    -def cli_run_in_process(cli, path, args):
    
    21
    -    def do_run(cli, path, args, queue):
    
    22
    -        result = cli.run(project=path, args=args)
    
    23
    -        queue.put(result.output)
    
    24
    -        queue.put(result.stderr)
    
    25
    -
    
    26
    -    queue = mp.Queue()
    
    27
    -    p = mp.Process(target=do_run, args=[cli, path, args, queue])
    
    28
    -    p.start()
    
    29
    -    return queue, p
    
    21
    +def subprocess_bst(path, args):
    
    22
    +    p = subprocess.Popen(["python3", "-m", "buildstream"] + args, cwd=path, stdout=subprocess.PIPE,
    
    23
    +                         stderr=subprocess.PIPE)
    
    24
    +    return p
    
    30 25
     
    
    31 26
     
    
    32 27
     @pytest.mark.datafiles(DATA_DIR)
    
    33 28
     def test_interrupt_fetch(cli, datafiles):
    
    34 29
         path = os.path.join(datafiles.dirname, datafiles.basename)
    
    35 30
     
    
    36
    -    queue, proc = cli_run_in_process(cli, path, args=['--on-error', 'terminate',
    
    37
    -                                                      'fetch', 'delaymock.bst'])
    
    31
    +    proc = subprocess_bst(path, args=['--on-error', 'terminate',
    
    32
    +                                          'fetch', 'delaymock.bst'])
    
    38 33
         # Wait a few seconds, fetch should then be in progress. With DelayedMockSource
    
    39 34
         # fetch should take 20s unless terminated
    
    40 35
         time.sleep(3)
    
    41
    -    os.kill(proc.pid, signal.SIGINT)
    
    36
    +    proc.send_signal(signal.SIGINT)
    
    42 37
     
    
    43
    -    # 10 second timeout
    
    44 38
         try:
    
    45
    -        output = queue.get(timeout=10)
    
    46
    -        stderr = queue.get(timeout=10)
    
    47
    -    except mp.queues.Empty:
    
    48
    -        assert False, 'Fetch failed to terminate'
    
    39
    +        stdout, stderr = proc.communicate(timeout=5)
    
    40
    +    except subprocess.TimeoutExpired:
    
    41
    +        assert False, "BuildStream failed to terminate on SIGINT."
    
    49 42
     
    
    50
    -    matches = re.findall(r'FAILURE\s*Fetch', stderr)
    
    51
    -    success_matches = re.findall(r'SUCCESS\s*Fetch', stderr)
    
    43
    +    matches = re.findall(r'FAILURE\s*Fetch', str(stderr))
    
    44
    +    success_matches = re.findall(r'SUCCESS\s*Fetch', str(stderr))
    
    52 45
         assert len(matches) or len(success_matches), "BuildStream exitted unexpectedly"
    
    53 46
         assert len(matches), "Unexpected success"
    
    54 47
     
    
    55
    -    matches = re.findall(r'STATUS\s*Fetch terminating', stderr)
    
    48
    +    matches = re.findall(r'STATUS\s*Fetch terminating', str(stderr))
    
    56 49
         assert len(matches) != 0, "Fetch failed to terminate"
    
    57 50
         assert len(matches) == 1, "Fetch attempted to terminate more than once"



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]