Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PaymentServer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Administrator
PaymentServer
Commits
b7ae13bf
Commit
b7ae13bf
authored
4 years ago
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
Generate load more aggressively
parent
477be199
No related branches found
No related tags found
1 merge request
!64
Faster fingerprinting
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
misc/load-test.py
+39
-5
39 additions, 5 deletions
misc/load-test.py
with
39 additions
and
5 deletions
misc/load-test.py
+
39
−
5
View file @
b7ae13bf
...
...
@@ -13,13 +13,26 @@
#
# $ for n in $(seq 0 30); do sqlite3 vouchers.db "insert into vouchers (name) values ('aaa$n')"; done
#
# Then the test can be run as many times as necessary. Repeated redemptions
# are allowed since the same tokens are used on every run.
# Then the test can be run as many times as necessary.
#
# The `redeemed` table must be cleared before each test run. Random tokens
# are generated for each test run and the server will reject tokens from a new
# run if tokens from an old run are still present.
#
# $ sqlite3 vouchers.db "delete from redeemed"
#
# Originally written for https://github.com/PrivateStorageio/PaymentServer/issues/60
from
__future__
import
division
from
os
import
(
urandom
,
)
from
base64
import
(
b64encode
,
)
from
time
import
(
time
,
)
...
...
@@ -45,18 +58,39 @@ from twisted.internet.defer import (
returnValue
,
)
PARALLELISM
=
30
PARALLELISM
=
50
NUM_TOKENS
=
5000
def
a_random_token
():
return
b64encode
(
urandom
(
32
))
def
tokens_for_voucher
(
key
,
cache
=
{}):
if
key
not
in
cache
:
print
(
"
Generating tokens for {}
"
.
format
(
key
))
cache
[
key
]
=
list
(
a_random_token
()
for
_
in
range
(
NUM_TOKENS
)
)
else
:
print
(
"
Using cached tokens for {}
"
.
format
(
key
))
return
cache
[
key
]
@inlineCallbacks
def
redeem
(
client
,
index
):
times
=
[]
voucher
=
"
aaa{}
"
.
format
(
index
)
for
i
in
range
(
16
):
tokens
=
tokens_for_voucher
((
voucher
,
i
))
before
=
time
()
response
=
yield
client
.
post
(
url
=
"
http://127.0.0.1:8080/v1/redeem
"
,
data
=
dumps
({
"
redeemVoucher
"
:
"
aaa{}
"
.
format
(
index
)
,
"
redeemTokens
"
:
[
"
foo-{}-{}
"
.
format
(
index
,
i
)]
,
"
redeemVoucher
"
:
voucher
,
"
redeemTokens
"
:
tokens
,
"
redeemCounter
"
:
i
,
}),
headers
=
{
"
content-type
"
:
"
application/json
"
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment