[Notes] [Git][BuildStream/buildstream][Qinusty/skipped-rework] 4 commits: tests.py: Test skip on push



Title: GitLab

Qinusty pushed to branch Qinusty/skipped-rework at BuildStream / buildstream

Commits:

4 changed files:

Changes:

  • buildstream/_artifactcache/cascache.py
    ... ... @@ -228,7 +228,7 @@ class CASCache(ArtifactCache):
    228 228
                 try:
    
    229 229
                     remote.init()
    
    230 230
     
    
    231
    -                element.info("Pulling {} <- {}".format(element._get_brief_display_key(), remote.spec.url))
    
    231
    +                element.status("Pulling {} <- {}".format(element._get_brief_display_key(), remote.spec.url))
    
    232 232
     
    
    233 233
                     request = buildstream_pb2.GetReferenceRequest()
    
    234 234
                     request.key = ref
    
    ... ... @@ -250,11 +250,8 @@ class CASCache(ArtifactCache):
    250 250
                         raise ArtifactError("Failed to pull artifact {}: {}".format(
    
    251 251
                             element._get_brief_display_key(), e)) from e
    
    252 252
                     else:
    
    253
    -                    self.context.message(Message(
    
    254
    -                        None,
    
    255
    -                        MessageType.INFO,
    
    256
    -                        "Remote ({}) does not have {} cached".format(
    
    257
    -                            remote.spec.url, element._get_brief_display_key())
    
    253
    +                    element.info("Remote ({}) does not have {} cached".format(
    
    254
    +                        remote.spec.url, element._get_brief_display_key()
    
    258 255
                         ))
    
    259 256
     
    
    260 257
             return False
    
    ... ... @@ -279,7 +276,7 @@ class CASCache(ArtifactCache):
    279 276
             for remote in push_remotes:
    
    280 277
                 remote.init()
    
    281 278
                 skipped_remote = True
    
    282
    -            element.info("Pushing {} -> {}".format(element._get_brief_display_key(), remote.spec.url))
    
    279
    +            element.status("Pushing {} -> {}".format(element._get_brief_display_key(), remote.spec.url))
    
    283 280
     
    
    284 281
                 try:
    
    285 282
                     for ref in refs:
    
    ... ... @@ -361,11 +358,8 @@ class CASCache(ArtifactCache):
    361 358
                         raise ArtifactError("Failed to push artifact {}: {}".format(refs, e), temporary=True) from e
    
    362 359
     
    
    363 360
                 if skipped_remote:
    
    364
    -                self.context.message(Message(
    
    365
    -                    None,
    
    366
    -                    MessageType.INFO,
    
    367
    -                    "Remote ({}) already has {} cached".format(
    
    368
    -                        remote.spec.url, element._get_brief_display_key())
    
    361
    +                element.info("Remote ({}) already has {} cached".format(
    
    362
    +                    remote.spec.url, element._get_brief_display_key()
    
    369 363
                     ))
    
    370 364
             return pushed
    
    371 365
     
    

  • buildstream/element.py
    ... ... @@ -1746,7 +1746,7 @@ class Element(Plugin):
    1746 1746
     
    
    1747 1747
             # Notify successfull download
    
    1748 1748
             display_key = self._get_brief_display_key()
    
    1749
    -        self.info("Downloaded artifact {}".format(display_key))
    
    1749
    +        self.info("Pulled artifact {}".format(display_key))
    
    1750 1750
             return True
    
    1751 1751
     
    
    1752 1752
         # _skip_push():
    
    ... ... @@ -1785,16 +1785,15 @@ class Element(Plugin):
    1785 1785
                 self.warn("Not pushing tainted artifact.")
    
    1786 1786
                 return False
    
    1787 1787
     
    
    1788
    -        display_key = self._get_brief_display_key()
    
    1789
    -        with self.timed_activity("Pushing artifact {}".format(display_key)):
    
    1790
    -            # Push all keys used for local commit
    
    1791
    -            pushed = self.__artifacts.push(self, self.__get_cache_keys_for_commit())
    
    1792
    -            if not pushed:
    
    1793
    -                return False
    
    1788
    +        # Push all keys used for local commit
    
    1789
    +        pushed = self.__artifacts.push(self, self.__get_cache_keys_for_commit())
    
    1790
    +        if not pushed:
    
    1791
    +            return False
    
    1794 1792
     
    
    1795
    -            # Notify successful upload
    
    1796
    -            self.info("Pushed artifact {}".format(display_key))
    
    1797
    -            return True
    
    1793
    +        # Notify successful upload
    
    1794
    +        display_key = self._get_brief_display_key()
    
    1795
    +        self.info("Pushed artifact {}".format(display_key))
    
    1796
    +        return True
    
    1798 1797
     
    
    1799 1798
         # _shell():
    
    1800 1799
         #
    

  • tests/frontend/push.py
    ... ... @@ -386,3 +386,26 @@ def test_push_cross_junction(cli, tmpdir, datafiles):
    386 386
     
    
    387 387
             cache_key = cli.get_element_key(project, 'junction.bst:import-etc.bst')
    
    388 388
             assert share.has_artifact('subtest', 'import-etc.bst', cache_key)
    
    389
    +
    
    390
    +
    
    391
    +@pytest.mark.datafiles(DATA_DIR)
    
    392
    +def test_push_already_cached(caplog, cli, tmpdir, datafiles):
    
    393
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    394
    +    caplog.set_level(1)
    
    395
    +
    
    396
    +    with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share:
    
    397
    +
    
    398
    +        cli.configure({
    
    399
    +            'artifacts': {'url': share.repo, 'push': True}
    
    400
    +        })
    
    401
    +        result = cli.run(project=project, args=['build', 'target.bst'])
    
    402
    +
    
    403
    +        result.assert_success()
    
    404
    +        assert "SKIPPED Push" not in result.stderr
    
    405
    +
    
    406
    +        result = cli.run(project=project, args=['push', 'target.bst'])
    
    407
    +
    
    408
    +        result.assert_success()
    
    409
    +        assert not result.get_pushed_elements(), "No elements should have been pushed since the cache was populated"
    
    410
    +        assert "INFO    Remote ({}) already has ".format(share.repo) in result.stderr
    
    411
    +        assert "SKIPPED Push" in result.stderr

  • tests/testutils/runcli.py
    ... ... @@ -178,7 +178,7 @@ class Result():
    178 178
             return list(pushed)
    
    179 179
     
    
    180 180
         def get_pulled_elements(self):
    
    181
    -        pulled = re.findall(r'\[\s*pull:(\S+)\s*\]\s*INFO\s*Downloaded artifact', self.stderr)
    
    181
    +        pulled = re.findall(r'\[\s*pull:(\S+)\s*\]\s*INFO\s*Pulled artifact', self.stderr)
    
    182 182
             if pulled is None:
    
    183 183
                 return []
    
    184 184
     
    



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