mirror of
https://blitiri.com.ar/repos/chasquid
synced 2026-01-07 17:47:14 +00:00
test: Use minidns in the Docker tests
The integration tests depend on having a DNS server that resolves "localhost", which is unfortunate but currently unavoidable given glibc's limitations ($HOSTALIASES only works on DNS-level aliases, and does not do lookups in /etc/hosts). Even under docker, this makes the tests depend on the DNS server, and whether it resolves localhost or not. In order to make the docker tests more hermetic and isolated from the environment, this patch introduces a docker entrypoint that, within the container, will launch minidns and override /etc/resolv.conf to use it. This guarantees that the tests will be able to resolve localhost, and also avoid accidental reliance on external DNS zones.
This commit is contained in:
@@ -27,6 +27,9 @@ RUN apt-get install -y -q \
|
||||
gettext-base dovecot-imapd \
|
||||
exim4-daemon-light
|
||||
|
||||
# Install sudo, needed for the docker entrypoint.
|
||||
RUN apt-get install -y -q sudo
|
||||
|
||||
# Prepare exim.
|
||||
RUN mkdir -p test/t-02-exim/.exim4 \
|
||||
&& ln -s /usr/sbin/exim4 test/t-02-exim/.exim4
|
||||
@@ -43,10 +46,13 @@ COPY . .
|
||||
# Install chasquid and its dependencies.
|
||||
RUN go get -d -v ./... && go install -v ./...
|
||||
|
||||
# Custom entry point, which uses our own DNS server.
|
||||
ENTRYPOINT ["./test/util/docker_entrypoint.sh"]
|
||||
|
||||
# Don't run the tests as root: it makes some integration tests more difficult,
|
||||
# as for example Exim has hard-coded protections against running as root.
|
||||
RUN useradd -m chasquid && chown -R chasquid:chasquid .
|
||||
USER chasquid
|
||||
#USER chasquid
|
||||
|
||||
# Tests expect the $USER variable set.
|
||||
ENV USER chasquid
|
||||
#ENV USER chasquid
|
||||
|
||||
Reference in New Issue
Block a user