alpine 3.2 startup tests fixed, web still failing

This commit is contained in:
diginc 2017-12-11 10:28:05 -06:00
parent d47442ee6e
commit d9fa9b1016
8 changed files with 69 additions and 19 deletions

View File

@ -17,7 +17,8 @@ ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/dow
# TODO Re-enable upgrade after php5 packages use the latest greatest libressl packages, conflicts are breaking build 2017-11-14
#RUN apk update && \
RUN apk upgrade --update && \
apk add bind-tools wget curl bash libcap ncurses && \
apk add bind-tools wget curl bash libcap ncurses shadow && \
usermod -s bash root && \
{% else %}
RUN apt-get update && \
apt-get install -y wget curl net-tools cron && \
@ -55,6 +56,7 @@ RUN mkdir -p /etc/pihole/ && \
sed -i "s/@INT@/eth0/" /etc/dnsmasq.d/01-pihole.conf && \
setcap CAP_NET_BIND_SERVICE=+eip `which dnsmasq` && \
echo 'Done!'
COPY s6/timeout /usr/local/bin/timeout
{% endif %}
# php config start passes special ENVs into

View File

@ -16,7 +16,8 @@ ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/dow
# TODO Re-enable upgrade after php5 packages use the latest greatest libressl packages, conflicts are breaking build 2017-11-14
#RUN apk update && \
RUN apk upgrade --update && \
apk add bind-tools wget curl bash libcap ncurses && \
apk add bind-tools wget curl bash libcap ncurses shadow && \
usermod -s bash root && \
curl -L -s $S6OVERLAY_RELEASE \
| tar xvzf - -C / && \
docker-install.sh && \
@ -45,6 +46,7 @@ RUN mkdir -p /etc/pihole/ && \
sed -i "s/@INT@/eth0/" /etc/dnsmasq.d/01-pihole.conf && \
setcap CAP_NET_BIND_SERVICE=+eip `which dnsmasq` && \
echo 'Done!'
COPY s6/timeout /usr/local/bin/timeout
# php config start passes special ENVs into
ENV PHP_ENV_CONFIG '/etc/php5/fpm.d/envs.conf'

View File

@ -14,9 +14,10 @@ ENV PIHOLE_INSTALL /tmp/ph_install.sh
ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.2.1/s6-overlay-armhf.tar.gz
# TODO Re-enable upgrade after php5 packages use the latest greatest libressl packages, conflicts are breaking build 2017-11-14
# RUN apk upgrade --update && \
RUN apk update && \
apk add bind-tools wget curl bash libcap && \
#RUN apk update && \
RUN apk upgrade --update && \
apk add bind-tools wget curl bash libcap ncurses shadow && \
usermod -s bash root && \
curl -L -s $S6OVERLAY_RELEASE \
| tar xvzf - -C / && \
docker-install.sh && \
@ -45,6 +46,7 @@ RUN mkdir -p /etc/pihole/ && \
sed -i "s/@INT@/eth0/" /etc/dnsmasq.d/01-pihole.conf && \
setcap CAP_NET_BIND_SERVICE=+eip `which dnsmasq` && \
echo 'Done!'
COPY s6/timeout /usr/local/bin/timeout
# php config start passes special ENVs into
ENV PHP_ENV_CONFIG '/etc/php5/fpm.d/envs.conf'

View File

@ -34,7 +34,7 @@ validate_env() {
unset ServerIPv6
return
fi
if nc -w 1 -z "$ServerIPv6" 53 2>&1 | grep -q "$nc_error" || ! ip route get "$ServerIPv6" ; then
if nc -w 1 -z "$ServerIPv6" 53 2>&1 | grep -q "$nc_error" || ! ip route get "$ServerIPv6" > /dev/null ; then
echo "ERROR: ServerIPv6 Environment variable ($ServerIPv6) doesn't appear to be a valid IPv6 address"
echo " TIP: If your server is not IPv6 enabled just remove '-e ServerIPv6' from your docker container"
exit 1

View File

@ -1,10 +1,15 @@
#!/usr/bin/with-contenv bash
bashCmd='bash'
if [ "${PH_VERBOSE:-0}" -gt 0 ] ; then
set -x ;
bashCmd='bash -x'
fi
# Early DNS Startup for the gravity list process to use
dnsmasq -7 /etc/dnsmasq.d
/start.sh
gravity.sh
$bashCmd /start.sh
$bashCmd gravity.sh
# Done with DNS, let s6 services start up properly configured dns now
killall -9 dnsmasq

View File

@ -1,10 +1,15 @@
#!/usr/bin/with-contenv bash
bashCmd='bash'
if [ "${PH_VERBOSE:-0}" -gt 0 ] ; then
set -x ;
bashCmd='bash -x'
fi
# Early DNS Startup for the gravity list process to use
dnsmasq -7 /etc/dnsmasq.d
/start.sh
gravity.sh
$bashCmd /start.sh
$bashCmd gravity.sh
# Done with DNS, let s6 services start up properly configured dns now
killall -9 dnsmasq

15
s6/timeout Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
# A shim to make busybox timeout take in debian style args
# v1 only need support for this style: `timeout 1 getent hosts github.com`
# Busybox args:
# Usage: timeout [-t SECS] [-s SIG] PROG ARGS
# Debian args:
# Usage: timeout [OPTION] DURATION COMMAND [ARG]...
# or: timeout [OPTION]
TIMEOUT=/usr/bin/timeout
SECS="${1}"
ARGS="${@:2}"
$TIMEOUT -t $SECS $ARGS

View File

@ -53,9 +53,15 @@ def test_indecies_are_present(RunningPiHole):
def test_html_index_requests_load_as_expected(RunningPiHole, Slow, addr, url):
command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://{}{}'.format(addr, url)
http_rc = RunningPiHole.run(command)
assert http_rc.rc == 0
assert int(http_rc.stdout) == 200
page_contents = RunningPiHole.run('cat /tmp/curled_file ').stdout
expeced_http_code = 200
if http_rc != 0 or http_rc.stdout != expected_http_code:
print 'CURL stdout: {}\nCURL stderr:{}\nCURL file:\n{}\n'.format(
http_rc.stdout, http_rc.stderr, page_contents)
assert http_rc.rc == 0
assert int(http_rc.stdout) == expected_http_code
assert 'testblock.pi-hole.local' in page_contents
@pytest.mark.parametrize('addr', [ 'testblock.pi-hole.local' ])
@ -63,9 +69,16 @@ def test_html_index_requests_load_as_expected(RunningPiHole, Slow, addr, url):
def test_javascript_requests_load_as_expected(RunningPiHole, addr, url):
command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://{}{}'.format(addr, url)
http_rc = RunningPiHole.run(command)
page_contents = RunningPiHole.run('cat /tmp/curled_file ').stdout
expeced_http_code = 200
if http_rc != 0 or http_rc.stdout != expected_http_code:
print 'CURL stdout: {}\nCURL stderr:{}\nCURL file:\n{}\n'.format(
http_rc.stdout, http_rc.stderr, page_contents)
assert http_rc.rc == 0
assert int(http_rc.stdout) == 200
assert 'var x = "Pi-hole: A black hole for Internet advertisements."' in RunningPiHole.run('cat /tmp/curled_file').stdout
assert int(http_rc.stdout) == expected_http_code
assert 'var x = "Pi-hole: A black hole for Internet advertisements."' in page_contents
# IPv6 checks aren't passing CORS, removed :(
@pytest.mark.parametrize('addr', [ 'localhost' ] )
@ -73,9 +86,15 @@ def test_javascript_requests_load_as_expected(RunningPiHole, addr, url):
def test_admin_requests_load_as_expected(RunningPiHole, addr, url):
command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://{}{}'.format(addr, url)
http_rc = RunningPiHole.run(command)
assert http_rc.rc == 0
assert int(http_rc.stdout) == 200
assert RunningPiHole.run('wc -l /tmp/curled_file ') > 10
assert RunningPiHole.run('grep -q "Content-Security-Policy" /tmp/curled_file ').rc == 0
assert RunningPiHole.run('grep -q "scripts/pi-hole/js/footer.js" /tmp/curled_file ').rc == 0
page_contents = RunningPiHole.run('cat /tmp/curled_file ').stdout
expeced_http_code = 200
if http_rc != 0 or http_rc.stdout != expected_http_code:
print 'CURL stdout: {}\nCURL stderr:{}\nCURL file:\n{}\n'.format(
http_rc.stdout, http_rc.stderr, page_contents)
assert http_rc.rc == 0
assert int(http_rc.stdout) == expected_http_code
for html_text in ['dns_queries_today', 'Content-Security-Policy', 'scripts/pi-hole/js/footer.js']:
assert html_text in page_contents