[Notes] [Git][BuildStream/buildstream][Qinusty/531-fetch-retries-on-terminate] Deleted 2 commits: tests: Add tests for interrupting a fetch operation



Title: GitLab

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

WARNING: The push did not contain any new commits, but force pushed to delete the commits and changes below.

Deleted commits:

7 changed files:

Changes:

  • .gitlab-ci.yml
    ... ... @@ -68,7 +68,7 @@ source_dist:
    68 68
     
    
    69 69
       # Run the tests from the source distribution, We run as a simple
    
    70 70
       # user to test for permission issues
    
    71
    -  - su buildstream -c 'python3 setup.py test --index-url invalid://uri --addopts --integration'
    
    71
    +  - su buildstream -c 'python3 setup.py test --index-url invalid://uri --addopts "--integration -s"'
    
    72 72
     
    
    73 73
       # Go back to the toplevel and collect our reports
    
    74 74
       - cd ../..
    

  • tests/frontend/delayedproj/__init__.py

  • tests/frontend/delayedproj/elements/delaymock.bst
    1
    +kind: import
    
    2
    +
    
    3
    +sources:
    
    4
    +  - kind: delayed
    \ No newline at end of file

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

  • tests/frontend/delayedproj/plugins/delayed.py
    1
    +import time
    
    2
    +from buildstream import Source, SourceError, Consistency
    
    3
    +
    
    4
    +
    
    5
    +class DelayedMockSource(Source):
    
    6
    +
    
    7
    +    def configure(self, node):
    
    8
    +        pass
    
    9
    +
    
    10
    +    def preflight(self):
    
    11
    +        pass
    
    12
    +
    
    13
    +    def get_unique_key(self):
    
    14
    +        return {}
    
    15
    +
    
    16
    +    def get_consistency(self):
    
    17
    +        return Consistency.RESOLVED
    
    18
    +
    
    19
    +    def get_ref(self):
    
    20
    +        return None
    
    21
    +
    
    22
    +    def set_ref(self, ref, node):
    
    23
    +        pass
    
    24
    +
    
    25
    +    def fetch(self):
    
    26
    +        LOOP_FOR = 40
    
    27
    +
    
    28
    +        def prog_percent(prog):
    
    29
    +            return "{}%".format((float(i) / float(LOOP_FOR)) * 100)
    
    30
    +
    
    31
    +        for i in range(LOOP_FOR):
    
    32
    +            time.sleep(0.5)
    
    33
    +            self.status("Mock Source progress {}".format(prog_percent(i)))
    
    34
    +
    
    35
    +    def stage(self, directory):
    
    36
    +        pass
    
    37
    +
    
    38
    +
    
    39
    +def setup():
    
    40
    +    return DelayedMockSource

  • tests/frontend/delayedproj/project.conf
    1
    +name: interruptions
    
    2
    +element-path: elements
    
    3
    +plugins:
    
    4
    +- origin: local
    
    5
    +  path: plugins
    
    6
    +  sources:
    
    7
    +    delayed: 0
    \ No newline at end of file

  • tests/frontend/interruptions.py
    1
    +import pytest
    
    2
    +import os
    
    3
    +import signal
    
    4
    +import re
    
    5
    +import time
    
    6
    +import multiprocessing as mp
    
    7
    +from multiprocessing import Process
    
    8
    +from multiprocessing.queues import Queue
    
    9
    +import subprocess
    
    10
    +
    
    11
    +from buildstream import _yaml
    
    12
    +from tests.testutils import cli
    
    13
    +
    
    14
    +
    
    15
    +DATA_DIR = os.path.join(
    
    16
    +    os.path.dirname(os.path.realpath(__file__)),
    
    17
    +    "delayedproj",
    
    18
    +)
    
    19
    +
    
    20
    +
    
    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
    
    25
    +
    
    26
    +
    
    27
    +@pytest.mark.datafiles(DATA_DIR)
    
    28
    +def test_interrupt_fetch(cli, datafiles):
    
    29
    +    path = os.path.join(datafiles.dirname, datafiles.basename)
    
    30
    +
    
    31
    +    proc = subprocess_bst(path, args=['--on-error', 'terminate',
    
    32
    +                                          'fetch', 'delaymock.bst'])
    
    33
    +    # Wait a few seconds, fetch should then be in progress. With DelayedMockSource
    
    34
    +    # fetch should take 20s unless terminated
    
    35
    +    time.sleep(3)
    
    36
    +    proc.send_signal(signal.SIGINT)
    
    37
    +
    
    38
    +    try:
    
    39
    +        stdout, stderr = proc.communicate(timeout=5)
    
    40
    +    except subprocess.TimeoutExpired:
    
    41
    +        assert False, "BuildStream failed to terminate on SIGINT."
    
    42
    +
    
    43
    +    print("stdout\n", stdout, "\n\nstderr\n", stderr)
    
    44
    +
    
    45
    +    matches = re.findall(r'FAILURE\s*Fetch', str(stderr))
    
    46
    +    success_matches = re.findall(r'SUCCESS\s*Fetch', str(stderr))
    
    47
    +    assert len(matches) or len(success_matches), "BuildStream exitted unexpectedly"
    
    48
    +    assert len(matches), "Unexpected success"
    
    49
    +
    
    50
    +    matches = re.findall(r'STATUS\s*Fetch terminating', str(stderr))
    
    51
    +    assert len(matches) != 0, "Fetch failed to terminate"
    
    52
    +    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]