[copr] master: Automatic commit of package [copr-backend] release [1.78-1]. (90f9372)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 90f937210e348272f9c4d8dfdb471f19dd95f144
Author: Miroslav Suchý <miroslav(a)suchy.cz>
Date: Mon Nov 16 09:19:56 2015 +0100
Automatic commit of package [copr-backend] release [1.78-1].
>---------------------------------------------------------------
backend/copr-backend.spec | 9 ++++++++-
rel-eng/packages/copr-backend | 2 +-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/backend/copr-backend.spec b/backend/copr-backend.spec
index 90674ba..50f350f 100644
--- a/backend/copr-backend.spec
+++ b/backend/copr-backend.spec
@@ -3,7 +3,7 @@
%endif
Name: copr-backend
-Version: 1.77
+Version: 1.78
Release: 1%{?dist}
Summary: Backend for Copr
@@ -246,6 +246,13 @@ useradd -r -g copr -G lighttpd -s /bin/bash -c "COPR user" copr
%exclude %{_pkgdocdir}/playbooks
%changelog
+* Mon Nov 16 2015 Miroslav Suchý <miroslav(a)suchy.cz> 1.78-1
+- handle_generate_gpg_key skips key creation when signing is disabled
+- Added test_handle_generate_gpg_key
+- fixed failing tests
+- show when createrepo is waiting for lock
+- do not block builds when processing too much actions
+
* Fri Nov 06 2015 Miroslav Suchý <msuchy(a)redhat.com> 1.77-1
- we need to have recent python-copr
- create copr-backend-service script to handle all copr services
diff --git a/rel-eng/packages/copr-backend b/rel-eng/packages/copr-backend
index c63ef44..ae51466 100644
--- a/rel-eng/packages/copr-backend
+++ b/rel-eng/packages/copr-backend
@@ -1 +1 @@
-1.77-1 backend/
+1.78-1 backend/
8 years, 5 months
[copr] master: [backend] handle_generate_gpg_key skips key creation when signing is disabled (cccc71d)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit cccc71d52ba190e1247429a02ad613db4fb108db
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Fri Nov 13 17:24:55 2015 +0100
[backend] handle_generate_gpg_key skips key creation when signing is disabled
>---------------------------------------------------------------
backend/backend/actions.py | 11 +++++++++--
backend/tests/test_action.py | 15 +++++++++++++--
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/backend/backend/actions.py b/backend/backend/actions.py
index ac2ad78..c3cc4cc 100644
--- a/backend/backend/actions.py
+++ b/backend/backend/actions.py
@@ -215,12 +215,17 @@ class Action(object):
os.remove(log_path)
def handle_generate_gpg_key(self, result):
- self.log.debug("Action generate gpg key")
-
ext_data = json.loads(self.data["data"])
+ self.log.info("Action generate gpg key: {}".format(ext_data))
+
username = ext_data["username"]
projectname = ext_data["projectname"]
+ if self.opts.do_sign is False:
+ # skip key creation, most probably sign component is unused
+ result.result = ActionResult.SUCCESS
+ return
+
try:
create_user_keys(username, projectname, self.opts)
result.result = ActionResult.SUCCESS
@@ -257,6 +262,8 @@ class Action(object):
elif action_type == ActionType.GEN_GPG_KEY:
self.handle_generate_gpg_key(result)
+ self.log.info("Action result: {}".format(result))
+
if "result" in result:
if result.result == ActionResult.SUCCESS and \
not getattr(result, "job_ended_on", None):
diff --git a/backend/tests/test_action.py b/backend/tests/test_action.py
index 2b637e5..e06ed8d 100644
--- a/backend/tests/test_action.py
+++ b/backend/tests/test_action.py
@@ -50,7 +50,9 @@ class TestAction(object):
destdir=None,
frontend_base_url=None,
- results_baseurl=RESULTS_ROOT_URL
+ results_baseurl=RESULTS_ROOT_URL,
+
+ do_sign=True,
)
def teardown_method(self, method):
@@ -644,7 +646,6 @@ class TestAction(object):
test_action.run()
result_dict = mc_front_cb.update.call_args[0][0]["actions"][0]
-
assert result_dict["id"] == 11
assert result_dict["result"] == ActionResult.SUCCESS
@@ -660,3 +661,13 @@ class TestAction(object):
assert result_dict["id"] == 11
assert result_dict["result"] == ActionResult.FAILURE
+ # test, that key creation is skipped when signing is disabled
+ self.opts.do_sign = False
+ mc_front_cb.reset_mock()
+ mc_cuk.reset_mock()
+ test_action.run()
+
+ assert not mc_cuk.called
+ result_dict = mc_front_cb.update.call_args[0][0]["actions"][0]
+ assert result_dict["id"] == 11
+ assert result_dict["result"] == ActionResult.SUCCESS
8 years, 5 months
[copr] master: [frontend] minor fix (f35e2e3)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit f35e2e34d5942b07d5478d15939e9989b8eb0640
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Fri Nov 13 17:09:21 2015 +0100
[frontend] minor fix
>---------------------------------------------------------------
frontend/coprs_frontend/coprs/logic/coprs_logic.py | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/logic/coprs_logic.py b/frontend/coprs_frontend/coprs/logic/coprs_logic.py
index 33924e4..a90f34a 100644
--- a/frontend/coprs_frontend/coprs/logic/coprs_logic.py
+++ b/frontend/coprs_frontend/coprs/logic/coprs_logic.py
@@ -205,6 +205,8 @@ class CoprsLogic(object):
CoprsLogic.new(user, copr,
check_for_duplicates=check_for_duplicates)
CoprChrootsLogic.new_from_names(copr, selected_chroots)
+
+ db.session.flush()
ActionsLogic.send_create_gpg_key(copr)
return copr
8 years, 5 months
[copr] master: [frontend] Sending action to create gpg key right after the project creation (f0f69ab)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit f0f69abaaca6ee5d074a1cc7343e8e89995003d6
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Fri Nov 13 17:00:56 2015 +0100
[frontend] Sending action to create gpg key right after the project creation
>---------------------------------------------------------------
frontend/coprs_frontend/coprs/helpers.py | 1 +
.../coprs_frontend/coprs/logic/actions_logic.py | 19 +++++++++++++++++
frontend/coprs_frontend/coprs/logic/coprs_logic.py | 2 +
.../tests/test_logic/test_coprs_logic.py | 22 ++++++++++++++++++-
4 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/helpers.py b/frontend/coprs_frontend/coprs/helpers.py
index e063b58..22f4ff0 100644
--- a/frontend/coprs_frontend/coprs/helpers.py
+++ b/frontend/coprs_frontend/coprs/helpers.py
@@ -66,6 +66,7 @@ class ActionTypeEnum(with_metaclass(EnumType, object)):
"legal-flag": 2,
"createrepo": 3,
"update_comps": 4,
+ "gen_gpg_key": 5,
}
diff --git a/frontend/coprs_frontend/coprs/logic/actions_logic.py b/frontend/coprs_frontend/coprs/logic/actions_logic.py
index 8a5b92b..3ff0e31 100644
--- a/frontend/coprs_frontend/coprs/logic/actions_logic.py
+++ b/frontend/coprs_frontend/coprs/logic/actions_logic.py
@@ -141,3 +141,22 @@ class ActionsLogic(object):
created_on=int(time.time())
)
db.session.add(action)
+
+ @classmethod
+ def send_create_gpg_key(cls, copr):
+ """
+ :type copr: models.Copr
+ """
+
+ data_dict = {
+ "username": copr.owner.name,
+ "projectname": copr.name,
+ }
+
+ action = models.Action(
+ action_type=helpers.ActionTypeEnum("gen_gpg_key"),
+ object_type="copr",
+ data=json.dumps(data_dict),
+ created_on=int(time.time()),
+ )
+ db.session.add(action)
diff --git a/frontend/coprs_frontend/coprs/logic/coprs_logic.py b/frontend/coprs_frontend/coprs/logic/coprs_logic.py
index c6fcbc9..33924e4 100644
--- a/frontend/coprs_frontend/coprs/logic/coprs_logic.py
+++ b/frontend/coprs_frontend/coprs/logic/coprs_logic.py
@@ -205,6 +205,8 @@ class CoprsLogic(object):
CoprsLogic.new(user, copr,
check_for_duplicates=check_for_duplicates)
CoprChrootsLogic.new_from_names(copr, selected_chroots)
+ ActionsLogic.send_create_gpg_key(copr)
+
return copr
@classmethod
diff --git a/frontend/coprs_frontend/tests/test_logic/test_coprs_logic.py b/frontend/coprs_frontend/tests/test_logic/test_coprs_logic.py
index 38e1cbf..e659f17 100644
--- a/frontend/coprs_frontend/tests/test_logic/test_coprs_logic.py
+++ b/frontend/coprs_frontend/tests/test_logic/test_coprs_logic.py
@@ -1,10 +1,13 @@
+import json
import pytest
from coprs.exceptions import ActionInProgressException
from coprs.helpers import ActionTypeEnum
+from coprs.logic.actions_logic import ActionsLogic
from coprs.logic.coprs_logic import CoprsLogic
from coprs import models
+from coprs.logic.users_logic import UsersLogic
from tests.coprs_test_case import CoprsTestCase
@@ -52,5 +55,20 @@ class TestCoprsLogic(CoprsTestCase):
obtained = len(results)
expected = u1_count + u2_count
- # TODO: uncomment after fix in flask-whooshee will be released
- # assert obtained == expected
+
+ assert obtained == expected
+
+ def test_copr_logic_add_sends_create_gpg_key_action(self, f_users, f_mock_chroots, f_db):
+ name = u"project_1"
+ selected_chroots = [self.mc1.name]
+
+ CoprsLogic.add(self.u1, name, selected_chroots)
+ self.db.session.commit()
+
+ actions = ActionsLogic.get_many(ActionTypeEnum("gen_gpg_key")).all()
+ assert len(actions) == 1
+ data = json.loads(actions[0].data)
+ assert data["username"] == self.u1.name
+ assert data["projectname"] == name
+
+
8 years, 5 months
[copr] master: [backend] Added test_handle_generate_gpg_key (5afa114)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 5afa114c44c5df6a6d2647c56e3ba4c116a4e02a
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Fri Nov 13 14:57:41 2015 +0100
[backend] Added test_handle_generate_gpg_key
>---------------------------------------------------------------
backend/backend/actions.py | 2 +-
backend/tests/test_action.py | 45 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/backend/backend/actions.py b/backend/backend/actions.py
index b6fa8fb..ac2ad78 100644
--- a/backend/backend/actions.py
+++ b/backend/backend/actions.py
@@ -223,7 +223,7 @@ class Action(object):
try:
create_user_keys(username, projectname, self.opts)
- result.results = ActionResult.SUCCESS
+ result.result = ActionResult.SUCCESS
except CoprKeygenRequestError:
result.result = ActionResult.FAILURE
diff --git a/backend/tests/test_action.py b/backend/tests/test_action.py
index e029740..2b637e5 100644
--- a/backend/tests/test_action.py
+++ b/backend/tests/test_action.py
@@ -19,8 +19,7 @@ else:
from backend.actions import Action, ActionType, ActionResult
-from backend.exceptions import CreateRepoError
-
+from backend.exceptions import CreateRepoError, CoprKeygenRequestError
RESULTS_ROOT_URL = "http://example.com/results"
STDOUT = "stdout"
@@ -619,3 +618,45 @@ class TestAction(object):
assert result_dict["id"] == 10
assert result_dict["result"] == ActionResult.FAILURE
+
+ @mock.patch("backend.actions.create_user_keys")
+ def test_handle_generate_gpg_key(self, mc_cuk, mc_time):
+ uname = "foo"
+ pname = "bar"
+ action_data = json.dumps({
+ "username": uname,
+ "projectname": pname,
+ })
+
+ expected_call = mock.call(uname, pname, self.opts)
+
+ mc_front_cb = MagicMock()
+ test_action = Action(
+ opts=self.opts,
+ action={
+ "action_type": ActionType.GEN_GPG_KEY,
+ "data": action_data,
+ "id": 11
+ },
+ frontend_client=mc_front_cb
+ )
+
+ test_action.run()
+
+ result_dict = mc_front_cb.update.call_args[0][0]["actions"][0]
+
+ assert result_dict["id"] == 11
+ assert result_dict["result"] == ActionResult.SUCCESS
+
+ assert mc_cuk.call_args == expected_call
+
+ # handle exception
+ mc_cuk.side_effect = CoprKeygenRequestError("foo")
+ mc_front_cb.reset_mock()
+ test_action.run()
+
+ result_dict = mc_front_cb.update.call_args[0][0]["actions"][0]
+
+ assert result_dict["id"] == 11
+ assert result_dict["result"] == ActionResult.FAILURE
+
8 years, 5 months
[copr] master: R: 20, 4: Method could be a function (no-self-use) (e9c13fe)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit e9c13fe73d228269a40e07f511c368a900eefb01
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Fri Nov 13 14:27:52 2015 +0100
R: 20, 4: Method could be a function (no-self-use)
>---------------------------------------------------------------
.../coprs/rest_api/resources/build.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/rest_api/resources/build.py b/frontend/coprs_frontend/coprs/rest_api/resources/build.py
index 8736f1e..b108ce7 100644
--- a/frontend/coprs_frontend/coprs/rest_api/resources/build.py
+++ b/frontend/coprs_frontend/coprs/rest_api/resources/build.py
@@ -17,7 +17,8 @@ from ..util import mm_deserialize, get_request_parser, arg_bool
class BuildListR(Resource):
- def get(self):
+ @classmethod
+ def get(cls):
parser = get_request_parser()
8 years, 5 months
[copr] master: W: 9, 0: Unused StatusEnum imported from helpers (unused-import) (afbb9b2)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit afbb9b2bffccbe561eb26e185a44721558819b56
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Fri Nov 13 14:30:27 2015 +0100
W: 9, 0: Unused StatusEnum imported from helpers (unused-import)
>---------------------------------------------------------------
.../coprs/rest_api/resources/build.py | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/rest_api/resources/build.py b/frontend/coprs_frontend/coprs/rest_api/resources/build.py
index 1fb1797..1b7782d 100644
--- a/frontend/coprs_frontend/coprs/rest_api/resources/build.py
+++ b/frontend/coprs_frontend/coprs/rest_api/resources/build.py
@@ -6,7 +6,6 @@ from flask_restful import Resource
from ... import db
from ...exceptions import ActionInProgressException, InsufficientRightsException, RequestCannotBeExecuted
-from ...helpers import StatusEnum
from ...logic.builds_logic import BuildsLogic
from ..common import get_project_safe
from ..exceptions import MalformedRequest, CannotProcessRequest, AccessForbidden
8 years, 5 months
[copr] master: R:205, 4: Method could be a function (no-self-use) (4169dfd)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 4169dfd805025d724e0749f3e6fc2d3e725195ee
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Fri Nov 13 14:29:32 2015 +0100
R:205, 4: Method could be a function (no-self-use)
>---------------------------------------------------------------
.../coprs/rest_api/resources/build.py | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/rest_api/resources/build.py b/frontend/coprs_frontend/coprs/rest_api/resources/build.py
index b979288..7641459 100644
--- a/frontend/coprs_frontend/coprs/rest_api/resources/build.py
+++ b/frontend/coprs_frontend/coprs/rest_api/resources/build.py
@@ -204,6 +204,7 @@ class BuildR(Resource):
return "", 204
+ @classmethod
@rest_api_auth_required
def put(self, build_id):
build = get_build_safe(build_id)
8 years, 5 months
[copr] master: W: 5, 0: Unused reqparse imported from flask_restful (unused-import) (94ddc68)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 94ddc685b050d742963f1b0041541ab0d1a07810
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Fri Nov 13 14:29:54 2015 +0100
W: 5, 0: Unused reqparse imported from flask_restful (unused-import)
>---------------------------------------------------------------
.../coprs/rest_api/resources/build.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/rest_api/resources/build.py b/frontend/coprs_frontend/coprs/rest_api/resources/build.py
index 7641459..1fb1797 100644
--- a/frontend/coprs_frontend/coprs/rest_api/resources/build.py
+++ b/frontend/coprs_frontend/coprs/rest_api/resources/build.py
@@ -2,7 +2,7 @@
import flask
from flask import url_for, make_response
-from flask_restful import Resource, reqparse
+from flask_restful import Resource
from ... import db
from ...exceptions import ActionInProgressException, InsufficientRightsException, RequestCannotBeExecuted
8 years, 5 months