summaryrefslogtreecommitdiff
path: root/gnu/tests
diff options
context:
space:
mode:
authorSören Tempel <soeren+git@soeren-tempel.net>2026-05-19 16:23:09 +0200
committerSören Tempel <soeren+git@soeren-tempel.net>2026-05-26 18:43:22 +0200
commit9609336829eea06ed9a761a2ea36a54a247a0d65 (patch)
treeee9d9ec83f4808109021e6df1bdfebf25bf1f003 /gnu/tests
parent056de157b2101d18222ee6dd5eff09f0798f7156 (diff)
services: web: Add system tests for gunicorn.
* gnu/tests/web.scm (%gunicorn-os): New variable. (run-gunicorn-test): New variable. (%test-gunicorn): New variable. Change-Id: I1ee3fd4c29c7c44aa9c271c6775f953790ca60c3
Diffstat (limited to 'gnu/tests')
-rw-r--r--gnu/tests/web.scm84
1 files changed, 84 insertions, 0 deletions
diff --git a/gnu/tests/web.scm b/gnu/tests/web.scm
index 9797a770a63..f29fb6b3748 100644
--- a/gnu/tests/web.scm
+++ b/gnu/tests/web.scm
@@ -42,6 +42,7 @@
42 #:use-module (gnu packages golang-xyz) 42 #:use-module (gnu packages golang-xyz)
43 #:use-module (gnu packages patchutils) 43 #:use-module (gnu packages patchutils)
44 #:use-module (gnu packages python) 44 #:use-module (gnu packages python)
45 #:use-module (gnu packages python-web)
45 #:use-module (gnu packages tls) 46 #:use-module (gnu packages tls)
46 #:use-module (gnu packages web) 47 #:use-module (gnu packages web)
47 #:use-module (guix packages) 48 #:use-module (guix packages)
@@ -59,6 +60,7 @@
59 %test-hpcguix-web 60 %test-hpcguix-web
60 %test-anonip 61 %test-anonip
61 %test-go-webdav 62 %test-go-webdav
63 %test-gunicorn
62 %test-patchwork 64 %test-patchwork
63 %test-sogogi 65 %test-sogogi
64 %test-agate 66 %test-agate
@@ -627,6 +629,88 @@ HTTP-PORT, along with php-fpm."
627 629
628 630
629;;; 631;;;
632;;; gunicorn
633;;;
634
635(define %gunicorn-os
636 (simple-operating-system
637 (service dhcpcd-service-type)
638 (service gunicorn-service-type
639 (gunicorn-configuration
640 (apps
641 (list (gunicorn-app
642 (name "werkzeug")
643 (package python-werkzeug)
644 (wsgi-app-module "werkzeug.testapp:test_app")
645 (sockets (list "0.0.0.0:8080"))
646 (user "root")
647 (group "users"))))))))
648
649(define (run-gunicorn-test)
650 (define os
651 (marionette-operating-system
652 %gunicorn-os
653 #:imported-modules '((gnu services herd))))
654
655 (define forwarded-port 8080)
656
657 (define vm
658 (virtual-machine
659 (operating-system os)
660 (memory-size 1024)
661 (port-forwardings `((8080 . ,forwarded-port)))))
662
663 (define test
664 (with-imported-modules '((gnu build marionette))
665 #~(begin
666 (use-modules (srfi srfi-11) (srfi srfi-64)
667 (gnu build marionette)
668 (web uri)
669 (web client)
670 (web response))
671
672 (define marionette
673 (make-marionette (list #$vm)))
674
675 (test-runner-current (system-test-runner #$output))
676 (test-begin "gunicorn")
677
678 (test-assert "service is running"
679 (marionette-eval
680 '(begin
681 (use-modules (gnu services herd))
682 (match (start-service 'gunicorn-werkzeug)
683 (#f #f)
684 (('service response-parts ...)
685 (match (assq-ref response-parts 'running)
686 ((#t) #t)
687 ((pid) pid)))))
688 marionette))
689
690 (test-assert "HTTP port ready"
691 (wait-for-tcp-port #$forwarded-port marionette))
692
693 (test-assert "get index page"
694 (let-values
695 (((response text)
696 (http-get #$(simple-format
697 #f "http://localhost:~A/" forwarded-port)
698 #:decode-body? #t)))
699 (and (equal? (response-code response) 200)
700 (string-contains text "WSGI Information"))))
701
702 (test-end))))
703
704 (gexp->derivation "gunicorn-test" test))
705
706(define %test-gunicorn
707 (system-test
708 (name "gunicorn")
709 (description "Test that gunicorn can serve the Werkzeug testapp.")
710 (value (run-gunicorn-test))))
711
712
713;;;
630;;; Patchwork 714;;; Patchwork
631;;; 715;;;
632 716