diff options
Diffstat (limited to 'gnu/tests/version-control.scm')
| -rw-r--r-- | gnu/tests/version-control.scm | 138 |
1 files changed, 136 insertions, 2 deletions
diff --git a/gnu/tests/version-control.scm b/gnu/tests/version-control.scm index d3cf19c9138..a7cde1f1632 100644 --- a/gnu/tests/version-control.scm +++ b/gnu/tests/version-control.scm | |||
| @@ -38,7 +38,8 @@ | |||
| 38 | #:use-module (guix modules) | 38 | #:use-module (guix modules) |
| 39 | #:export (%test-cgit | 39 | #:export (%test-cgit |
| 40 | %test-git-http | 40 | %test-git-http |
| 41 | %test-gitolite)) | 41 | %test-gitolite |
| 42 | %test-gitile)) | ||
| 42 | 43 | ||
| 43 | (define README-contents | 44 | (define README-contents |
| 44 | "Hello! This is what goes inside the 'README' file.") | 45 | "Hello! This is what goes inside the 'README' file.") |
| @@ -63,7 +64,10 @@ | |||
| 63 | (invoke git "commit" "-m" "That's a commit.")) | 64 | (invoke git "commit" "-m" "That's a commit.")) |
| 64 | 65 | ||
| 65 | (mkdir-p "/srv/git") | 66 | (mkdir-p "/srv/git") |
| 66 | (rename-file "/tmp/test-repo/.git" "/srv/git/test"))))) | 67 | (rename-file "/tmp/test-repo/.git" "/srv/git/test") |
| 68 | (with-output-to-file "/srv/git/test/git-daemon-export-ok" | ||
| 69 | (lambda _ | ||
| 70 | (display ""))))))) | ||
| 67 | 71 | ||
| 68 | (define %test-repository-service | 72 | (define %test-repository-service |
| 69 | ;; Service that creates /srv/git/test. | 73 | ;; Service that creates /srv/git/test. |
| @@ -416,3 +420,133 @@ HTTP-PORT." | |||
| 416 | (name "gitolite") | 420 | (name "gitolite") |
| 417 | (description "Clone the Gitolite admin repository.") | 421 | (description "Clone the Gitolite admin repository.") |
| 418 | (value (run-gitolite-test)))) | 422 | (value (run-gitolite-test)))) |
| 423 | |||
| 424 | ;;; | ||
| 425 | ;;; Gitile. | ||
| 426 | ;;; | ||
| 427 | |||
| 428 | (define %gitile-configuration-nginx | ||
| 429 | (nginx-server-configuration | ||
| 430 | (root "/does/not/exists") | ||
| 431 | (try-files (list "$uri" "=404")) | ||
| 432 | (listen '("19418")) | ||
| 433 | (ssl-certificate #f) | ||
| 434 | (ssl-certificate-key #f))) | ||
| 435 | |||
| 436 | (define %gitile-os | ||
| 437 | ;; Operating system under test. | ||
| 438 | (simple-operating-system | ||
| 439 | (service dhcp-client-service-type) | ||
| 440 | (simple-service 'srv-git activation-service-type | ||
| 441 | #~(mkdir-p "/srv/git")) | ||
| 442 | (service gitile-service-type | ||
| 443 | (gitile-configuration | ||
| 444 | (base-git-url "http://localhost") | ||
| 445 | (repositories "/srv/git") | ||
| 446 | (nginx %gitile-configuration-nginx))) | ||
| 447 | %test-repository-service)) | ||
| 448 | |||
| 449 | (define* (run-gitile-test #:optional (http-port 19418)) | ||
| 450 | "Run tests in %GITOLITE-OS, which has nginx running and listening on | ||
| 451 | HTTP-PORT." | ||
| 452 | (define os | ||
| 453 | (marionette-operating-system | ||
| 454 | %gitile-os | ||
| 455 | #:imported-modules '((gnu services herd) | ||
| 456 | (guix combinators)))) | ||
| 457 | |||
| 458 | (define vm | ||
| 459 | (virtual-machine | ||
| 460 | (operating-system os) | ||
| 461 | (port-forwardings `((8081 . ,http-port))))) | ||
| 462 | |||
| 463 | (define test | ||
| 464 | (with-imported-modules '((gnu build marionette)) | ||
| 465 | #~(begin | ||
| 466 | (use-modules (srfi srfi-11) (srfi srfi-64) | ||
| 467 | (gnu build marionette) | ||
| 468 | (web uri) | ||
| 469 | (web client) | ||
| 470 | (web response)) | ||
| 471 | |||
| 472 | (define marionette | ||
| 473 | (make-marionette (list #$vm))) | ||
| 474 | |||
| 475 | (mkdir #$output) | ||
| 476 | (chdir #$output) | ||
| 477 | |||
| 478 | (test-begin "gitile") | ||
| 479 | |||
| 480 | ;; XXX: Shepherd reads the config file *before* binding its control | ||
| 481 | ;; socket, so /var/run/shepherd/socket might not exist yet when the | ||
| 482 | ;; 'marionette' service is started. | ||
| 483 | (test-assert "shepherd socket ready" | ||
| 484 | (marionette-eval | ||
| 485 | `(begin | ||
| 486 | (use-modules (gnu services herd)) | ||
| 487 | (let loop ((i 10)) | ||
| 488 | (cond ((file-exists? (%shepherd-socket-file)) | ||
| 489 | #t) | ||
| 490 | ((> i 0) | ||
| 491 | (sleep 1) | ||
| 492 | (loop (- i 1))) | ||
| 493 | (else | ||
| 494 | 'failure)))) | ||
| 495 | marionette)) | ||
| 496 | |||
| 497 | ;; Wait for nginx to be up and running. | ||
| 498 | (test-assert "nginx running" | ||
| 499 | (marionette-eval | ||
| 500 | '(begin | ||
| 501 | (use-modules (gnu services herd)) | ||
| 502 | (start-service 'nginx)) | ||
| 503 | marionette)) | ||
| 504 | |||
| 505 | ;; Make sure the PID file is created. | ||
| 506 | (test-assert "PID file" | ||
| 507 | (marionette-eval | ||
| 508 | '(file-exists? "/var/run/nginx/pid") | ||
| 509 | marionette)) | ||
| 510 | |||
| 511 | ;; Make sure Git test repository is created. | ||
| 512 | (test-assert "Git test repository" | ||
| 513 | (marionette-eval | ||
| 514 | '(file-exists? "/srv/git/test") | ||
| 515 | marionette)) | ||
| 516 | |||
| 517 | (sleep 2) | ||
| 518 | |||
| 519 | ;; Make sure we can access pages that correspond to our repository. | ||
| 520 | (letrec-syntax ((test-url | ||
| 521 | (syntax-rules () | ||
| 522 | ((_ path code) | ||
| 523 | (test-equal (string-append "GET " path) | ||
| 524 | code | ||
| 525 | (let-values (((response body) | ||
| 526 | (http-get (string-append | ||
| 527 | "http://localhost:8081" | ||
| 528 | path)))) | ||
| 529 | (response-code response)))) | ||
| 530 | ((_ path) | ||
| 531 | (test-url path 200))))) | ||
| 532 | (test-url "/") | ||
| 533 | (test-url "/css/gitile.css") | ||
| 534 | (test-url "/test") | ||
| 535 | (test-url "/test/commits") | ||
| 536 | (test-url "/test/tree" 404) | ||
| 537 | (test-url "/test/tree/-") | ||
| 538 | (test-url "/test/tree/-/README") | ||
| 539 | (test-url "/test/does-not-exist" 404) | ||
| 540 | (test-url "/test/tree/-/does-not-exist" 404) | ||
| 541 | (test-url "/does-not-exist" 404)) | ||
| 542 | |||
| 543 | (test-end) | ||
| 544 | (exit (= (test-runner-fail-count (test-runner-current)) 0))))) | ||
| 545 | |||
| 546 | (gexp->derivation "gitile-test" test)) | ||
| 547 | |||
| 548 | (define %test-gitile | ||
| 549 | (system-test | ||
| 550 | (name "gitile") | ||
| 551 | (description "Connect to a running Gitile server.") | ||
| 552 | (value (run-gitile-test)))) | ||
