Skip to content

Commit

Permalink
Common Test suites added
Browse files Browse the repository at this point in the history
  • Loading branch information
Eonblast committed Dec 13, 2011
1 parent 0d33806 commit 4fdf9ee
Show file tree
Hide file tree
Showing 19 changed files with 902 additions and 33 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.beam
*.html
ebin/*.beam
ebin/*.app
t/*.beam
Expand All @@ -12,4 +13,7 @@ priv/*.config
*.rej
readme.edoc
README.html

test/*.beam
test/*.html
test/ct_run*
test/variables-ct*
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ LIBDIR=$(shell erl -eval 'io:format("~s~n", [code:lib_dir()])' -s init stop -nos
VERSION=0.2
PKGNAME=emysql
APP_NAME=emysql
CRYPTO_PATH=/opt/local/var/macports/software/erlang/R14A_0/opt/local/lib/erlang/lib/crypto-2.0/ebin/

MODULES=$(shell ls -1 src/*.erl | awk -F[/.] '{ print $$2 }' | sed '$$q;s/$$/,/g')
MAKETIME=$(shell date)

all: app
(cd src;$(MAKE))

Expand Down Expand Up @@ -45,6 +47,14 @@ clean:
rm -f src/erl_crash.dump
rm -f erl_crash.dump
rm -f doc/*.html
rm -rf test/ct_run*
rm -f test/variables-ct*
rm -f test/*.beam
rm -f test/*.html
rm -rf ct_run*
rm -f variables-ct*
rm -f *.beam
rm -f *.html

package: clean
@mkdir $(PKGNAME)-$(VERSION)/ && cp -rf ebin include Makefile README src support t $(PKGNAME)-$(VERSION)
Expand All @@ -55,5 +65,8 @@ install:
@for i in ebin/*.beam ebin/*.app include/*.hrl src/*.erl; do install -m 644 -D $$i $(prefix)/$(LIBDIR)/$(PKGNAME)-$(VERSION)/$$i ; done

test: all
(cd test; ct_run -suite environment_SUITE basics_SUITE -pa ../ebin $(CRYPTO_PATH))

prove: all
(cd t;$(MAKE))
prove t/*.t
94 changes: 94 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,100 @@ For other record types, see include/emysql.hrl.
end || Foo <- Recs].


## Tests

Some Common Tests (Unit Tests) have been added in the `test` folder. They are not in shape yet to help finding more interesting problems. But they might help you find trip ups in your system set up.

**Please add a suite if you are proposing a pull request!**

Run the tests using make:

make test

You need the test database set up and a mysql server running as described above:

$ mysql [-u<user> -p]
mysql> create database hello_database;
mysql> use hello_database;
mysql> create table hello_table (hello_text char(20));
mysql> grant all privileges on hello_database.* to hello_username@localhost identified by 'hello_password';

The tests currently check access to the database (environment suite) and the same functionality as the samples (basics suite).

You see the test results when opening test/index.html with a browser. It should look like this:

<div style="border: 2px solid black; margin: 10px;">
<CENTER>
<H1>Test Results</H1>
</CENTER>
<BR />
<CENTER>
<A HREF="all_runs.html">All test runs in "test"</A>
<br /><br />
<TABLE border="3" cellpadding="5" BGCOLOR="#E4F0FE">
<th>Test Name</th>
<th>Label</th>
<th>Test Run Started</th>
<th><font color="#E4F0FE">_</font>Ok<font color="#E4F0FE">_</font></th>
<th>Failed</th>
<th>Skipped<br />(User/Auto)</th>

<th>Missing<br />Suites</th>
<th>Node</th>
<th>CT Log</th>
<th>Old Runs</th>

<TR valign="top">
<TD><FONT SIZE="-1"><A HREF="">me.Emysql.basics_SUITE</A></FONT></TD>
<TD ALIGN="center"><FONT SIZE="-1"><B>-</B></FONT></TD>
<TD><FONT SIZE="-1">Tue Dec 13 2011 04:17:29</FONT></TD>

<TD ALIGN="right">7</TD>
<TD ALIGN="right">0</TD>
<TD ALIGN="right">0 (0/0)</TD>
<TD ALIGN="right">0</TD>
<TD ALIGN="right"><FONT SIZE="-1">ct@machine</FONT></TD>
<TD><FONT SIZE="-1"><A HREF="">CT Log</A></FONT></TD>
<TD><FONT SIZE="-1">none</FONT></TD>
</TR>
<TR valign="top">
<TD><FONT SIZE="-1"><A HREF="">me.Emysql.environment_SUITE</A></FONT></TD>

<TD ALIGN="center"><FONT SIZE="-1"><B>-</B></FONT></TD>
<TD><FONT SIZE="-1">Tue Dec 13 2011 04:17:29</FONT></TD>
<TD ALIGN="right">6</TD>
<TD ALIGN="right">0</TD>
<TD ALIGN="right">0 (0/0)</TD>
<TD ALIGN="right">0</TD>
<TD ALIGN="right"><FONT SIZE="-1">ct@machine</FONT></TD>
<TD><FONT SIZE="-1"><A HREF="">CT Log</A></FONT></TD>
<TD><FONT SIZE="-1">none</FONT></TD>

</TR>
<TR valign="top">
<TD><B>Total</B></TD><TD> </TD>
<TD> </TD>
<TD ALIGN="right"><B>13</B></TD>
<TD ALIGN="right"><B>0</B></TD>
<TD ALIGN="right">0 (0/0)</TD>
<TD ALIGN="right"><B>0</B></TD>
<TD> </TD>
<TD> </TD>
</TR>
</TABLE>

</CENTER>
<P /><CENTER>
<BR /><BR />
<HR />
<P /><FONT SIZE="-1">
Copyright (C) 2011 <A HREF="">Open Telecom Platform</A><BR />
Updated: Tue Dec 13 2011 04:17:36<BR/>
</FONT>
</CENTER>
</div>


## History <a name="History"></a>

Open Source Erlang MySQL driver efforts are a fractured matter. You may find yourself digging in the sources to find out about their relationships with each other - and which one to pick. Here is a brief history.
Expand Down
12 changes: 11 additions & 1 deletion doc/changes.edoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
@doc
== Changes ==

=== 0.2 Stored Procedures and Docs ===
=== current 'master' branch ===

<li> proposed solution for issue #7</li>

=== current 'stable' branch ===

<li> connection re-opening after mysql server temporarily unreachable</li>
<li> restriction on PoolIDs to be atoms removed</li>
<li> providing for rebar</li>

=== 0.2 Stored Procedures and Docs ===

<li> Correct handling of stored procedures result packages</li>
<li> Module emysql_tcp extended to handle the flag SERVER_MORE_RESULTS_EXIST correctly</li>
Expand Down
10 changes: 5 additions & 5 deletions doc/emysql.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h4><a name="Implementation">Implementation</a></h4>
of this module. A lot gets repeated for default values in lesser arities.
The quintessential execute however is this, in execute/2:
<pre> execute(PoolId, Query, Args, Timeout)
when is_atom(PoolId) andalso (is_list(Query) orelse is_binary(Query)) andalso is_list(Args) andalso is_integer(Timeout) -&gt;
when (is_list(Query) orelse is_binary(Query)) andalso is_list(Args) andalso is_integer(Timeout) -&gt;

Connection =
emysql_conn_mgr:wait_for_connection(PoolId),
Expand Down Expand Up @@ -297,8 +297,8 @@ <h4><a name="Sample">Sample</a></h4>

Result = emysql:execute(hello_pool, hello_stmt, ["Hello%"]),

io:format("~n~s~n", [string:chars($-,72)]),
io:format("~p~n", [Result]),
%-% io:format("~n~s~n", [string:chars($-,72)]),
%-% io:format("~p~n", [Result]),

ok.</pre>
Output:
Expand Down Expand Up @@ -327,7 +327,7 @@ <h4><a name="Implementation">Implementation</a></h4>
ParamNamesBin = list_to_binary(string:join([[$@ | integer_to_list(I)] || I &lt;- lists:seq(1, length(Args))], ", ")),
StmtNameBin = atom_to_binary(StmtName, utf8),
Packet = &lt;&lt;?COM_QUERY, "EXECUTE ", StmtNameBin/binary, " USING ", ParamNamesBin/binary&gt;&gt;,
emysql_tcp:send_and_recv_packet(Connection#connection.socket, Packet, 0);
emysql_tcp:send_and_recv_packet(Connection#emysql_connection.socket, Packet, 0);
Error -&gt;
Error
end.</pre>
Expand Down Expand Up @@ -386,6 +386,6 @@ <h4><a name="From_the_Erlang_Manual">From the Erlang Manual</a></h4><p>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Feb 18 2011, 20:25:06.</i></p>
<p><i>Generated by EDoc, Dec 13 2011, 05:02:30.</i></p>
</body>
</html>
2 changes: 1 addition & 1 deletion doc/emysql_app.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ <h3 class="function"><a name="stop-1">stop/1</a></h3>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Feb 18 2011, 20:25:05.</i></p>
<p><i>Generated by EDoc, Dec 13 2011, 05:02:29.</i></p>
</body>
</html>
2 changes: 1 addition & 1 deletion doc/emysql_auth.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ <h3 class="function"><a name="do_handshake-3">do_handshake/3</a></h3>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Feb 18 2011, 20:25:05.</i></p>
<p><i>Generated by EDoc, Dec 13 2011, 05:02:29.</i></p>
</body>
</html>
8 changes: 4 additions & 4 deletions doc/emysql_conn.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h2><a name="index">Function Index</a></h2>
<tr><td valign="top"><a href="#open_connections-1">open_connections/1</a></td><td></td></tr>
<tr><td valign="top"><a href="#open_n_connections-2">open_n_connections/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#prepare-3">prepare/3</a></td><td></td></tr>
<tr><td valign="top"><a href="#reset_connection-2">reset_connection/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#reset_connection-3">reset_connection/3</a></td><td></td></tr>
<tr><td valign="top"><a href="#set_database-2">set_database/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#set_encoding-2">set_encoding/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#unprepare-2">unprepare/2</a></td><td></td></tr>
Expand Down Expand Up @@ -57,9 +57,9 @@ <h3 class="function"><a name="prepare-3">prepare/3</a></h3>
<p><tt>prepare(Connection, Name, Statement) -&gt; any()</tt></p>
</div>

<h3 class="function"><a name="reset_connection-2">reset_connection/2</a></h3>
<h3 class="function"><a name="reset_connection-3">reset_connection/3</a></h3>
<div class="spec">
<p><tt>reset_connection(Pools, Conn) -&gt; any()</tt></p>
<p><tt>reset_connection(Pools, Conn, StayLocked) -&gt; any()</tt></p>
</div>

<h3 class="function"><a name="set_database-2">set_database/2</a></h3>
Expand All @@ -79,6 +79,6 @@ <h3 class="function"><a name="unprepare-2">unprepare/2</a></h3>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Feb 18 2011, 20:25:05.</i></p>
<p><i>Generated by EDoc, Dec 13 2011, 05:02:29.</i></p>
</body>
</html>
26 changes: 16 additions & 10 deletions doc/emysql_conn_mgr.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ <h2><a name="index">Function Index</a></h2>
<tr><td valign="top"><a href="#handle_info-2">handle_info/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#init-1">init/1</a></td><td></td></tr>
<tr><td valign="top"><a href="#lock_connection-1">lock_connection/1</a></td><td></td></tr>
<tr><td valign="top"><a href="#pass_connection-1">pass_connection/1</a></td><td></td></tr>
<tr><td valign="top"><a href="#pools-0">pools/0</a></td><td></td></tr>
<tr><td valign="top"><a href="#remove_connections-2">remove_connections/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#remove_pool-1">remove_pool/1</a></td><td></td></tr>
<tr><td valign="top"><a href="#replace_connection-2">replace_connection/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#replace_connection_as_available-2">replace_connection_as_available/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#replace_connection_as_locked-2">replace_connection_as_locked/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#start_link-0">start_link/0</a></td><td></td></tr>
<tr><td valign="top"><a href="#terminate-2">terminate/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#unlock_connection-1">unlock_connection/1</a></td><td></td></tr>
<tr><td valign="top"><a href="#wait_for_connection-1">wait_for_connection/1</a></td><td></td></tr>
<tr><td valign="top"><a href="#waiting-0">waiting/0</a></td><td></td></tr>
</table>
Expand Down Expand Up @@ -81,6 +82,11 @@ <h3 class="function"><a name="lock_connection-1">lock_connection/1</a></h3>
<p><tt>lock_connection(PoolId) -&gt; any()</tt></p>
</div>

<h3 class="function"><a name="pass_connection-1">pass_connection/1</a></h3>
<div class="spec">
<p><tt>pass_connection(Connection) -&gt; any()</tt></p>
</div>

<h3 class="function"><a name="pools-0">pools/0</a></h3>
<div class="spec">
<p><tt>pools() -&gt; any()</tt></p>
Expand All @@ -96,9 +102,14 @@ <h3 class="function"><a name="remove_pool-1">remove_pool/1</a></h3>
<p><tt>remove_pool(PoolId) -&gt; any()</tt></p>
</div>

<h3 class="function"><a name="replace_connection-2">replace_connection/2</a></h3>
<h3 class="function"><a name="replace_connection_as_available-2">replace_connection_as_available/2</a></h3>
<div class="spec">
<p><tt>replace_connection(OldConn, NewConn) -&gt; any()</tt></p>
<p><tt>replace_connection_as_available(OldConn, NewConn) -&gt; any()</tt></p>
</div>

<h3 class="function"><a name="replace_connection_as_locked-2">replace_connection_as_locked/2</a></h3>
<div class="spec">
<p><tt>replace_connection_as_locked(OldConn, NewConn) -&gt; any()</tt></p>
</div>

<h3 class="function"><a name="start_link-0">start_link/0</a></h3>
Expand All @@ -111,11 +122,6 @@ <h3 class="function"><a name="terminate-2">terminate/2</a></h3>
<p><tt>terminate(Reason, State) -&gt; any()</tt></p>
</div>

<h3 class="function"><a name="unlock_connection-1">unlock_connection/1</a></h3>
<div class="spec">
<p><tt>unlock_connection(Connection) -&gt; any()</tt></p>
</div>

<h3 class="function"><a name="wait_for_connection-1">wait_for_connection/1</a></h3>
<div class="spec">
<p><tt>wait_for_connection(PoolId) -&gt; any()</tt></p>
Expand All @@ -128,6 +134,6 @@ <h3 class="function"><a name="waiting-0">waiting/0</a></h3>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Feb 18 2011, 20:25:05.</i></p>
<p><i>Generated by EDoc, Dec 13 2011, 05:02:29.</i></p>
</body>
</html>
2 changes: 1 addition & 1 deletion doc/emysql_statements.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ <h3 class="function"><a name="version-2">version/2</a></h3>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Feb 18 2011, 20:25:05.</i></p>
<p><i>Generated by EDoc, Dec 13 2011, 05:02:29.</i></p>
</body>
</html>
2 changes: 1 addition & 1 deletion doc/emysql_sup.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ <h3 class="function"><a name="start_link-0">start_link/0</a></h3>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Feb 18 2011, 20:25:05.</i></p>
<p><i>Generated by EDoc, Dec 13 2011, 05:02:29.</i></p>
</body>
</html>
8 changes: 7 additions & 1 deletion doc/emysql_tcp.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ <h1>Module emysql_tcp</h1>

<h2><a name="index">Function Index</a></h2>
<table width="100%" class=index border="0" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#recv_packet-1">recv_packet/1</a></td><td></td></tr>
<tr><td valign="top"><a href="#response-2">response/2</a></td><td></td></tr>
<tr><td valign="top"><a href="#send_and_recv_packet-3">send_and_recv_packet/3</a></td><td></td></tr>
</table>

Expand All @@ -24,13 +25,18 @@ <h3 class="function"><a name="recv_packet-1">recv_packet/1</a></h3>
<p><tt>recv_packet(Sock) -&gt; any()</tt></p>
</div>

<h3 class="function"><a name="response-2">response/2</a></h3>
<div class="spec">
<p><tt>response(Sock, Packet) -&gt; any()</tt></p>
</div>

<h3 class="function"><a name="send_and_recv_packet-3">send_and_recv_packet/3</a></h3>
<div class="spec">
<p><tt>send_and_recv_packet(Sock, Packet, SeqNum) -&gt; any()</tt></p>
</div>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Feb 18 2011, 20:25:05.</i></p>
<p><i>Generated by EDoc, Dec 13 2011, 05:02:29.</i></p>
</body>
</html>
2 changes: 1 addition & 1 deletion doc/emysql_tracer.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ <h3 class="function"><a name="trace_module-1">trace_module/1</a></h3>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Feb 18 2011, 20:25:05.</i></p>
<p><i>Generated by EDoc, Dec 13 2011, 05:02:29.</i></p>
</body>
</html>
2 changes: 1 addition & 1 deletion doc/emysql_util.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@ <h3 class="function"><a name="rnd-3">rnd/3</a></h3>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Feb 18 2011, 20:25:05.</i></p>
<p><i>Generated by EDoc, Dec 13 2011, 05:02:29.</i></p>
</body>
</html>
2 changes: 1 addition & 1 deletion doc/emysql_worker.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ <h3 class="function"><a name="start-1">start/1</a></h3>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Feb 18 2011, 20:25:05.</i></p>
<p><i>Generated by EDoc, Dec 13 2011, 05:02:28.</i></p>
</body>
</html>
Loading

0 comments on commit 4fdf9ee

Please sign in to comment.