Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : master
---------------------------------------------------------------
commit c9ea561667b71563e7f243829d9590c0731933fa
Merge: c8e4d8f 96cfc8a
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Mon Mar 23 09:45:39 2015 +0100
Merge branch 'hotfix_1203753'
---------------------------------------------------------------
backend/backend/actions.py | 5 ++
backend/copr-backend.spec | 17 +++++-
.../coprs/logic/__init__.py => backend/run/test.sh | 0
backend/tests/test_action.py | 55 ++++++++++++++++++++
rel-eng/packages/copr-backend | 2 +-
5 files changed, 75 insertions(+), 4 deletions(-)
diff --git a/backend/backend/actions.py b/backend/backend/actions.py
index 6b82ebe..c195100 100644
--- a/backend/backend/actions.py
+++ b/backend/backend/actions.py
@@ -107,6 +107,11 @@ class Action(object):
chroots_requested = set(ext_data["chroots"])
package_name =
os.path.basename(ext_data["pkgs"]).replace(".src.rpm", "")
+ # TODO: replace with explicit pkg_name, send cleaned string into the action
+ if not package_name:
+ self.add_event("Bad package name {}, action data: {}
".format(package_name, ext_data))
+ return
+
path = os.path.join(self.destdir, project)
self.add_event("Deleting package {0}".format(package_name))
diff --git a/backend/copr-backend.spec b/backend/copr-backend.spec
index 82cb38b..45e5fff 100644
--- a/backend/copr-backend.spec
+++ b/backend/copr-backend.spec
@@ -3,7 +3,7 @@
%endif
Name: copr-backend
-Version: 1.58
+Version: 1.60
Release: 1%{?dist}
Summary: Backend for Copr
@@ -25,6 +25,7 @@ BuildRequires: python-requests
BuildRequires: python2-devel
BuildRequires: python-copr
BuildRequires: systemd
+BuildRequires: redis
%if 0%{?rhel} < 7 && 0%{?rhel} > 0
BuildRequires: python-argparse
%endif
@@ -162,9 +163,12 @@ cp -a conf/playbooks %{buildroot}%{_pkgdocdir}/
%check
-#PYTHONPATH=backend:run:$PYTHONPATH python -B -m pytest \
-# -s --cov-report term-missing --cov ./backend --cov ./run ./tests/
+redis-server --port 7777 &> /dev/null &
+PYTHONPATH=backend:run:$PYTHONPATH python -B -m pytest \
+ -s --cov-report term-missing --cov ./backend --cov ./run ./tests/
+
+kill %1
%pre
getent group copr >/dev/null || groupadd -r copr
@@ -223,6 +227,13 @@ useradd -r -g copr -G lighttpd -s /bin/bash -c "COPR user"
copr
%exclude %{_pkgdocdir}/playbooks
%changelog
+* Fri Mar 20 2015 Valentin Gologuzov <vgologuz(a)redhat.com> 1.60-1
+- [backend][spec] start/stop redis server during package build tests
+
+* Fri Mar 20 2015 Valentin Gologuzov <vgologuz(a)redhat.com> 1.59-1
+- [backend][hotfix] 1203753 : don't process delete action if src_pkg is
+ mallformed
+
* Mon Mar 02 2015 Valentin Gologuzov <vgologuz(a)redhat.com> 1.58-1
- [rhbz:#1185959] - RFE: Present statistics about project
popularity. A few more counters for downloads from backend's result
diff --git a/frontend/coprs_frontend/coprs/logic/__init__.py b/backend/run/test.sh
similarity index 100%
copy from frontend/coprs_frontend/coprs/logic/__init__.py
copy to backend/run/test.sh
diff --git a/backend/tests/test_action.py b/backend/tests/test_action.py
index 74a8e2b..2ca6d47 100644
--- a/backend/tests/test_action.py
+++ b/backend/tests/test_action.py
@@ -382,6 +382,8 @@ class TestAction(object):
test_action.run()
assert not os.path.exists(foo_pkg_dir)
assert not os.path.exists(log_path)
+ assert os.path.exists(chroot_1_dir)
+ assert os.path.exists(chroot_2_dir)
assert_what_from_queue(self.test_q, msg_list=[
"Action delete build",
@@ -418,6 +420,10 @@ class TestAction(object):
with pytest.raises(EmptyQueue):
self.test_q.get_nowait()
+ assert os.path.exists(chroot_1_dir)
+ assert os.path.exists(chroot_2_dir)
+
+
create_repo_expected_call = mock.call(
username=u'foo',
projectname=u'bar',
@@ -531,6 +537,10 @@ class TestAction(object):
assert not os.path.isdir(os.path.join(chroot_20_path,
"rubygem-log4r-1.1.10-2.fc21"))
assert not os.path.isdir(os.path.join(chroot_21_path,
"rubygem-log4r-1.1.10-2.fc21"))
+ assert os.path.exists(chroot_20_path)
+ assert os.path.exists(chroot_21_path)
+
+
@mock.patch("backend.actions.createrepo")
def test_delete_two_chroots_two_remains(self, mc_createrepo_unsafe, mc_time):
"""
@@ -602,6 +612,51 @@ class TestAction(object):
assert os.path.isdir(os.path.join(chroot_20_i386_path,
"rubygem-log4r-1.1.10-2.fc21"))
assert os.path.isdir(os.path.join(chroot_21_i386_path,
"rubygem-log4r-1.1.10-2.fc21"))
+ @mock.patch("backend.actions.createrepo")
+ def test_delete_build_with_bad_pkg_name(self, mc_createrepo, mc_time):
+ """
+ regression:
https://bugzilla.redhat.com/show_bug.cgi?id=1203753
+
+ """
+ mc_time.time.return_value = self.test_time
+
+ resource_name = "1171796_doubled.tar.gz"
+ self.unpack_resource(resource_name)
+
+ chroot_20_path = os.path.join(self.tmp_dir_name, "old_dir",
"fedora-20-x86_64")
+ chroot_21_path = os.path.join(self.tmp_dir_name, "old_dir",
"fedora-21-x86_64")
+
+ mc_createrepo.return_value = 0, STDOUT, ""
+ mc_front_cb = MagicMock()
+ test_action = Action(
+ action={
+ "action_type": ActionType.DELETE,
+ "object_type": "build",
+ "object_id": 15,
+ "id": 15,
+ "old_value": "old_dir",
+ "data": json.dumps({
+ "pkgs": "http://example.com/",
+ "username": "foo",
+ "projectname": "bar",
+ "chroots": ["fedora-20-x86_64",
"fedora-21-x86_64"]
+ }),
+ },
+ events=self.test_q, lock=None,
+ frontend_callback=mc_front_cb,
+ destdir=self.tmp_dir_name,
+ front_url=None,
+ results_root_url=RESULTS_ROOT_URL
+ )
+
+ assert os.path.exists(chroot_20_path)
+ assert os.path.exists(chroot_21_path)
+ test_action.run()
+ # shouldn't touch chroot dirs
+ assert os.path.exists(chroot_20_path)
+ assert os.path.exists(chroot_21_path)
+
+
@mock.patch("backend.actions.createrepo_unsafe")
def test_delete_two_chroots_two_builds_stay_untouched(self, mc_createrepo_unsafe,
mc_time):
# TODO: prepare archive
diff --git a/rel-eng/packages/copr-backend b/rel-eng/packages/copr-backend
index d19bf95..0b75fea 100644
--- a/rel-eng/packages/copr-backend
+++ b/rel-eng/packages/copr-backend
@@ -1 +1 @@
-1.58-1 backend/
+1.60-1 backend/