Example #1
0
 def test_cant_post(self):
     self.mock_post.return_value = mock.MagicMock(status_code=404, text='')
     with self.assertRaises(Exception):
         utils.post_to_url(self.post_spec, None)
     assert self.mock_private_log.info.call_args_list == [
         mock.call("post error", code=404, text=''),
     ] * 5
Example #2
0
    def post_readme(self):
        '''Post the README file in the source repository to the configured url

        Uploads the contents of a found README file to the configured signed url so it
        can be retrieved by clients at a later time.
        '''
        if self.readme_path:
            utils.post_to_url(self.signed_urls['post']['readme'],
                              os.path.abspath(self.readme_path),
                              self.push_attempt_count)
Example #3
0
    def post_dockerfile(self):
        '''Post the target Dockerfile to the configured url

        Uploads the Dockerfile contents to the configured signed url so it can be
        retrieved by clients at a later time.

        '''
        private_log.info("Getting Dockerfile")
        file_path = os.path.join(self.build_path, self.dockerfile_path)
        utils.post_to_url(self.signed_urls['post']['dockerfile'],
                          os.path.abspath(file_path), self.push_attempt_count)
Example #4
0
    def run(self):
        '''Execute the full build process

        This method provides a logging carriage to ensure that any results of the build
        process are properly logged and uploaded.
        '''
        exit_code = 0
        try:
            exit_code = self._run()
        except Exception:
            private_log.exception("TOP-LEVEL EXCEPTION")
        finally:
            utils.post_to_url(self.signed_urls['post']['logs'], '/public.log')
            utils.post_to_url(self.signed_urls['post']['debug'],
                              '/private.log')
            utils.post_to_url(self.signed_urls['post']['metrics'],
                              '/metrics.log')
        return exit_code
Example #5
0
def interrupt(log_spec, signum, frame):
    public_log.info('Build canceled.')
    utils.post_to_url(log_spec, '/public.log')
    utils.post_to_url(log_spec, '/private.log')
    exit(3)
Example #6
0
 def test_returns_true(self):
     self.mock_post.return_value = mock.MagicMock(status_code=204)
     assert utils.post_to_url(self.post_spec, None)
Example #7
0
 def test_no_spec(self):
     assert utils.post_to_url(None, None) is None