{"id":14,"date":"2018-10-05T16:29:00","date_gmt":"2018-10-05T16:29:00","guid":{"rendered":""},"modified":"2018-12-10T14:29:23","modified_gmt":"2018-12-10T14:29:23","slug":"hammerdb-command-line-build-and-test-examples","status":"publish","type":"post","link":"https:\/\/www.hammerdb.com\/blog\/uncategorized\/hammerdb-command-line-build-and-test-examples\/","title":{"rendered":"HammerDB command line build and test examples"},"content":{"rendered":"<p>With the HammerDB command line its very easy to script the schema build and automated test so that if you don&#8217;t have a GUI or don&#8217;t want to use one you can still access all of the HammerDB functionality. The following example is with MySQL on Linux but can easily apply to any database you choose.<\/p>\n<p><span style=\"font-size: 1rem;\">Firstly if you don&#8217;t have MySQL installed copy the client library to your home directory<\/span><\/p>\n<div class=\"post-body entry-content\">\n<pre class=\"yiv7786198409MsoNormal\">$ ls -l libmysqlclient.so.20\r\n-rw-r--r-- 1 mysql mysql 4237408 Apr 23 09:21 libmysqlclient.so.20<\/pre>\n<div class=\"yiv7786198409MsoNormal\">and add it to your path<\/div>\n<pre class=\"yiv7786198409MsoNormal\">$ export LD_LIBRARY_PATH=\/home\/intel:$LD_LIBRARY_PATH<\/pre>\n<div class=\"yiv7786198409MsoNormal\">The CLI command librarycheck will verify if the library can be loaded.<\/div>\n<pre class=\"yiv7786198409MsoNormal\">$ .\/hammerdbcli\r\nHammerDB CLI v3.1\r\nCopyright (C) 2003-2018 Steve Shaw\r\nType \"help\" for a list of commands\r\nThe xml is well-formed, applying configuration\r\nhammerdb&gt;librarycheck\r\n...\r\nChecking database library for MySQL\r\nSuccess ... loaded library mysqltcl for MySQL\r\n...<\/pre>\n<div class=\"yiv7786198409MsoNormal\">Using a text editor create a script with your configuration, such as follows. Note that in this example the build is going to be run on the database server itself.<\/div>\n<pre class=\"yiv7786198409MsoNormal\">$ more schemabuild.tcl\r\n#!\/bin\/tclsh\r\nputs \"SETTING CONFIGURATION\"\r\ndbset db mysql\r\ndiset connection mysql_host 127.0.0.1\r\ndiset connection mysql_port 3306\r\ndiset tpcc mysql_count_ware 800\r\ndiset tpcc mysql_partition true\r\ndiset tpcc mysql_num_vu 64\r\ndiset tpcc mysql_storage_engine innodb\r\nprint dict\r\nbuildschema<\/pre>\n<div class=\"yiv7786198409MsoNormal\">Then run the hammerdb CLI and type source schemabuild.tcl &#8211; hammerdb will then run the build you specified.<\/div>\n<pre class=\"yiv7786198409MsoNormal\">$ .\/hammerdbcli\r\nHammerDB CLI v3.1\r\nCopyright (C) 2003-2018 Steve Shaw\r\nType \"help\" for a list of commands\r\nThe xml is well-formed, applying configuration\r\nhammerdb&gt;source schemabuild.tcl<\/pre>\n<div class=\"yiv7786198409MsoNormal\">To run the test you can configure a script to automate a sequence of tests just like the autopilot feature in the GUI. This example runs tests from 1 right through to 104 virtual users. Note in this case the driver is now being run from a client system (remember to install the client library and check that it loads here as well) and logtotemp is set so that all of the output is captured to a file.<\/div>\n<pre class=\"yiv7786198409MsoNormal\">$ more mysqlrun.tcl\r\n#!\/bin\/tclsh\r\nproc runtimer { seconds } {\r\nset x 0\r\nset timerstop 0\r\nwhile {!$timerstop} {\r\nincr x\r\nafter 1000\r\n\u00a0 if { ![ expr {$x % 60} ] } {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 set y [ expr $x \/ 60 ]\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 puts \"Timer: $y minutes elapsed\"\r\n\u00a0 }\r\nupdate\r\nif {\u00a0 [ vucomplete ] || $x eq $seconds } { set timerstop 1 }\r\n\u00a0\u00a0\u00a0 }\r\nreturn\r\n}\r\nputs \"SETTING CONFIGURATION\"\r\ndbset db mysql\r\ndiset connection mysql_host 192.168.1.1\r\ndiset connection mysql_port 3306\r\ndiset tpcc mysql_driver timed\r\ndiset tpcc my_rampup 2\r\ndiset tpcc my_duration 5\r\nvuset logtotemp 1\r\nloadscript\r\nputs \"SEQUENCE STARTED\"\r\nforeach z { 1 2 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 } {\r\nputs \"$z VU TEST\"\r\nvuset vu $z\r\nvucreate\r\nvurun\r\nruntimer 600\r\nvudestroy\r\nafter 5000\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\nputs \"TEST SEQUENCE COMPLETE\"<\/pre>\n<div class=\"yiv7786198409MsoNormal\"><\/div>\n<div class=\"yiv7786198409MsoNormal\">Then as above run the script, it will now run the script unattended executing the sequence of tests.<\/div>\n<pre class=\"yiv7786198409MsoNormal\">$ .\/hammerdbcli\r\nHammerDB CLI v3.1\r\nCopyright (C) 2003-2018 Steve Shaw\r\nType \"help\" for a list of commands\r\nThe xml is well-formed, applying configuration\r\nhammerdb&gt;source mysqlrun.tcl<\/pre>\n<div class=\"yiv7786198409MsoNormal\">That&#8217;s all you need to build a schema and run a sequence of tests with HammerDB without the GUI.<\/div>\n<\/div>\n<p><script>\n  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n  })(window,document,'script','https:\/\/www.google-analytics.com\/analytics.js','ga');\n  ga('create', 'UA-87720879-1', 'auto');\n  ga('send', 'pageview');\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the HammerDB command line its very easy to script the schema build and automated test so that if you don&#8217;t have a GUI or don&#8217;t want to use one you can still access all of the HammerDB functionality. The following example is with MySQL on Linux but can easily apply to any database you &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.hammerdb.com\/blog\/uncategorized\/hammerdb-command-line-build-and-test-examples\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;HammerDB command line build and test examples&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"ppma_author":[5],"class_list":["post-14","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"authors":[{"term_id":5,"user_id":2,"is_guest":0,"slug":"hammerdb","display_name":"HammerDB","avatar_url":{"url":"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2018\/10\/logo-white.png","url2x":"https:\/\/www.hammerdb.com\/blog\/wp-content\/uploads\/2018\/10\/logo-white.png"},"author_category":"","user_url":"http:\/\/www.hammerdb.com","last_name":"","first_name":"","job_title":"","description":""}],"_links":{"self":[{"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/posts\/14","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/comments?post=14"}],"version-history":[{"count":10,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/posts\/14\/revisions"}],"predecessor-version":[{"id":295,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/posts\/14\/revisions\/295"}],"wp:attachment":[{"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/media?parent=14"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/categories?post=14"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/tags?post=14"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=14"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}