Skip to content

Commit

Permalink
New cluster setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
glogiotatidis committed Dec 2, 2020
1 parent cfb4b0b commit ef7d95b
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 14 deletions.
16 changes: 4 additions & 12 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
variables:
DOCKER_REPOSITORY: "mozmeao/snippets"
DOCKER_IMAGE_TAG: "${DOCKER_REPOSITORY}:${CI_COMMIT_SHORT_SHA}"
# Cannot use $DOCKER_IMAGE_TAG because it contains other variables itself.
DOCKER_RUN_CMD: "docker run --env-file .docker-env ${DOCKER_REPOSITORY}:${CI_COMMIT_SHORT_SHA}"

stages:
- build
Expand Down Expand Up @@ -70,21 +67,14 @@ run-unit-tests-redirector:
script:
- bin/update-config.sh

dev:
extends: .deploy
only:
- master
variables:
NAMESPACE: snippets-dev
CLUSTERS: oregon-a

stage:
extends: .deploy
only:
- stage
variables:
NAMESPACE: snippets-stage
CLUSTERS: oregon-a
DOCKER_IMAGE_TAG: "${DOCKER_REPOSITORY}:${CI_COMMIT_SHORT_SHA}"

admin:
extends: .deploy
Expand All @@ -93,11 +83,13 @@ admin:
variables:
NAMESPACE: snippets-admin
CLUSTERS: oregon-a
DOCKER_IMAGE_TAG: "${DOCKER_REPOSITORY}:${CI_COMMIT_SHORT_SHA}"

prod:
extends: .deploy
only:
- prod
variables:
NAMESPACE: snippets-prod
CLUSTERS: frankfurt oregon-a
CLUSTERS: frankfurt-eks oregon-eks
DOCKER_IMAGE_TAG: "${DOCKER_REPOSITORY}:redirector-${CI_COMMIT_SHORT_SHA}"
57 changes: 57 additions & 0 deletions bin/acceptance-tests-redirector.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
EXIT=0
BASE_URL=${1:-https://snippets.mozilla.com}
URLS=(
"/"
"/healthz/"

"/6/Firefox/62.0.1/20160922113459/WINNT_x86-msvc/en-US/release/Windows_NT%206.1/default/default/"
)

function check_http_code {
echo -n "Checking URL ${1} "
curl -k -L -s -o /dev/null -I -w "%{http_code}" $1 | grep ${2:-200} > /dev/null
if [ $? -eq 0 ];
then
echo "OK"
else
echo "Failed"
EXIT=1
fi
}

function check_zero_content_length {
echo -n "Checking zero content length of URL ${1} "
test=$(curl -L -s ${1} | wc -c);
if [[ $test -eq 0 ]];
then
echo "OK"
else
echo "Failed"
EXIT=1
fi
}

function check_empty_json {
echo -n "Checking empty json for URL ${1} "
test=$(curl -L -s ${1});
if [ $test = '{}' ];
then
echo "OK"
else
echo "Failed"
EXIT=1
fi
}

for url in ${URLS[*]}
do
check_http_code ${BASE_URL}${url}
done

# Check a page that throws 404. Not ideal but will surface 500s
check_http_code ${BASE_URL}/foo 404

check_empty_json ${BASE_URL}/6/Firefox/56.0.1/20160922113459/WINNT_x86-msvc/xx/release/Windows_NT%206.1/default/default/

exit ${EXIT}
1 change: 1 addition & 0 deletions bin/acceptance-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ URLS=(
"/"
"/healthz/"
"/readiness/"
"/admin/"
"/robots.txt"
"/contribute.json"
"/6/Firefox/62.0.1/20160922113459/WINNT_x86-msvc/en-US/release/Windows_NT%206.1/default/default/"
Expand Down
4 changes: 2 additions & 2 deletions bin/update-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ for CLUSTER in ${CLUSTERS}; do
done
done

cp ${BIN_DIR}/acceptance-tests.sh .
git add acceptance-tests.sh
cp ${BIN_DIR}/acceptance-tests*.sh .
git add acceptance-tests*.sh
git commit -m "set image to ${DOCKER_IMAGE_TAG}" || echo "nothing new to commit"
git push
popd

0 comments on commit ef7d95b

Please sign in to comment.