Functional test for the CoprReleaser.

This commit is contained in:
Devan Goodwin 2014-03-10 16:33:59 -03:00
parent 9673394342
commit 9091afd684
6 changed files with 91 additions and 8 deletions

View file

@ -1,3 +1,8 @@
[globalconfig]
default_builder = tito.builder.Builder
default_tagger = tito.tagger.VersionTagger
lib_dir = rel-eng/custom/
[buildconfig]
builder = tito.builder.Builder
tagger = tito.tagger.VersionTagger

View file

@ -222,6 +222,16 @@ def run_command(command, print_on_success=False):
return output
def runProcess(cmd):
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while(True):
retcode = p.poll() #returns None while subprocess is running
line = p.stdout.readline()
yield line
if(retcode is not None):
break
def tag_exists_locally(tag):
(status, output) = getstatusoutput("git tag | grep %s" % tag)
if status > 0:
@ -233,7 +243,7 @@ def tag_exists_locally(tag):
def tag_exists_remotely(tag):
""" Returns True if the tag exists in the remote git repo. """
try:
repo_url = get_git_repo_url()
get_git_repo_url()
except:
sys.stderr.write('Warning: remote.origin do not exist. Assuming --offline, for remote tag checking.\n')
return False

View file

@ -25,11 +25,11 @@ class CoprReleaser(KojiReleaser):
cli_tool = "copr-cli"
NAME = "Copr"
def __init__(self, name=None, version=None, tag=None, build_dir=None,
def __init__(self, name=None, tag=None, build_dir=None,
config=None, user_config=None,
target=None, releaser_config=None, no_cleanup=False,
test=False, auto_accept=False, **kwargs):
KojiReleaser.__init__(self, name, version, tag, build_dir, config,
KojiReleaser.__init__(self, name, tag, build_dir, config,
user_config, target, releaser_config, no_cleanup, test,
auto_accept, **kwargs)
@ -50,7 +50,7 @@ class CoprReleaser(KojiReleaser):
def _submit_build(self, executable, koji_opts, tag, srpm_location):
""" Copy srpm to remote destination and submit it to Copr """
cmd = self.releaser_config.get(self.target, "upload_command", raw=True)
cmd = self.releaser_config.get(self.target, "upload_command")
url = self.releaser_config.get(self.target, "remote_location")
if self.srpm_submitted:
srpm_location = self.srpm_submitted
@ -65,6 +65,7 @@ class CoprReleaser(KojiReleaser):
self.print_dry_run_warning(cmd_upload)
self.print_dry_run_warning(cmd_submit)
return
# TODO: no error handling when run_command fails:
if not self.srpm_submitted:
print("Uploading src.rpm.")
print(run_command(cmd_upload))

View file

@ -70,8 +70,11 @@ class Releaser(ConfigObject):
config_builder_args['test'] = True # builder must know to build from HEAD
# Override with builder args from command line if any were given:
self.builder_args = dict(config_builder_args.items() +
kwargs['builder_args'].items())
if 'builder_args' in kwargs:
self.builder_args = dict(config_builder_args.items() +
kwargs['builder_args'].items())
else:
self.builder_args = config_builder_args
# While we create a builder here, we don't actually call run on it
# unless the releaser needs to:
@ -761,7 +764,8 @@ class KojiReleaser(Releaser):
target=None, releaser_config=None, no_cleanup=False,
test=False, auto_accept=False, **kwargs):
Releaser.__init__(self, name, tag, build_dir, config,
user_config, target, releaser_config, no_cleanup, test, auto_accept)
user_config, target, releaser_config, no_cleanup, test, auto_accept,
**kwargs)
self.only_tags = []
if 'ONLY_TAGS' in os.environ:

View file

@ -0,0 +1,63 @@
#
# Copyright (c) 2008-2014 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public License,
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
#
# Red Hat trademarks are not licensed under GPLv2. No permission is
# granted to use or replicate Red Hat trademarks that are incorporated
# in this software or its documentation.
"""
Functional Tests for the CoprReleaser.
"""
from functional.fixture import TitoGitTestFixture
from tito.compat import *
from tito.release import CoprReleaser
PKG_NAME = "releaseme"
RELEASER_CONF = """
[test]
releaser = tito.release.CoprReleaser
builder = tito.builder.Builder
"""
class CoprReleaserTests(TitoGitTestFixture):
def setUp(self):
TitoGitTestFixture.setUp(self)
self.create_project(PKG_NAME)
# Setup test config:
self.config = RawConfigParser()
self.config.add_section("buildconfig")
self.config.set("buildconfig", "builder",
"tito.builder.Builder")
self.config.set("buildconfig", "offline",
"true")
self.releaser_config = RawConfigParser()
self.releaser_config.add_section('test')
self.releaser_config.set('test', 'releaser',
'tito.release.CoprReleaser')
self.releaser_config.set('test', 'builder',
'tito.builder.Builder')
self.releaser_config.set('test', 'project_name', PKG_NAME)
self.releaser_config.set('test', 'upload_command',
'scp %(srpm)s example.com/public_html/my_srpm/')
self.releaser_config.set('test', 'remote_location',
'http://example.com/~someuser/my_srpm/')
def test_with_releaser(self):
releaser = CoprReleaser(PKG_NAME, None, '/tmp/tito/',
self.config, {}, 'test', self.releaser_config, False,
False, False, **{'offline': True})
releaser.release(dry_run=True)
self.assertTrue(releaser.srpm_submitted is not None)

View file

@ -12,7 +12,7 @@
# granted to use or replicate Red Hat trademarks that are incorporated
# in this software or its documentation.
"""
Functional Tests for the FetchBuilder.
Functional Tests for the YumReleaser.
"""
import glob