[copr] master: [backend] .spec: added dependency on `python-copr` (8a555a7)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 8a555a730fe84b0057ab833bb8d68f9f3f3bbd22
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Fri Oct 24 14:38:37 2014 +0200
[backend] .spec: added dependency on `python-copr`
>---------------------------------------------------------------
backend/copr-backend.spec | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/backend/copr-backend.spec b/backend/copr-backend.spec
index 7885430..c718176 100644
--- a/backend/copr-backend.spec
+++ b/backend/copr-backend.spec
@@ -23,6 +23,7 @@ BuildRequires: util-linux
BuildRequires: python-setuptools
BuildRequires: python-requests
BuildRequires: python2-devel
+BuildRequires: python-copr
BuildRequires: systemd
%if 0%{?rhel} < 7 && 0%{?rhel} > 0
BuildRequires: python-argparse
@@ -46,6 +47,7 @@ Requires: python-lockfile
Requires: python-requests
Requires: python-setproctitle
Requires: python-retask
+Requires: python-copr
Requires: redis
Requires: logrotate
Requires: fedmsg
9 years, 6 months
[copr] master: [backend] stupid bug with Lock object and context manager (0f33256)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 0f3325606d1f48de2b456c355e08c5bdad1f59b8
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Fri Oct 24 12:01:05 2014 +0200
[backend] stupid bug with Lock object and context manager
>---------------------------------------------------------------
backend/backend/createrepo.py | 2 +-
backend/tests/test_action.py | 4 ----
backend/tests/test_createrepo.py | 4 ++--
3 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/backend/backend/createrepo.py b/backend/backend/createrepo.py
index 5d73436..6673be4 100644
--- a/backend/backend/createrepo.py
+++ b/backend/backend/createrepo.py
@@ -44,7 +44,7 @@ def createrepo_unsafe(path, lock=None, dest_dir=None, base_url=None):
comm.append(path)
if lock:
- with lock.acquire():
+ with lock:
cmd = Popen(comm, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = cmd.communicate()
else:
diff --git a/backend/tests/test_action.py b/backend/tests/test_action.py
index 05b3429..e618676 100644
--- a/backend/tests/test_action.py
+++ b/backend/tests/test_action.py
@@ -387,7 +387,6 @@ class TestAction(object):
"Running createrepo",
"Package bar dir not found in chroot fedora20",
"Running createrepo",
-
])
ev = self.test_q.get_nowait()
@@ -405,8 +404,6 @@ class TestAction(object):
assert_what_from_queue(self.test_q, msg_list=["In chroot epel7"])
assert_epel7()
-
-
with pytest.raises(EmptyQueue):
self.test_q.get_nowait()
@@ -456,7 +453,6 @@ class TestAction(object):
assert error_event_recorded
-
def assert_what_from_queue(q, msg_list, who="action"):
for msg in msg_list:
ev = q.get_nowait()
diff --git a/backend/tests/test_createrepo.py b/backend/tests/test_createrepo.py
index bd6db31..088c5c8 100644
--- a/backend/tests/test_createrepo.py
+++ b/backend/tests/test_createrepo.py
@@ -90,8 +90,8 @@ class TestCreaterepoUnsafe(object):
self.shared_state["lock_status"] = copy.copy(self.shared_state["in_lock"])
return mock.DEFAULT
- mocked_lock.acquire.return_value.__enter__.side_effect = enter_lock
- mocked_lock.acquire.return_value.__exit__.side_effect = exit_lock
+ mocked_lock.__enter__.side_effect = enter_lock
+ mocked_lock.__exit__.side_effect = exit_lock
mc_popen.side_effect = popen_side_effect
mc_popen.return_value.communicate.return_value = ("", "")
9 years, 6 months
[copr] master: [backend] createrepo: provides correct path for `dest_dir` option (08d1c11)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 08d1c1159ebbe2d1ac35f3df5ebdbc5e65966eed
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Thu Oct 23 23:25:13 2014 +0200
[backend] createrepo: provides correct path for `dest_dir` option
>---------------------------------------------------------------
backend/backend/createrepo.py | 2 +-
backend/tests/test_createrepo.py | 41 +++++++++++++++++++------------------
2 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/backend/backend/createrepo.py b/backend/backend/createrepo.py
index fc6f5c7..5d73436 100644
--- a/backend/backend/createrepo.py
+++ b/backend/backend/createrepo.py
@@ -33,8 +33,8 @@ def createrepo_unsafe(path, lock=None, dest_dir=None, base_url=None):
comm.extend(['-s', 'sha', '--checksum', 'md5'])
if dest_dir:
- comm.extend(['--outputdir', dest_dir])
dest_dir_path = os.path.join(path, dest_dir)
+ comm.extend(['--outputdir', dest_dir_path])
if not os.path.exists(dest_dir_path):
os.makedirs(dest_dir_path)
diff --git a/backend/tests/test_createrepo.py b/backend/tests/test_createrepo.py
index ea6b2b4..bd6db31 100644
--- a/backend/tests/test_createrepo.py
+++ b/backend/tests/test_createrepo.py
@@ -128,10 +128,12 @@ class TestCreaterepoUnsafe(object):
path_epel_5 = os.path.join(self.tmp_dir_name, "epel-5")
expected_epel_5 = ['/usr/bin/createrepo_c', '--database', '--ignore-lock',
'-s', 'sha', '--checksum', 'md5',
- '--outputdir', 'devel', '--baseurl', '../', path_epel_5]
+ '--outputdir', os.path.join(path_epel_5, "devel"),
+ '--baseurl', '../', path_epel_5]
path_fedora = os.path.join(self.tmp_dir_name, "fedora-21")
expected_fedora = ['/usr/bin/createrepo_c', '--database', '--ignore-lock',
- '--outputdir', 'devel', '--baseurl', '../', path_fedora]
+ '--outputdir', os.path.join(path_fedora, "devel"),
+ '--baseurl', '../', path_fedora]
for path, expected in [(path_epel_5, expected_epel_5), (path_fedora, expected_fedora)]:
os.makedirs(path)
@@ -149,28 +151,27 @@ class TestCreaterepoUnsafe(object):
path_epel_5 = os.path.join(self.tmp_dir_name, "epel-5")
expected_epel_5 = ['/usr/bin/createrepo_c', '--database', '--ignore-lock',
'-s', 'sha', '--checksum', 'md5',
- '--outputdir', 'devel', '--baseurl', '../', path_epel_5]
+ '--outputdir', os.path.join(path_epel_5, "devel"),
+ '--baseurl', '../', path_epel_5]
path_fedora = os.path.join(self.tmp_dir_name, "fedora-21")
expected_fedora = ['/usr/bin/createrepo_c', '--database', '--ignore-lock',
- '--outputdir', 'devel', '--baseurl', '../', path_fedora]
- for path, expected in [(path_epel_5, expected_epel_5), (path_fedora, expected_fedora)]:
- os.makedirs(path)
-
- createrepo_unsafe(path, lock=None, base_url="../", dest_dir="devel")
- assert mc_popen.call_args == mock.call(expected, stderr=-1, stdout=-1)
-
- def test_createrepo_devel_creates_folder(self, mc_popen):
-
- mc_popen.return_value.communicate.return_value = ("", "")
- path_epel_5 = os.path.join(self.tmp_dir_name, "epel-5")
- expected_epel_5 = ['/usr/bin/createrepo_c', '--database', '--ignore-lock',
- '-s', 'sha', '--checksum', 'md5',
- '--outputdir', 'devel', '--baseurl', '../', path_epel_5]
- path_fedora = os.path.join(self.tmp_dir_name, "fedora-21")
- expected_fedora = ['/usr/bin/createrepo_c', '--database', '--ignore-lock',
- '--outputdir', 'devel', '--baseurl', '../', path_fedora]
+ '--outputdir', os.path.join(path_fedora, "devel"),
+ '--baseurl', '../', path_fedora]
for path, expected in [(path_epel_5, expected_epel_5), (path_fedora, expected_fedora)]:
os.makedirs(path)
createrepo_unsafe(path, lock=None, base_url="../", dest_dir="devel")
assert os.path.exists(os.path.join(path, "devel"))
+ assert mc_popen.call_args == mock.call(expected, stderr=-1, stdout=-1)
+ #
+ # def test_createrepo_devel_creates_folder(self, mc_popen):
+ #
+ # mc_popen.return_value.communicate.return_value = ("", "")
+ # path_epel_5 = os.path.join(self.tmp_dir_name, "epel-5")
+ # path_fedora = os.path.join(self.tmp_dir_name, "fedora-21")
+ #
+ # for path in [path_epel_5, path_fedora]:
+ # os.makedirs(path)
+ #
+ # createrepo_unsafe(path, lock=None, base_url="../", dest_dir="devel")
+ # assert os.path.exists(os.path.join(path, "devel"))
9 years, 6 months
[copr] master: [backend] added to mockchroot -a /devel/repodata subfolder (2ff2186)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 2ff2186e1c5b849d1bfd80c386f2e9c2b733bbfb
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Thu Oct 23 23:40:07 2014 +0200
[backend] added to mockchroot -a /devel/repodata subfolder
>---------------------------------------------------------------
backend/backend/dispatcher.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/backend/backend/dispatcher.py b/backend/backend/dispatcher.py
index 70ea14b..080a9b8 100644
--- a/backend/backend/dispatcher.py
+++ b/backend/backend/dispatcher.py
@@ -590,6 +590,9 @@ class Worker(multiprocessing.Process):
try:
chroot_repos = list(job.repos)
chroot_repos.append(job.results + '/' + job.chroot)
+ # for RHBZ: #1150954
+ chroot_repos.append(job.results + '/' + job.chroot + '/devel')
+
chrootlogfile = "{0}/build-{1}.log".format(
chroot_destdir, job.build_id)
9 years, 6 months
[copr] master: [backend] bigfix ... (15a046b)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 15a046b7b84f58ff8c95f8c2af146a20ff403b32
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Thu Oct 23 22:34:05 2014 +0200
[backend] bigfix ...
>---------------------------------------------------------------
backend/backend/dispatcher.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/backend/backend/dispatcher.py b/backend/backend/dispatcher.py
index 5564cb9..70ea14b 100644
--- a/backend/backend/dispatcher.py
+++ b/backend/backend/dispatcher.py
@@ -615,7 +615,7 @@ class Worker(multiprocessing.Process):
buildroot_pkgs=job.buildroot_pkgs,
callback=mockremote.CliLogCallBack(
quiet=True, logfn=chrootlogfile),
- front_url=self.opts.frontend_url,
+ front_url=self.opts.frontend_base_url,
)
build_details = mr.build_pkgs(job.pkgs)
9 years, 6 months
[copr] master: [backend] bugfix: passing correct url to fronend public api for ActionHandler (6b0f899)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 6b0f8999c56488c85ce23664e2d5ee018194a5c8
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Fri Oct 24 17:23:36 2014 +0200
[backend] bugfix: passing correct url to fronend public api for ActionHandler
>---------------------------------------------------------------
backend/copr-be.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/backend/copr-be.py b/backend/copr-be.py
index 52c95a8..4673e5e 100755
--- a/backend/copr-be.py
+++ b/backend/copr-be.py
@@ -116,7 +116,7 @@ class CoprJobGrab(multiprocessing.Process):
for action in r_json["actions"]:
ao = Action(self.events, action, self.lock, destdir=self.opts.destdir,
frontend_callback=FrontendCallback(self.opts),
- front_url=self.opts.frontend_url)
+ front_url=self.opts.frontend_base_url)
ao.run()
def run(self):
9 years, 6 months
[copr] master: [backend] createrepo: added logic to create repomd in the `devel` subdir (ed95f04)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit ed95f04c071bffb64c9abbf2bc0b71f72d65d398
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Thu Oct 23 17:18:38 2014 +0200
[backend] createrepo: added logic to create repomd in the `devel` subdir
>---------------------------------------------------------------
backend/backend/createrepo.py | 28 ++++++++++-
backend/run/copr_create_repo.py | 13 ++----
backend/tests/test_createrepo.py | 73 +++++++++++++++++++--------
backend/tests/test_run_copr_create_repo.py | 8 ---
4 files changed, 81 insertions(+), 41 deletions(-)
diff --git a/backend/backend/createrepo.py b/backend/backend/createrepo.py
index 0319c8e..31532c4 100644
--- a/backend/backend/createrepo.py
+++ b/backend/backend/createrepo.py
@@ -9,7 +9,7 @@ from copr.client import CoprClient
from backend.helpers import SortedOptParser
-def createrepo_unsafe(path, lock=None):
+def createrepo_unsafe(path, lock=None, dest_dir=None, base_url=None):
"""
Run createrepo_c on the given path
@@ -18,6 +18,10 @@ def createrepo_unsafe(path, lock=None):
:param string path: target location to create repo
:param lock: [optional]
+ :param str dest_dir: [optional] target location for repomd, in most cases
+ you should also provide base_url
+ :param str base_url: optional parameter for createrepo_c, "--baseurl"
+
:return tuple: (return_code, stdout, stderr)
"""
@@ -27,6 +31,13 @@ def createrepo_unsafe(path, lock=None):
if "epel-5" in path:
# this is because rhel-5 doesn't know sha256
comm.extend(['-s', 'sha', '--checksum', 'md5'])
+
+ if dest_dir:
+ comm.extend(['--outputdir', dest_dir])
+
+ if base_url:
+ comm.extend(['--baseurl', base_url])
+
comm.append(path)
if lock:
@@ -51,10 +62,23 @@ def get_auto_createrepo_status(front_url, username, projectname):
def createrepo(path, front_url, username, projectname, lock=None):
+ """
+ Creates repo depending on the project setting "auto_createrepo".
+ When enabled creates `repodata` at the provided path, otherwise
+
+ :param str path: directory with rpms
+ :param str front_url: url to the copr frontend
+ :param str username: copr project owner username
+ :param str projectname: copr project name
+ :param Multiprocessing.Lock lock: [optional] global copr-backend lock
+
+
+ :return: tuple(returncode, stdout, stderr) produced by `createrepo_c`
+ """
# TODO: add means of logging
if get_auto_createrepo_status(front_url, username, projectname):
return createrepo_unsafe(path, lock)
else:
- return None
+ return createrepo_unsafe(path, lock, base_url="../", dest_dir="devel")
diff --git a/backend/run/copr_create_repo.py b/backend/run/copr_create_repo.py
index ea11a1a..49ea3b5 100644
--- a/backend/run/copr_create_repo.py
+++ b/backend/run/copr_create_repo.py
@@ -31,21 +31,16 @@ def main(args):
sys.exit(1)
if not opts.front_url:
- print("No api url was specified, exiting", file=sys.stderr)
+ print("No front url was specified, exiting", file=sys.stderr)
sys.exit(1)
if not args:
print("No directory with repo was specified, exiting", file=sys.stderr)
sys.exit(1)
- result = createrepo(path=args[0], front_url=opts.front_url,
- username=opts.user, projectname=opts.project)
- if not result:
- print("Createrepo was skipped")
- else:
- retcode, stdout, stderr = result
- print("STDOUT: {}".format(stdout))
- print("STDERR: {}".format(stderr))
+ createrepo(path=args[0], front_url=opts.front_url,
+ username=opts.user, projectname=opts.project)
+
if __name__ == "__main__":
diff --git a/backend/tests/test_createrepo.py b/backend/tests/test_createrepo.py
index 23dfad6..01762b4 100644
--- a/backend/tests/test_createrepo.py
+++ b/backend/tests/test_createrepo.py
@@ -26,25 +26,34 @@ from backend.createrepo import createrepo, createrepo_unsafe
@mock.patch('backend.createrepo.createrepo_unsafe')
@mock.patch('backend.createrepo.CoprClient')
-def test_createrepo_conditional(mc_client, mc_create_unsafe):
+def test_createrepo_conditional_true(mc_client, mc_create_unsafe):
mc_client.return_value.get_project_details.return_value = MagicMock(data={"detail": {}})
createrepo(path="/tmp/", front_url="http://example.com/api",
username="foo", projectname="bar", lock=None)
- assert mc_create_unsafe.called # old behaviour
+
mc_create_unsafe.reset_mock()
- for val in [True, False]:
- mc_client.return_value.get_project_details.return_value = MagicMock(data={"detail": {"auto_createrepo": val}})
- createrepo(path="/tmp/", front_url="http://example.com/api",
- username="foo", projectname="bar", lock=None)
- assert val == mc_create_unsafe.called
- mc_create_unsafe.reset_mock()
+ mc_client.return_value.get_project_details.return_value = MagicMock(data={"detail": {"auto_createrepo": True}})
+ createrepo(path="/tmp/", front_url="http://example.com/api",
+ username="foo", projectname="bar", lock=None)
-(a)mock.patch('backend.createrepo.Popen')
+ mc_create_unsafe.reset_mock()
+
+(a)mock.patch('backend.createrepo.createrepo_unsafe')
@mock.patch('backend.createrepo.CoprClient')
+def test_createrepo_conditional_false(mc_client, mc_create_unsafe):
+ mc_client.return_value.get_project_details.return_value = MagicMock(data={"detail": {"auto_createrepo": False}})
+
+ createrepo(path="/tmp/", front_url="http://example.com/api",
+ username="foo", projectname="bar", lock=None)
+
+ assert mc_create_unsafe.call_args == mock.call('/tmp/', None, dest_dir='devel', base_url='../')
+
+
+(a)mock.patch('backend.createrepo.Popen')
class TestCreaterepoUnsafe(object):
def setup_method(self, method):
self.tmp_dir_name = self.make_temp_dir()
@@ -67,9 +76,8 @@ class TestCreaterepoUnsafe(object):
return self.tmp_dir_name
- def test_createrepo_unsafe_lock_usage(self, mc_client, mc_popen):
+ def test_createrepo_unsafe_lock_usage(self, mc_popen):
mocked_lock = MagicMock()
-
self.shared_state = dict(in_lock=False, lock_status=None)
def enter_lock(*args, **kwargs):
@@ -78,8 +86,6 @@ class TestCreaterepoUnsafe(object):
def exit_lock(*args, **kwargs):
self.shared_state["in_lock"] = False
- #mock_cmd_result = MagicMock()
-
def popen_side_effect(*args, **kwargs):
self.shared_state["lock_status"] = copy.copy(self.shared_state["in_lock"])
return mock.DEFAULT
@@ -91,13 +97,13 @@ class TestCreaterepoUnsafe(object):
mc_popen.return_value.communicate.return_value = ("", "")
createrepo_unsafe(self.tmp_dir_name, lock=mocked_lock)
- assert self.shared_state["lock_status"] == True
+ assert self.shared_state["lock_status"]
self.shared_state["lock_status"] = None
createrepo_unsafe(self.tmp_dir_name, lock=None)
- assert self.shared_state["lock_status"] == False
+ assert not self.shared_state["lock_status"]
- def test_createrepo_generated_commands_existing_repodata(self, mc_client, mc_popen):
+ def test_createrepo_generated_commands_existing_repodata(self, mc_popen):
mc_popen.return_value.communicate.return_value = ("", "")
path_epel_5 = os.path.join(self.tmp_dir_name, "epel-5")
expected_epel_5 = ['/usr/bin/createrepo_c', '--database',
@@ -116,17 +122,40 @@ class TestCreaterepoUnsafe(object):
createrepo_unsafe(path, None)
assert mc_popen.call_args == mock.call(expected, stderr=-1, stdout=-1)
- def test_createrepo_generated_commands(self, mc_client, mc_popen):
+
+ def test_createrepo_devel_generated_commands_existing_repodata(self, mc_popen):
+
mc_popen.return_value.communicate.return_value = ("", "")
path_epel_5 = os.path.join(self.tmp_dir_name, "epel-5")
- expected_epel_5 = ['/usr/bin/createrepo_c', '--database',
- '--ignore-lock', '-s', 'sha', '--checksum', 'md5', path_epel_5]
+ expected_epel_5 = ['/usr/bin/createrepo_c', '--database', '--ignore-lock',
+ '-s', 'sha', '--checksum', 'md5',
+ '--outputdir', 'devel', '--baseurl', '../', path_epel_5]
path_fedora = os.path.join(self.tmp_dir_name, "fedora-21")
- expected_fedora = ['/usr/bin/createrepo_c', '--database',
- '--ignore-lock', path_fedora]
+ expected_fedora = ['/usr/bin/createrepo_c', '--database', '--ignore-lock',
+ '--outputdir', 'devel', '--baseurl', '../', path_fedora]
for path, expected in [(path_epel_5, expected_epel_5), (path_fedora, expected_fedora)]:
os.makedirs(path)
+ repo_path = os.path.join(path, "devel", "repodata")
+ os.makedirs(repo_path)
+ with open(os.path.join(repo_path, "repomd.xml"), "w") as handle:
+ handle.write("1")
- createrepo_unsafe(path, None)
+ createrepo_unsafe(path, lock=None, base_url="../", dest_dir="devel")
+ assert mc_popen.call_args == mock.call(expected, stderr=-1, stdout=-1)
+
+ def test_createrepo_devel_generated_commands(self, mc_popen):
+
+ mc_popen.return_value.communicate.return_value = ("", "")
+ path_epel_5 = os.path.join(self.tmp_dir_name, "epel-5")
+ expected_epel_5 = ['/usr/bin/createrepo_c', '--database', '--ignore-lock',
+ '-s', 'sha', '--checksum', 'md5',
+ '--outputdir', 'devel', '--baseurl', '../', path_epel_5]
+ path_fedora = os.path.join(self.tmp_dir_name, "fedora-21")
+ expected_fedora = ['/usr/bin/createrepo_c', '--database', '--ignore-lock',
+ '--outputdir', 'devel', '--baseurl', '../', path_fedora]
+ for path, expected in [(path_epel_5, expected_epel_5), (path_fedora, expected_fedora)]:
+ os.makedirs(path)
+
+ createrepo_unsafe(path, lock=None, base_url="../", dest_dir="devel")
assert mc_popen.call_args == mock.call(expected, stderr=-1, stdout=-1)
diff --git a/backend/tests/test_run_copr_create_repo.py b/backend/tests/test_run_copr_create_repo.py
index c5e0bd9..9443b46 100644
--- a/backend/tests/test_run_copr_create_repo.py
+++ b/backend/tests/test_run_copr_create_repo.py
@@ -31,13 +31,6 @@ class TestArgParser(object):
mc_createrepo.return_value = 0, "", ""
createrepo_main(args)
-
- assert mc_createrepo.call_args == mock.call(username='foo', projectname='bar',
- front_url='http://example.com/api/', path='/tmp')
-
- mc_createrepo.return_value = None
- createrepo_main(args)
-
assert mc_createrepo.call_args == mock.call(username='foo', projectname='bar',
front_url='http://example.com/api/', path='/tmp')
@@ -61,7 +54,6 @@ class TestArgParser(object):
stdout, stderr = capsys.readouterr()
assert "No user" in stderr
-
def test_arg_parser_missing_project(self, mc_main, capsys):
args = ['-u', 'foo', '-f', 'http://example.com/api/', '/tmp']
9 years, 6 months
[copr] master: [backend] Action unittest fix 2 (adf0d4e)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit adf0d4e1c9e852fa32c9bfa205684d794cd49ab2
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Thu Oct 23 23:50:49 2014 +0200
[backend] Action unittest fix 2
>---------------------------------------------------------------
backend/tests/test_action.py | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/backend/tests/test_action.py b/backend/tests/test_action.py
index 19469cc..05b3429 100644
--- a/backend/tests/test_action.py
+++ b/backend/tests/test_action.py
@@ -401,6 +401,7 @@ class TestAction(object):
assert_what_from_queue(self.test_q, msg_list=["Removing log"])
else:
assert_fedora20()
+ assert_what_from_queue(self.test_q, msg_list=["Removing log"])
assert_what_from_queue(self.test_q, msg_list=["In chroot epel7"])
assert_epel7()
9 years, 6 months
[copr] master: [backend] passing username/projectname to Action::delete_build (45535f5)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 45535f53b8a10c396876e12011d9148c05d6b9d4
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Thu Oct 23 18:06:09 2014 +0200
[backend] passing username/projectname to Action::delete_build
>---------------------------------------------------------------
backend/backend/actions.py | 14 ++++++--
backend/copr-be.py | 3 +-
backend/tests/test_action.py | 35 ++++++++++++-------
.../coprs_frontend/coprs/logic/builds_logic.py | 7 +++-
.../test_views/test_coprs_ns/test_coprs_builds.py | 3 +-
5 files changed, 42 insertions(+), 20 deletions(-)
diff --git a/backend/backend/actions.py b/backend/backend/actions.py
index d9b4f00..3da35e7 100644
--- a/backend/backend/actions.py
+++ b/backend/backend/actions.py
@@ -1,10 +1,11 @@
+import json
import os.path
import shutil
import time
from bunch import Bunch
-from mockremote import createrepo
+from .createrepo import createrepo
class Action(object):
@@ -23,13 +24,14 @@ class Action(object):
"""
- def __init__(self, events, action, lock, frontend_callback, destdir):
+ def __init__(self, events, action, lock, frontend_callback, destdir, front_url):
super(Action, self).__init__()
self.frontend_callback = frontend_callback
self.destdir = destdir
self.data = action
self.events = events
self.lock = lock
+ self.front_url = front_url
def event(self, what):
self.events.put({"when": time.time(), "who": "action", "what": what})
@@ -66,8 +68,11 @@ class Action(object):
def handle_delete_build(self):
self.event("Action delete build")
project = self.data["old_value"]
+ ext_data = json.loads(self.data["data"])
+
packages = [os.path.basename(x).replace(".src.rpm", "") for x in \
- self.data["data"].split()]
+ ext_data["pkgs"].split()]
+ # self.data["data"].split()]
path = os.path.join(self.destdir, project)
@@ -106,7 +111,8 @@ class Action(object):
if altered:
self.event("Running createrepo")
- _, _, err = createrepo(os.path.join(path, chroot), self.lock)
+ _, _, err = createrepo(path=os.path.join(path, chroot), lock=self.lock,
+ front_url=self.front_url)
if err.strip():
self.event(
"Error making local repo: {0}".format(err))
diff --git a/backend/copr-be.py b/backend/copr-be.py
index c213770..bc60ea8 100755
--- a/backend/copr-be.py
+++ b/backend/copr-be.py
@@ -112,7 +112,8 @@ class CoprJobGrab(multiprocessing.Process):
for action in r_json["actions"]:
ao = Action(self.events, action, self.lock, destdir=self.opts.destdir,
- frontend_callback=FrontendCallback(self.opts))
+ frontend_callback=FrontendCallback(self.opts),
+ front_url=self.opts.frontend_url)
ao.run()
def run(self):
diff --git a/backend/tests/test_action.py b/backend/tests/test_action.py
index 934765d..e0c4515 100644
--- a/backend/tests/test_action.py
+++ b/backend/tests/test_action.py
@@ -75,7 +75,7 @@ class TestAction(object):
def test_action_event(self, mc_time):
test_action = Action(events=self.test_q, action={}, lock=None,
- frontend_callback=None, destdir=None)
+ frontend_callback=None, destdir=None, front_url=None)
with pytest.raises(EmptyQueue):
test_action.events.get_nowait()
@@ -98,7 +98,8 @@ class TestAction(object):
},
events=self.test_q, lock=None,
frontend_callback=mc_front_cb,
- destdir=None
+ destdir=None,
+ front_url=None
)
test_action.run()
assert not mc_front_cb.called
@@ -128,7 +129,8 @@ class TestAction(object):
},
events=self.test_q, lock=None,
frontend_callback=mc_front_cb,
- destdir=tmp_dir
+ destdir=tmp_dir,
+ front_url=None
)
test_action.run()
result_dict = mc_front_cb.update.call_args[0][0]["actions"][0]
@@ -158,7 +160,8 @@ class TestAction(object):
},
events=self.test_q, lock=None,
frontend_callback=mc_front_cb,
- destdir=os.path.join(tmp_dir, "dir-not-exists")
+ destdir=os.path.join(tmp_dir, "dir-not-exists"),
+ front_url=None
)
test_action.run()
result_dict = mc_front_cb.update.call_args[0][0]["actions"][0]
@@ -187,7 +190,8 @@ class TestAction(object):
},
events=self.test_q, lock=None,
frontend_callback=mc_front_cb,
- destdir=tmp_dir
+ destdir=tmp_dir,
+ front_url=None
)
test_action.run()
result_dict = mc_front_cb.update.call_args[0][0]["actions"][0]
@@ -216,7 +220,8 @@ class TestAction(object):
},
events=self.test_q, lock=None,
frontend_callback=mc_front_cb,
- destdir=os.path.join(tmp_dir, "dir-not-exists")
+ destdir=os.path.join(tmp_dir, "dir-not-exists"),
+ front_url=None
)
test_action.run()
@@ -250,7 +255,8 @@ class TestAction(object):
},
events=self.test_q, lock=None,
frontend_callback=mc_front_cb,
- destdir=tmp_dir
+ destdir=tmp_dir,
+ front_url=None
)
test_action.run()
@@ -286,11 +292,12 @@ class TestAction(object):
"object_type": obj_type,
"id": 7,
"old_value": "not-existing-project",
- "data": " ".join(self.pkgs),
+ "data": json.dumps({"pkgs": " ".join(self.pkgs)}),
},
events=self.test_q, lock=None,
frontend_callback=mc_front_cb,
- destdir=tmp_dir
+ destdir=tmp_dir,
+ front_url=None
)
with mock.patch("backend.actions.shutil") as mc_shutil:
test_action.run()
@@ -342,12 +349,13 @@ class TestAction(object):
"object_type": "build-succeeded",
"id": 7,
"old_value": "old_dir",
- "data": " ".join(self.pkgs),
+ "data": json.dumps({"pkgs": " ".join(self.pkgs)}),
"object_id": 42
},
events=self.test_q, lock=None,
frontend_callback=mc_front_cb,
- destdir=tmp_dir
+ destdir=tmp_dir,
+ front_url=None,
)
assert os.path.exists(foo_pkg_dir)
@@ -421,12 +429,13 @@ class TestAction(object):
"object_type": "build-succeeded",
"id": 7,
"old_value": "old_dir",
- "data": " ".join(self.pkgs),
+ "data": json.dumps({"pkgs": " ".join(self.pkgs)}),
"object_id": 42
},
events=self.test_q, lock=None,
frontend_callback=mc_front_cb,
- destdir=tmp_dir
+ destdir=tmp_dir,
+ front_url=None
)
test_action.run()
diff --git a/frontend/coprs_frontend/coprs/logic/builds_logic.py b/frontend/coprs_frontend/coprs/logic/builds_logic.py
index 225ecfe..e1907ec 100644
--- a/frontend/coprs_frontend/coprs/logic/builds_logic.py
+++ b/frontend/coprs_frontend/coprs/logic/builds_logic.py
@@ -1,3 +1,4 @@
+import json
import os
import time
from sqlalchemy import or_
@@ -211,12 +212,16 @@ class BuildsLogic(object):
# Only failed (and finished), succeeded, skipped and cancelled get here.
if build.state != "cancelled": #has nothing in backend to delete
object_type = "build-{0}".format(build.state)
+ data_dict = {"pkgs": build.pkgs,
+ "username": build.copr.owner.name,
+ "project": build.copr.name}
+
action = models.Action(action_type=helpers.ActionTypeEnum("delete"),
object_type=object_type,
object_id=build.id,
old_value="{0}/{1}".format(build.copr.owner.name,
build.copr.name),
- data=build.pkgs,
+ data=json.dumps(data_dict),
created_on=int(time.time()))
db.session.add(action)
diff --git a/frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_builds.py b/frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_builds.py
index 47e3a8b..1be3cc2 100644
--- a/frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_builds.py
+++ b/frontend/coprs_frontend/tests/test_views/test_coprs_ns/test_coprs_builds.py
@@ -1,3 +1,4 @@
+import json
from coprs import models
from tests.coprs_test_case import CoprsTestCase, TransactionDecorator
@@ -119,7 +120,7 @@ class TestCoprDeleteBuild(CoprsTestCase):
act = self.models.Action.query.first()
assert act.object_type == "build-succeeded"
assert act.old_value == "user1/foocopr"
- assert act.data == pkgs
+ assert json.loads(act.data)["pkgs"] == pkgs
@TransactionDecorator("u2")
def test_copr_build_non_submitter_cannot_delete_build(self, f_users,
9 years, 6 months
[copr] master: [frontend] fixed html new option to configure copr->auto_creatrepo (b0008c2)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit b0008c26ee718dfc72223341e43d08b7b52ba646
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Fri Oct 24 13:55:30 2014 +0200
[frontend] fixed html new option to configure copr->auto_creatrepo
>---------------------------------------------------------------
.../coprs/templates/coprs/_coprs_forms.html | 31 ++++++++++++++------
1 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/templates/coprs/_coprs_forms.html b/frontend/coprs_frontend/coprs/templates/coprs/_coprs_forms.html
index f7ece5e..cae838b 100644
--- a/frontend/coprs_frontend/coprs/templates/coprs/_coprs_forms.html
+++ b/frontend/coprs_frontend/coprs/templates/coprs/_coprs_forms.html
@@ -36,16 +36,23 @@
{% for ch in chs %}
<tr>
<td>
- {{ form|attr(ch)|attr('label') }}
- {% if form|attr(ch)|attr('label') %}
- {% else %}
- {{ form|attr(ch)|attr('label') }}
- {% endif %}
- </td><td>{{ form|attr(ch) }}
+ {{ form|attr(ch)|attr('label') }}
+ {% if form|attr(ch)|attr('label') %}
+ {% else %}
+ {{ form|attr(ch)|attr('label') }}
+ {% endif %}
+ </td>
+ <td>
+ {{ form|attr(ch) }}
+ </td>
{% if copr and form|attr(ch)|attr('data') %}
- </td><td><a href="{{ url_for('coprs_ns.chroot_edit', username = copr.owner.name, coprname = copr.name, chrootname = form|attr(ch)|attr('label')|attr('text'))}}">[Edit]</a>
+ <td>
+ <a href="{{ url_for('coprs_ns.chroot_edit', username = copr.owner.name, coprname = copr.name, chrootname = form|attr(ch)|attr('label')|attr('text'))}}">
+ [Edit]
+ </a>
+
+ </td>
{% endif %}
- </td>
</tr>
{% endfor %}
</table>
@@ -55,7 +62,13 @@
{{ render_field(form.initial_pkgs, rows=5, cols=50, placeholder='Optional - list of src.rpm to build initially. Can be skipped and submitted later.') }}
{% endif %}
- {{ render_field(form.auto_createrepo, label="Generate repo data after build ") }}
+ <dt class="field-label">
+ <label for="auto_createrepo">Build release options</label>
+ </dt>
+ <dd>
+ Automatically re-create repository metadata:
+ {{ form.auto_createrepo }}
+ </dd>
<dt><input type="submit" value="{% if copr %}Update{% else %}Create{% endif %}"></dt>
9 years, 6 months