Debian Codegraph @

docs/docbook/testing-again.dbk

raw
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd">
4 <article>
5 <title>Testing (again)</title>
6
7 <authorblurb>
8 <para><author><lineage>Steve Loughran</lineage></author></para>
9 </authorblurb>
10
11 <sect1>
12 <title>Where we are today?</title>
13
14 <para>We are now at the second revision of the Axis test framework. The
15 original design had all classes in a package under java/test, built them
16 in one big &lt;javac&gt; and then executed them. While it ran the tests,
17 it was not that flexible. It was hard to run individual tests, and it
18 was hard to maintain. A major effort by Matt Siebert refactored the test
19 process to address these.</para>
20
21 <para>The revision attempted to address this with a modular design, based
22 on separate Ant build files for each test package, using common XML entity
23 references to share build file fragments between the files. This gave us
24 isolated builds of each subcomponents, the ability to build and run tests
25 on their own, and the flexiblity to have very different build processes
26 for each of the tests.</para>
27
28 <para>The many build files compile the source, all of java/test/*.java
29 into build/classes, putting them into the hierarchy build/classes/test.
30 Test packages which have special dependencies can make their builds
31 conditional, so only those tests for which we have support get compiled
32 down. This architecture makes it easy to add a new test package, without
33 having to edit shared build files.</para>
34
35 <para>We have a separation between "unit tests" and
36 "functional" tests; the latter includes the interop and attachment
37 tests. There are separate targets in build test to build them, as the
38 choice of which tests to execute is primarily driven by the compilation
39 process. Nearly all the tests in the class tree will get executed, so to
40 select which tests to run, you control which tests get built. This is a
41 simple way of letting the test package-specific build files control which
42 test to run.</para>
43
44 <sect2>
45 <title>The Tests</title>
46
47 <para>The many build files compile the source, all of java/test/*.java
48 into build/classes, putting them into the hierarchy build/classes/test.
49 Test packages which have special dependencies can make their builds
50 conditional, so only those tests for which we have support get compiled
51 down.</para>
52
53 <para>We have a separation between "unit tests" and
54 "functional" tests; the latter includes the interop and
55 attachment tests. There are separate targets in build test to build
56 them, as the choice of which tests to execute is primarily driven by the
57 compilation process. Nearly all the tests in the class tree will get
58 executed, so to select which tests to run, you control which tests get
59 built. This is a simple way of letting the test package-specific build
60 files control which test to run.</para>
61 </sect2>
62
63 <sect2>
64 <title>WSDL</title>
65
66 <para>A core component of many of the tests is generating Java source
67 from WSDL files, both local test case WSDL and remote interop WSDL. The
68 latter introduces a requirement to be on line, and on-line through a
69 transparent firewall -we dont look after proxy settings enough to run
70 behind a firewall whose sole net access is via a proxy 80. This is
71 somewhat ironic, given that such a facility is the selling point of the
72 transport-stack-atop-port-80 that is the SOAP and WS-* specification
73 suite.</para>
74
75 <para>As well as lacking off-line support for generating WSDL, we cant
76 (obviously) run the interop tests without a network connection. This
77 means that when a remote interop server goes down, the build fails.</para>
78 </sect2>
79
80 <sect2>
81 <title>Execution</title>
82
83 <para>After compiling all the code down, we run the tests. This is done
84 by batch JUnit execution of all the test suites in all the packages with
85 a PackageTests.class class in their package (i.e. all of
86 build/classes/**/PackageTests.class).</para>
87
88 <para>Functional tests are all of **/FunctionalTests.class and
89 **/*TestCase.class; the latter are those test cases which are
90 auto-created by the Wsdl2Java routine, often with manual editing to make
91 the test complete.</para>
92
93 <para>When the tests need a functional servlet engine to host the web
94 services, we bring up the simple axis server; a minimal implementation
95 of the servlet API that omits the production-quality aspects of a web
96 server, including JSP support. The &lt;runaxisfunctionaltests&gt; task
97 starts and stops the server, using an execution process borrowed from
98 Cactus: we supply the task with the target names of the start and stop
99 targets, and the task executes them before and after running all the
100 functional tests.</para>
101 </sect2>
102
103 <sect2>
104 <title>Result Processing</title>
105
106 <para>In a Gump build, the build stops after the first failure, and the
107 team notified. The property <varname>test.functional.fail</varname> sets
108 the <symbol>haltonfailure</symbol> attribute of the &lt;junit&gt;
109 task; set it to true and the test suite runs all tests before
110 completing. Either way, the <symbol>create-test-report</symbol> target
111 will, if Xalan or other XSLT engine is present, convert the XML reports
112 of the test run into an HTML report, package by package.</para>
113
114 </sect2>
115 </sect1>
116
117 <sect1>
118 <title>What do we want from a test suite?</title>
119
120
121 <sect2>
122 <title>Basic Improvements to the current status quo</title>
123
124
125 <itemizedlist>
126 <listitem>
127 <para>All the tests to pass :)</para>
128 </listitem>
129
130 <listitem>
131 <para>Faster tests</para>
132 </listitem>
133
134 <listitem>
135 <para>Scalability: easy to add new tests</para>
136 </listitem>
137
138 <listitem>
139 <para>Offline support, and robustness against unavailable interop
140 servers.</para>
141 </listitem>
142 </itemizedlist>
143 </sect2>
144
145 <sect2>
146 <title>Functional testing on production app servers</title>
147
148 <para>If we look at a lot of bugreps they are related to config and
149 operations on app servers. "Weblogic doesnt save
150 server-config.wsdd", "SunOne server has the wrong
151 classpath", "Jboss.net won't compile .JWS pages that import
152 javax.servlet.*", etc, etc. We need to run more tests on production
153 systems, rather than wait for user feedback after we ship. Now everybody
154 runs their apps on some such systems, so we have implicit testing, but
155 it is not part of the daily Gump or any other regular, controlled test
156 process.</para>
157
158 <para>We could modify the test system so that instead of starting the
159 SimpleAxisServer servlet routine, we can deploy to a local web server or
160 app server. This would verify that the core test suite runs on different
161 systems.</para>
162 </sect2>
163
164 <sect2>
165 <title>Test more than SOAP</title>
166
167 <para>We need more tests to validate the configuration; extending the
168 httpunit tests to have more tests of not-quite-SOAP requests. What
169 happens when the server gets less than they were promised? What about
170 more than promised? near-infinite recursive XML? xsd:import statements
171 in the XML? What happens when a client starts parsing from a socket that
172 doesnt close its connection, or lies about the amount it is sending?</para>
173
174 <para>These are the security and robustness categories we aren't
175 testing for today.</para>
176 </sect2>
177
178 <sect2>
179 <title>Automated invocation of compliance test suites: JAX-RPC TCK, WS-I
180 Basic</title>
181
182 <para>We have one test suite, JAX-RPC, that is only available under
183 restricted conditions. We need someone with access to the test suite to
184 run it.</para>
185 </sect2>
186
187 <sect2>
188 <title>Understandig that Interop servers are regularly unavailable</title>
189
190 <para>If Axis depends on everyone's interop server to be present,
191 then we have a global build system that breaks every time somebody in
192 their machine off -"the light switch in belgium problem". This
193 is too brittle. We need to cache the external WSDL in CVS, then probe
194 the servers to see if that has changed, downloading it only if it is
195 different. It would be nice to only regenerate the java proxy classes
196 from the WSDL when such a change has occurred.</para>
197 </sect2>
198
199 <sect2>
200 <title>Load testing</title>
201
202 <para>What happens to the system under load? This is very dependent upon
203 the app server; having tests running on the production server is a first
204 step to this. Traditional load testing has N clients each making M
205 requests, for N*M simultaneous requests. The facilities for individuals
206 to perform aggressive load tests are limited, but there is strength in
207 numbers; many Axis developers could have their test systems sychronised
208 to test an externally visible server together. This co-ordination could
209 be though a P2P infrastructure, such as JXTA or Chord, but as we are not
210 trying to design a stealth DDoS system, we could do it client-server
211 with a (separate) SOAP service choreographing the clients.</para>
212
213 <para>This would seem to be a long term project.</para>
214 </sect2>
215
216 <sect2>
217 <title>Performance testing</title>
218
219 <para>This is related to load testing, but doesnt need as many clients.
220 We need to know how long it takes for actions to be executed, and we
221 need to log this over time so that major regressions can get picked up.
222 If on the daily run one test takes 50% longer than usual, it is
223 immediately obvious that one of the day's changes caused the
224 problem. If the performance of the system doesn't get looked at till the
225 next version goes into RC phase, performance slippages get missed, and
226 even institutionalised.</para>
227 </sect2>
228
229 <sect2>
230 <title>Coverage Analysis</title>
231
232 <para>We should be able to use quilt
233 (<ulink url="http://quilt.sourceforge.net/">http://quilt.sourceforge.net/</ulink>)
234 to do this today. As with performance tests, tracking coverage changes
235 over time is informative; it shows whether things are improving or
236 getting worse.</para>
237 </sect2>
238
239 <sect2>
240 <title>Local interop testing with non-Axis clients and servers</title>
241
242 <para>We already have some examples of .net client tests against axis,
243 with an Ant build but sadly no automatic .NUnit test case generation. We
244 can also build axis clients against .Net and other servers, where we can
245 create JUnit stubs for ease of test generation. If such tests were part
246 of the main test suite, then suitably equipped systems could run our own
247 interop tests. These would be an extension of the SoapBuilders main
248 suite. Here we"d want to verify that fixes worked and continued to
249 work (e.g. the .NET1.0 empty array bugfix). We can also add stuff that
250 isn't in the SoapBuilders: Cookie Sessions, Http Header sessions,
251 is-date-in-the-right-TZ-at-the-far-end tests, and so on.</para>
252
253 <para>There are logistical/tactical and strategic arguments against
254 doing this. Logistical: even for the example of one client platform is
255 daunting; we don't want to expose a .NET server to the internet for
256 anyone to hit it, so the tests will only run on localhost when
257 localhost=windows, which excludes the Gump builds.</para>
258
259 <para>The strategic argument is that the combinatorial explosion of
260 local interop testing against multiple clients and servers is too big;
261 that is what the SoapBuilders are for. Either we focus on one or two key
262 platforms to interop test against -.net and MSSTK, or we raise the
263 problem back to SoapBuilders.</para>
264
265 <para>What would we want from SoapBuilders, to help our regression and
266 interop problems? I'd argue for extra tests, above and beyond the
267 formal "rounds", wherever someone has an interop issue. We
268 should be able to announce that we have a problem and the URL of a test
269 endpoint, and everyone can add it to the things we can test against.
270 Similarly, other platforms should not just fix things, they should
271 provide means for outsiders to test the system.</para>
272
273 <para>Glen Daniels has proposed a pattern-matching server that waits for
274 expected wire traces, and generates preprogrammed responses, simulating
275 part of the behaviour of a foreign server. This has the advantage of
276 being standalone, but with the disadvantage of not being as thorough as
277 a live test. You also have the challenge of keeping the datasets up to
278 date.</para>
279 </sect2>
280
281 <sect2>
282 <title>Wiretrace logging in the test case results</title>
283
284 <para>This is just an extra little feature for diagnosis: can we record
285 the wire traces of sent and received messages, and whenever we get a
286 test failure, save the results to the JUnit log for an easier
287 post-mortem. Just a thought :)</para>
288
289 <para></para>
290 </sect2>
291
292 <sect2>
293 <title>Ease of learning, installation, use</title>
294
295 <para>We are an open source project where anyone can download the
296 source, build it and run the tests. Therefore the test framework must be
297 easy to run, easy to work with, and easy to maintain by people other
298 than the original authors. We also want to keep effort minimised by
299 re-using as much as possible of other OSS projects.</para>
300 </sect2>
301 </sect1>
302
303 <sect1>
304 <title>Options</title>
305
306 <para>Here are some of the things we can do</para>
307
308 <sect2>
309 <title>Nothing</title>
310
311 <para>Leave things as they are. Maybe move to Ant1.6 alpha builds to get
312 better memory management, the faster build.xml parser and the refactored
313 .NET tasks, or just up to 1.5.3/1.5.4 to get the memory leak fix.</para>
314
315 <para>Costs: nothing at first; a gradual increase in longer term costs.</para>
316
317 </sect2>
318
319 <sect2>
320 <title>Improve build.xml reuse</title>
321
322 <para>We don't necessarily need a separate build file in every test
323 package. Instead we can have a properties file in there that sets well
324 known properties</para>
325
326 <programlisting>package=test/example
327 conditions=httpunit.present
328 online=false
329 needsserver=true
330 functional=true</programlisting>
331
332 <para>This can be read in by something (ant or custom java) and used to
333 control the build. Reading it into pure ant (i.e. without writing our
334 own task) would be tricky as condition expressions are tricky. An XML
335 description might be better, and could be XSLT'd into the build
336 files.</para>
337
338 </sect2>
339
340 <sect2>
341 <title>Caching WSDL Generation</title>
342
343 <para>This is a trick we can do with any of these.</para>
344
345 <para>Write a new &lt;axis-importwsdl&gt; task that implements
346 dependency awareness around the inner generation process. We could go
347 one step further and integrate dependency logic into the generation
348 process, but as that is more fundamental, I am a bit leery of that.
349 </para>
350
351 <orderedlist>
352 <listitem>
353 <para>caches the results of the fetch.</para>
354 </listitem>
355
356 <listitem>
357 <para>uses the if-modified-since tag to conditionally retrieve
358 content</para>
359 </listitem>
360
361 <listitem>
362 <para>even if content is returned, compares it byte-for-byte against
363 the cached copy</para>
364 </listitem>
365
366 <listitem>
367 <para>only imports the wsdl if the wsdl file is newer than a
368 timestamp marker file in the generated dir (and a force option is
369 false)</para>
370 </listitem>
371
372 <listitem>
373 <para>if the server is unreachable, but the cached copy is present,
374 don't fail the build, just set a property saying the server isn't
375 there and continue with the WSDL generation.</para>
376 </listitem>
377
378 <listitem>
379 <para>if the server is unreachable and the cached copy isn't there,
380 only fail the build if some attribute is set, otherwise a
381 wsdlnotpresent property is set</para>
382
383 <para>We could do this over a fairly convoluted set of ant 1.6
384 tasks, but only if the httptasks in the Ant sandbox were pulled in for
385 more graceful handling of missing servers. Pulling it in to one Axis
386 task gives us more control, ant1.5 support and wouldn't be that
387 hard to implement.</para>
388 </listitem>
389 </orderedlist>
390 </sect2>
391
392 <sect2>
393 <title>Write our own test harness</title>
394
395 <para>This deserves a mention: could we do our own complete test
396 harness? Why? is the reponse. What would that add?</para>
397
398 <para>In theory, having our own hosting app would let us run tests
399 differently from core JUnit, doing more SOAP related things like post
400 XML and expect responses.</para>
401
402 </sect2>
403
404 <sect2>
405 <title>Return to being JUnit-centric</title>
406
407 <para>The advantage of an ant-centric test system is that we can use Ant
408 to build stuff during testing. The disadvantage is in complexity and
409 time in running the tests. Is there a better compromise? Maybe. </para>
410
411 <para>It is possible to run Ant from inside JUnit. This is how Ant runs
412 its many self tests; by invoking Ant from JUnit itself. If we
413 put JUnit in charge, then those tests that do need a complex Ant-based
414 test system can call Ant to aid it, the rest run straight from JUnit.</para>
415
416 <para>We may be able to take advantage of this by categorising tests
417 into various patterns that we can build and run differently.</para>
418
419
420 <orderedlist>
421 <listitem>
422 <para>Pure unit tests that compile and run without needing any
423 server at all</para>
424 </listitem>
425
426 <listitem>
427 <para>WSDL-importing tests that need to import WSDL and generate
428 code before the tests run</para>
429 </listitem>
430
431 <listitem>
432 <para>Local functional tests that run against an instance of the
433 Axis running on a servlet engine</para>
434 </listitem>
435
436 <listitem>
437 <para>Local functional tests that only run on a full J2EE app server</para>
438 </listitem>
439
440 <listitem>
441 <para>Remote interop tests</para>
442 </listitem>
443 </orderedlist>
444
445 <para>Clearly this stuff is not 100% exclusive: a lot of the local
446 functional tests generate WSDL first, as do all the interop tests. And
447 there are other flags which will include/exclude test items: the
448 presence/absence of needed libraries, such as attachment support, and an
449 online/offline flag to distinguish tests that need a full internet
450 connection, from those that don't. All the interop tests are online, but
451 so are a few of the others.</para>
452
453 <para>In a JUnit-centric world, first the local unit tests would get
454 built and run, all in in a couple of big &lt;javac&gt; and
455 &lt;junit&gt; task. Then the WSDL import process can take place, using
456 something like the new dependency-aware wsdl import task proposed
457 earlier. </para>
458 </sect2>
459 </sect1>
460 </article>