@@ -54,6 +54,46 @@ public function testMissingFile() : void
5454$ parser ->getSessions ();
5555}
5656
57+ public function testMysqlVsMariadb () : void
58+ {
59+ $ parser = new \PHPFUI \MySQLSlowQuery \Parser (__DIR__ . '/logs/ignoredData.log ' );
60+ $ sessions = $ parser ->getSessions ();
61+ $ entries = $ parser ->getEntries ();
62+ $ this ->assertCount (9 , $ sessions );
63+ // See comments in logfile for why session 3-6 are buggy and 7-9 are not.
64+ $ this ->assertEquals ('c:\wamp64\bin\mysql\mysql8.0.21\bin\mysqld.exe, Version: 8.0.21 (MySQL Community Server - GPL) ' , $ sessions [0 ]->Server );
65+ $ this ->assertEquals ('c:\wamp64\bin\mysql\mysql8.0.21\bin\mysqld.exe, Version: 8.0.21 (MySQL Community Server - GPL) ' , $ sessions [1 ]->Server );
66+ $ this ->assertEquals ('Tcp Port: 3306, Named Pipe: /tmp/mysql.sock ' , $ sessions [2 ]->Server );
67+ $ this ->assertEquals ('Tcp port: 0 Unix socket: /run/mysqld/mysqld.sock ' , $ sessions [3 ]->Server );
68+ $ this ->assertEquals ('Tcp port: 0 Unix socket: /run/mysqld/mysqld.sock ' , $ sessions [4 ]->Server );
69+ $ this ->assertEquals ('Tcp port: 0 Unix socket: /run/mysqld/mysqld.sock ' , $ sessions [5 ]->Server );
70+ $ this ->assertEquals ('mysqld, Version: 10.7.1-MariaDB-1:10.7.1+maria~focal-log (mariadb.org binary distribution) ' , $ sessions [6 ]->Server );
71+ // It took until the previous session for mariadb to kick in, but going
72+ // forward "sessions without query entries" are parsed OK.
73+ $ this ->assertEquals ('mysqld, Version: 10.7.1-MariaDB-1:10.7.1+maria~focal-log (mariadb.org binary distribution) ' , $ sessions [7 ]->Server );
74+ $ this ->assertEquals ('mysqld, Version: 10.7.1-MariaDB-1:10.7.1+maria~focal-log (mariadb.org binary distribution) ' , $ sessions [8 ]->Server );
75+ $ this ->assertEquals ('Unix socket: /run/mysqld/mysqld.sock ' , $ sessions [8 ]->Transport );
76+ // See comments in logfile for why the query is not found in the first/third
77+ // entry (backward compatible style parsing). The comments are swept up into
78+ // a seventh fake entry.
79+ $ this ->assertCount (7 , $ entries );
80+ $ this ->assertEmpty ($ entries [0 ]->Query );
81+ $ this ->assertNotEmpty ($ entries [1 ]->Query );
82+ $ this ->assertEmpty ($ entries [2 ]->Query );
83+ $ this ->assertNotEmpty ($ entries [3 ]->Query );
84+ $ this ->assertNotEmpty ($ entries [4 ]->Query );
85+ $ this ->assertNotEmpty ($ entries [5 ]->Query );
86+ // Done on Mariadb only:
87+ // Comments above "Time: " are parsed:
88+ $ this ->assertEquals ('0.001519 ' , $ entries [4 ]->Query_time );
89+ // Extra properties:
90+ $ this ->assertEquals ('1 ' , $ entries [4 ]->Rows_affected );
91+ // "Time: 220907 18:55:33" is reformatted to be the same as mysql:
92+ $ this ->assertEquals ('2022-09-07T18:55:33.000000Z ' , $ entries [4 ]->Time );
93+ // Time is copied into next entry if not present in comment header:
94+ $ this ->assertEquals ('2022-09-07T18:55:33.000000Z ' , $ entries [5 ]->Time );
95+ }
96+
5797public function testSingleSession () : void
5898{
5999$ parser = new \PHPFUI \MySQLSlowQuery \Parser (__DIR__ . '/logs/singleSession.log ' );
@@ -120,44 +160,4 @@ public function testTripleSession() : void
120160$ this ->assertEquals ('0 ' , $ entry ->Rows_sent );
121161$ this ->assertEquals ('6 ' , $ entry ->Rows_examined );
122162}
123-
124- public function testMysqlVsMariadb () : void
125- {
126- $ parser = new \PHPFUI \MySQLSlowQuery \Parser (__DIR__ . '/logs/ignoredData.log ' );
127- $ sessions = $ parser ->getSessions ();
128- $ entries = $ parser ->getEntries ();
129- $ this ->assertCount (9 , $ sessions );
130- // See comments in logfile for why session 3-6 are buggy and 7-9 are not.
131- $ this ->assertEquals ('c:\wamp64\bin\mysql\mysql8.0.21\bin\mysqld.exe, Version: 8.0.21 (MySQL Community Server - GPL) ' , $ sessions [0 ]->Server );
132- $ this ->assertEquals ('c:\wamp64\bin\mysql\mysql8.0.21\bin\mysqld.exe, Version: 8.0.21 (MySQL Community Server - GPL) ' , $ sessions [1 ]->Server );
133- $ this ->assertEquals ('Tcp Port: 3306, Named Pipe: /tmp/mysql.sock ' , $ sessions [2 ]->Server );
134- $ this ->assertEquals ('Tcp port: 0 Unix socket: /run/mysqld/mysqld.sock ' , $ sessions [3 ]->Server );
135- $ this ->assertEquals ('Tcp port: 0 Unix socket: /run/mysqld/mysqld.sock ' , $ sessions [4 ]->Server );
136- $ this ->assertEquals ('Tcp port: 0 Unix socket: /run/mysqld/mysqld.sock ' , $ sessions [5 ]->Server );
137- $ this ->assertEquals ('mysqld, Version: 10.7.1-MariaDB-1:10.7.1+maria~focal-log (mariadb.org binary distribution) ' , $ sessions [6 ]->Server );
138- // It took until the previous session for mariadb to kick in, but going
139- // forward "sessions without query entries" are parsed OK.
140- $ this ->assertEquals ('mysqld, Version: 10.7.1-MariaDB-1:10.7.1+maria~focal-log (mariadb.org binary distribution) ' , $ sessions [7 ]->Server );
141- $ this ->assertEquals ('mysqld, Version: 10.7.1-MariaDB-1:10.7.1+maria~focal-log (mariadb.org binary distribution) ' , $ sessions [8 ]->Server );
142- $ this ->assertEquals ('Unix socket: /run/mysqld/mysqld.sock ' , $ sessions [8 ]->Transport );
143- // See comments in logfile for why the query is not found in the first/third
144- // entry (backward compatible style parsing). The comments are swept up into
145- // a seventh fake entry.
146- $ this ->assertCount (7 , $ entries );
147- $ this ->assertEmpty ($ entries [0 ]->Query );
148- $ this ->assertNotEmpty ($ entries [1 ]->Query );
149- $ this ->assertEmpty ($ entries [2 ]->Query );
150- $ this ->assertNotEmpty ($ entries [3 ]->Query );
151- $ this ->assertNotEmpty ($ entries [4 ]->Query );
152- $ this ->assertNotEmpty ($ entries [5 ]->Query );
153- // Done on Mariadb only:
154- // Comments above "Time: " are parsed:
155- $ this ->assertEquals ('0.001519 ' , $ entries [4 ]->Query_time );
156- // Extra properties:
157- $ this ->assertEquals ('1 ' , $ entries [4 ]->Rows_affected );
158- // "Time: 220907 18:55:33" is reformatted to be the same as mysql:
159- $ this ->assertEquals ('2022-09-07T18:55:33.000000Z ' , $ entries [4 ]->Time );
160- // Time is copied into next entry if not present in comment header:
161- $ this ->assertEquals ('2022-09-07T18:55:33.000000Z ' , $ entries [5 ]->Time );
162- }
163163}
0 commit comments