-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest-servlet.ss
42 lines (34 loc) · 1.56 KB
/
test-servlet.ss
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
#lang scheme/base
(require (only-in web-server/managers/manager manager?)
web-server/managers/lru
(planet untyped/mirrors:2)
"all-smoke-tests.ss"
"test-base.ss")
; Servlet stuff --------------------------------
(define interface-version 'v2)
; request -> response
; The library tests itself entirely by continuation:
; this servlet serves no real purpose.
(define (start initial-request)
(make-html-response
(xml (html (head (title "Tests not running"))
(body (p "For some reason the Smoke test suite did not start."))))))
; request -> response
(define (instance-expiration-handler response)
(error "Expired instance!"))
; manager
(define manager
(let ([memory-threshold (* 32 1024 1024)])
(create-LRU-manager
instance-expiration-handler ; request -> response
5 ; check condition X every 5 seconds
(* 30 60) ; deduct one life point every 30 minutes
(cut >= (current-memory-use) memory-threshold) ; condition X
#:initial-count 12 ; 12 life points to start with
#:inform-p void))) ; called when instances are collected
; Provide statements ---------------------------
(provide/contract
[interface-version symbol?]
[start (-> request? (or/c response/full? response/incremental?))]
[instance-expiration-handler (-> request? (or/c response/full? response/incremental?))]
[manager manager?])