Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
d43a3021
Commit
d43a3021
authored
Feb 28, 2013
by
Giorgos Korfiatis
Browse files
Update stress test to use the new transaction decorator
parent
0189a7fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
snf-astakos-app/astakos/test/stress.py
View file @
d43a3021
...
...
@@ -50,6 +50,7 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'synnefo.settings'
from
astakos.im.api.callpoint
import
AstakosCallpoint
from
astakos.im.functions
import
get_chain_of_application_id
from
views
import
submit
,
approve
,
join
,
leave
from
synnefo.lib.db.transaction
import
commit_on_success_strict
USERS
=
{}
PROJECTS
=
{}
...
...
@@ -87,6 +88,7 @@ def new_user():
return
r
.
data
[
'id'
],
email
@
commit_on_success_strict
()
def
new_users
(
count
):
for
i
in
range
(
count
):
uid
,
email
=
new_user
()
...
...
snf-astakos-app/astakos/test/views.py
View file @
d43a3021
...
...
@@ -33,25 +33,20 @@
from
datetime
import
datetime
,
timedelta
from
astakos.im.models
import
AstakosUser
,
PendingMembershipError
from
astakos.im.models
import
AstakosUser
from
astakos.im.functions
import
(
join_project
,
leave_project
,
submit_application
,
approve_application
)
from
astakos.im.project_xctx
import
cmd_project_transaction_context
from
astakos.im.retry_xctx
import
RetryException
from
synnefo.lib.db.transaction
import
commit_on_success_strict
@
c
md_project_transaction_context
(
sync
=
True
)
@
c
ommit_on_success_strict
(
)
def
join
(
proj_id
,
user_id
,
ctx
=
None
):
join_project
(
proj_id
,
user_id
)
@
c
md_project_transaction_context
(
sync
=
True
)
@
c
ommit_on_success_strict
(
)
def
leave
(
proj_id
,
user_id
,
ctx
=
None
):
try
:
leave_project
(
proj_id
,
user_id
)
except
PendingMembershipError
as
e
:
print
e
raise
RetryException
()
leave_project
(
proj_id
,
user_id
)
@
c
md_project_transaction_contex
t
()
@
c
ommit_on_success_stric
t
()
def
submit
(
name
,
user_id
,
prec
,
ctx
=
None
):
try
:
owner
=
AstakosUser
.
objects
.
get
(
id
=
user_id
)
...
...
@@ -73,6 +68,6 @@ def submit(name, user_id, prec, ctx=None):
app
=
submit_application
(
data
,
request_user
=
owner
)
return
app
.
id
@
c
md_project_transaction_context
(
sync
=
True
)
@
c
ommit_on_success_strict
(
)
def
approve
(
app_id
,
ctx
=
None
):
approve_application
(
app_id
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment