Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Db queries verification to tfb toolset verif procedure #5145

Merged
merged 167 commits into from
Nov 1, 2019
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
e31a1a1
Add toolset Db queries verification
jcheron Oct 11, 2019
9e834c5
[ci skip] revert easier debug
jcheron Oct 11, 2019
0bd1729
[ci skip] Reintegrate the modified files in PR https://github.com/Tec…
jcheron Oct 11, 2019
87358fb
[ci skip] Add check methods to Mysql Database
jcheron Oct 11, 2019
959d6ea
[ci skip] Add forgotten empty line
jcheron Oct 11, 2019
a5c826a
[ci skip] Add super class Database
jcheron Oct 11, 2019
c924771
[ci skip] call verify_queries
jcheron Oct 11, 2019
98a7e87
[ci skip] Add queries checking in Postgres & Mongodb
jcheron Oct 12, 2019
ceb7c35
[ci skip] Fix indentation
jcheron Oct 12, 2019
5a4659e
[ci skip] Fix tbl_name for Postgres
jcheron Oct 12, 2019
2fef1f2
[ci skip] db_type pb
jcheron Oct 12, 2019
9d7d3d7
[ci skip] staticmethod->classmethod
jcheron Oct 12, 2019
c666e12
[ci skip] cls attr in abstract_database
jcheron Oct 12, 2019
a309709
[ci skip] Remove cls arg in calls
jcheron Oct 12, 2019
d4a252d
[ci skip] test with abstractmethod
jcheron Oct 12, 2019
14c3f79
[ci skip] Fix indented block
jcheron Oct 12, 2019
6d5a047
[ci skip] Add return!
jcheron Oct 12, 2019
dfa081f
[ci skip] ABC?
jcheron Oct 12, 2019
5009909
[ci skip] Fix abstractmethod
jcheron Oct 12, 2019
be180ec
[ci skip] Add abstract methods in AbstractDatabase
jcheron Oct 12, 2019
4cf4f87
[ci skip] Add verification for updates
jcheron Oct 12, 2019
72859d8
[ci skip] add pass log
jcheron Oct 12, 2019
0c43414
[ci skip] Fix typo
jcheron Oct 12, 2019
105c48c
[ci skip] Add pass log for rows & rows_updated
jcheron Oct 12, 2019
0097962
[ci skip] Fix typos
jcheron Oct 12, 2019
28ebdb7
[ci skip] check updates in Mongo
jcheron Oct 12, 2019
9d64f5d
[ci skip] Include the error deviation for Mysql.
jcheron Oct 12, 2019
4ae27b4
[ci skip] remove the old deviation
jcheron Oct 12, 2019
2cbbd5e
[ci skip] Test with siege instead of ab
jcheron Oct 12, 2019
2b77cb1
[ci skip] Fix float error in Mysql
jcheron Oct 12, 2019
67b3326
[ci skip] create siege config
jcheron Oct 12, 2019
06e0491
[ci skip] create siege dir
jcheron Oct 12, 2019
1bfb419
[ci skip] siege keep alive
jcheron Oct 12, 2019
0861fe6
[ci skip] Fix typo
jcheron Oct 12, 2019
03d93fb
[ci skip]( pb in sh command
jcheron Oct 12, 2019
782ce2a
[skip ci] ( pb in sh
jcheron Oct 12, 2019
9ec0fdf
[ci skip] add siegerc file
jcheron Oct 12, 2019
b3436b0
[ci skip] try without mysql approximation
jcheron Oct 12, 2019
94dc12d
[ci skip] revert remove Mysql approx (1.001)
jcheron Oct 12, 2019
a2cc00e
[ci skip] fix getQueries in Mongodb (argument!)
jcheron Oct 12, 2019
fe804da
[ci skip] remove unused tbl_name arg in Mongodb
jcheron Oct 12, 2019
fce5e4b
[ci skip] Inclusion of Mongodb rows
jcheron Oct 12, 2019
da63f96
[ci skip] Fix pb with rows in Fortunes (Mongodb)
jcheron Oct 12, 2019
b5506b7
[ci skip] fortune count return 0 (mongodb)
jcheron Oct 12, 2019
510d38a
[ci skip] usage of count_documents({})
jcheron Oct 12, 2019
a29ca51
[ci skip] code documentation
jcheron Oct 13, 2019
288a554
[ci skip] Remove siege verbose
jcheron Oct 13, 2019
f9151ae
Ready for clean up
jcheron Oct 13, 2019
4a506e6
[ci skip] no query test for cached_queries
jcheron Oct 13, 2019
ccd2c50
[ci skip] Fix spaces
jcheron Oct 13, 2019
3d98293
[ci skip] display real number of rows without margin
jcheron Oct 13, 2019
ee2b121
[ci skip] try Mysql stats with global status
jcheron Oct 13, 2019
f542fe7
[ci skip] try with flush status (Mysql)
jcheron Oct 13, 2019
01e0ba5
[ci skip] give reload privileges to Mysql user
jcheron Oct 13, 2019
65aee78
[ci skip] revert flush status + global (Mysql)
jcheron Oct 13, 2019
bb257fe
[ci skip] Try with INFORMATION_SCHEMA.SESSION_STATUS (Mysql)
jcheron Oct 13, 2019
424f094
[ci skip] Performance_shema since 5.7
jcheron Oct 13, 2019
0d92d52
[ci skip] Remove updated rows from get_rows in Mysql
jcheron Oct 13, 2019
0581733
[ci skip] display queries refactoring
jcheron Oct 13, 2019
42f5fa3
[ci skip] add verbose to siege for Python frameworks pb
jcheron Oct 13, 2019
7c540ff
[ci skip] Update Postgres for table names with quotes in queries
jcheron Oct 13, 2019
243d6d4
[ci skip] Update Postgre stats regex
jcheron Oct 13, 2019
c6f5fd9
Remove siege verbose + Fix Python-pg pb
jcheron Oct 13, 2019
43cb7a6
[ci skip] Trying more precision for Mysql requests
jcheron Oct 14, 2019
c405dc8
[ci skip] Fix query (one field!)
jcheron Oct 14, 2019
a1325aa
[ci skip] Fix Mysql query
jcheron Oct 14, 2019
f41efd1
[ci skip] more precision in queries couting for Mysql
jcheron Oct 14, 2019
2cf7f25
[skip ci] add connexion infos
jcheron Oct 14, 2019
1115c04
[ci skip] Fix arg omited
jcheron Oct 14, 2019
41a070c
[ci skip] log db infos
jcheron Oct 15, 2019
35133ab
reduce travis execution time (1 repetition * 512) + add mysql stats i…
jcheron Oct 15, 2019
e5ed556
Add toolset Db queries verification
jcheron Oct 11, 2019
4f83b7e
[ci skip] revert easier debug
jcheron Oct 11, 2019
a7b9767
[ci skip] Reintegrate the modified files in PR https://github.com/Tec…
jcheron Oct 11, 2019
3413cd2
[ci skip] Add check methods to Mysql Database
jcheron Oct 11, 2019
846d814
[ci skip] Add forgotten empty line
jcheron Oct 11, 2019
cd2cb64
[ci skip] Add super class Database
jcheron Oct 11, 2019
835ba15
[ci skip] call verify_queries
jcheron Oct 11, 2019
704ed9f
[ci skip] Add queries checking in Postgres & Mongodb
jcheron Oct 12, 2019
e7afc79
[ci skip] Fix indentation
jcheron Oct 12, 2019
9868049
[ci skip] Fix tbl_name for Postgres
jcheron Oct 12, 2019
06e9622
[ci skip] db_type pb
jcheron Oct 12, 2019
80f1bb8
[ci skip] staticmethod->classmethod
jcheron Oct 12, 2019
b455ed9
[ci skip] cls attr in abstract_database
jcheron Oct 12, 2019
8bfa600
[ci skip] Remove cls arg in calls
jcheron Oct 12, 2019
c0303fe
[ci skip] test with abstractmethod
jcheron Oct 12, 2019
58af78a
[ci skip] Fix indented block
jcheron Oct 12, 2019
39cf694
[ci skip] Add return!
jcheron Oct 12, 2019
7342510
[ci skip] ABC?
jcheron Oct 12, 2019
508c0c1
[ci skip] Fix abstractmethod
jcheron Oct 12, 2019
24807c9
[ci skip] Add abstract methods in AbstractDatabase
jcheron Oct 12, 2019
52c2213
[ci skip] Add verification for updates
jcheron Oct 12, 2019
d3aff85
[ci skip] add pass log
jcheron Oct 12, 2019
2f77d7f
[ci skip] Fix typo
jcheron Oct 12, 2019
5a690af
[ci skip] Add pass log for rows & rows_updated
jcheron Oct 12, 2019
47c7b02
[ci skip] Fix typos
jcheron Oct 12, 2019
ebe3892
[ci skip] check updates in Mongo
jcheron Oct 12, 2019
7cf05a1
[ci skip] Include the error deviation for Mysql.
jcheron Oct 12, 2019
4eea455
[ci skip] remove the old deviation
jcheron Oct 12, 2019
36bcbcd
[ci skip] Test with siege instead of ab
jcheron Oct 12, 2019
787c3e3
[ci skip] Fix float error in Mysql
jcheron Oct 12, 2019
73401bb
[ci skip] create siege config
jcheron Oct 12, 2019
a5fdd52
[ci skip] create siege dir
jcheron Oct 12, 2019
477aed0
[ci skip] siege keep alive
jcheron Oct 12, 2019
a03d0af
[ci skip] Fix typo
jcheron Oct 12, 2019
c1111be
[ci skip]( pb in sh command
jcheron Oct 12, 2019
8174152
[skip ci] ( pb in sh
jcheron Oct 12, 2019
58a43eb
[ci skip] add siegerc file
jcheron Oct 12, 2019
5a6f5ca
[ci skip] try without mysql approximation
jcheron Oct 12, 2019
6f3105d
[ci skip] revert remove Mysql approx (1.001)
jcheron Oct 12, 2019
87c8767
[ci skip] fix getQueries in Mongodb (argument!)
jcheron Oct 12, 2019
138ad88
[ci skip] remove unused tbl_name arg in Mongodb
jcheron Oct 12, 2019
60ff2df
[ci skip] Inclusion of Mongodb rows
jcheron Oct 12, 2019
1b3cb1f
[ci skip] Fix pb with rows in Fortunes (Mongodb)
jcheron Oct 12, 2019
b3835b7
[ci skip] fortune count return 0 (mongodb)
jcheron Oct 12, 2019
589133b
[ci skip] usage of count_documents({})
jcheron Oct 12, 2019
f22bea3
[ci skip] code documentation
jcheron Oct 13, 2019
b4f32c4
[ci skip] Remove siege verbose
jcheron Oct 13, 2019
0aec230
Ready for clean up
jcheron Oct 13, 2019
fa45862
[ci skip] no query test for cached_queries
jcheron Oct 13, 2019
a965de4
[ci skip] Fix spaces
jcheron Oct 13, 2019
33ddc7b
[ci skip] display real number of rows without margin
jcheron Oct 13, 2019
f703f6f
[ci skip] try Mysql stats with global status
jcheron Oct 13, 2019
cd1bdcc
[ci skip] try with flush status (Mysql)
jcheron Oct 13, 2019
23df15b
[ci skip] give reload privileges to Mysql user
jcheron Oct 13, 2019
d75f174
[ci skip] revert flush status + global (Mysql)
jcheron Oct 13, 2019
851ee10
[ci skip] Try with INFORMATION_SCHEMA.SESSION_STATUS (Mysql)
jcheron Oct 13, 2019
ca87b78
[ci skip] Performance_shema since 5.7
jcheron Oct 13, 2019
fda0a21
[ci skip] Remove updated rows from get_rows in Mysql
jcheron Oct 13, 2019
577c219
[ci skip] display queries refactoring
jcheron Oct 13, 2019
59f14e2
[ci skip] add verbose to siege for Python frameworks pb
jcheron Oct 13, 2019
893a5f8
[ci skip] Update Postgres for table names with quotes in queries
jcheron Oct 13, 2019
4c49341
[ci skip] Update Postgre stats regex
jcheron Oct 13, 2019
51e3e97
Remove siege verbose + Fix Python-pg pb
jcheron Oct 13, 2019
27a254e
[ci skip] Trying more precision for Mysql requests
jcheron Oct 14, 2019
463fd0a
[ci skip] Fix query (one field!)
jcheron Oct 14, 2019
420ec1e
[ci skip] Fix Mysql query
jcheron Oct 14, 2019
96e4677
[ci skip] more precision in queries couting for Mysql
jcheron Oct 14, 2019
460d58a
[skip ci] add connexion infos
jcheron Oct 14, 2019
0e80e28
[ci skip] Fix arg omited
jcheron Oct 14, 2019
dcdb670
[ci skip] log db infos
jcheron Oct 15, 2019
71695a3
reduce travis execution time (1 repetition * 512) + add mysql stats i…
jcheron Oct 15, 2019
00663b5
Merge branch 'toolset-queries-verification' of https://github.com/php…
jcheron Oct 15, 2019
6fe5df6
[ci skip] Remove Mysql error infos: irrelevant
jcheron Oct 15, 2019
099c87a
Decrease concurrency for checking pg stats
jcheron Oct 17, 2019
730bb82
[ci skip] cancel concurrency change
jcheron Oct 17, 2019
ff43132
[ci skip] Possible bulk updates included
jcheron Oct 17, 2019
b8bf1e3
postgres factorization + run travis
jcheron Oct 17, 2019
6aa43a9
[ci skip] cleaner getQueries for Mysql
jcheron Oct 19, 2019
ffb1581
[ci skip] add marge for bulk update queries
jcheron Oct 19, 2019
d75ce0d
[ci skip] Fix typo
jcheron Oct 19, 2019
1ae6bce
[ci skip] warn for excessive number + restore query number for no bulk
jcheron Oct 19, 2019
7077838
run travis
jcheron Oct 19, 2019
9051a48
[ci skip] max(self.config.concurrency_levels) usage
jcheron Oct 20, 2019
6631bc3
Fixed Hibernate cache problem for ninja-standalone (demo)
jcheron Oct 25, 2019
dca78cc
[ci skip] import AtomicInteger !!
jcheron Oct 25, 2019
f3d5b65
travis for ninja + remove -1 in Mysql
jcheron Oct 25, 2019
2ad50ac
[ci skip] Add a margin based on the number of processors
jcheron Oct 25, 2019
5fde684
run travis with margin on queries (1.015)
jcheron Oct 25, 2019
9c26352
Increase default margin
jcheron Oct 29, 2019
085654b
[ci skip] Add transactions failures checking
jcheron Oct 29, 2019
55ad54d
[ci skip] better names
jcheron Oct 29, 2019
8097250
[ci skip] update to pgsql 12
jcheron Oct 30, 2019
8578cdf
Merge remote-tracking branch 'upstream/master' into toolset-queries-v…
jcheron Oct 31, 2019
cb2dac8
[ci skip] Remove failed transactions checking on Travis
jcheron Oct 31, 2019
87635cc
Merge remote-tracking branch 'upstream/master' into toolset-queries-v…
jcheron Oct 31, 2019
6a0db21
[ci skip] merge last 5 PRs
jcheron Oct 31, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ RUN apt-get -yqq install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::

RUN pip install colorama==0.3.1 requests MySQL-python psycopg2-binary pymongo docker==4.0.2 psutil

RUN apt-get install -yqq siege

# Fix for docker-py trying to import one package from the wrong location
RUN cp -r /usr/local/lib/python2.7/dist-packages/backports/ssl_match_hostname/ /usr/lib/python2.7/dist-packages/backports

Expand Down
10 changes: 8 additions & 2 deletions toolset/benchmark/test_types/db_type.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from toolset.benchmark.test_types.framework_test_type import FrameworkTestType
from toolset.benchmark.test_types.verifications import basic_body_verification, verify_headers, verify_randomnumber_object
from toolset.benchmark.test_types.verifications import basic_body_verification, verify_headers, verify_randomnumber_object, verify_queries_count


class DBTestType(FrameworkTestType):
Expand All @@ -9,7 +9,7 @@ def __init__(self, config):
'name': 'db',
'accept_header': self.accept('json'),
'requires_db': True,
'args': ['db_url']
'args': ['db_url', 'database']
}
FrameworkTestType.__init__(self, config, **kwargs)

Expand All @@ -22,6 +22,10 @@ def verify(self, base_url):
'randomNumber', both of which must map to integers
'''

# Initialization for query counting
repetitions = 2
expected_queries = repetitions * 512

url = base_url + self.db_url
headers, body = self.request_headers_and_body(url)

Expand Down Expand Up @@ -52,6 +56,8 @@ def verify(self, base_url):
problems += verify_randomnumber_object(response, url)
problems += verify_headers(self.request_headers_and_body, headers, url, should_be='json')

if len(problems) == 0:
problems += verify_queries_count(self, "World", url, 512, repetitions, expected_queries, expected_queries)
if len(problems) == 0:
return [('pass', '', url)]
else:
Expand Down
11 changes: 8 additions & 3 deletions toolset/benchmark/test_types/fortune_type.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from toolset.benchmark.test_types.framework_test_type import FrameworkTestType
from toolset.benchmark.fortune_html_parser import FortuneHTMLParser
from toolset.benchmark.test_types.verifications import basic_body_verification, verify_headers
from toolset.benchmark.test_types.verifications import basic_body_verification, verify_headers, verify_queries_count


class FortuneTestType(FrameworkTestType):
Expand All @@ -10,7 +10,7 @@ def __init__(self, config):
'name': 'fortune',
'accept_header': self.accept('html'),
'requires_db': True,
'args': ['fortune_url']
'args': ['fortune_url','database']
}
FrameworkTestType.__init__(self, config, **kwargs)

Expand All @@ -23,6 +23,10 @@ def verify(self, base_url):
FortuneHTMLParser whether the parsed string is a
valid fortune response
'''
# Initialization for query counting
repetitions = 2
expected_queries = repetitions * 512
expected_rows = 12 * expected_queries

url = base_url + self.fortune_url
headers, body = self.request_headers_and_body(url)
Expand All @@ -38,7 +42,8 @@ def verify(self, base_url):

if valid:
problems += verify_headers(self.request_headers_and_body, headers, url, should_be='html')

if len(problems) == 0:
problems += verify_queries_count(self, "fortune", url, 512, repetitions, expected_queries, expected_rows)
if len(problems) == 0:
return [('pass', '', url)]
else:
Expand Down
4 changes: 2 additions & 2 deletions toolset/benchmark/test_types/query_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self, config):
'name': 'query',
'accept_header': self.accept('json'),
'requires_db': True,
'args': ['query_url']
'args': ['query_url', 'database']
}
FrameworkTestType.__init__(self, config, **kwargs)

Expand All @@ -29,7 +29,7 @@ def verify(self, base_url):
cases = [('2', 'fail'), ('0', 'fail'), ('foo', 'fail'),
('501', 'warn'), ('', 'fail')]

problems = verify_query_cases(self, cases, url)
problems = verify_query_cases(self, cases, url, False)

if len(problems) == 0:
return [('pass', '', url + case) for case, _ in cases]
Expand Down
42 changes: 42 additions & 0 deletions toolset/benchmark/test_types/verifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
from toolset.databases import databases
from time import sleep

# Cross-platform colored text
from colorama import Fore, Style

def basic_body_verification(body, url, is_json_check=True):
'''
Takes in a raw (stringy) response body, checks that it is non-empty,
Expand Down Expand Up @@ -330,11 +333,16 @@ def verify_query_cases(self, cases, url, check_updates=False):
problems = []
MAX = 500
MIN = 1
# Initialization for query counting
repetitions = 2
expected_queries = 20 * repetitions * 512
expected_rows = expected_queries

# Only load in the World table if we are doing an Update verification
world_db_before = {}
if check_updates:
world_db_before = databases[self.database.lower()].get_current_world_table(self.config)
expected_queries = 2 * expected_queries

for q, max_infraction in cases:
case_url = url + q
Expand Down Expand Up @@ -384,4 +392,38 @@ def verify_query_cases(self, cases, url, check_updates=False):
expected_len, headers, body, case_url, max_infraction)
problems += verify_headers(self.request_headers_and_body, headers, case_url)

if hasattr(self, 'database'):
# verify the number of queries and rows read for 20 queries, with a concurrency level of 512, with 2 repetitions
problems += verify_queries_count(self, "world", url+"20", 512, repetitions, expected_queries, expected_rows, check_updates)
return problems


def verify_queries_count(self, tbl_name, url, concurrency=512, count=2, expected_queries=1024, expected_rows = 1024, check_updates = False):
'''
Checks that the number of executed queries, at the given concurrency level,
corresponds to: the total number of http requests made * the number of queries per request
'''
log("VERIFYING QUERY COUNT FOR %s" % url, border='-', color=Fore.WHITE + Style.BRIGHT)

problems = []

queries, rows, rows_updated, margin = databases[self.database.lower()].verify_queries(self.config, tbl_name, url, concurrency, count, check_updates)

problems.append(display_queries_count_result(queries, expected_queries, queries, "executed queries", url))
problems.append(display_queries_count_result(rows, expected_rows, int(rows / margin), "rows read", url))
if check_updates:
problems.append(display_queries_count_result(rows_updated, expected_rows, int(rows_updated / margin), "rows updated", url))

return problems

def display_queries_count_result(result, expected_result, displayed_result, caption, url):
'''
Returns a single result in counting queries, rows read or updated
'''
if result < expected_result :
return (
"fail",
"Only %s %s in the database out of roughly %s expected."
% (displayed_result, caption, expected_result), url)
else:
return ("pass","%s: %s/%s" % (caption.capitalize(), displayed_result,expected_result), url)
Loading