Merge "Run gitea with memcached cache adapter"

This commit is contained in:
Zuul 2025-02-28 21:54:54 +00:00 committed by Gerrit Code Review
commit 343dacc4bc
5 changed files with 44 additions and 4 deletions

View File

@ -34,8 +34,12 @@
- name: Install distro packages
package:
name:
# TODO(clarkb) does the install-docker role handle these two packages?
- docker-compose
- python3-requests
# Installed to make checking memcached stats easy in testing and for
# human led debugging.
- netcat-openbsd
state: present
- name: Install reverse proxy
@ -63,9 +67,9 @@
shell:
cmd: docker-compose stop --timeout 60
chdir: /etc/gitea-docker/
- name: Run docker-compose up mariadb gitea-web
- name: Run docker-compose up mariadb memcached gitea-web
shell:
cmd: docker-compose up -d --timeout 60 mariadb gitea-web
cmd: docker-compose up -d --timeout 60 mariadb memcached gitea-web
chdir: /etc/gitea-docker/
# We wait here for the main gitea service to start before starting

View File

@ -30,6 +30,10 @@ PASSWD = {{ gitea_db_password }}
SSL_MODE = disable
LOG_SQL = false
[cache]
ADAPTER = memcache
HOST = 127.0.0.1:11211
[repository]
ROOT = /data/git/repositories
DISABLED_REPO_UNITS = repo.issues,repo.pulls,repo.wiki,repo.projects,repo.actions

View File

@ -20,9 +20,22 @@ services:
driver: journald
options:
tag: "docker-mariadb"
memcached:
image: quay.io/opendevmirror/memcached:latest
network_mode: host
restart: always
command:
- -v
- --listen=127.0.0.1:11211
- --memory-limit=1024
logging:
driver: journald
options:
tag: "docker-memcached"
gitea-web:
depends_on:
- mariadb
- memcached
image: docker.io/opendevorg/gitea:latest
network_mode: host
restart: always

View File

@ -26,6 +26,8 @@ def test_gitea_listening(host):
assert gitea_ssh.is_listening
gitea_proxy = host.socket("tcp://0.0.0.0:3081")
assert gitea_proxy.is_listening
memcached = host.socket("tcp://127.0.0.1:11211")
assert memcached.is_listening
def test_ulimit(host):
cmd = host.run("/usr/local/bin/docker-compose "
@ -73,6 +75,12 @@ def test_ondisk_logs(host):
mariadb_log = host.file('/var/log/containers/docker-mariadb.log')
assert mariadb_log.exists
# Commented out for now as memcached logging is either very quiet and
# we don't create the file or very verbose and far too chatty for
# production (basically no logs or every set and get is logged).
#memcached_log = host.file('/var/log/containers/docker-memcached.log')
#assert memcached_log.exists
gitea_log = host.file('/var/log/containers/docker-gitea.log')
assert gitea_log.exists
@ -135,11 +143,14 @@ def test_no_500_template_content(host):
assert '<title>Internal Server Error' not in cmd.stdout
def test_gitea_screenshots(host):
shots = (
('https://localhost:3081', None, 'gitea-main.png'),
('https://localhost:3081/opendev/system-config', None,
'gitea-project-system-config.png'),
# Fetch system-config twice to ensure we exercise the caching
# system.
('https://localhost:3081/opendev/system-config', None,
'gitea-project-system-config2.png'),
('https://localhost:3081/opendev/disk-image-builder', None,
'gitea-project-dib.png'),
('https://localhost:3081/opendev/', None,
@ -150,3 +161,11 @@ def test_gitea_screenshots(host):
take_screenshots(host, shots)
def test_memcached_has_data(host):
# We only listen on localhost on the gitea server otherwise we could
# open a socket directly from this test case and request the stats data.
cmd = host.run("echo 'stats' | nc -N 127.0.0.1 11211")
assert cmd.succeeded
# Having more than 0 bytes in memcached implies gitea is using
# the server as a cache.
assert 'STAT bytes 0' not in cmd.stdout

View File

@ -651,7 +651,7 @@
parent: system-config-run-containers
description: |
Run the playbook for the gitea servers.
timeout: 4800
timeout: 5400
nodeset:
nodes:
- <<: *bridge_node_x86