Skip to content

Commit

Permalink
Added a first test based on the mysql integration test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Tudor Golubenco committed Dec 4, 2014
1 parent 3ee628e commit 511b7a0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/packetbeat
Submodule packetbeat updated from 3eed90 to f87f18
Binary file added tests/pcaps/mysql_int_string_operations.pcap
Binary file not shown.
1 change: 1 addition & 0 deletions tests/test_0001_mysql_spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def test_mysql_with_spaces(self):
objs = self.read_output()
assert all([o["type"] == "mysql" for o in objs])
assert len(objs) == 7
assert all([o["dst_port"] == 3306 for o in objs])

assert objs[0]["mysql"]["method"] == "SET"
assert objs[0]["mysql"]["tables"] == ""
Expand Down
5 changes: 3 additions & 2 deletions tests/test_0002_thrift_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_thrift_tutorial_socket(self):
assert objs[0]["request_raw"] == "ping()"
assert objs[11]["response_raw"] == "Exceptions: (1: (1: 4, 2: " + \
"\"Cannot divide by 0\"))"
assert all([o["dst_port"] == 9090 for o in objs])

def test_thrift_tutorial_framed(self):
self.render_config_template(
Expand Down Expand Up @@ -150,9 +151,9 @@ def test_thrift_integration(self):

assert objs[20]["thrift"]["request"]["method"] == "testString"
assert objs[20]["thrift"]["request"]["params"] == "(thing: \"" + \
("Python"*20) + "\")"
("Python" * 20) + "\")"
assert objs[20]["thrift"]["reply"]["returnValue"] == '"' + \
("Python"*20) + '"'
("Python" * 20) + '"'

def test_thrift_send_request_response(self):
# send_request=true send_response=false
Expand Down
26 changes: 26 additions & 0 deletions tests/test_0005_mysql_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from pbtests.packetbeat import TestCase

"""
Tests based on the MySQL integration test suite.
"""


class Test(TestCase):

def test_string_operations(self):
self.render_config_template(
mysql_ports=[13001]
)
self.run_packetbeat(pcap="mysql_int_string_operations.pcap")

objs = self.read_output()
assert all([o["type"] == "mysql" for o in objs])
assert len(objs) == 157
assert all([o["dst_port"] == 13001 for o in objs])

assert len([o for o in objs if o["mysql"]["method"] == "SELECT"]) == 134
assert len([o for o in objs if o["mysql"]["method"] == "SHOW"]) == 10
assert len([o for o in objs if o["mysql"]["method"] == "ALTER"]) == 4
assert len([o for o in objs if o["mysql"]["method"] == "SET"]) == 3
assert len([o for o in objs if o["mysql"]["method"] == "CREATE"]) == 2
assert len([o for o in objs if o["mysql"]["method"] == "CREATE"]) == 2

0 comments on commit 511b7a0

Please sign in to comment.