[copr] skvidal-backend: pass the ip of our builder over to terminate() (3ab6609)
by skvidal@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
>---------------------------------------------------------------
commit 3ab66097ae55f9898010c625834c0a67e61a7676
Author: Seth Vidal <skvidal(a)fedoraproject.org>
Date: Fri Nov 30 11:44:28 2012 -0500
pass the ip of our builder over to terminate()
>---------------------------------------------------------------
backend/dispatcher.py | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index a5349e6..286cffd 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -125,14 +125,14 @@ class Worker(multiprocessing.Process):
return i
return None
- def terminate_instance(self):
+ def terminate_instance(self,ip):
"""call the terminate playbook to destroy the building instance"""
self.callback.log('terminate instance begin')
stats = callbacks.AggregateStats()
playbook_cb = SilentPlaybookCallbacks(verbose=False)
runner_cb = callbacks.DefaultRunnerCallbacks()
- play = ansible.playbook.PlayBook(host_list=[self.ip], stats=stats, playbook=self.opts.terminate_playbook,
+ play = ansible.playbook.PlayBook(host_list=[ip], stats=stats, playbook=self.opts.terminate_playbook,
callbacks=playbook_cb, runner_callbacks=runner_cb,
remote_user='root')
@@ -187,7 +187,6 @@ class Worker(multiprocessing.Process):
ip = self.spawn_instance()
if not ip:
raise errors.CoprWorkerError, "No IP found from creating instance"
- self.ip = ip
except ansible.errors.AnsibleError, e:
self.callback.log('failure to setup instance: %s' % e)
@@ -224,5 +223,5 @@ class Worker(multiprocessing.Process):
self.return_results(job)
self.callback.log('worker finished build: %s' % ip)
# clean up the instance
- self.terminate_instance()
+ self.terminate_instance(ip)
10 years, 9 months
[copr] skvidal-backend: need to record the ip of each worker so we can kill it later (7080aeb)
by skvidal@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
>---------------------------------------------------------------
commit 7080aebc8fbb3200c405c722b9301d755a313263
Author: Seth Vidal <skvidal(a)fedoraproject.org>
Date: Fri Nov 30 11:43:30 2012 -0500
need to record the ip of each worker so we can kill it later
>---------------------------------------------------------------
backend/dispatcher.py | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index dac7498..a5349e6 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -187,6 +187,7 @@ class Worker(multiprocessing.Process):
ip = self.spawn_instance()
if not ip:
raise errors.CoprWorkerError, "No IP found from creating instance"
+ self.ip = ip
except ansible.errors.AnsibleError, e:
self.callback.log('failure to setup instance: %s' % e)
10 years, 9 months
[copr] skvidal-backend: move to shutil.move not os.rename b/c of mount boundaries (452080a)
by Seth Vidal
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
>---------------------------------------------------------------
commit 452080a9c849b46663760d0a7c67383f25121a94
Author: Seth Vidal <skvidal(a)fedoraproject.org>
Date: Fri Nov 30 11:36:00 2012 -0500
move to shutil.move not os.rename b/c of mount boundaries
>---------------------------------------------------------------
backend/dispatcher.py | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index 8b47c70..dac7498 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -3,6 +3,7 @@
import os
import sys
+import shutil
import multiprocessing
import time
import Queue
@@ -101,6 +102,7 @@ class Worker(multiprocessing.Process):
self.callback.log('creating worker: %s' % ip)
def spawn_instance(self):
+ """call the spawn playbook to startup/provision a building instance"""
self.callback.log('spawning instance begin')
stats = callbacks.AggregateStats()
@@ -124,6 +126,7 @@ class Worker(multiprocessing.Process):
return None
def terminate_instance(self):
+ """call the terminate playbook to destroy the building instance"""
self.callback.log('terminate instance begin')
stats = callbacks.AggregateStats()
@@ -154,9 +157,10 @@ class Worker(multiprocessing.Process):
return jobdata
def return_results(self, job):
+ """write out a completed json file to the results dir and submit the results to the frontend"""
self.callback.log('%s status %s. Took %s seconds' % (job.build_id, job.status, job.ended_on - job.started_on))
jobfilename = os.path.basename(job.jobfile)
- os.rename(job.jobfile, job.destdir + '/' + jobfilename)
+ shutil.move(job.jobfile, job.destdir + '/' + jobfilename)
#FIXME - this should either return job status/results
# into a queue or it should submit results directly to the frontend
10 years, 9 months
[copr] skvidal-backend: basename not dirname (3d0d368)
by Seth Vidal
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
>---------------------------------------------------------------
commit 3d0d368615ea4fee2c4d41a3c140f1aef8ef7a91
Author: Seth Vidal <skvidal(a)fedoraproject.org>
Date: Fri Nov 30 11:08:32 2012 -0500
basename not dirname
>---------------------------------------------------------------
backend/dispatcher.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index c9b34e9..8b47c70 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -155,7 +155,7 @@ class Worker(multiprocessing.Process):
def return_results(self, job):
self.callback.log('%s status %s. Took %s seconds' % (job.build_id, job.status, job.ended_on - job.started_on))
- jobfilename = os.path.dirname(job.jobfile)
+ jobfilename = os.path.basename(job.jobfile)
os.rename(job.jobfile, job.destdir + '/' + jobfilename)
#FIXME - this should either return job status/results
# into a queue or it should submit results directly to the frontend
10 years, 9 months
[copr] skvidal-backend: terminate instances when the build finishes (23ceef0)
by Seth Vidal
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : skvidal-backend
>---------------------------------------------------------------
commit 23ceef0bdc9cd7adedfe81f03b4292bdbc1c924a
Author: Seth Vidal <skvidal(a)fedoraproject.org>
Date: Fri Nov 30 10:55:23 2012 -0500
terminate instances when the build finishes
>---------------------------------------------------------------
backend/dispatcher.py | 21 ++++++++++++++++-----
backend/mockremote.py | 5 +++++
copr-be.py | 3 ++-
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/backend/dispatcher.py b/backend/dispatcher.py
index ef621be..c9b34e9 100644
--- a/backend/dispatcher.py
+++ b/backend/dispatcher.py
@@ -108,7 +108,7 @@ class Worker(multiprocessing.Process):
runner_cb = callbacks.DefaultRunnerCallbacks()
# fixme - extra_vars to include ip as a var if we need to specify ips
# also to include info for instance type to handle the memory requirements of builds
- play = ansible.playbook.PlayBook(stats=stats, playbook=self.opts.playbook,
+ play = ansible.playbook.PlayBook(stats=stats, playbook=self.opts.spawn_playbook,
callbacks=playbook_cb, runner_callbacks=runner_cb,
remote_user='root')
@@ -123,6 +123,19 @@ class Worker(multiprocessing.Process):
return i
return None
+ def terminate_instance(self):
+ self.callback.log('terminate instance begin')
+
+ stats = callbacks.AggregateStats()
+ playbook_cb = SilentPlaybookCallbacks(verbose=False)
+ runner_cb = callbacks.DefaultRunnerCallbacks()
+ play = ansible.playbook.PlayBook(host_list=[self.ip], stats=stats, playbook=self.opts.terminate_playbook,
+ callbacks=playbook_cb, runner_callbacks=runner_cb,
+ remote_user='root')
+
+ play.run()
+ self.callback.log('terminate instance end')
+
def parse_job(self, jobfile):
# read the json of the job in
# break out what we need return a bunch of the info we need
@@ -205,8 +218,6 @@ class Worker(multiprocessing.Process):
job.status = status
self.return_results(job)
self.callback.log('worker finished build: %s' % ip)
- # FIXME call terminate on the instance
-
-
-
+ # clean up the instance
+ self.terminate_instance()
diff --git a/backend/mockremote.py b/backend/mockremote.py
index 7a48857..5bfb1f2 100755
--- a/backend/mockremote.py
+++ b/backend/mockremote.py
@@ -482,6 +482,11 @@ class MockRemote(object):
self.callback.end_download(pkg)
+ # FIXME
+ # need a plugin hook or some mechanism to check random
+ # info about the pkgs
+
+
# checking where to stick stuff
if not b_status:
if self.recurse:
diff --git a/copr-be.py b/copr-be.py
index d638ddd..0d20e20 100644
--- a/copr-be.py
+++ b/copr-be.py
@@ -55,7 +55,8 @@ class CoprBackend(object):
opts.results_baseurl = _get_conf(cp,'backend', 'results_baseurl', 'http://copr')
opts.frontend_url = _get_conf(cp, 'backend', 'frontend_url', 'http://coprs/rest/api')
opts.frontend_auth = _get_conf(cp,'backend', 'frontend_auth', 'PASSWORDHERE')
- opts.playbook = _get_conf(cp,'backend','playbook', '/etc/copr/builder_playbook.yml')
+ opts.spawn_playbook = _get_conf(cp,'backend','spawn_playbook', '/etc/copr/builder_playbook.yml')
+ opts.terminate_playbook = _get_conf(cp,'backend','terminate_playbook', '/etc/copr/terminate_playbook.yml')
opts.jobsdir = _get_conf(cp, 'backend', 'jobsdir', None)
opts.destdir = _get_conf(cp, 'backend', 'destdir', None)
opts.sleeptime = int(_get_conf(cp, 'backend', 'sleeptime', 10))
10 years, 9 months
[copr] bkabrda-workspace: Fix displaying the permissions table (7869d40)
by bkabrda@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit 7869d405748c3beeb75230977cbfa61a90a51af5
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Wed Nov 28 18:36:55 2012 +0100
Fix displaying the permissions table
>---------------------------------------------------------------
coprs_frontend/coprs/templates/coprs/detail.html | 2 +-
.../tests/test_views/test_coprs_ns/test_general.py | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/coprs_frontend/coprs/templates/coprs/detail.html b/coprs_frontend/coprs/templates/coprs/detail.html
index 7f6a977..fb94430 100644
--- a/coprs_frontend/coprs/templates/coprs/detail.html
+++ b/coprs_frontend/coprs/templates/coprs/detail.html
@@ -22,7 +22,7 @@
</ul>
{% endif %}
<h3>Permissions</h3>
- {% if g.user.id == copr.owner_id %}
+ {% if g.user.id == copr.owner_id or not g.user %}
{{ permissions_table(permissions, copr, None) }}
{% else %}
{{ permissions_table(permissions, copr, permission_applier_form) }}
diff --git a/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py b/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py
index 57c3d7b..6a318bd 100644
--- a/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py
+++ b/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py
@@ -109,7 +109,11 @@ class TestCoprDetail(CoprsTestCase):
r = self.tc.get('/coprs/detail/{0}/{1}/'.format(self.u1.name, self.c1.name))
assert r.data.count('<tr class=build') == 2
- def test_copr_detail_contains_permissions(self, f_users, f_coprs, f_copr_permissions):
+ def test_copr_detail_anonymous_doesnt_contain_permissions_table_when_no_permissions(self, f_users, f_coprs, f_copr_permissions):
+ r = self.tc.get('/coprs/detail/{0}/{1}/'.format(self.u1.name, self.c1.name))
+ assert '<table class=permissions' not in r.data
+
+ def test_copr_detail_contains_permissions_table(self, f_users, f_coprs, f_copr_permissions):
r = self.tc.get('/coprs/detail/{0}/{1}/'.format(self.u2.name, self.c3.name))
assert '<table class=permissions' in r.data
assert '<tr><td>{0}'.format(self.u3.name) in r.data
10 years, 10 months
[copr] bkabrda-workspace: Fix showing cancel build button (e9724c2)
by bkabrda@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit e9724c2fcf404fae63f274b17a1bd428605efed8
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Wed Nov 28 18:18:38 2012 +0100
Fix showing cancel build button
>---------------------------------------------------------------
.../coprs/templates/coprs/_builds_table.html | 8 +++++-
.../coprs/templates/coprs/_coprs_forms.html | 2 +-
coprs_frontend/coprs/templates/coprs/detail.html | 2 +-
.../coprs/templates/coprs/show_builds.html | 2 +-
.../tests/test_views/test_coprs_ns/test_general.py | 24 +++++++++++++++++++-
5 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/coprs_frontend/coprs/templates/coprs/_builds_table.html b/coprs_frontend/coprs/templates/coprs/_builds_table.html
index 9366bdb..8b7082c 100644
--- a/coprs_frontend/coprs/templates/coprs/_builds_table.html
+++ b/coprs_frontend/coprs/templates/coprs/_builds_table.html
@@ -20,7 +20,13 @@
<td>{{ build.ended_on|date_from_secs or 'Not yet' }}</td>
<td>{{ build.state }}</td>
<td>{{ build.results }}</td>
- <td>{{ copr_build_cancel_form(build) }}</td>
+ <td>
+ {% if g.user and g.user == build.user %}
+ {{ copr_build_cancel_form(build) }}
+ {% else %}
+ ---
+ {% endif %}
+ </td>
</tr>
<tr>
<td colspan=7>
diff --git a/coprs_frontend/coprs/templates/coprs/_coprs_forms.html b/coprs_frontend/coprs/templates/coprs/_coprs_forms.html
index 02c632e..98e9b40 100644
--- a/coprs_frontend/coprs/templates/coprs/_coprs_forms.html
+++ b/coprs_frontend/coprs/templates/coprs/_coprs_forms.html
@@ -63,7 +63,7 @@
{% macro copr_build_cancel_form(build) %}
{% if build.cancelable %}
- <form action="{{ url_for('coprs_ns.copr_cancel_build', username = build.copr.owner.name, coprname = build.copr.name, build_id = build.id)}}">
+ <form action="{{ url_for('coprs_ns.copr_cancel_build', username = build.copr.owner.name, coprname = build.copr.name, build_id = build.id)}}" method=post>
<input type=submit value=Cancel>
</form>
{% endif %}
diff --git a/coprs_frontend/coprs/templates/coprs/detail.html b/coprs_frontend/coprs/templates/coprs/detail.html
index 30b653c..7f6a977 100644
--- a/coprs_frontend/coprs/templates/coprs/detail.html
+++ b/coprs_frontend/coprs/templates/coprs/detail.html
@@ -1,7 +1,7 @@
{% extends "layout.html" %}
{% block title %}{{ copr.owner.name }}/{{ copr.name }} Copr{% endblock %}
{% block header %}Information for Copr {{ copr.owner.name }}/{{ copr.name }}{% endblock %}
-{% from "coprs/_builds_table.html" import builds_table %}
+{% from "coprs/_builds_table.html" import builds_table with context %}
{% from "coprs/_permissions_table.html" import permissions_table with context%}
{% from "coprs/_coprs_forms.html" import copr_build_form,
copr_build_cancel_form with context %}
diff --git a/coprs_frontend/coprs/templates/coprs/show_builds.html b/coprs_frontend/coprs/templates/coprs/show_builds.html
index 2432088..cf19cb8 100644
--- a/coprs_frontend/coprs/templates/coprs/show_builds.html
+++ b/coprs_frontend/coprs/templates/coprs/show_builds.html
@@ -2,7 +2,7 @@
{% block title %}Builds in {{ request.view_args['name'] }}{% endblock %}
{% block header %}Builds in {{ request.view_args['name'] }} Copr{% endblock %}
{% from "_helpers.html" import render_pagination %}
-{% from "coprs/_builds_table.html" import builds_table %}
+{% from "coprs/_builds_table.html" import builds_table with context %}
{% from "coprs/_coprs_forms.html" import copr_build_cancel_form %}
{% block body %}
{{ builds_table(builds) }}
diff --git a/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py b/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py
index f57efe9..57c3d7b 100644
--- a/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py
+++ b/coprs_frontend/tests/test_views/test_coprs_ns/test_general.py
@@ -138,6 +138,29 @@ class TestCoprDetail(CoprsTestCase):
r = c.get('/coprs/detail/{0}/{1}/'.format(self.u2.name, self.c2.name))
assert '/permissions_applier_change/' not in r.data
+ def test_copr_detail_doesnt_show_cancel_build_for_anonymous(self, f_users, f_coprs, f_builds):
+ r = self.tc.get('/coprs/detail/{0}/{1}/'.format(self.u2.name, self.c2.name))
+ assert '/cancel_build/' not in r.data
+
+ def test_copr_detail_doesnt_allow_non_submitter_to_cancel_build(self, f_users, f_coprs, f_builds):
+ with self.tc as c:
+ with c.session_transaction() as s:
+ s['openid'] = self.u1.openid_name
+
+ self.db.session.add_all([self.u2, self.c2])
+ r = c.get('/coprs/detail/{0}/{1}/'.format(self.u2.name, self.c2.name))
+ assert '/cancel_build/' not in r.data
+
+ def test_copr_detail_allows_submitter_to_cancel_build(self, f_users, f_coprs, f_builds):
+ with self.tc as c:
+ with c.session_transaction() as s:
+ s['openid'] = self.u2.openid_name
+
+ self.db.session.add_all([self.u2, self.c2])
+ r = c.get('/coprs/detail/{0}/{1}/'.format(self.u2.name, self.c2.name))
+ assert '/cancel_build/' in r.data
+
+
class TestCoprEdit(CoprsTestCase):
def test_edit_prefills_id(self, f_users, f_coprs):
with self.tc as c:
@@ -161,7 +184,6 @@ class TestCoprEdit(CoprsTestCase):
assert '<input id="copr_builder_1" name="copr_builder_1" type="checkbox" value="y">' in r.data
assert '<input checked id="copr_admin_1" name="copr_admin_1" type="checkbox" value="y">' in r.data
-
class TestCoprUpdate(CoprsTestCase):
def test_update_no_changes(self, f_users, f_coprs):
with self.tc as c:
10 years, 10 months
[copr] bkabrda-workspace: A little simplification... (26e2324)
by bkabrda@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit 26e23245cd37b3c7e8aae0cbf29c5ba64471eaf9
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Wed Nov 28 18:02:08 2012 +0100
A little simplification...
>---------------------------------------------------------------
coprs_frontend/coprs/models.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/coprs_frontend/coprs/models.py b/coprs_frontend/coprs/models.py
index 73166f6..69f446e 100644
--- a/coprs_frontend/coprs/models.py
+++ b/coprs_frontend/coprs/models.py
@@ -174,4 +174,4 @@ class Build(db.Model, Serializer):
@property
def cancelable(self):
- return True if self.state == 'pending' else False
+ return self.state == 'pending'
10 years, 10 months
[copr] bkabrda-workspace: Make sure build.pkgs is not None before splitting (422bcaf)
by bkabrda@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit 422bcaf09feeccb80a179ba8506549a2ad993996
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Wed Nov 28 16:43:12 2012 +0100
Make sure build.pkgs is not None before splitting
>---------------------------------------------------------------
.../coprs/templates/coprs/_builds_table.html | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/coprs_frontend/coprs/templates/coprs/_builds_table.html b/coprs_frontend/coprs/templates/coprs/_builds_table.html
index 47beb41..9366bdb 100644
--- a/coprs_frontend/coprs/templates/coprs/_builds_table.html
+++ b/coprs_frontend/coprs/templates/coprs/_builds_table.html
@@ -26,9 +26,11 @@
<td colspan=7>
<h4>Package URLs:</h4>
<ul class=packages-list>
- {% for pkg in build.pkgs.split() %}
- <li>{{ pkg }}</li>
- {% endfor %}
+ {% if build.pkgs is not none %}
+ {% for pkg in build.pkgs.split() %}
+ <li>{{ pkg }}</li>
+ {% endfor %}
+ {% endif %}
</ul>
</td>
</tr>
10 years, 10 months
[copr] bkabrda-workspace: Rewrite update_builds to be more legible, some more tests for it (2d295d0)
by bkabrda@fedorahosted.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : bkabrda-workspace
>---------------------------------------------------------------
commit 2d295d007edf72fe4aea9b6fe826dd196634b2e6
Author: Bohuslav Kabrda <bkabrda(a)redhat.com>
Date: Wed Nov 28 16:35:06 2012 +0100
Rewrite update_builds to be more legible, some more tests for it
>---------------------------------------------------------------
.../coprs/views/backend_ns/backend_general.py | 14 ++--
.../test_views/test_backend_ns/test_general.py | 77 +++++++++++++++++++-
2 files changed, 83 insertions(+), 8 deletions(-)
diff --git a/coprs_frontend/coprs/views/backend_ns/backend_general.py b/coprs_frontend/coprs/views/backend_ns/backend_general.py
index 1755e79..4c08e88 100644
--- a/coprs_frontend/coprs/views/backend_ns/backend_general.py
+++ b/coprs_frontend/coprs/views/backend_ns/backend_general.py
@@ -21,21 +21,21 @@ def waiting_builds():
@backend_ns.route('/update_builds/', methods = ['POST', 'PUT'])
@misc.backend_authenticated
def update_builds():
- build_ids = []
+ to_update = {}
for build in flask.request.json['builds']: # first get ids of sent builds
- build_ids.append(build['id'])
+ to_update[build['id']] = build
- if not build_ids:
+ if not to_update:
return json.dumps({'warning': 'No parsed builds'})
existing = {} # create a dict of existing builds {build.id: build, ...}
- for build in builds_logic.BuildsLogic.get_by_ids(None, build_ids).all():
+ for build in builds_logic.BuildsLogic.get_by_ids(None, to_update.keys()).all():
existing[build.id] = build
- non_existing_ids = list(set(build_ids) - set(existing.keys()))
+ non_existing_ids = list(set(to_update.keys()) - set(existing.keys()))
- for build in flask.request.json['builds']: # actually update existing builds
- builds_logic.BuildsLogic.update_state_from_dict(None, existing[build['id']], build)
+ for i, build in existing.items(): # actually update existing builds
+ builds_logic.BuildsLogic.update_state_from_dict(None, build, to_update[i])
db.session.commit()
diff --git a/coprs_frontend/tests/test_views/test_backend_ns/test_general.py b/coprs_frontend/tests/test_views/test_backend_ns/test_general.py
index 5f3eaa3..d7df4c2 100644
--- a/coprs_frontend/tests/test_views/test_backend_ns/test_general.py
+++ b/coprs_frontend/tests/test_views/test_backend_ns/test_general.py
@@ -26,7 +26,7 @@ class TestUpdateBuilds(CoprsTestCase):
{
"id": 1,
"copr_id": 2,
- "results": "http://server/results/$ownername/$coprname/",
+ "results": "http://server/results/foo/bar/",
"started_on": 1234
}
]
@@ -38,3 +38,78 @@ class TestUpdateBuilds(CoprsTestCase):
data = data)
assert json.loads(r.data)["updated_builds_ids"] == [1]
assert json.loads(r.data)["non_existing_builds_ids"] == []
+
+ updated = self.models.Build.query.filter(self.models.Build.id == 1).first()
+ assert updated.results == 'http://server/results/foo/bar/'
+ assert updated.started_on == 1234
+
+ def test_update_build_ended(self, f_users, f_coprs, f_builds):
+ data = """
+{
+ "builds":[
+ {
+ "id": 1,
+ "copr_id": 2,
+ "status": 1,
+ "ended_on": 12345
+ }
+ ]
+}
+ """
+ r = self.tc.post('/backend/update_builds/',
+ content_type='application/json',
+ headers = self.auth_header,
+ data = data)
+ assert json.loads(r.data)["updated_builds_ids"] == [1]
+ assert json.loads(r.data)["non_existing_builds_ids"] == []
+
+ updated = self.models.Build.query.filter(self.models.Build.id == 1).first()
+ assert updated.status == 1
+ assert updated.ended_on == 12345
+
+ def test_update_more_existent_and_non_existent_builds(self, f_users, f_coprs, f_builds):
+ data = """
+{
+ "builds":[
+ {
+ "id": 1,
+ "copr_id": 2,
+ "results": "http://server/results/foo/bar/",
+ "started_on": 1234
+ },
+ {
+ "id": 2,
+ "copr_id": 1,
+ "status": 0,
+ "ended_on": 123456
+ },
+ {
+ "id": 123321,
+ "copr_id": 1,
+ "status": 0,
+ "ended_on": 123456
+ },
+ {
+ "id": 1234321,
+ "copr_id": 2,
+ "results": "http://server/results/foo/bar/",
+ "started_on": 1234
+ }
+ ]
+}
+ """
+ r = self.tc.post('/backend/update_builds/',
+ content_type='application/json',
+ headers = self.auth_header,
+ data = data)
+
+ assert sorted(json.loads(r.data)["updated_builds_ids"]) == [1, 2]
+ assert sorted(json.loads(r.data)["non_existing_builds_ids"]) == [123321, 1234321]
+
+ started = self.models.Build.query.filter(self.models.Build.id == 1).first()
+ assert started.results == 'http://server/results/foo/bar/'
+ assert started.started_on == 1234
+
+ ended = self.models.Build.query.filter(self.models.Build.id == 2).first()
+ assert ended.status == 0
+ assert ended.ended_on == 123456
10 years, 10 months