Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tests_api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Show more breadcrumbs
hive
tests_api
Commits
8aac0997
Commit
8aac0997
authored
4 years ago
by
Dariusz Kędzierski
Browse files
Options
Downloads
Patches
Plain Diff
benchmark_generator.py moved to hivemind
parent
be68740e
No related branches found
No related tags found
1 merge request
!162
benchmark_generator.py moved to hivemind
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hivemind/benchmarks/README.md
+3
-1
3 additions, 1 deletion
hivemind/benchmarks/README.md
hivemind/benchmarks/benchmark_generator.py
+0
-71
0 additions, 71 deletions
hivemind/benchmarks/benchmark_generator.py
with
3 additions
and
72 deletions
hivemind/benchmarks/README.md
+
3
−
1
View file @
8aac0997
...
...
@@ -4,6 +4,8 @@ Script `benchmark_generator` will scan given test directory for tavern test file
test parameters from each file and will create benchmark test basing on that parameters. Benchmarks generated
from directory are stored in a single file.
Script moved to hivemind scripts/ci/ directory.
## Examples
```
bash
...
...
@@ -14,4 +16,4 @@ $ ./benchmark_generator.py <path_to_test_directory> <name_of_the_generated_bench
```
bash
$
./benchmark_generator.py ../tavern/condenser_api_patterns/ condenser_benchmarks.py http://127.0.0.1:8080
$
pytest condenser_benchmarks.py
```
\ No newline at end of file
```
This diff is collapsed.
Click to expand it.
hivemind/benchmarks/benchmark_generator.py
deleted
100755 → 0
+
0
−
71
View file @
be68740e
#!/usr/bin/python3
from
json
import
dumps
def
make_benchmark_header
():
return
"""
from requests import post
from json import dumps
def send_rpc_query(address, data):
response = post(address, data=data)
response_json = response.json()
return response_json
"""
def
make_benchmark
(
test_name
,
address
,
test_payload
):
return
"""
def test_{}(benchmark):
response_json = benchmark(send_rpc_query,
"
{}
"
, dumps({}))
error = response_json.get(
"
error
"
, None)
result = response_json.get(
"
result
"
, None)
assert error is not None or result is not None,
"
No error or result in response
"
"""
.
format
(
test_name
,
address
,
test_payload
)
def
get_request_from_yaml
(
path_to_yaml
):
import
yaml
yaml_document
=
None
with
open
(
path_to_yaml
,
"
r
"
)
as
yaml_file
:
yaml_document
=
yaml
.
load
(
yaml_file
,
Loader
=
yaml
.
BaseLoader
)
if
"
stages
"
in
yaml_document
:
if
"
request
"
in
yaml_document
[
"
stages
"
][
0
]:
json_parameters
=
yaml_document
[
"
stages
"
][
0
][
"
request
"
].
get
(
"
json
"
,
None
)
assert
json_parameters
is
not
None
,
"
Unable to find json parameters in request
"
return
dumps
(
json_parameters
)
return
None
def
make_test_name_from_path
(
test_path
):
splited
=
test_path
.
split
(
"
/
"
)
return
(
"
_
"
.
join
(
splited
[
-
3
:])).
replace
(
"
.
"
,
"
_
"
).
replace
(
"
-
"
,
"
_
"
)
def
make_benchmark_test_file
(
file_name
,
address
,
tests_root_dir
):
import
os
from
fnmatch
import
fnmatch
pattern
=
"
*.tavern.yaml
"
test_files
=
[]
for
path
,
subdirs
,
files
in
os
.
walk
(
tests_root_dir
):
for
name
in
files
:
if
fnmatch
(
name
,
pattern
):
test_files
.
append
(
os
.
path
.
join
(
path
,
name
))
with
open
(
file_name
,
"
w
"
)
as
benchmarks_file
:
benchmarks_file
.
write
(
make_benchmark_header
())
for
test_file
in
test_files
:
test_name
=
make_test_name_from_path
(
test_file
)
test_payload
=
get_request_from_yaml
(
test_file
)
benchmarks_file
.
write
(
make_benchmark
(
test_name
,
address
,
test_payload
))
benchmarks_file
.
write
(
"
\n
"
)
if
__name__
==
"
__main__
"
:
import
argparse
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
path_to_test_dir
"
,
type
=
str
,
help
=
"
Path to test directory for given xml file
"
)
parser
.
add_argument
(
"
benchmark_test_file_name
"
,
type
=
str
,
help
=
"
Name of the generated test file
"
)
parser
.
add_argument
(
"
target_ip_address
"
,
type
=
str
,
help
=
"
Address of the hivemind
"
)
args
=
parser
.
parse_args
()
make_benchmark_test_file
(
args
.
benchmark_test_file_name
,
args
.
target_ip_address
,
args
.
path_to_test_dir
)
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