Project

General

Profile

1
<!--
2
  * sitemaps.html
3
  *
4
  *      Authors: Michael Daigle
5
  *    Copyright: 2008 Regents of the University of California and the
6
  *               National Center for Ecological Analysis and Synthesis
7
  *  For Details: http://www.nceas.ucsb.edu/
8
  *      Created: 2008 November 4
9
  *      Version: 
10
  *    File Info: '$ '
11
  * 
12
  * 
13
-->
14
<HTML>
15
<HEAD>
16
<TITLE>Testing Metacat</TITLE>
17
<!-- unfortunately, we have to look for the common css file in the 
18
     user docs directory.  This is because the user docs deploy to 
19
     the top level of the metacat docs on the knb web server -->
20
<link rel="stylesheet" type="text/css" href="../user/common.css">
21
<link rel="stylesheet" type="text/css" href="./default.css">
22
</HEAD> 
23
<BODY>
24
  <table width="100%">
25
    <tr>
26
      <td class="tablehead" colspan="2"><p class="label">Testing Metacat</p></td>
27
      <td class="tablehead" colspan="2" align="right">
28
        <a href="./building-metacat.html">Back</a> | <a href="./index.html">Home</a> | 
29
        <a href="./troubleshooting.html">Next</a>
30
      </td>
31
    </tr>
32
  </table>
33
      
34
  <div class="header1">Table of Contents</div>
35
  <div class="toc">
36
    <div class="toc1"><a href="#Intro">About Metacat Testing</a></div>
37
      <div class="toc2"><a href="#Overview">Overview</a></div>
38
      <div class="toc2"><a href="#MetacatImplementation">JUnit Implementation in Metacat</a></div>
39
    <div class="toc1"><a href="#WritingTestCase">Writing a Test Case</a></div>
40
      <div class="toc2"><a href="#Basics">Basics</a></div>
41
      <div class="toc2"><a href="#MCTestCase">MCTestCase Base Class</a></div>           
42
      <div class="toc2"><a href="#BestPractices">Best Practices</a></div>
43
    <div class="toc1"><a href="#RunTests">Running Test Cases</a></div>
44
      <div class="toc2"><a href="#AntTask">Ant task</a></div>
45
      <div class="toc2"><a href="#ConfigureMetacat">Configure Metacat For Testing</a></div>
46
      <div class="toc2"><a href="#RunAllTests">Run All Tests</a></div>
47
      <div class="toc2"><a href="#RunOneTest">Run One Test</a></div>
48
      <div class="toc2"><a href="#ViewingOutput">Viewing Test Output</a></div>
49
    <div class="toc1"><a href="#TestDbVersions">Testing Different Database Schema Versions</a></div>
50
      <div class="toc2"><a href="#Scripts">Scripts to Run</a></div>
51
      <div class="toc2"><a href="#CheckoutScripts">Get Scripts Via Checkout</a></div>
52
      <div class="toc2"><a href="#ScriptRepo">Script Repository</a></div>
53
      <div class="toc2"><a href="#ManuallyRunScripts">Manually Run Scripts</a></div>
54
    <div class="toc1"><a href="#UserTesting">User Testing</a></div>
55
      <div class="toc2"><a href="#TestingSkins">Testing Skins</a></div>
56
      <div class="toc2"><a href="#TestingWebLDAP">Testing LDAP Web Interface</a></div>
57
      <div class="toc2"><a href="#TestingRegistry">Testing Metadata Registry</a></div>
58
      <div class="toc2"><a href="#TestingEcogridRegistry">Testing the EcoGrid Registry Service</a></div>
59
    <div class="toc1"><a href="#LoadTesting">Load Testing</a></div>
60
      <div class="toc2"><a href="#LoadTestCodeFiles">Load Test Code Files</a></div>
61
      <div class="toc2"><a href="#GeneratingDictionaryFiles">Generating Dictionary Files</a></div>
62
      <div class="toc2"><a href="#InsertLoadTest">Insert Load Test</a></div>
63
      <div class="toc2"><a href="#SQueryLoadTest">SQuery Load Test</a></div>
64
      <div class="toc2"><a href="#ReadLoadTest">Read Load Test</a></div>
65
      <div class="toc2"><a href="#TestDriverScript">Test Driver Script</a></div>
66
    <div class="toc1"><a href="#ProfilingMetacat">Profiling Metacat</a></div>
67
  </div>  
68
  
69
  <a name="Intro"></a><div class="header1">About Metacat Testing</div>
70
  <a name="Overview"></a><div class="header2">Overview</div>
71
  <p>Metacat uses JUnit tests to test its core functionality.  These tests are
72
  good for testing the internal workings of an application, but don't test the 
73
  layout and appearance.  JUnit tests are meant to be one tool in the developer's 
74
  test arsinal. If you are not familiar with JUnit, you should search out some 
75
  tutorial documentation online.  One such tutorial is at 
76
  <a href="http://clarkware.com/articles/JUnitPrimer.html"> The Clarkware JUnit primer</a></p>
77
  
78
  <p>Metacat test cases will need to be run on the same server as the Metacat
79
  instance that you want to test.  Since Metacat and its test cases share the same
80
  configuration files, there is no way to run the tests remotely.</p>
81

    
82
  <a name="MetacatImplementation"></a><div class="header2">JUnit Implementation in Metacat</div>
83
  <p>Metacat test cases are located in the code at:
84
  <div class="code">&lt;workspace&gt;/metacat/test/edu/ucsb/nceas/metacat*/</div>  
85
  There you will find several java files that define JUnit tests.</p>
86
  
87
  <p> Test cases are run via an ant task, and output from the tests appears in 
88
  a build directory.  More on this to follow.</p>
89

    
90
  <a name="WritingTestCase"></a><div class="header1">Writing a Test Case</div>
91
  <a name="Basics"></a><div class="header2">Basics</div>
92
  <p>All you need to do to get your JUnit test included into the Metacat test 
93
  suite is to create it in one of the &lt;workspace&gt;/test/edu/ucsb/nceas/metacat*/
94
  directories.  The ant test tasks will know that it should be run. </p>
95
  
96
  <p> The following methods are required in a test case class:
97
  <ul>
98
    <li>public &lt;Constructor&gt;(String name) - The constructor for the test class. </li>
99
	<li>public void setUp() - Set up any dependencies for the tests.  This is run before each test case.</li> 
100
	<li>public void tearDown() - Release an resources used by the test.</li> 
101
	<li>public static Test suite() - define the test methods that need to be run.</li>
102
	<li>public void initialize() - define any global initializations that need to be done.</li>
103
  </ul>
104
  
105
  You will test for failure using the many assertion methods available.</p>
106
  
107
  <a name="MCTestCase"></a><div class="header2">MCTestCase Base Class</div>
108
  <p>Metacat test cases extend the MCTestCase base class, which holds common 
109
  methods and variables.  Some of these include:
110
  <ul>
111
    <li>SUCCESS/FALURE - boolean variables holding the values for success and failure. </li>
112
	<li>metacatUrl, username, password - connection variables used for LDAP connectivity</li> 
113
	<li>readDocumentIdWhichEqualsDoc() - method to read a document from Metacat server.</li> 
114
	<li>debug() - method to display debug output to standard error.</li>
115
  </ul>
116
  These are just a few examples to give you an idea of what is in MCTestCase.
117
  </p>
118
  
119
  <a name="BestPractices"></a><div class="header2">Best Practices</div>
120
  <p>The following are a few best practices when writing test cases:
121
  <ul>
122
    <li>Extend MCTestCase - Although strictly speaking, it is possible to bypass MCTestCase
123
    and just extend the JUnit TestCase class, you should not do so.   You should always
124
    extend the MCTestCase class.</li>
125
    <li>Extend Multiple Test Methods - Try to strike a balance between the number of test 
126
    methods and the size of each test.  If a test method starts to get huge, you might see
127
    if you can break it down into mulitple tests based on functionality.  If the number of
128
    tests in the test suite starts to get large, you might see if it makes sense to 
129
    separate them out into different test classes.</li>
130
	<li>Use assertion message - Most assertion methods have an alternate implementation that 
131
	includes a message parameter.  This message will be shown if the assertion fails.  You
132
	should use this version of the assertion method.</li> 
133
	<li>debug() - You should use the debug() method available in the MCTestCase class to
134
	display debug output as opposed to System.err.println().  The test configuration will
135
	allow you to turn off debug output when you use the debug() method.</li>
136
  </ul>
137

    
138
  <a name="RunTests"></a><div class="header1">Running Test Cases</div>
139
  <a name="AntTask"></a><div class="header2">Ant task</div>
140
  <p>As we discussed earlier, the test cases run from within ant tasks.  There is a 
141
  task to run all tests and a task to run individual tests. </p>
142
  <p>You will need to have ant installed on your system.  For downloads and instructions,
143
  visit the <a href="http://ant.apache.org/">Apache Ant site</a>.
144
  </p>
145
  <a name="ConfigureMetacat"></a><div class="header2">Configure Metacat For Testing</div>
146
  <p>The test cases will look at the server's metacat properties file for configuration, 
147
  so there are two places that need to be configured.</p>
148
  <p>First, you need to edit the configuration file at:
149
  <div class="code">&lt;workspace&gt;/metacat/test/test.properties</div>
150
  This should only hold one property: metacat.contextDir.  This should point to 
151
  the context directory for the metacat server you are testing.  For example:
152
  <div class="code">metacat.contextDir=/var/lib/tomcat6/webapps/knb</div>
153
  The test classes will use this to determine where to look for the server
154
  metacat.properties file.</p>
155
  
156
  <p>the remainder of the configuration needs to happen in the actual server's 
157
  metacat.properties file located at:
158
  <div class="code">&lt;workspace&gt;/metacat/lib/metacat.properties</div>
159
  You will need to verify that all test.* properties are set correctly:
160
  <ul>
161
    <li>test.printdebug - true if you want debug output, false otherwise </li>
162
    <li>test.metacatUrl - the url for the metacat servlet (i.e. http://localhost:8080/knb/metacat)</li>
163
    <li>test.contextUrl - the url for the metacat web service (i.e. http://localhost:8080/knb)</li>
164
    <li>test.metacatDeployDir - the directory where metacat is physically deployed (i.e. /usr/local/tomcat/webapps/knb)</li>
165
    <li>test.mcUser - the first metacat test user ("uid=kepler,o=unaffiliated,dc=ecoinformatics,dc=org" should be fine)</li>
166
    <li>test.mcPassword - the first metacat test password ("kepler" should be fine)</li>
167
    <li>test.mcAnotherUser - the second metacat test user.  This user must be a member of the knb-usr 
168
        group in ldap. ("uid=test,o=NCEAS,dc=ecoinformatics,dc=org" should be fine)</li>
169
    <li>test.mcAnotherPassword - the second metacat test password ("test" should be fine)</li>
170
    <li>test.piscoUser - the pisco test user ("uid=piscotest,o=PISCO,dc=ecoinformatics,dc=org" should be fine)</li>
171
    <li>test.piscoPassword - the pisco test password ("testPW" should be fine)</li>
172
    <li>test.lterUser - the lter test user ("uid=tmonkey,o=LTER,dc=ecoinformatics,dc=org" should be fine)</li>
173
    <li>test.lterPassword - the lter test password ("T3$tusr" should be fine)</li>
174
    <li>test.testProperty - a property to verify that we can read properties (leave as "testing")</li>
175
  </ul>
176
  </p>
177
  
178
  <p>Note that none of the test users should also be administrative users.  This will mess up 
179
  the access tests since some document modifications will succeed when we expect them to fail.</p>
180
  
181
  <p>Once this is done, you will need to rebuild and redeploy the Metacat server.  Note that
182
  changing these properties does nothing to change the way the Metacat server runs.  Rebuilding
183
  and redeploying merely makes the test properties available to the JUnit tests.</p>
184
  
185
  <a name="RunAllTests"></a><div class="header2">Run All Tests</div>
186
  <p>To run all tests, go to the &lt;workspace&gt;/metacat directory and type</p>
187
  <div class="code">ant clean test</div>
188
  You will see a line to standard output summarizing each test result.
189
  </p>
190
  
191
  <a name="RunOneTest"></a><div class="header2">Run One Test</div>
192
  <p>To run one test, go to the &lt;workspace&gt;/metacat directory and type</p>
193
  <div class="code">ant clean runonetest -Dtesttorun=&lt;test_name&gt;</div>
194
  Where &lt;test_name&gt; is the name of the JUnit test class (without .java on 
195
  the end).  You will see debug information print to standard error.
196
  </p>
197
  
198
  <a name="ViewingOutput"></a><div class="header2">Viewing Test Output</div>
199
  <p>Regardless of whether you ran one test or all tests, you will see output in
200
  the Metacat build directory in your code at:
201
  <div class="code">&lt;workspace&gt;/metacat/build</div>
202
  There will be one output file for each test class.  The files will look like 
203
  <div class="code">TEST-edu.ucsb.nceas.&lt;test_dir&gt;.&lt;test_name&gt;.txt</div>
204
  where &lt;test_dir&gt; is the metacat* directory where the test lives and 
205
  &lt;test_name&gt; is the name of the JUnit test class. These output files will have
206
  all standard error and standard out output as well as information on assertion 
207
  failures in the event of a failed test.
208
  </p>
209
  
210
  <a name="TestDbVersions"></a><div class="header1">Testing Different Database Schema Versions</div>
211
  <p>Now and again it is necessary to restore your test database to an older schema version
212
  either because you need to test upgrade functionality, or you need to test backwords 
213
  compatibility of code.  This section describes how to get your db schema to an older 
214
  version.
215
  
216
  <a name="Scripts"></a><div class="header2">Scripts to Run</div>
217
  <p>It is assumed that you have an empty metacat database up and running with a 
218
  metacat user.
219
  <p>There are two types of scripts that need to be run in order to create a Metacat
220
  schema:</p>
221
  <ul>
222
  <li>xmltables-&lt;dbtype&gt;.sql - where &lt;dbtype&gt; is either oracle or postgres
223
  depending on what type of database you are running against.  This script creates the
224
  necessary tables for Metacat.</li>
225
  <li>loaddtdschema-&lt;dbtype&gt;.sql - where &lt;dbtype&gt; is either oracle or postgres
226
  depending on what type of database you are running against.  This script creates the
227
  necessary seed data for Metacat.</li>
228
  </ul> 
229
  
230
  <a name="CheckoutScripts"></a><div class="header2">Get Scripts Via Checkout</div>
231
  <p>One way to get the scripts you need is to check out the release tag for the version
232
  of metacat that you want to install.  You can then run the two scripts shown above to
233
  create your database.</p>
234
  
235
  <a name="ScriptRepo"></a><div class="header2">Script Repository</div>
236
  <p>For convenience, the scripts to create each version have been extracted and 
237
  checked into:</p>
238
    <div class="code">&lt;metacat_code&gt;/src/scripts/metacat-db-versions</div>
239
  <p>The files look like:</p>
240
  <ul>
241
  <li>&lt;version&gt;_xmltables-&lt;dbtype&gt;.sql - where &lt;version&gt; is the version
242
  of the schema that you want to create and &lt;dbtype&gt; is either oracle or postgres
243
  depending on what type of database you are running against.  This script creates the
244
  necessary tables for Metacat.</li>
245
  <li>&lt;version&gt;_loaddtdschema-&lt;dbtype&gt;.sql - where &lt;version&gt; is the version
246
  of the schema that you want to create and &lt;dbtype&gt; is either oracle or postgres
247
  depending on what type of database you are running against.  This script creates the
248
  necessary seed data for Metacat.</li>
249
  <li>&lt;version&gt;_cleanall-&lt;dbtype&gt;.sql - where &lt;version&gt; is the version
250
  of the schema that you want to create and &lt;dbtype&gt; is either oracle or postgres
251
  depending on what type of database you are running against. This is a convenience script
252
  to clean out the changes for that version.</li>
253
  </ul>
254
  
255
  <a name="ManuallyRunScripts"></a><div class="header2">Manually Run Scripts</div>
256
  <p>For instructions on running database scripts manually, please refer to:
257
  <a href="../user/run-db-scripts.html">how to run database scripts</a></p>
258
    
259
  <a name="UserTesting"></a><div class="header1">User Testing</div>
260
  <p>The following sections describe some basic end user testing to stress
261
  code that might not get tested by unit testing.</p>
262
  
263
  <a name="TestingSkins"></a><div class="header2">Testing Skins</div>  
264
  <p>For each Skin:</p>
265
  <ul>
266
  <li>View main skin page by going to:
267
    <div class="code">http://dev.nceas.ucsb.edu/knb/style/skins/&lt;skin_name&gt;</div>
268
  for each skin, where &lt;skin_name&gt; is in:
269
    <div class="code">default, nceas, esa, knb, lter, ltss, obfs, nrs, sanparks, saeon</div>  
270
  Note that the kepler skin is installed on a different metacat instance and can be found at:
271
    <div class="code">http://kepler-dev.nceas.ucsb.edu/kepler</div>
272
  </li>
273
  <li>Test logging in.  Where applicable (available on the skin) log in using an LDAP account.</li>
274
  <li>Test Basic searching
275
     <ul>
276
     <li>Do a basic search with nothing in the search field.  Should return all docs.</li>
277
     <li>Select a distinct word in the title of a doc.  Go back to main page and search for 
278
     that word.</li>
279
     <li>Select the link to the doc and open the metadata.  Choose a distinct word from a 
280
     field that is not Title, Abstract, Keywords or Personnel.  Go back to the main page and 
281
     search all fields (if applicable)</li>
282
     </ul>
283
  </li>   
284
  <li>Test Advanced Searching
285
     <ul>
286
     <li>On the main page, choose advanced search (if applicable)</li>
287
     <li>Test a variety of different search criteria</li>
288
     </ul>
289
  </li>
290
  <li>Test Registry (if applicable)
291
     <ul>
292
     <li>Create a new account</li>
293
     <li>use the "forgot your password" link</li>
294
     <li>change your password</li>
295
     </ul>
296
  </li>
297
  <li>Test Viewing Document
298
     <ul>
299
     <li>Use your search to find a document</li>
300
     <li>Choose the link to a document - you should see document details
301
     <li>In a separate browser, try the shortcut to the doc:
302
       <div class="code">http://dev.nceas.ucsb.edu/knb/metacat/&lt;doc_id&gt;/&lt;skin_name&gt;</div>
303
     You should see the same results as going to the doc via search.</li>
304
     </ul>
305
  </li>
306
  <li>Download Metadata
307
     <ul>
308
     <li>Choose the metadata download</li>
309
     <li>Save the file</li>
310
     <li>view contents for basic validity (contents exist, etc)</li>
311
     </ul>
312
  </li>
313
  <li>Download Data
314
     <ul>
315
     <li>Choose the data download</li>
316
     <li>view the data for basic validity (contents exist, etc)</li>
317
     </ul>
318
  </li>
319
  <li>View Data Table
320
     <ul>
321
     <li>Find a document with a data table</li>
322
     <li>Choose to view the data table</li>
323
     <li>view the data table for basic validity (contents exist, etc)</li>
324
     </ul>
325
  </li>
326
  </ul>
327
   
328
  <a name="TestingWebLDAP"></a><div class="header2">Testing LDAP Web Interface</div>  
329
  <p>The following skins use a perl based LDAP web interface to create
330
     accounts, change passwords and reset forgotten passwords: </p>
331
     <div class="code">default, nceas, esa, knb, lter, ltss, obfs, nrs, sanparks, saeon</div>
332
  <p>Following the instructions in the <a href="#TestingSkins"> Testing Skins</a>  section
333
     go to each of these skins and test:</p>
334
  
335
  <ul>
336
  <li>Create LDAP Account
337
    <ul>
338
    <li>Choose the "Create a New Account" link</li>
339
    <li>Fill out the required information.
340
      <ul>
341
      <li>Choose a username that will be easy to find and remove from ldap later.</li>
342
      <li>Use your real email address</li>
343
      </ul>
344
    </li>  
345
    <li>Hit the "Register" button</li>
346
    <li>You may see a page with similar accounts.  If so, choose to continue.</li>
347
    <li>You should get a "Registration Succeeded" message.</li>
348
    </ul>
349
  </li>  
350
  <li>Change LDAP Password (if available)</li>
351
    <ul>
352
    <li>Choose the "Change Your Password" link</li>
353
    <li>Fill out the requested information</li>
354
    <li>Hit the "Change password" button</li>
355
    <li>You should get a "Your password has been changed" message.</li>
356
    </ul>
357
  </li>   
358
  <li>Request Forgotten LDAP Password Reset
359
    <ul>
360
    <li>Choose the "Forgot Your Password" link</li>
361
    <li>Enter your username</li>
362
    <li>Hit the "Reset Password" button</li>
363
    <li>You should get a "Your password has been reset" message.</li>
364
    <li>You should get an email with your new password</li>
365
    <li>Verify that you can log in with the new password</li>
366
    </ul>
367
  </li>
368
  </ul>
369
   
370
  <a name="TestingRegistry"></a><div class="header2">Testing Metadata Registry</div>   
371
  <p>The following skins use a perl based registry service to register metadata and
372
     data in metacat via the web: </p>
373
     <div class="code">nceas, esa, ltss, obfs, nrs, sanparks, saeon</div>
374
  <p>Following the instructions in the <a href="#TestingSkins"> Testing Skins</a> section
375
     go to each of these skins and test:</p>
376
     
377
  <ul>
378
  <li>Choose the "Register Dataset" link</li>
379
  <li>Fill out required fields.  Note that there are typically many different fields.  
380
      You should test out different combinations including attaching datasets if
381
      available.</li>
382
  <li>Hit the "Submit Dataset" button</li>
383
  <li>Review the information for accuracy</li>
384
  <li>Submit the data set</li>
385
  <li>You should get a "Success" message.</li>
386
  <li>Search for the data set in metacat and review for accuracy</li>
387
  </ul>
388
       
389
  <a name="TestingEcogridRegistry"></a><div class="header2">Testing the EcoGrid Registry Service</div>  
390
  <p>The EcoGrid registry service maintains a database of systems that are available to EcoGrid. Primarily, 
391
  these are Metacat instances which are built with the EcoGrid service automatically activated.  Testing
392
  the registry service is somewhat complicated.  The procedure described here uses Eclipse to test. 
393
  These instructions assume that you have Eclipse installed and the Seek project set up as a Java project
394
  in Eclipse.</p>
395
  
396
  <ul>
397
  <li>Configure the Seek project in Eclipse
398
    <ul>
399
    <li>Right click on the Seek project and go to Properties->Java Build Path->Source</li>
400
    <li>Only the following two direcories should be set up as source:
401
      <ul>
402
      <li>seek/projects/ecogrid/src</li>
403
      <li>seek/projects/ecogrid/tests</li>
404
      </ul>
405
    </li>
406
    <li>Right click on the Seek project and go to Properties->Java Build Path->Libraries</li>
407
    <li>Add all Jars from:
408
      <ul>
409
      <li>seek/projects/ecogrid/lib/</li>
410
      <li>seek/projects/ecogrid/lib/axis-1_3/</li>
411
      <li>seek/projects/ecogrid/build/lib/</li>
412
      </ul>
413
    </li>  
414
    <li>If you do not already have an Ant view open in Eclipse, in the menu, go to 
415
        Window->Show View->Ant</li>
416
    <li>drag the file from the seek project at seek/projects/ecogrid/build.xml into
417
        the Ant window you just opened.</li>
418
    <li>Double click the serverjar and stubjar targets to build those jar files.<li>
419
    <li>Right click on the Seek project and go to Properties->Java Build Path->Libraries</li>
420
    <li>Add the two Jar files you just created:
421
      <ul>
422
      <li>seek/projects/ecogrid/build/lib/RegistryServiceImpl.jar</li> 
423
      <li>seek/projects/ecogrid/build/lib/RegistryService-stub.jar</li>   
424
      </ul> 
425
    </li>  
426
    </ul>
427
  </li>
428
  <li>View the RegistryServiceClient usage
429
    <ul>
430
    <li>In Eclipse, go to the registry service client at: <br>
431
        seek/projects/ecogrid/src/org/ecoinformatics/ecogrid/client/RegistryServiceClient.java</li>
432
    <li>Right click on RegistryServiceClient.java and go to Run As->Open Run Dialog</li>
433
    <li>Name it something like "RegistryServiceClient noargs" since you are running it without arguments.</li>
434
    <li>Hit the "Apply" button and then the "Run" button.</li>
435
    <li>Proceed past the project error warning dialog</li>
436
    <li>In the Eclipse console you should see usage instructions that look like:
437
      <ul>
438
      <li>Usage: java RegistryServiceClient add session_id local_file GSH</li>
439
      <li>Usage: java RegistryServiceClient update session_id  docid local_file GSH</li>
440
      <li>Usage: java RegistryServiceClient remove session_id docid GSH</li>
441
      <li>Usage: java RegistryServiceClient list session_id GSH</li>
442
      <li>Usage: java RegistryServiceClient query session_id query_field query_string GSH</li>
443
      </ul>
444
    </li>
445
    <li>Note: now you can run the client using the green "run" button in the Eclipse
446
    menu. We will use that button from now on, instead of going to the java file.</li>
447
    </ul>    
448
  </li> 
449
  <li>List Registry Services on dev
450
    <ul>
451
    <li>In Eclipse, go to the green run button dropdown and choose "Open Run Dialog"</li>
452
    <li>Right click on the "RegistryServiceClient noargs" configuration you created earlier and choose "duplicate".</li>   
453
    <li>Name your new configuration "RegistryServiceClient list dev.nceas"
454
    <li>Go to the Arguments tab and enter: list 12345 http://dev.nceas.ucsb.edu/registry/services/RegistryService
455
      <ul>
456
      <li>This conforms to the list usage we saw earlier</li>
457
      <li>Note that the session ID is not needed for listing, so we include a random value.</li>
458
      <li>GSH always refers to the server where the registry database is held.</li>
459
      </ul>
460
    </li>
461
    <li>Choose "Run"</li>
462
    <li>Proceed past the project error warning dialog</li>
463
    <li>You should see a listing of details for all services registered on the dev server.</li>
464
    </ul>
465
  </li> 
466
  <li>Register a new  service on dev
467
    <ul>
468
    <li>Look in your service list you just printed and find a service that has a 
469
        service type of: http://ecoinformatics.org/identifierservice-1.0.0</li>
470
    <li>Get the service ID and use it to get the xml description from dev metacat by going to:</br>
471
        http://kepler-dev.nceas.ucsb.edu/kepler/metacat/&lt;service_id&gt;</li>
472
    <li>Save the file to disk</li>
473
    <li>Edit the file and change the id to something unique and the description to be something
474
        easily recognizable.</li>
475
    <li>In the browser, go to: http://kepler-dev.nceas.ucsb.edu/kepler/style/skins/dev/login.html</li>
476
    <li>Log in and make note of the sessionId that was returned</li>
477
    <li>In Eclipse, go to the green run button dropdown and choose "Open Run Dialog"</li>
478
    <li>Right click on the "RegistryServiceClient noargs" configuration you created earlier and choose "duplicate".</li>   
479
    <li>Name your new configuration "RegistryServiceClient add-test dev.nceas"
480
    <li>Go to the Arguments tab and enter: add &lt;sessionId&gt; &lt;xml_file_path&gt; http://dev.nceas.ucsb.edu/registry/services/RegistryService
481
      <ul>
482
      <li>This conforms to the add usage we saw earlier</li>
483
      <li>The &lt;sessionId&gt; is the id you got after loggin in via the dev skin.</li>
484
      <li>The &lt;xml_file_path&gt; is the full path to the descriptor file you downloaded and modified.</li>
485
      <li>GSH always refers to the server where the registry database is held.</li>
486
      </ul>
487
    </li>
488
    <li>Choose "Run"</li>
489
    <li>Proceed past the project error warning dialog</li>
490
    <li>You should see a message saying: "The new id is &lt;id&gt;, where &lt;id&gt; is the unique id
491
        you added to the service descriptor file.</li>
492
    <li>Follow the instructions shown above to list services to make sure your new service shows up</li>
493
    </ul>  
494
  </li>      
495
  </ul>
496
  
497
  <a name="LoadTesting"></a><div class="header1">Load Testing</div>
498
  <p>This section dicussed the available load testing code and its usage.</p>
499

    
500
  <a name="LoadTestCodeFiles"></a><div class="header2">Load Test Code Files</div>  
501
  <p>The code to do load testing is located in the metacat project in this directory:</p>
502
     <div class="code">&lt;metacat_src&gt;/test/stress-test</div>
503

    
504
  <p>The test code files are written in python for the following tests:</p>
505

    
506
  <ul>
507
  <li> read - read-load-test.py </li>
508
  <li> insert - insert-load-test.py </li>
509
  <li> squery - squery-load-test.py </li>
510
  </ul>
511

    
512
  <p>While these can be run directly from the command line, there is also a driver 
513
    file written in bash for convenience named: load-test-driver.sh</p>
514

    
515
  <p>The insert and squery tests rely on the following template files respectively: </p>
516
    <div class="code">insert.xml.tmpl and squery.xml.tmpl</div>
517

    
518
  <p>The insert and squery tests rely on dictionary files to create unique document IDs. 
519
    These files are generated using a shell script named:</p> 
520
    <div class="code">generate-dictionaries.sh</div>
521

    
522
  <p>Each of these files will be discussed in the next sections</p>
523

    
524
  <a name="GeneratingDictionaryFiles"></a><div class="header2">Generating Dictionary Files</div>  
525

    
526
  <p>The insert and squery tests (see following sections) will need to create unique document IDs to avoid conflicts and to bypass caching mechanisms. The dictionary files are created by running:
527
     <div class="code">./generate-dictionaries.sh</div>
528

    
529
  <p>This will create a separate file for each letter of the alphabet that looks like:</p>
530
     <div class="code">dictionary-a.txt, dictionary-b.txt, etc.</div>
531

    
532
  <p>Each file will contain all the five letter word combinations that start with the 
533
    letter associated with that file. You should run this script right away, as it takes a little 
534
    time to run.</p>
535

    
536
  <a name="InsertLoadTest"></a><div class="header2">Insert Load Test</div>      
537

    
538
  <p>The insert load test is run via a python script with the following usage:</p>
539
     <div class="code">./insert-load-test.py &lt;letter&gt; &lt;iterations&gt; &lt;interval&gt; &lt;host&gt; 2>&1 &</div>
540

    
541
  <p>Where:</p>
542

    
543
  <ul>
544
  <li> letter - the letter of the dictionary you want to use to generate doc IDs.</li>
545
  <li> iterations - the number of inserts you would like the test to perform.</li>
546
  <li> interval - the delay in seconds between each insert. You can enter a decimal for 
547
    less than one second.</li>
548
  <li> host - the server that is running the instance of metacat you are load testing. 
549
    You should not be running the test drivers on the same machine as metacat, since that 
550
    could affect the outcome of the load test.</li>
551
  </ul>
552

    
553
  <p>The insert test will iterate through the dictionary for the letter you have specified. 
554
    For each word, it will create a doc ID that looks like:</p>
555
     <div class="code">&lt;word>&lt;epoch_date&gt;.&lt;epoch_date&gt;.1</div>
556

    
557
  <p>For instance, if the test started at epoch date 123914076495 and the 67th word in the 
558
    dictionary file (for letter c) is caacp, your doc ID will look like:</p>
559
     <div class="code">caacp123914076495.67.1</div>
560

    
561
  <p>This docid is subtituted for each values of @!docid!@ in the insert template at:</p>
562
     <div class="code">insert.xml.tmpl</div>
563

    
564
  <p>Each doc will then be inserted into Metacat using the metacat.py interface file.</p>
565

    
566
  <p>Output will be written to a file named:</p>
567
     <div class="code">insert-&lt;letter&gt;.out</div>
568

    
569
  <p>Note that you can run several of the insert tests at the same time. You should run 
570
    each against a different letter to avoid doc ID naming conflicts and to be able to 
571
    view the output from each test in a different output file. See the load-test-driver.sh 
572
    for some examples.</p>
573
    
574
  <a name="SQueryLoadTest"></a><div class="header2">SQuery Load Test</div>  
575

    
576
  <p>The squery load test is run via a python script with the following usage:</p>
577
     <div class="code">./squery-load-test.py &lt;letter&gt; &lt;iterations&gt; &lt;interval&gt; &lt;host&gt; 2>&1 &</div>
578

    
579
  <p>Where:</p>
580

    
581
  <ul>
582
  <li> letter - the letter of the dictionary you want to use to generate doc IDs.</li>
583
  <li> iterations - the number of squeries you would like the test to perform.</li>
584
  <li> interval - the delay in seconds between each squery. You can enter a decimal for 
585
    less than one second.</li>
586
  <li> host - the server that is running the instance of metacat you are load testing. 
587
    You should not be running the test drivers on the same machine as metacat, since 
588
      that could affect the outcome of the load test.</li>
589
  </ul>
590

    
591
  <p>The squery test will iterate through the dictionary for the letter you have specified. 
592
    For each word, it will create a query by substituting the dictionary word for every 
593
    instance of @!search-word!@ in the squery template at:</p>
594
     <div class="code">squery.xml.tmpl</div>
595

    
596
  <p>Each of these queries will be run against Metacat using the metacat.py interface file. 
597
  By changing the query for each word, we insure that we do not get cached query results 
598
  back from Metacat, which would not cause a significant load.</p>
599

    
600
  <p>Output will be written to a file named:</p>
601
     <div class="code">squery-&lt;letter&gt;.out</div>
602

    
603
  <p>Note that you can run several of the squery tests at the same time. You should run 
604
    each against a different letter to avoid doc ID naming conflicts and to be able to 
605
    view the output from each test in a different output file. See the load-test-driver.sh 
606
    for some examples. If you are going to run a test against the same letter more than 
607
    once, you will need to restart the instance of Metacat being tested to clear the query 
608
    cache on that system.</p>
609
 
610
  <a name="ReadLoadTest"></a><div class="header2">Read Load Test</div>     
611

    
612
  <p>The read load test is run via a python script with the following usage:</p>
613
     <div class="code">./read-load-test.py &lt;letter&gt; &lt;iterations&gt; &lt;interval&gt; &lt;host&gt; 2>&1 &</div>
614

    
615
  <p>Where:</p>
616

    
617
  <ul>
618
  <li> letter - the read test does not use a dictionary. The letter helps us insure that 
619
    each test reads a different document, and writes to its own output file.</li>
620
  <li> iterations - the number of reads you would like the test to perform.</li>
621
  <li> interval - the delay in seconds between each read. You can enter a decimal for 
622
    less than one second.</li>
623
  <li> host - the server that is running the instance of metacat you are load testing. 
624
    You should not be running the test drivers on the same machine as metacat, since 
625
    that could affect the outcome of the load test.</li>
626
  </ul>
627

    
628
  <p>The read test will create a doc ID that looks like:</p>
629
     <div class="code">readtest-&lt;letter&gt;&lt;epoch_date&gt;.1.1</div>
630

    
631
  <p>It will do a single insert using that doc ID and the template at:</p>
632
     <div class="code">insert.xml.tmpl</div>
633

    
634
  <p>It will then do a read of that document from Metacat using the metacat.py interface 
635
    file for the number of iterations you have specified.</p>
636

    
637
  <p>Output will be written to a file named:</p>
638
     <div class="code">read-&lt;letter&gt;.out</div>
639

    
640
  <p>Note that you can run several of the read tests at the same time. You should run 
641
  each against a different letter to avoid doc ID naming conflicts and to be able to 
642
  view the output from each test in a different output file. See the load-test-driver.sh 
643
  for some examples.</p>
644

    
645
  <a name="TestDriverScript"></a><div class="header2">Test Driver Script</div> 
646

    
647
  <p>There is a very simple driver script that allows you to easily run multiple instances 
648
  and combinations of the different load tests called:</p>
649
     <div class="code">./load-test-driver.sh</div>
650
  <p>Uncomment the tests you want to run. </p>
651
  
652
  <br>
653
  <a href="./building-metacat.html">Back</a> | <a href="./index.html">Home</a> | 
654
  <!--a href="add next file here when one exists" -->Next<!-- /a -->
655

    
656
</BODY>
657
</HTML>
(33-33/35)