[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] branch main updated: tests: web-server: Wait until the s
From: |
Ludovic Courtès |
Subject: |
[Guile-commits] branch main updated: tests: web-server: Wait until the server is listening. |
Date: |
Tue, 15 Mar 2022 09:40:08 -0400 |
This is an automated email from the git hooks/post-receive script.
civodul pushed a commit to branch main
in repository guile.
The following commit(s) were added to refs/heads/main by this push:
new f18f67022 tests: web-server: Wait until the server is listening.
f18f67022 is described below
commit f18f67022314eefced887df0a470a440f70f592c
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Tue Mar 15 14:38:40 2022 +0100
tests: web-server: Wait until the server is listening.
Fixes synchronization issues observed on slow or loaded machines, where
client connection attempts would fail with ECONNREFUSED:
https://issues.guix.gnu.org/54348
* test-suite/tests/web-server.test ("server is listening"): New test.
---
test-suite/tests/web-server.test | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/test-suite/tests/web-server.test b/test-suite/tests/web-server.test
index 486c99b58..f5081889f 100644
--- a/test-suite/tests/web-server.test
+++ b/test-suite/tests/web-server.test
@@ -1,6 +1,6 @@
;;;; web-server.test --- HTTP server -*- mode: scheme; coding: utf-8; -*-
;;;;
-;;;; Copyright (C) 2019, 2020 Free Software Foundation, Inc.
+;;;; Copyright (C) 2019-2020, 2022 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@@ -76,6 +76,29 @@
(throw 'unresolved)))
+(pass-if "server is listening"
+ ;; First, wait until the server is listening, up to a few seconds.
+ (let ((socket (socket AF_INET SOCK_STREAM 0)))
+ (let loop ((n 1))
+ (define success?
+ (catch 'system-error
+ (lambda ()
+ (format (current-error-port)
+ "connecting to the server, attempt #~a~%" n)
+ (connect socket AF_INET INADDR_LOOPBACK %port-number)
+ (close-port socket)
+ #t)
+ (lambda args
+ (if (and (= ECONNREFUSED (system-error-errno args))
+ (<= n 15))
+ #f
+ (apply throw args)))))
+
+ (or success?
+ (begin
+ (sleep 1)
+ (loop (+ n 1)))))))
+
(pass-if-equal "GET /"
"Hello, λ world!"
(expect http-get "/" 200))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Guile-commits] branch main updated: tests: web-server: Wait until the server is listening.,
Ludovic Courtès <=