source: project/wiki/eggref/4/server-test @ 30121

Last change on this file since 30121 was 30121, checked in by Mario Domenech Goulart, 6 years ago

server-test (wiki): release note for version 0.5

File size: 4.4 KB
Line 
1== server-test
2
3[[toc:]]
4
5=== Description
6
7Utilities to help testing servers
8
9=== Author
10
11[[/users/mario-domenech-goulart|Mario Domenech Goulart]]
12
13
14=== Repository
15
16[[https://github.com/mario-goulart/server-test|https://github.com/mario-goulart/server-test]]
17
18
19=== Parameters
20
21==== test-server-port
22
23<parameter>(test-server-port [integer])</parameter>
24
25The port to access the test server.  The default value is {{8080}}.
26
27==== connect-procedure
28
29<parameter>(connect-procedure [procedure])</parameter>
30
31The procedure to be used to check if the server is ready to accept
32requests.  Default is {{tcp-connect}} from
33[[/man/4/Unit tcp|unit tcp]].
34
35
36==== standby-time
37<parameter>(standby-time [integer])</parameter>
38
39Time in seconds to wait for the server to start serving after it has
40started accepting connections.  This parameter was introduced in
41version 0.4.
42
43
44==== max-attempts-to-connect
45<parameter>(max-attempts-to-connect [integer])</parameter>
46
47Maximum number of attempts to connect to the server before assuming
48that it failed to start. This parameter was introduced in version 0.4.
49
50
51==== time-between-attempts-to-connect
52<parameter>(time-between-attempts-to-connect [integer])</parameter>
53
54Time in seconds to wait between to consecutive attempts to connect to
55the server. This parameter was introduced in version 0.4.
56
57
58=== Procedures
59
60==== High level interface
61
62===== with-test-server
63<procedure>(with-test-server server-thunk tests-thunk)</procedure>
64
65Start the server by executing {{server-thunk}}, run the tests
66({{tests-thunk}}) and stop the server.
67
68Here's a usage example with the [[/egg/awful|awful]],
69[[/egg/test|test]] and [[/egg/http-client|http-client]] eggs:
70
71The awful application to be tested:
72
73<enscript highlight=scheme>
74(use awful)
75
76(define-page "/foo"
77  (lambda ()
78    "foo")
79  no-template: #t)
80</enscript>
81
82The test program:
83
84<enscript highlight=scheme>
85(use server-test awful http-client test)
86
87;; The awful application to be tested
88(awful-apps (list "foo.scm"))
89
90(with-test-server
91 awful-start
92 (lambda ()   
93   (test "foo"
94         (with-input-from-request "http://localhost:8080/foo"
95                                  #f
96                                  read-string))))
97</enscript>
98
99
100==== Low level interface
101
102===== start-test-server
103<procedure>(start-test-server thunk)</procedure>
104
105Start the test server and returns its pid.  {{thunk}} is the procedure
106which actually runs the server.
107
108
109===== stop-test-server
110<procedure>(stop-server pid)</procedure>
111
112Stops the server whose pid is the given {{pid}}.
113
114
115
116=== License
117
118 Copyright (c) 2012 Mario Domenech Goulart
119 All rights reserved.
120 
121 Redistribution and use in source and binary forms, with or without
122 modification, are permitted provided that the following conditions are
123 met:
124 
125 Redistributions of source code must retain the above copyright
126 notice, this list of conditions and the following disclaimer.
127 
128 Redistributions in binary form must reproduce the above copyright
129 notice, this list of conditions and the following disclaimer in the
130 documentation and/or other materials provided with the distribution.
131 
132 Neither the name of the author nor the names of its contributors may
133 be used to endorse or promote products derived from this software
134 without specific prior written permission.
135 
136 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
137 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
138 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
139 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
140 COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
141 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
142 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
143 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
144 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
145 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
146 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
147 OF THE POSSIBILITY OF SUCH DAMAGE.
148
149
150
151=== Version history
152
153===== version 0.5
154
155* Bug fix: propagate exceptions raised when running tests code
156
157
158===== version 0.4
159
160* Add {{standby-time}}, {{max-attempts-to-connect}} and {{time-between-attempts-to-connect}} parameters
161
162
163===== version 0.3
164
165* Fixed release numbers/tags (thanks to Peter Bex)
166
167
168===== version 0.2
169
170* Bug fix in the internal {{can-connect?}} procedure (it was not honoring {{test-server-port}})
171
172
173===== version 0.1
174
175* Initial release
Note: See TracBrowser for help on using the repository browser.