{"id":607,"date":"2019-11-28T10:38:34","date_gmt":"2019-11-28T10:38:34","guid":{"rendered":"http:\/\/www.hammerdb.com\/blog\/?p=607"},"modified":"2019-11-29T10:53:17","modified_gmt":"2019-11-29T10:53:17","slug":"automating-cli-tests-on-windows","status":"publish","type":"post","link":"https:\/\/www.hammerdb.com\/blog\/uncategorized\/automating-cli-tests-on-windows\/","title":{"rendered":"Automating CLI Tests on Windows"},"content":{"rendered":"\n<p>The information in this post is a duplicate of this GitHub Issue https:\/\/github.com\/TPC-Council\/HammerDB\/issues\/84. The issue regards running build and driver scripts automatically in Windows.\u00a0 As both build and driver examples are not given together in previous posts, the examples are copied here. This is intended as a template that you can take and modify for your own needs.<\/p>\n<p>A few things to note. Firstly these scripts are multithreaded so once you do build schema and vurun it is running multiple threads. We need a different approach for both because in the schema build we are waiting for all of the virtual users to finish (vwait forever), however for the driver we are waiting for a set period of time before terminating them. For the build I have created more warehouses but with 5 virtual users to show the multithreaded nature of the build. For the driver we have set a rampup and duration of 3 minutes in total (180 secs) &#8211; this runs in the virtual users, then in the main monitor virtual user it runs a timer &#8211; this is set to 200 seconds more than the rampup and driver combined (if it is less it will terminate the test before ending).<\/p>\n<p>With both I copied the scripts to C:\\Program Files\\HammerDB-3.3. I then did:<\/p>\n<p><code>hammerdbcli.bat auto autorunbuild.tcl<\/code><\/p>\n<p>and<\/p>\n<p><code>hammerdbcli.bat auto autorundrive.tcl<\/code><\/p>\n<p>When both are complete the shell will exit as intended therefore it is a good idea to set logtotemp to ensure that you receive both the output and errors (for example if the build script exits because the database already exists).<\/p>\n<p>Build Script &#8211; autorunbuild.tcl<\/p>\n<pre><code>puts \"SETTING CONFIGURATION\"\nglobal complete\nproc wait_to_complete {} {\nglobal complete\nset complete [vucomplete]\nif {!$complete} { after 5000 wait_to_complete } else { exit }\n}\nputs \"SETTING CONFIGURATION\"\ndbset db mssqls\ndiset connection mssqls_server {(local)\\SQLDEVELOP}\ndiset tpcc mssqls_count_ware 10\ndiset tpcc mssqls_num_vu 5\nvuset logtotemp 1\nbuildschema\nwait_to_complete\nvwait forever\n<\/code><\/pre>\n<p>Driver Script &#8211; autorundrive.tcl<\/p>\n<pre><code>#!\/bin\/tclsh\nproc runtimer { seconds } {\nset x 0\nset timerstop 0\nwhile {!$timerstop} {\nincr x\nafter 1000\n  if { ![ expr {$x % 60} ] } {\n          set y [ expr $x \/ 60 ]\n          puts \"Timer: $y minutes elapsed\"\n  }\nupdate\nif {  [ vucomplete ] || $x eq $seconds } { set timerstop 1 }\n    }\nreturn\n}\nputs \"SETTING CONFIGURATION\"\ndbset db mssqls\ndiset connection mssqls_server {(local)\\SQLDEVELOP}\ndiset tpcc mssqls_driver timed\ndiset tpcc mssqls_rampup 1\ndiset tpcc mssqls_duration 2\nvuset logtotemp 1\nloadscript\nputs \"SEQUENCE STARTED\"\nforeach z { 1 2 4 } {\nputs \"$z VU TEST\"\nvuset vu $z\nvucreate\nvurun\n#Runtimer in seconds must exceed rampup + duration\nruntimer 200\nvudestroy\nafter 5000\n}\nputs \"TEST SEQUENCE COMPLETE\"\n<\/code><\/pre>\n<p>A recommended editor that recognises TCL syntax for editing HammerDB script is <a href=\"https:\/\/www.vim.org\/\">Vim.\u00a0<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The information in this post is a duplicate of this GitHub Issue https:\/\/github.com\/TPC-Council\/HammerDB\/issues\/84. The issue regards running build and driver scripts automatically in Windows.\u00a0 As both build and driver examples are not given together in previous posts, the examples are copied here. This is intended as a template that you can take and modify for &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.hammerdb.com\/blog\/uncategorized\/automating-cli-tests-on-windows\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Automating CLI Tests on Windows&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"ppma_author":[5],"class_list":["post-607","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\/607","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=607"}],"version-history":[{"count":4,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/posts\/607\/revisions"}],"predecessor-version":[{"id":611,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/posts\/607\/revisions\/611"}],"wp:attachment":[{"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/media?parent=607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/categories?post=607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/tags?post=607"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.hammerdb.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}