This file is indexed.

/usr/share/doc/red5/html/testing.html is in red5-doc 1.0~svn4374-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
<html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   <title>Chapter&nbsp;18.&nbsp;Testing Red5</title><link rel="stylesheet" type="text/css" href="html.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Red5 - Reference Documentation"><link rel="up" href="core-components.html" title="Part&nbsp;II.&nbsp;Red5 Core Components"><link rel="prev" href="demo-applications.html" title="Chapter&nbsp;17.&nbsp;Red5 Demo Applications"><link rel="next" href="plugins.html" title="Chapter&nbsp;19.&nbsp;Plugins"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div xmlns="http://www.w3.org/TR/xhtml1/transitional" style="background-color:white;border:none;height:73px;border:1px solid black;"><a style="border:none;" href="http://osflash.org/red5" title="Red5 Open Source Flash Server"><img style="border:none;" src="images/red5-banner.png"></img></a><a style="border:none;" href="http://osflash.org/red5" title="Red5 Open Source Flash Server"><img style="border:none;position:absolute;padding-top:5px;right:42px;" src="images/red5-banner-logo.png"></img></a></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="testing"></a>Chapter&nbsp;18.&nbsp;Testing Red5</h2></div></div></div>
	
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2406"></a>18.1.&nbsp;Overview</h2></div></div></div>
		
		<p>As of version 0.8, the Red5 Testing framework has been modified and updated. The unit-tests have been updated to pass, and a automated system-testing and continuous integration framework has been added.
			This document attempts to explain the thoughts and architecture involved so as to facilitate review by the Red5 core team.</p>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2409"></a>18.2.&nbsp;How to Start Testing Without Reading This Chapter</h2></div></div></div>
		
		<p>To see the results of the Red5 continuous build server (this URL may change), go to 
			<a class="ulink" href="http://build.theyard.net/" target="_top">http://build.theyard.net/</a>.
		</p>
		<p>The build server runs after every check-in, as well as every night. We test against JDK5 and JDK6.</p>
		<p>To run all the Red5 unit tests yourself, check out the Red5 tree, and run:</p>
		<pre class="screen"> 
$ ant run-tests
</pre>
		<p>To see the results, open this file in a browser</p>
		<div class="literallayout"><p>&nbsp;<br>
doc/test/index.html<br>
</p></div>
		<p>To run all the Red5 system tests, make sure you don't already have red5 running then in one terminal type:</p>
		<pre class="screen"> 
$ ant run-tests-server
</pre>
		<p>Then open this file in a browser.&amp;nbsp; When the security dialog comes up, give it access to your camera, and select the box to remember the setting (if you want it to auto-run in the future):</p>
		<div class="literallayout"><p>&nbsp;<br>
test/fixtures/red5-selftest.swf<br>
</p></div>
		<p>You can find all log files generate by the red5 test server in:</p>
		<div class="literallayout"><p>&nbsp;<br>
bin/testcases/testreports/dist/log<br>
</p></div>
		<p>You can find the documentation for what the system tests do here (and can add to it by just putting ASDoc style comments in any System tests you add):</p>
		<p><a class="ulink" href="http://build.theyard.net/job/red5_flash_selftest_trunk_flex3.1/javadoc/" target="_top">Current Flash System Tests</a></p>
		<p>And that's it.</p>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2428"></a>18.3.&nbsp;Who Should Read This Chapter In Depth?</h2></div></div></div>
		
		<p>This chapter is targeted at people who are:</p>
		<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
				<p>Modifying Red5 code directly and want to make sure their code works.</p>
			</li><li class="listitem">
				<p>Interested in how Red5 is working to improve quality, and has some experience with software testing.</p>
			</li><li class="listitem">
				<p>People who have found a bug in Red5, and want to submit a patch with a Unit Test or System Test that will catch regressions.</p>
			</li><li class="listitem">
				<p>Goblins.</p>
			</li></ol></div>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2440"></a>18.4.&nbsp;Red5 Testing Strategy</h2></div></div></div>
		
		<p>The Red5 Testing Strategy has 5 components to it:</p>
		<div class="informaltable"><table>
			<tr>
				<td>\# </td>
				<td>Type </td>
				<td>Description </td>
			</tr>
			<tr>
				<td>1 </td>
				<td>Code </td>
				<td>Write great code; we've done this from day one and see no reason to stop now. </td>
			</tr>
			<tr>
				<td>2 </td>
				<td>Unit Tests </td>
				<td></td>
			</tr>
			<tr>
				<td>3 </td>
				<td>Functional Tests </td>
				<td>Write functional tests to simulate network interactions</td>
			</tr>
		</table></div>
		<p>
			<span class="bold"><strong>This is not yet implemented.</strong></span> We plan to do this in the future using RTMPClient, but any help the community can give here is appreciated. ||
		</p>
		<div class="informaltable"><table>
			<tr>
				<td>4 </td>
				<td>System Tests </td>
				<td>Use flash-based system-tests (using 
					<a class="ulink" href="http://asunit.org/" target="_top">AsUnit</a>) that make sure end-to-end interaction with Adobe's flash player works as expected. For example, we test that we can connect from Flash via RTMP, we can play back pre-recorded FLV files, and we can publish from a Camera. 
				</td>
			</tr>
			<tr>
				<td>5 </td>
				<td>Continuous Building </td>
				<td>Build and run all tests every time someone checks in to make sure all tests still pass. Currently the continuous server can be found here (but it will move):
					<a class="ulink" href="http://build.theyard.net/" target="_top">http://build.theyard.net/</a> 
				</td>
			</tr>
		</table></div>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2473"></a>18.5.&nbsp;Red5 Testing Props</h2></div></div></div>
		
		<p>Major props go to the following folks:</p>
		<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
				<p>The red5 development team because, well, test frameworks don't mean shit if you don't got good stuff to test.</p>
			</li><li class="listitem">
				<p>Thijs, who set up the initial Red5 build server, and showed me how to get get Apache and Tomcat working nicely together.</p>
			</li></ol></div>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2481"></a>18.6.&nbsp;Unit Testing</h2></div></div></div>
		
		<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e2483"></a>18.6.1.&nbsp;Purpose</h3></div></div></div>
			
			<p>The purpose of a unit test is to make sure a java object operates according to its specification, regardless of how it is plugged in with other objects. For a good overview of check out this 
				<a class="ulink" href="http://en.wikipedia.org/wiki/Unit_testing" target="_top">Wikipedia Unit Testing web page</a>.
				For example, you can (and we do) have Unit Tests that test we're encoding and decoding data from AMF codec's correctly using Mock Objects, that test whether or not we can load information from Spring, and whether or not we can inject Meta Data into FLV viles correctly.
			</p>
		</div>
		<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e2487"></a>18.6.2.&nbsp;Technology</h3></div></div></div>
			
			<p>Red5 uses the 
				<a class="ulink" href="http://junit.org/" target="_top">JUnit</a> unit testing framework. If you're not familiar with that suite, please check it out. It is the de-facto standard for Java Unit Testing.
			</p>
		</div>
		<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e2491"></a>18.6.3.&nbsp;Running Tests</h3></div></div></div>
			
			<p> To run tests, checkout the latest server build, and run the following ant command:</p>
			<pre class="screen"> 
$ ant run-tests
</pre>
			<p>To see the results, you can open the doc/test/index.html file once the tests are finished.</p>
			<div class="literallayout"><p>&nbsp;<br>
firefox&nbsp;doc/test/index.html<br>
</p></div>
		</div>
		<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e2497"></a>18.6.4.&nbsp;Creating New Tests</h3></div></div></div>
			
			<p>Writing unit tests in the 
				<a class="ulink" href="http://junit.org" target="_top">JUnit</a> framework is beyond the scope of this document, but you can find help at the JUnit site. The Red5 unit test framework support JUnit 4.0, but can run JUnit 3.x-style tests as well.
				To create a new unit test, just create a new JUnitclass source file to the right path under test, and end the source filename with the string "Test.java". For example, to test org.red5.server.api.ANewClass, you would create the following java file under the "test" directory:
			</p>
			<div class="literallayout"><p>&nbsp;<br>
test/org/red5/server/api/ANewClassTest.java<br>
</p></div>
			<p>Once you do that, the compile process should pick up your new file and run the tests automatically.&amp;nbsp;</p>
			<p>By default, the run-tests runs all unit tests in the following directory:</p>
			<div class="literallayout"><p>&nbsp;<br>
bin/testcases/testreports<br>
</p></div>
		</div>
		<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e2505"></a>18.6.5.&nbsp;Running unit tests from eclipse</h3></div></div></div>
			
			<p>In theory every should work, but you may need to set the directory eclipse runs the test from.  Make sure it is set to:</p>
			<div class="literallayout"><p>&nbsp;<br>
bin/testcases/testreports<br>
</p></div>
		</div>
		<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e2509"></a>18.6.6.&nbsp;Guidelines for New Unit Tests</h3></div></div></div>
			
			<p>Unit tests help make the code base stronger, but that said we do need to make sure that unit tests meet certain guidelines so we can have a useful build process. Those guidelines are:</p>
			<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
					<p>Unit Tests MUST be self-contained (i.e. each test should run independently).</p>
				</li></ul></div>
			<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
					<p>Unit Tests MUST not require a Red5 server to be running.</p>
				</li><li class="listitem">
					<p>Unit Tests MAY assume that no Red5 instance is currently running while they run (and so may fire up Red5 objects that bind to ports if appropriate).</p>
				</li><li class="listitem">
					<p>Unit Tests MUST NOT require thread-timing specific to your machine to run (or fail) consistently.</p>
				</li><li class="listitem">
					<p>Unit Tests MUST run successfully 100% in order to be checked in. That means, no checking in tests that fail with "not implemented".</p>
				</li><li class="listitem">
					<p>Unit Tests SHOULD try to avoid introducing new dependencies, but if you must use one (for example 
						<a class="ulink" href="http://multithreadedtc.googlecode.com/" target="_top">http://multithreadedtc.googlecode.com/</a> can be useful), identify it when you submit a JUnit test case and we'll review whether or not to add to the ivy test dependencies.
					</p>
				</li><li class="listitem">
					<p>Unit Tests MUST document what they do, and how to tell if they really worked, in JavaDoc comments above each test method.</p>
				</li><li class="listitem">
					<p>Unit Tests SHOULD be written using JUnit 4.x annotations</p>
				</li></ul></div>
		</div>
		<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e2531"></a>18.6.7.&nbsp;Submitting New Unit Tests</h3></div></div></div>
			
			<p>We really want new Unit Tests, so if you have a Unit Test that meets the above guidelines we'd love to consider it. To submit it, do the following:</p>
			<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
					<p>Review the guidelines above. Really.</p>
				</li><li class="listitem">
					<p>If you're fixing a bug:</p>
					<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>Create a unit test and make sure it fails 100% of the time before you fix the bug.</p></li><li class="listitem"><p>Fix the bug.</p></li><li class="listitem"><p>Ensure that unit test succeeds 100% of the time after you fix the bug.</p></li></ul></div>
				</li></ul></div>
			<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
					<p>If you're testing a new feature:</p>
					<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>Write your new feature.</p></li><li class="listitem"><p>Create a diff file with your patch using "svn diff" from tip of tree.</p></li><li class="listitem"><p>Ensure that unit test succeeds 100% of the time after you fix the bug.</p></li></ul></div>
				</li></ul></div>
			<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
					<p>File a new issue in Trac in the "Developer Tools" section. Please attach the diff files and the contents of any new files, and specify the following:</p>
					<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>What the test tests.</p></li><li class="listitem"><p>Brief overview of how it works.</p></li></ul></div>
				</li></ul></div>
			<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
					<p>Someone (probably Art) will review it and get back to you on changes that may be needed, or will commit it.</p>
				</li></ul></div>
		</div>
		<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e2567"></a>18.6.8.&nbsp;Suggesting New Unit Tests</h3></div></div></div>
			
			<p>We really do want new unit tests, and would love suggestions. But bear in mind that Red5 is a 100% volunteer project and most people who work on it have full time day jobs (their time spent on red5 is a labor of love). So don't be hurt if your suggestion for a test is not picked up on.</p>
			<p>That said, a great way to suggest an area to test is to go ahead and write the system test yourself\! Send it to the list, and it'll probably get a warm reception.</p>
		</div>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2571"></a>18.7.&nbsp;Integration Testing</h2></div></div></div>
		
		<p>We currently don't have a 
			<a class="ulink" href="http://en.wikipedia.org/wiki/Integration_testing" target="_top">integration testing framework</a>, but when I next return to this area, I'll try adding one. The basic idea for this (which I love) is to make a framework based on the RTMPClient.
		</p>
		<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e2575"></a>18.7.1.&nbsp;Purpose</h3></div></div></div>
			
			<p>The purpose of integration testing is to start to plug together different simpler modules (that hopefully have been unit tested) to see if they play nice together. See this Integration Testing Wikipedia Pagefor an overview of the concepts.</p>
		</div>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2578"></a>18.8.&nbsp;System Testing</h2></div></div></div>
		
		<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e2580"></a>18.8.1.&nbsp;Purpose</h3></div></div></div>
			
			<p>When all is set and done, and you've Unit tested everything, and did integration testing by mixing together different components, you're still not done. At some point, a user is going to pick up your application, and start using it. And if you haven't tested from that end to your code and back, well chances are something will break.</p>
			<p>That's where 
				<a class="ulink" href="http://en.wikipedia.org/wiki/Functional_testing" target="_top">System Testing</a> comes in. In the System Test we try to do some basic end-to-end tests to see if our code performs as expected from the end-user's perspective.
			</p>
		</div>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2585"></a>18.9.&nbsp;Technology</h2></div></div></div>
		
		<p>For Flash system testing (a.k.a selftest), we use the 
			<a class="ulink" href="http://junit.org/" target="_top">ASUnit|http://asunit.org/</a> framework, which is very similar to 
			<a class="ulink" href="JUnit" target="_top">JUnit</a>. You can find the current Flash self test here.
		</p>
		<p>We also use 
			<a class="ulink" href="http://theyard.googlecode.com/" target="_top">The Yard Flash Libraries</a> to abstract away some components of Flash connecting and stream playing, but you're not required to use those libraries if you submit new flash unit tests.
		</p>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2592"></a>18.10.&nbsp;Running Tests</h2></div></div></div>
		
		<p>The Red5 system tests require a special test server to be running. This is just a mostly empty red5 server with one special application installed:</p>
		<div class="literallayout"><p>&nbsp;<br>
http://localhost/selftest<br>
</p></div>
		<p>That selftest Red5 application has the following service exposed under the name "echo":</p>
		<div class="literallayout"><p>&nbsp;<br>
red5.server.services.IEchoService.java:<br>
[http://code.google.com/p/red5/source/browse/java/server/trunk/test/org/red5/server/service/IEchoService.java]<br>
</p></div>
		<p>Every method on that Java Interface is callable from Flash by using the prefix "echo.".&amp;nbsp; For example, "echo.echoNumber" will call the echoNumber method over RTMP/AMF.&amp;nbsp;</p>
		<p>There are two ways to run the system test:</p>
		<p>
			<span class="bold"><strong>Attended</strong></span> -  Run a Test Server 
		</p>
		<pre class="screen"> 
$ ant run-tests-server
</pre>
		<p>Start up the Flash Self Test application</p>
		<div class="literallayout"><p>&nbsp;<br>
flashplayer&nbsp;tests/fixtures/red5-selftest.swf<br>
</p></div>
		<p> </p>
		<p>This method assumes someone is watching the test. </p>
		<p>
			<span class="bold"><strong>Unattended</strong></span> - 
		</p>
		<pre class="screen"> 
$ ant run-tests-systemtest
</pre>
		<p>This only works on Linux. 
			It starts up a red5 server, runs the system test in the background, and then collects all log artifacts in the directory "output" relative to the current directory. 
			It will also take snapshop pictures of the desktop as running if ImageMagick's import tool is installed. ||</p>
		<p>System tests run the server with RED5_HOME set to bin/testcases/testreports/dist, and runs the flash clients from the directory bin/testcases/testreports/fixtures.</p>
		<p>Lastly, you should ensure red5 is not currently running on the server you run a system test on. However, because the system tests use their own version of Red5, you don't need to worry about them clobbering anything in your own Red5 installation.</p>
		<p>The System Tests use a series of scripts located in:</p>
		<div class="literallayout"><p>&nbsp;<br>
test/scripts<br>
</p></div>
		<p>to automatically start-up and shutdown red5, as well as find the necessary flash logs from different parts of the system. The main one of interest is:</p>
		<div class="literallayout"><p>&nbsp;<br>
test/scripts/red5-flash-player-headless<br>
</p></div>
		<p>It assumes it's running under a Windowing system (e.g. XWindows) with a Bourne Shell, and then starts a clean red5 server, runs the Flash system tests, and cleans up afterwards.</p>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2618"></a>18.11.&nbsp;Creating New Tests</h2></div></div></div>
		
		<p>Writing unit tests in theAsUnit framework is beyond the scope of this document, but you can find help at the AsUnit site.</p>
		<p>But to create a new system test, you can start with the Flash selftest application:svn checkout 
			<a class="ulink" href="http://red5.googlecode.com/svn/flash/trunk/selftest" target="_top">http://red5.googlecode.com/svn/flash/trunk/selftest</a> red5_selftestTo create a new AsUnit test just create a newclass source file to the right path under test, and end the source filename with the string "Test.as". For example:
		</p>
		<div class="literallayout"><p>&nbsp;<br>
test/org/red5/server/decodingComplexObjectOverAMFTest3.as<br>
</p></div>
		<p>Once you do that, you'll need to modify the AllTests.as file in the directory to add your new test.</p>
		<p>We use 
			<a class="ulink" href="http://ofb.net/~aclarke/theyard/flashutils-0.1.0/api/" target="_top">The Yard flash libraries|http://code.google.com/p/theyard/</a> to abstract away some of the complexities of connecting to and manipulating NetConnection and NetStream objects. See the 
			<a class="ulink" href="The" target="_top">Yard flash library documentation</a>. You don't have to use them for new tests, but they can make things a lot easier (for example, by taking care of connecting for you).
		</p>
		<p>To see documentation of existing tests, run:</p>
		<div class="literallayout"><p>&nbsp;<br>
ant&nbsp;doc<br>
</p></div>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2630"></a>18.12.&nbsp;A Sample System Test</h2></div></div></div>
		
		<p>Here's a very straightforward System Test submitted by trebor (at) vlideshow.com.</p>
		<p>This test connects to the test server and calls the "echo.echoString" method to pass a String to Red5, and then make sure we get the same array back.&amp;nbsp; It tests both AMF0 and AMF3 using the same code path because they should be the same.</p>
		<div class="literallayout"><p>&nbsp;<br>
EchoStringTest.as:&nbsp;AMF0&nbsp;and&nbsp;AMF3&nbsp;Strings&nbsp;sent&nbsp;over&nbsp;RTMP&nbsp;Test<br>
[http://code.google.com/p/red5/source/browse/flash/trunk/selftest/test/src/org/red5/server/io/EchoStringTest.as]<br>
</p></div>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2635"></a>18.13.&nbsp;Guidelines for New System Tests</h2></div></div></div>
		
		<p>Unfortunately Flash ActionScript is not as forgiving as Java is about cleaning up after a test is finished, so the guidelines for writing System Tests are somewhat more involved.&amp;nbsp; Also, these tests MUST be runnable in a "unattended" mode \-\- meaning requiring no human interaction, to the bar is higher.</p>
		<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
				<p>System Tests MUST not require any human interaction \-\- i.e. if a human can't give permission for something, it should fail without blocking.</p>
			</li><li class="listitem">
				<p>System Tests MAY draw on the flash screen but MUST remove any artifacts when done</p>
			</li><li class="listitem">
				<p>System Tests MUST be self-contained (i.e. each test should run independently).</p>
			</li><li class="listitem">
				<p>System Tests MAY assume that a Red5 instance is running on localhost, on port 1935, and that the selftest application is available.</p>
			</li><li class="listitem">
				<p>System Tests MAY assume that the selftest application has the Echo service installed.</p>
			</li><li class="listitem">
				<p>System Tests MUST clean up fully after themselves. That is, they must disconnect and remove any event handlers..</p>
			</li><li class="listitem">
				<p>System Tests MUST run successfully 100% in order to be checked in. That means, no checking in tests that fail with "not implemented".</p>
			</li><li class="listitem">
				<p>System Tests SHOULD try to avoid introducing new dependencies, but if you must use one (for example 
					<a class="ulink" href="http://theyard.googlecode.com/" target="_top">http://theyard.googlecode.com/</a> can be useful), identify it when you submit a test case and we'll review whether or not to add to the ivy test dependencies.
				</p>
			</li><li class="listitem">
				<p>System Tests MUST document what they do, and how to tell if they really worked, in AsDoc comments above each test method.</p>
			</li></ul></div>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2658"></a>18.14.&nbsp;Submitting New System Tests</h2></div></div></div>
		
		<p>We really want new System Tests, so if you have a System Test that meets the above guidelines we'd love to consider it. To submit it, do the following:</p>
		<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
				<p>Review the guidelines above. Really.</p>
			</li><li class="listitem">
				<p>If you're fixing a bug:</p>
			</li></ul></div>
		<p> ** Create a system test and make sure it fails 100% of the time before you fix the bug.
			 ** Fix the bug, and run a new test server.
			 ** Ensure that unit test succeeds 100% of the time after you fix the bug.</p>
		<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
				<p>If you're testing a new feature:</p>
			</li></ul></div>
		<p> ** Write your new feature.
			 ** Create a unit test and make it it succeeds 100% of the time with the new feature.</p>
		<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
				<p>Create a diff file with your patch using "svn diff" from tip of tree.</p>
			</li><li class="listitem">
				<p>File a new issue in Trac in the "Developer Tools" section. Please attach the diff files and the contents of any new files, and specify the following:</p>
			</li></ul></div>
		<p> ** What the test tests
			 ** Brief overview of how it works</p>
		<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
				<p>Someone (probably Art) will review it and get back to you on changes that may be needed, or will commit it.</p>
			</li></ul></div>
		<p>If your change is accepted, we'll integrate it into the Flash self-test, and update the Java Server trunk to use the new Flash selftest as our system test.</p>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2681"></a>18.15.&nbsp;Suggesting New System Tests</h2></div></div></div>
		
		<p>We really do want new tests, and would love suggestions. But bear in mind that Red5 is a 100% volunteer project and most people who work on it have full time day jobs (their time spent on red5 is a labor of love). So don't be hurt if your suggestion for a test is not picked up on.</p>
		<p>That said, a great way to suggest an area to test is to go ahead and write the system test yourself\! Send it to the list, and it'll probably get a warm reception.</p>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2685"></a>18.16.&nbsp;Continuous Integration</h2></div></div></div>
		
		<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e2687"></a>18.16.1.&nbsp;Overview</h3></div></div></div>
			
			<p>The last step of our testing framework is to run a continuous build. See this Wikipedia Pagefor some of the principles involved.</p>
			<p>The basic idea is to do a checkout, run all unit, functional and system tests, and then notify the person who checked in, and any others that are interested, about the current state of the build. The idea is that it is easier to fix bugs when they are introduced, than if they are found days or weeks later.</p>
		</div>
		<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e2691"></a>18.16.2.&nbsp;Technology</h3></div></div></div>
			
			<p>We use Hudson as our continuous build server running inside a Tomcat instance (running as the Hudson, not root, user) that is forwarded to by Apache2. This currently runs on an Amazon EC2 small instance hosted at:</p>
			<div class="literallayout"><p>&nbsp;<br>
[http://build.theyard.net/]<br>
</p></div>
			<p>E-Mail notification of bad builds are sent to the last person who checked in, and to the red5-builds (at) googlecode.com group.</p>
			<p>We run the following builds continuously:</p>
			<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
					<p>We build the java/server/trunk against JDK 1.6 on Linux i386 (Ubuntu) and run all units tests</p>
				</li><li class="listitem">
					<p>If this is successful, we run all system tests under JDK 1.6 on Linux i386 (Ubuntu) .</p>
				</li><li class="listitem">
					<p>We build the java/server/trunk against JDK 1.5 on Linux i386 (Ubuntu) and run all unit tests.</p>
				</li><li class="listitem">
					<p>If this is successful, we run all system tests under JDK 1.5 on Linux i386 (Ubuntu) .</p>
				</li></ul></div>
		</div>
		<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e2706"></a>18.16.3.&nbsp;How To Run The Continuous Build</h3></div></div></div>
			
			<p>The Continuous Build server will run any time you check something into the Java Server.  It also runs once every night.</p>
			<p>If you're on the Red5 dev team and want to set up new job, or log-in to hudson directly, talk to Art Clarke and he'll hook you up.</p>
		</div>
		<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e2710"></a>18.16.4.&nbsp;How to Submit New Jobs for Continuous Building</h3></div></div></div>
			
			<p>For now, send a request to red5devs@osflash.org and we'll evaluate it.</p>
		</div>
	</div>
	<div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d5e2713"></a>18.17.&nbsp;How you can help with Continuous Building</h2></div></div></div>
		
		<p>If you're willing do donate a i386 Amazon EC2 instance or an i86_64 Amazon EC2 instance, we're in need of both to do testing on. The current set up is temporary.</p>
		<div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="d5e2716"></a>18.17.1.&nbsp;How to Set up a Continuous Build Server</h3></div></div></div>
			
			<p>NOTE: THIS SECTION IS MEANT FOR SERIOUSLY ADVANCED RED5 USERS. 99.999999% of people shouldn't even read this.</p>
			<p>Glad you asked. We used an Amazon EC2 instance to get us started. Specifically this AMI from Eric Hammon at alestic.com.</p>
			<p>We then created a script that makes that image into one that can run Red5's continuous build server. See:</p>
			<div class="literallayout"><p>&nbsp;<br>
http://red5.googlecode.com/svn/build/remote/trunk/ec2/<br>
</p></div>
			<p>To set up an AWS EC2 instance to build and auto-test red5, do the following:</p>
			<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
					<p>Learn how to use Amazon EC2.</p>
				</li><li class="listitem">
					<p>Start up an instance of Ubuntu 8.04 LTS Hardy: ami-1cd73375</p>
				</li><li class="listitem">
					<p>Check out the Red5 remote build branch:</p>
				</li></ol></div>
			<pre class="screen"> 
$ svn checkout http://red5.googlecode.com/build/remote/trunk/
</pre>
			<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
					<p>Copy the ec2/ec2-explode directory to your new Amazon EC2 instance:</p>
				</li></ol></div>
			<pre class="screen"> 
cd ec2/ec2-explode
./ec2-implode ../ec2.tgz
scp -i YOUR_AWS_KEYPAIR root@YOUR_AWS_PUBLIC_IP:/tmp
</pre>
			<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
					<p>Log into your AWS EC2 instance:</p>
				</li></ol></div>
			<pre class="screen"> 
$ ssh -i YOUR_AWS_KEYPAIR -l root YOUR_AWS_PUBLIC_IP
</pre>
			<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
					<p>Prepare your ec2-explode package:</p>
				</li></ol></div>
			<pre class="screen"> 
cd tmp
  tar xzvf ec2.tgz
</pre>
			<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
					<p>Run the ec2-explode script:</p>
				</li></ol></div>
			<div class="literallayout"><p>&nbsp;<br>
./ec2-explode<br>
</p></div>
			<p> You will have to accept the Sun JDK license, choose a password for your XAuthority file (don't worry \-\- the X ports aren't opened, you just need that to run a headless X Server to make the Flash System Tests run), and enter the data necessary to send mail from your machine.</p>
			<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
					<p>You'll need to patch up your Apache 2 files to reflect your domain name:</p>
				</li></ol></div>
			<pre class="screen"> 
rename /etc/apache2/sites-enabled/build.theyard.net /etc/apache2/sites-enabled/YOUR-APACHE-SITE
vi /etc/apache2/sites-enabled/YOUR-APACHE-SITE
service apache2 restart
</pre>
			<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
					<p>Go to your website and make sure hudson is running:</p>
				</li></ol></div>
			<div class="literallayout"><p>&nbsp;<br>
http://YOUR-AWS-PUBLIC-IP/<br>
</p></div>
			<p>It's probably a good idea to change the default "hudson" password as well.  It defaults to:
				 10.</p>
			<div class="literallayout"><p>&nbsp;<br>
fmskiller<br>
</p></div>
			<p>This is the password for the Hudson UI, not the password on the hudson linux account. By default the linux hudson account doesn't allow log in using passwords.</p>
		</div>
	</div>
</div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navfooter"><hr></hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="demo-applications.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="plugins.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;17.&nbsp;Red5 Demo Applications&nbsp;</td><td width="20%" align="center"><span style="color:white;font-size:90%;"><a href="http://osflash.org/red5" title="Red5">Red5 Open Source Flash Server</a></span></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;19.&nbsp;Plugins</td></tr></table></div></body></html>