mirror of
https://github.com/lancachenet/monolithic
synced 2024-11-22 03:53:06 +00:00
Change maps to allow user agent mapping too (#87)
Correclty disable StrictHostKeyChecking whilst we are at it! map "$http_useragent---$http_host" $cacheidentifier { Hostnames in maps file need to be regexs Save the docker image into the artifacts store to allow download for testing Need to handle *. wildcard Use # instead of / as regex/sed seperator to provide a slightly cleaner sed line for debug Provide comments and breakdown for sed (Requested by @GotenXiao Changed UA/Host seperator from --- to £££ @rconan suggestion from UKLans chat Closes #86 See github for details
This commit is contained in:
parent
1e15d97551
commit
f013ac0958
4 changed files with 23 additions and 10 deletions
|
@ -54,6 +54,9 @@ jobs:
|
||||||
- store_artifacts:
|
- store_artifacts:
|
||||||
path: reports
|
path: reports
|
||||||
destination: reports
|
destination: reports
|
||||||
|
- store_artifacts:
|
||||||
|
path: workspace/lancachenet-monolithic.tar
|
||||||
|
destination: docker-lancachenet-monolithic.tar
|
||||||
publish_latest:
|
publish_latest:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/python:2-jessie
|
- image: circleci/python:2-jessie
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
map $http_host $cacheidentifier {
|
map "$http_user_agent£££$http_host" $cacheidentifier {
|
||||||
hostnames;
|
|
||||||
default $http_host;
|
default $http_host;
|
||||||
|
~Valve\/Steam\ HTTP\ Client\ 1\.0£££.* steam;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
IFS=' '
|
IFS=' '
|
||||||
mkdir -p /data/cachedomains
|
mkdir -p /data/cachedomains
|
||||||
cd /data/cachedomains
|
cd /data/cachedomains
|
||||||
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostCACHE_IDENTIFIERChecking=no"
|
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
||||||
if [[ ! -d .git ]]; then
|
if [[ ! -d .git ]]; then
|
||||||
git clone ${CACHE_DOMAINS_REPO} .
|
git clone ${CACHE_DOMAINS_REPO} .
|
||||||
fi
|
fi
|
||||||
|
@ -14,9 +14,11 @@ if [[ "${NOFETCH:-false}" != "true" ]]; then
|
||||||
fi
|
fi
|
||||||
TEMP_PATH=$(mktemp -d)
|
TEMP_PATH=$(mktemp -d)
|
||||||
OUTPUTFILE=${TEMP_PATH}/outfile.conf
|
OUTPUTFILE=${TEMP_PATH}/outfile.conf
|
||||||
echo "map \$http_host \$cacheidentifier {" >> $OUTPUTFILE
|
echo "map \"\$http_user_agent£££\$http_host\" \$cacheidentifier {" >> $OUTPUTFILE
|
||||||
echo " hostnames;" >> $OUTPUTFILE
|
|
||||||
echo " default \$http_host;" >> $OUTPUTFILE
|
echo " default \$http_host;" >> $OUTPUTFILE
|
||||||
|
echo " ~Valve\\/Steam\\ HTTP\\ Client\\ 1\.0£££.* steam;" >> $OUTPUTFILE
|
||||||
|
#Next line probably no longer needed as we are now regexing to victory
|
||||||
|
#echo " hostnames;" >> $OUTPUTFILE
|
||||||
jq -r '.cache_domains | to_entries[] | .key' cache_domains.json | while read CACHE_ENTRY; do
|
jq -r '.cache_domains | to_entries[] | .key' cache_domains.json | while read CACHE_ENTRY; do
|
||||||
#for each cache entry, find the cache indentifier
|
#for each cache entry, find the cache indentifier
|
||||||
CACHE_IDENTIFIER=$(jq -r ".cache_domains[$CACHE_ENTRY].name" cache_domains.json)
|
CACHE_IDENTIFIER=$(jq -r ".cache_domains[$CACHE_ENTRY].name" cache_domains.json)
|
||||||
|
@ -32,7 +34,9 @@ jq -r '.cache_domains | to_entries[] | .key' cache_domains.json | while read CAC
|
||||||
CACHE_HOST=${CACHE_HOST// /}
|
CACHE_HOST=${CACHE_HOST// /}
|
||||||
echo "new host: $CACHE_HOST"
|
echo "new host: $CACHE_HOST"
|
||||||
if [ ! "x${CACHE_HOST}" == "x" ]; then
|
if [ ! "x${CACHE_HOST}" == "x" ]; then
|
||||||
echo " ${CACHE_HOST} ${CACHE_IDENTIFIER};" >> $OUTPUTFILE
|
#Use sed to replace . with \. and * with .*
|
||||||
|
REGEX_CACHE_HOST=$(sed -e "s#\.#\\\.#g" -e "s#\*#\.\*#g" <<< ${CACHE_HOST})
|
||||||
|
echo " ~.*£££.*?${REGEX_CACHE_HOST} ${CACHE_IDENTIFIER};" >> $OUTPUTFILE
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
14
run-tests.sh
14
run-tests.sh
|
@ -13,18 +13,24 @@ GOSS_WAIT_OPS="-r 60s -s 1s"
|
||||||
docker build --tag lancachenet/monolithic:goss-test .
|
docker build --tag lancachenet/monolithic:goss-test .
|
||||||
case $1 in
|
case $1 in
|
||||||
circleci)
|
circleci)
|
||||||
shift;
|
shift;
|
||||||
mkdir -p ./reports/goss
|
mkdir -p ./reports/goss
|
||||||
if [[ "$1" == "keepimage" ]]; then
|
if [[ "$1" == "keepimage" ]]; then
|
||||||
KEEPIMAGE=true
|
KEEPIMAGE=true
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
export GOSS_OPTS="$GOSS_OPTS --format junit"
|
export GOSS_OPTS="$GOSS_OPTS --format junit"
|
||||||
|
export CONTAINER_LOG_OUTPUT="reports/goss/docker.log"
|
||||||
dgoss run $@ lancachenet/monolithic:goss-test > reports/goss/report.xml
|
dgoss run $@ lancachenet/monolithic:goss-test > reports/goss/report.xml
|
||||||
#store result for exit code
|
#store result for exit code
|
||||||
RESULT=$?
|
RESULT=$?
|
||||||
|
#Ensure non blank docker.log
|
||||||
|
echo \
|
||||||
|
"Container Output:
|
||||||
|
$(cat reports/goss/docker.log)" \
|
||||||
|
> reports/goss/docker.log
|
||||||
#delete the junk that goss currently outputs :(
|
#delete the junk that goss currently outputs :(
|
||||||
sed -i '0,/^</d' reports/goss/report.xml
|
sed -i '0,/^</d' reports/goss/report.xml
|
||||||
#remove invalid system-err outputs from junit output so circleci can read it
|
#remove invalid system-err outputs from junit output so circleci can read it
|
||||||
sed -i '/<system-err>.*<\/system-err>/d' reports/goss/report.xml
|
sed -i '/<system-err>.*<\/system-err>/d' reports/goss/report.xml
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in a new issue