<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-21201213</id><updated>2012-02-16T01:47:18.976-08:00</updated><category term='testing'/><category term='redis'/><title type='text'>Computer Musings</title><subtitle type='html'>Collection of articles mainly related to computer programming</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ardsrk.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21201213/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://ardsrk.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Arvind Laxminarayan</name><uri>http://www.blogger.com/profile/00152275664702335916</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_oUsW02iJkaM/SVZer0AEXtI/AAAAAAAAATg/X1j6hO8pvRs/S220/arvind.jpeg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-21201213.post-803852278539288704</id><published>2010-12-31T10:21:00.000-08:00</published><updated>2010-12-31T10:29:30.269-08:00</updated><title type='text'>The year that was 2010</title><content type='html'>Below is a list of things I did in 2010:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Attended few Bangalore Python user group meets,&lt;/li&gt;&lt;li&gt;Helped organize inpycon2010,&lt;/li&gt;&lt;li&gt;Contributed a small patch to GNU Wget,&lt;/li&gt;&lt;li&gt;Joined &lt;a href="http://c42.in/"&gt;C42&lt;/a&gt;,&lt;/li&gt;&lt;li&gt;Dabbled in Redis, RoR, Ruby, Python, Scheme, Javascript, Haskell and C,&lt;/li&gt;&lt;li&gt;Shifted to Ubuntu ( from Fedora ),&lt;/li&gt;&lt;li&gt;Read few books.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21201213-803852278539288704?l=ardsrk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ardsrk.blogspot.com/feeds/803852278539288704/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21201213&amp;postID=803852278539288704' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21201213/posts/default/803852278539288704'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21201213/posts/default/803852278539288704'/><link rel='alternate' type='text/html' href='http://ardsrk.blogspot.com/2010/12/year-that-was-2010.html' title='The year that was 2010'/><author><name>Arvind Laxminarayan</name><uri>http://www.blogger.com/profile/00152275664702335916</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_oUsW02iJkaM/SVZer0AEXtI/AAAAAAAAATg/X1j6hO8pvRs/S220/arvind.jpeg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-21201213.post-8437665757257497547</id><published>2010-09-08T10:11:00.000-07:00</published><updated>2010-09-13T22:17:56.060-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='testing'/><category scheme='http://www.blogger.com/atom/ns#' term='redis'/><title type='text'>One thing I learned from Redis tests</title><content type='html'>&lt;div  style="text-align: right; font-family: verdana;font-family:lucida grande;"&gt;&lt;span style="font-style: italic;"&gt;Behind every useful product,&lt;br /&gt;there is an awesome test suite.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span style="font-family: verdana;font-family:lucida grande;" &gt;&lt;br /&gt;&lt;a href="http://code.google.com/p/redis/"&gt;Redis&lt;/a&gt; is an advanced key-value store. I have been following Redis development for quite sometime now. The speed of development is very pacy with numerous features and bug fixes being added almost every day. This is expected as it is a young database ( just over a year and a half ) trying to solve all the scalability problems for today's sophisticated web applications. Redis 2.0.0 was released recently with a lot of &lt;a href="http://github.com/antirez/redis/blob/2.0.0/00-RELEASENOTES"&gt;cool features&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;As you can see, Redis 2.0.0 accommodates a lot of features and bug fixes. This is where Redis tests comes in. The &lt;a href="http://github.com/antirez/redis/tree/master/tests/"&gt;Redis test suite&lt;/a&gt; is made of very well written bunch of &lt;a href="http://www.tcl.tk/"&gt;TCL&lt;/a&gt; scripts consisting of functional test cases that are executed against a running Redis server instance. The test cases test everything between basic operations like &lt;a href="http://code.google.com/p/redis/wiki/SetCommand"&gt;SET&lt;/a&gt; and complex operations like &lt;a href="http://code.google.com/p/redis/wiki/SortCommand"&gt;SORT&lt;/a&gt;. The test suite is kept up-to-date as features and bug fixes are added. This enables drastic code &lt;a href="http://twitter.com/antirez/status/16799267282"&gt;refactoring&lt;/a&gt; possible that is &lt;a href="http://en.wikipedia.org/wiki/Open_source_software_development#Refactoring.2C_rewrites_and_other_revamps"&gt;critical&lt;/a&gt; to the survival of an opensource project.&lt;br /&gt;&lt;br /&gt;Let's see how TCL interpreter interprets code. TCL interpreter expects every line of code to be of the form:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div  style="text-align: center; font-family: verdana;font-family:lucida grande;"&gt;command arg1 arg2 ... argN&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;span style="font-style: italic;"&gt;command&lt;/span&gt; can be a built-in TCL command, like &lt;span style="font-style: italic;"&gt;set&lt;/span&gt; (wow, Redis commands seem to be inspired from TCL commands) or  user-defined commands defined using the &lt;span style="font-style: italic;"&gt;proc&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style="font-family: verdana;font-family:lucida grande;" &gt;keyword:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div  style="text-align: center; font-family: verdana;font-family:lucida grande;"&gt;proc commandName {arg1 arg2 ... argN} {body}&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;Arguments can be any of the TCL built-in types, (plain variable, lists, dictionary, array, and so on) procedures (passed by their names) or even raw TCL code (of the form "&lt;span style="font-style: italic;"&gt;command arg1 arg2 ... argN&lt;/span&gt;"). Guess what the below snippet does:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;% proc execTcl {code} {&lt;a href="http://en.wikipedia.org/wiki/Uplevel"&gt;uplevel&lt;/a&gt; 1 $code}&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;Then,&lt;br /&gt;&lt;div style="text-align: center;"&gt;% execTcl {set a 10}&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;span style="font-family: verdana;font-family:lucida grande;" &gt;You will see why that mini-TCL tutorial was needed in a moment.&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://github.com/antirez/redis/blob/master/tests/support/server.tcl#L100"&gt;&lt;span style="font-style: italic;"&gt;start_server&lt;/span&gt;&lt;/a&gt; TCL procedure is the centrepiece of the test suite. The procedure has the following declaration:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div  style="text-align: center; font-family: verdana;font-family:lucida grande;"&gt;proc start_server {options {code undefined}}&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;Below is a list of important stuff it does in imperative order:&lt;br /&gt;&lt;br /&gt;*  Produce a configuration file taking settings from the &lt;span style="font-style: italic;"&gt;options&lt;/span&gt; argument if any. &lt;span style="font-style: italic;"&gt;start_server&lt;/span&gt; expects&lt;span style="font-style: italic;"&gt; options&lt;/span&gt; to be a list of key-value pairs. Sets the tags for set of tests to be executed in the redis instance started by this &lt;span style="font-style: italic;"&gt;start_server&lt;/span&gt; call. This enables you to selectively execute certain tests:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;make test TAGS="list"&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;* Start the Redis server instance:&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;exec src/redis-server $config_file &gt; $stdout 2&gt; $stderr &amp;amp;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;* Initialize a redis dictionary to identify the particular redis instance. Important is the key named &lt;span style="font-style: italic;"&gt;client&lt;/span&gt; whose value is a procedure (returned from a call to &lt;a href="http://github.com/antirez/redis/blob/master/tests/support/redis.tcl#L59"&gt;redis&lt;/a&gt;) that is called everytime there is a need to send/receive redis commands.  The &lt;span style="font-style: italic;"&gt;redis&lt;/span&gt; procedure returns a handle to &lt;a href="http://github.com/antirez/redis/blob/master/tests/support/redis.tcl#L70"&gt;__dispatch__&lt;/a&gt; that performs the network I/O. The handle is returned by a call to &lt;a href="http://wiki.tcl.tk/3044"&gt;interp&lt;/a&gt; command:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt; interp alias {} ::redis::redisHandle$id {} ::redis::__dispatch__ $id&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;* The &lt;span style="font-style: italic;"&gt;code&lt;/span&gt; passed in as an argument is executed.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;uplevel 1 $code&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;* &lt;span style="font-style: italic;"&gt;code&lt;/span&gt; consists of a series of Redis test cases.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;* After executing all the tests the redis instance is killed via a call to kill_server.&lt;br /&gt;&lt;br /&gt;So far I have really enjoyed the time I have spent studying Redis. Redis has certainly become a very valuable tool to the developer community. Thanks to &lt;a href="http://twitter.com/antirez"&gt;Salvatore&lt;/a&gt;, &lt;a href="http://twitter.com/pnoordhuis/"&gt;Peiter&lt;/a&gt; and all others involved in its development.&lt;br /&gt;&lt;br /&gt;By the way, what was the one thing I learned from Redis tests??&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: center; font-family: verdana;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/21201213-8437665757257497547?l=ardsrk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ardsrk.blogspot.com/feeds/8437665757257497547/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=21201213&amp;postID=8437665757257497547' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/21201213/posts/default/8437665757257497547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/21201213/posts/default/8437665757257497547'/><link rel='alternate' type='text/html' href='http://ardsrk.blogspot.com/2010/09/one-thing-i-learned-from-redis-tests.html' title='One thing I learned from Redis tests'/><author><name>Arvind Laxminarayan</name><uri>http://www.blogger.com/profile/00152275664702335916</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://4.bp.blogspot.com/_oUsW02iJkaM/SVZer0AEXtI/AAAAAAAAATg/X1j6hO8pvRs/S220/arvind.jpeg'/></author><thr:total>0</thr:total></entry></feed>
