From 827b447cf3a16f3608b1c2e29f03ef7ae88229ef Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Fri, 17 Jan 2025 09:32:14 +0000
Subject: [PATCH] Load data from test blogs

---
 .gitlab-ci.yml | 13 +++++++++++--
 docker/test.sh |  2 +-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b903ecb9..b4cb5524 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,6 +1,13 @@
 include: "https://git.autistici.org/pipelines/containers/raw/master/common.yml"
 
-# test the newly built container before releasing it.
+# Test the newly built container before releasing it.
+#
+# Use "float-podman-runner" to set up a rootless container like 'float' does.
+# Use "ai3/testdata" to populate a MySQL database that looks like the real
+# noblogs.org, and finally run some HTTP tests (in docker/test.sh).
+# NOTE: The database configuration (docker/test-config.json) does not match
+# production as there is no sharding, instead everything is stored in the
+# main 'noblogs' database.
 test:
   stage: container-test
   image: registry.git.autistici.org/pipelines/images/test/float-podman-runner:master
@@ -12,7 +19,8 @@ test:
   tags: [podman]
   variables:
     APACHE_PORT: 8080
-    SITE_URL: "http://localhost:8080"
+    TARGET_URL: "http://localhost:8080"
+    TARGET_ADDR: "127.0.0.1:8080"
     MYSQL_DATABASE: noblogs
     MYSQL_ROOT_PASSWORD: rootpass
   before_script:
@@ -21,5 +29,6 @@ test:
     - dnf install -y mysql xz git
     - git clone --depth=1 https://gitlab-ci-token:${CI_JOB_TOKEN}@git.autistici.org/ai3/testdata.git /tmp/testdata.$CI_JOB_ID
     - xzcat /tmp/testdata.$CI_JOB_ID/noblogs/noblogs.sql.xz | mysql --user=root --password=rootpass --host=mysql noblogs
+    - for blog in cavallette detriti docs ; do xzcat /tmp/testdata.$CI_JOB_ID/noblogs/noblogs_${blog}.sql.xz | mysql --user=root --password=rootpass --host=mysql noblogs; done
     - with-container --expose=8080 --mount=type=bind,source=docker/test-config.json,destination=/etc/noblogs/config.json --mount=type=tmpfs,destination=/opt/noblogs/www/wp-content/blogs.dir --mount=type=tmpfs,destination=/opt/noblogs/www/wp-content/cache $IMAGE_TAG ./docker/test.sh
 
diff --git a/docker/test.sh b/docker/test.sh
index 55dcaed1..55ab1657 100755
--- a/docker/test.sh
+++ b/docker/test.sh
@@ -1,4 +1,4 @@
 #!/bin/sh
 
-exec curl -H 'Host: noblogs.org' -v -s ${SITE_URL}/
+exec curl -H 'X-Forwarded-Proto: https' -H 'Host: noblogs.org' -v -s ${TARGET_URL}/
 
-- 
GitLab