Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : master
---------------------------------------------------------------
commit b0063eb1bd0aabaaf2112bd8f9034c2f1f0ac64b
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Thu Jul 30 12:38:59 2015 +0200
[backend] fix BuildJob.results_dir; eliminated MockRemote.pkg_dest_path
---------------------------------------------------------------
backend/backend/daemons/dispatcher.py | 2 ++
backend/backend/job.py | 6 +++---
backend/backend/mockremote/__init__.py | 11 +++--------
backend/tests/mockremote/test_mockremote.py | 8 ++++----
4 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/backend/backend/daemons/dispatcher.py
b/backend/backend/daemons/dispatcher.py
index 58076c7..70953e8 100644
--- a/backend/backend/daemons/dispatcher.py
+++ b/backend/backend/daemons/dispatcher.py
@@ -342,6 +342,8 @@ class Worker(multiprocessing.Process):
def copy_mock_logs(self, job):
if not os.path.isdir(job.results_dir):
+ self.log.info("Job results dir doesn't exists, couldn't copy
main log; path: {}"
+ .format(job.results_dir))
return
log_names = [(job.chroot_log_name, "mockchain.log.gz"),
diff --git a/backend/backend/job.py b/backend/backend/job.py
index 3a62678..a30c468 100644
--- a/backend/backend/job.py
+++ b/backend/backend/job.py
@@ -87,7 +87,7 @@ class BuildJob(object):
@property
def results_dir(self):
- return os.path.join(self.chroot_dir, self.package_name)
+ return os.path.join(self.chroot_dir, self.target_dir_name)
@property
def target_dir_name(self):
@@ -153,5 +153,5 @@ class BuildJob(object):
return str(self.__unicode__())
def __unicode__(self):
- return u"BuildJob<id: {build_id}, owner: {project_owner}, " \
- u"project: {project_name}, git branch: {git_branch}, git_hash:
{git_hash} >".format(**self.__dict__)
+ return u"BuildJob<id: {build_id}, owner: {project_owner}, project:
{project_name}, " \
+ u"git branch: {git_branch}, git_hash: {git_hash}, status: {status}
>".format(**self.__dict__)
diff --git a/backend/backend/mockremote/__init__.py
b/backend/backend/mockremote/__init__.py
index 0b2e0a4..c96190d 100755
--- a/backend/backend/mockremote/__init__.py
+++ b/backend/backend/mockremote/__init__.py
@@ -172,11 +172,6 @@ class MockRemote(object):
def pkg(self):
return self.job.pkg
- @property
- def pkg_dest_path(self):
- return os.path.normpath("{}/{}/{}".format(
- self.job.destdir, self.job.chroot, self.job.target_dir_name))
-
def add_pubkey(self):
"""
Adds pubkey.gpg with public key to ``chroot_dir``
@@ -266,7 +261,7 @@ class MockRemote(object):
self.do_createrepo()
def prepare_build_dir(self):
- p_path = self.pkg_dest_path
+ p_path = self.job.results_dir
# if it's marked as fail, nuke the failure and try to rebuild it
if os.path.exists(os.path.join(p_path, "fail")):
os.unlink(os.path.join(p_path, "fail"))
@@ -316,7 +311,7 @@ class MockRemote(object):
raise MockRemoteError("Error occurred during build {}: {}"
.format(self.job, error))
finally:
- self.builder.download(self.pkg_dest_path)
+ self.builder.download(self.job.results_dir)
# self.add_log_symlinks() # todo: add config option, need this for nginx
self.log.info("End Build: {0}".format(self.job))
@@ -329,7 +324,7 @@ class MockRemote(object):
into the directory with downloaded files.
"""
- info_file_path = os.path.join(self.pkg_dest_path, "build.info")
+ info_file_path = os.path.join(self.job.results_dir, "build.info")
self.log.info("marking build dir with build_id, ")
try:
with open(info_file_path, 'w') as info_file:
diff --git a/backend/tests/mockremote/test_mockremote.py
b/backend/tests/mockremote/test_mockremote.py
index d1b17a8..d9986b8 100644
--- a/backend/tests/mockremote/test_mockremote.py
+++ b/backend/tests/mockremote/test_mockremote.py
@@ -176,7 +176,7 @@ class TestMockRemote(object):
assert self.mr.do_createrepo.called
def test_prepare_build_dir_erase_fail_file(self, f_mock_remote):
- target_dir = self.mr.pkg_dest_path
+ target_dir = self.mr.job.results_dir
os.makedirs(target_dir)
fail_path = os.path.join(target_dir, "fail")
with open(fail_path, "w") as handle:
@@ -187,7 +187,7 @@ class TestMockRemote(object):
assert os.path.exists(fail_path) is False
def test_prepare_build_dir_erase_success_file(self, f_mock_remote):
- target_dir = self.mr.pkg_dest_path
+ target_dir = self.mr.job.results_dir
os.makedirs(target_dir)
fail_path = os.path.join(target_dir, "success")
with open(fail_path, "w") as handle:
@@ -200,7 +200,7 @@ class TestMockRemote(object):
def test_prepare_build_dir_creates_dirs(self, f_mock_remote):
self.mr.prepare_build_dir()
- assert os.path.exists(self.mr.pkg_dest_path)
+ assert os.path.exists(self.mr.job.results_dir)
def test_build_pkg_and_process_results(self, f_mock_remote):
self.mr.on_success_build = MagicMock()
@@ -246,7 +246,7 @@ class TestMockRemote(object):
def test_mark_dir_with_build_id(self, f_mock_remote):
# TODO: create real test
- target_dir = self.mr.pkg_dest_path
+ target_dir = self.mr.job.results_dir
os.makedirs(target_dir)
info_file_path = os.path.join(target_dir, "build.info")