[Notes] [Git][BuildStream/buildstream][tristan/fix-pullbuildtrees-test] tests/integration/pullbuildtrees.py: Fix the non-integration case.



Title: GitLab

Tristan Van Berkom pushed to branch tristan/fix-pullbuildtrees-test at BuildStream / buildstream

Commits:

1 changed file:

Changes:

  • tests/integration/pullbuildtrees.py
    ... ... @@ -2,7 +2,7 @@ import os
    2 2
     import shutil
    
    3 3
     import pytest
    
    4 4
     
    
    5
    -from tests.testutils import cli_integration as cli, create_artifact_share
    
    5
    +from tests.testutils import cli, cli_integration as cli2, create_artifact_share
    
    6 6
     from tests.testutils.integration import assert_contains
    
    7 7
     from tests.testutils.site import HAVE_BWRAP, IS_LINUX
    
    8 8
     from buildstream._exceptions import ErrorDomain, LoadErrorReason
    
    ... ... @@ -32,7 +32,7 @@ def default_state(cli, tmpdir, share):
    32 32
     @pytest.mark.integration
    
    33 33
     @pytest.mark.datafiles(DATA_DIR)
    
    34 34
     @pytest.mark.skipif(IS_LINUX and not HAVE_BWRAP, reason='Only available with bubblewrap on Linux')
    
    35
    -def test_pullbuildtrees(cli, tmpdir, datafiles):
    
    35
    +def test_pullbuildtrees(cli2, tmpdir, datafiles):
    
    36 36
         project = os.path.join(datafiles.dirname, datafiles.basename)
    
    37 37
         element_name = 'autotools/amhello.bst'
    
    38 38
     
    
    ... ... @@ -40,115 +40,115 @@ def test_pullbuildtrees(cli, tmpdir, datafiles):
    40 40
         with create_artifact_share(os.path.join(str(tmpdir), 'share1')) as share1,\
    
    41 41
             create_artifact_share(os.path.join(str(tmpdir), 'share2')) as share2,\
    
    42 42
             create_artifact_share(os.path.join(str(tmpdir), 'share3')) as share3:
    
    43
    -        cli.configure({
    
    43
    +        cli2.configure({
    
    44 44
                 'artifacts': {'url': share1.repo, 'push': True},
    
    45 45
                 'artifactdir': os.path.join(str(tmpdir), 'artifacts')
    
    46 46
             })
    
    47 47
     
    
    48 48
             # Build autotools element, checked pushed, delete local
    
    49
    -        result = cli.run(project=project, args=['build', element_name])
    
    49
    +        result = cli2.run(project=project, args=['build', element_name])
    
    50 50
             assert result.exit_code == 0
    
    51
    -        assert cli.get_element_state(project, element_name) == 'cached'
    
    52
    -        assert share1.has_artifact('test', element_name, cli.get_element_key(project, element_name))
    
    53
    -        default_state(cli, tmpdir, share1)
    
    51
    +        assert cli2.get_element_state(project, element_name) == 'cached'
    
    52
    +        assert share1.has_artifact('test', element_name, cli2.get_element_key(project, element_name))
    
    53
    +        default_state(cli2, tmpdir, share1)
    
    54 54
     
    
    55 55
             # Pull artifact with default config, assert that pulling again
    
    56 56
             # doesn't create a pull job, then assert with buildtrees user
    
    57 57
             # config set creates a pull job.
    
    58
    -        result = cli.run(project=project, args=['artifact', 'pull', element_name])
    
    58
    +        result = cli2.run(project=project, args=['artifact', 'pull', element_name])
    
    59 59
             assert element_name in result.get_pulled_elements()
    
    60
    -        result = cli.run(project=project, args=['artifact', 'pull', element_name])
    
    60
    +        result = cli2.run(project=project, args=['artifact', 'pull', element_name])
    
    61 61
             assert element_name not in result.get_pulled_elements()
    
    62
    -        cli.configure({'cache': {'pull-buildtrees': True}})
    
    63
    -        result = cli.run(project=project, args=['artifact', 'pull', element_name])
    
    62
    +        cli2.configure({'cache': {'pull-buildtrees': True}})
    
    63
    +        result = cli2.run(project=project, args=['artifact', 'pull', element_name])
    
    64 64
             assert element_name in result.get_pulled_elements()
    
    65
    -        default_state(cli, tmpdir, share1)
    
    65
    +        default_state(cli2, tmpdir, share1)
    
    66 66
     
    
    67 67
             # Pull artifact with default config, then assert that pulling
    
    68 68
             # with buildtrees cli flag set creates a pull job.
    
    69 69
             # Also assert that the buildtree is added to the artifact's
    
    70 70
             # extract dir
    
    71
    -        result = cli.run(project=project, args=['artifact', 'pull', element_name])
    
    71
    +        result = cli2.run(project=project, args=['artifact', 'pull', element_name])
    
    72 72
             assert element_name in result.get_pulled_elements()
    
    73
    -        elementdigest = share1.has_artifact('test', element_name, cli.get_element_key(project, element_name))
    
    73
    +        elementdigest = share1.has_artifact('test', element_name, cli2.get_element_key(project, element_name))
    
    74 74
             buildtreedir = os.path.join(str(tmpdir), 'artifacts', 'extract', 'test', 'autotools-amhello',
    
    75 75
                                         elementdigest.hash, 'buildtree')
    
    76 76
             assert not os.path.isdir(buildtreedir)
    
    77
    -        result = cli.run(project=project, args=['--pull-buildtrees', 'artifact', 'pull', element_name])
    
    77
    +        result = cli2.run(project=project, args=['--pull-buildtrees', 'artifact', 'pull', element_name])
    
    78 78
             assert element_name in result.get_pulled_elements()
    
    79 79
             assert os.path.isdir(buildtreedir)
    
    80
    -        default_state(cli, tmpdir, share1)
    
    80
    +        default_state(cli2, tmpdir, share1)
    
    81 81
     
    
    82 82
             # Pull artifact with pullbuildtrees set in user config, then assert
    
    83 83
             # that pulling with the same user config doesn't creates a pull job,
    
    84 84
             # or when buildtrees cli flag is set.
    
    85
    -        cli.configure({'cache': {'pull-buildtrees': True}})
    
    86
    -        result = cli.run(project=project, args=['artifact', 'pull', element_name])
    
    85
    +        cli2.configure({'cache': {'pull-buildtrees': True}})
    
    86
    +        result = cli2.run(project=project, args=['artifact', 'pull', element_name])
    
    87 87
             assert element_name in result.get_pulled_elements()
    
    88
    -        result = cli.run(project=project, args=['artifact', 'pull', element_name])
    
    88
    +        result = cli2.run(project=project, args=['artifact', 'pull', element_name])
    
    89 89
             assert element_name not in result.get_pulled_elements()
    
    90
    -        result = cli.run(project=project, args=['--pull-buildtrees', 'artifact', 'pull', element_name])
    
    90
    +        result = cli2.run(project=project, args=['--pull-buildtrees', 'artifact', 'pull', element_name])
    
    91 91
             assert element_name not in result.get_pulled_elements()
    
    92
    -        default_state(cli, tmpdir, share1)
    
    92
    +        default_state(cli2, tmpdir, share1)
    
    93 93
     
    
    94 94
             # Pull artifact with default config and buildtrees cli flag set, then assert
    
    95 95
             # that pulling with pullbuildtrees set in user config doesn't create a pull
    
    96 96
             # job.
    
    97
    -        result = cli.run(project=project, args=['--pull-buildtrees', 'artifact', 'pull', element_name])
    
    97
    +        result = cli2.run(project=project, args=['--pull-buildtrees', 'artifact', 'pull', element_name])
    
    98 98
             assert element_name in result.get_pulled_elements()
    
    99
    -        cli.configure({'cache': {'pull-buildtrees': True}})
    
    100
    -        result = cli.run(project=project, args=['artifact', 'pull', element_name])
    
    99
    +        cli2.configure({'cache': {'pull-buildtrees': True}})
    
    100
    +        result = cli2.run(project=project, args=['artifact', 'pull', element_name])
    
    101 101
             assert element_name not in result.get_pulled_elements()
    
    102
    -        default_state(cli, tmpdir, share1)
    
    102
    +        default_state(cli2, tmpdir, share1)
    
    103 103
     
    
    104 104
             # Assert that a partial build element (not containing a populated buildtree dir)
    
    105 105
             # can't be pushed to an artifact share, then assert that a complete build element
    
    106 106
             # can be. This will attempt a partial pull from share1 and then a partial push
    
    107 107
             # to share2
    
    108
    -        result = cli.run(project=project, args=['artifact', 'pull', element_name])
    
    108
    +        result = cli2.run(project=project, args=['artifact', 'pull', element_name])
    
    109 109
             assert element_name in result.get_pulled_elements()
    
    110
    -        cli.configure({'artifacts': {'url': share2.repo, 'push': True}})
    
    111
    -        result = cli.run(project=project, args=['artifact', 'push', element_name])
    
    110
    +        cli2.configure({'artifacts': {'url': share2.repo, 'push': True}})
    
    111
    +        result = cli2.run(project=project, args=['artifact', 'push', element_name])
    
    112 112
             assert element_name not in result.get_pushed_elements()
    
    113
    -        assert not share2.has_artifact('test', element_name, cli.get_element_key(project, element_name))
    
    113
    +        assert not share2.has_artifact('test', element_name, cli2.get_element_key(project, element_name))
    
    114 114
     
    
    115 115
             # Assert that after pulling the missing buildtree the element artifact can be
    
    116 116
             # successfully pushed to the remote. This will attempt to pull the buildtree
    
    117 117
             # from share1 and then a 'complete' push to share2
    
    118
    -        cli.configure({'artifacts': {'url': share1.repo, 'push': False}})
    
    119
    -        result = cli.run(project=project, args=['--pull-buildtrees', 'artifact', 'pull', element_name])
    
    118
    +        cli2.configure({'artifacts': {'url': share1.repo, 'push': False}})
    
    119
    +        result = cli2.run(project=project, args=['--pull-buildtrees', 'artifact', 'pull', element_name])
    
    120 120
             assert element_name in result.get_pulled_elements()
    
    121
    -        cli.configure({'artifacts': {'url': share2.repo, 'push': True}})
    
    122
    -        result = cli.run(project=project, args=['artifact', 'push', element_name])
    
    121
    +        cli2.configure({'artifacts': {'url': share2.repo, 'push': True}})
    
    122
    +        result = cli2.run(project=project, args=['artifact', 'push', element_name])
    
    123 123
             assert element_name in result.get_pushed_elements()
    
    124
    -        assert share2.has_artifact('test', element_name, cli.get_element_key(project, element_name))
    
    125
    -        default_state(cli, tmpdir, share1)
    
    124
    +        assert share2.has_artifact('test', element_name, cli2.get_element_key(project, element_name))
    
    125
    +        default_state(cli2, tmpdir, share1)
    
    126 126
     
    
    127 127
             # Assert that bst push will automatically attempt to pull a missing buildtree
    
    128 128
             # if pull-buildtrees is set, however as share3 is the only defined remote and is empty,
    
    129 129
             # assert that no element artifact buildtrees are pulled (no available remote buildtree) and thus the
    
    130 130
             # artifact cannot be pushed.
    
    131
    -        result = cli.run(project=project, args=['artifact', 'pull', element_name])
    
    131
    +        result = cli2.run(project=project, args=['artifact', 'pull', element_name])
    
    132 132
             assert element_name in result.get_pulled_elements()
    
    133
    -        cli.configure({'artifacts': {'url': share3.repo, 'push': True}})
    
    134
    -        result = cli.run(project=project, args=['--pull-buildtrees', 'artifact', 'push', element_name])
    
    133
    +        cli2.configure({'artifacts': {'url': share3.repo, 'push': True}})
    
    134
    +        result = cli2.run(project=project, args=['--pull-buildtrees', 'artifact', 'push', element_name])
    
    135 135
             assert "Attempting to fetch missing artifact buildtrees" in result.stderr
    
    136 136
             assert element_name not in result.get_pulled_elements()
    
    137 137
             assert not os.path.isdir(buildtreedir)
    
    138 138
             assert element_name not in result.get_pushed_elements()
    
    139
    -        assert not share3.has_artifact('test', element_name, cli.get_element_key(project, element_name))
    
    139
    +        assert not share3.has_artifact('test', element_name, cli2.get_element_key(project, element_name))
    
    140 140
     
    
    141 141
             # Assert that if we add an extra remote that has the buildtree artfact cached, bst push will
    
    142 142
             # automatically attempt to pull it and will be successful, leading to the full artifact being pushed
    
    143 143
             # to the empty share3. This gives the ability to attempt push currently partial artifacts to a remote,
    
    144 144
             # without exlipictly requiring a bst pull.
    
    145
    -        cli.configure({'artifacts': [{'url': share1.repo, 'push': False}, {'url': share3.repo, 'push': True}]})
    
    146
    -        result = cli.run(project=project, args=['--pull-buildtrees', 'artifact', 'push', element_name])
    
    145
    +        cli2.configure({'artifacts': [{'url': share1.repo, 'push': False}, {'url': share3.repo, 'push': True}]})
    
    146
    +        result = cli2.run(project=project, args=['--pull-buildtrees', 'artifact', 'push', element_name])
    
    147 147
             assert "Attempting to fetch missing artifact buildtrees" in result.stderr
    
    148 148
             assert element_name in result.get_pulled_elements()
    
    149 149
             assert os.path.isdir(buildtreedir)
    
    150 150
             assert element_name in result.get_pushed_elements()
    
    151
    -        assert share3.has_artifact('test', element_name, cli.get_element_key(project, element_name))
    
    151
    +        assert share3.has_artifact('test', element_name, cli2.get_element_key(project, element_name))
    
    152 152
     
    
    153 153
     
    
    154 154
     # Ensure that only valid pull-buildtrees boolean options make it through the loading
    



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