Skip to content
Browse files

adding 503 tests

  • Loading branch information...
1 parent 7eb2ea7 commit 59c2221b34b2cdf2d95254f23b06863abf26b7b1 @dyoo dyoo committed
Showing with 22 additions and 2 deletions.
  1. +19 −1 compiler-service.rkt
  2. +3 −1 servlet-htdocs/evaluator.js
View
20 compiler-service.rkt
@@ -90,6 +90,24 @@
(and elts (member "gzip" (regexp-split #px"," (cdr elts))) #t))
+;; For testing.
+;; Raises 503 half of the time, to make sure the evaluator
+;; can still handle it.
+(define (start/maybe-503 request)
+ (cond
+ [(= (random 2) 0)
+ (response
+ 503 #"Service Unavailable"
+ (current-seconds)
+ #"text/plain"
+ '()
+ (lambda (op)
+ (void)))]
+ [else
+ (start request)]))
+
+
+
;; Web service consuming programs and producing bytecode.
(define (start request)
(with-handlers ([void
@@ -471,7 +489,7 @@
(serve #:dispatch
(apply sequencer:make
(append
- (list (filter:make #rx"^/servlets/standalone.ss" (lift:make start)))
+ (list (filter:make #rx"^/servlets/standalone.ss" (lift:make start #;start/maybe-503)))
(map (lambda (extra-files-path)
(files:make
#:url->path (fsmap:make-url->path extra-files-path)
View
4 servlet-htdocs/evaluator.js
@@ -219,7 +219,9 @@ var Evaluator = (function() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
- if (xhr.status === 200) {
+ if (xhr.status == 503) {
+ that.compileProgram(programName, code, onDone, onDoneError);
+ } else if (xhr.status === 200) {
onDone(xhr.responseText);
} else {
onDoneError(xhr.responseText);

0 comments on commit 59c2221

Please sign in to comment.
Something went wrong with that request. Please try again.