http_headers: Substitute Nginx version based on OS.

success-http-headers-bionic.txt and success-http-headers-focal.txt
differ only in the nginx version so this substitution will allow
us to have single file for both of them. Also this change helps
to avoid CI failure if Nginx version is updated in the OS.
This commit is contained in:
arpit551
2020-07-04 16:47:27 +05:30
committed by Tim Abbott
parent 04ef6ba63a
commit 4f6cd6577c
6 changed files with 10 additions and 43 deletions

View File

@@ -299,8 +299,7 @@ jobs:
# Must be relative path from root # Must be relative path from root
paths: paths:
- zulip-server-test.tar.gz - zulip-server-test.tar.gz
- success-http-headers-bionic.txt - success-http-headers.template.txt
- success-http-headers-focal.txt
- production-install - production-install
- production-verify - production-verify
- production-upgrade-pg - production-upgrade-pg

View File

@@ -32,8 +32,7 @@ fi
# .circleci/config.yml # .circleci/config.yml
mv /tmp/tmp.*/zulip-server-test.tar.gz /tmp/ mv /tmp/tmp.*/zulip-server-test.tar.gz /tmp/
cp -a \ cp -a \
tools/ci/success-http-headers-bionic.txt \ tools/ci/success-http-headers.template.txt \
tools/ci/success-http-headers-focal.txt \
tools/ci/production-install \ tools/ci/production-install \
tools/ci/production-verify \ tools/ci/production-verify \
tools/ci/production-upgrade-pg \ tools/ci/production-upgrade-pg \

View File

@@ -5,11 +5,6 @@
set -e set -e
set -x set -x
if [ -f /etc/os-release ]; then
os_info="$(. /etc/os-release; printf '%s\n' "$VERSION_CODENAME")"
{ read -r os_version_codename || true; } <<< "$os_info"
fi
cat >>/etc/zulip/settings.py <<EOF cat >>/etc/zulip/settings.py <<EOF
# CircleCI override settings above # CircleCI override settings above
AUTHENTICATION_BACKENDS = ( 'zproject.backends.EmailAuthBackend', ) AUTHENTICATION_BACKENDS = ( 'zproject.backends.EmailAuthBackend', )
@@ -43,13 +38,15 @@ echo; echo "Now testing that the newly installed server's homepage loads"; echo
wget https://localhost -O /tmp/index.html --no-check-certificate -S 2> /tmp/wget-output || true # || true so we see errors.log if this 500s wget https://localhost -O /tmp/index.html --no-check-certificate -S 2> /tmp/wget-output || true # || true so we see errors.log if this 500s
grep -vi '\(Vary\|Content-Language\|expires\|issued by\|modified\|saved\|[.][.][.]\|Date\|[-][-]\)' /tmp/wget-output > /tmp/http-headers-processed grep -vi '\(Vary\|Content-Language\|expires\|issued by\|modified\|saved\|[.][.][.]\|Date\|[-][-]\)' /tmp/wget-output > /tmp/http-headers-processed
nginx_version="$(nginx -v 2>&1 | awk '{print $3, $4}')"
# Simplify the diff by getting replacing 4-5 digit length numbers with <Length>. # Simplify the diff by getting replacing 4-5 digit length numbers with <Length>.
sed -i 's|Length: [0-9]\+\( [(][0-9]\+[.][0-9]K[)]\)\?|Length: <Length>|' /tmp/http-headers-processed sed -i 's|Length: [0-9]\+\( [(][0-9]\+[.][0-9]K[)]\)\?|Length: <Length>|' /tmp/http-headers-processed
sed -i 's|Length: [0-9]\+\( [(][0-9]\+[.][0-9]K[)]\)\?|Length: <Length>|' /tmp/success-http-headers-"$os_version_codename".txt sed -i -e 's|Length: [0-9]\+\( [(][0-9]\+[.][0-9]K[)]\)\?|Length: <Length>|' -e "s|{nginx_version_string}|$nginx_version|g" /tmp/success-http-headers.template.txt
if ! diff -ur /tmp/http-headers-processed /tmp/success-http-headers-"$os_version_codename".txt; then if ! diff -ur /tmp/http-headers-processed /tmp/success-http-headers.template.txt; then
set +x set +x
echo echo
echo "FAILURE: The HTTP Headers returned from loading the homepage on the server do not match the contents of tools/ci/success-http-headers.txt. Typically, this means that the server threw a 500 when trying to load the homepage." echo "FAILURE: The HTTP Headers returned from loading the homepage on the server do not match the contents of tools/ci/success-http-headers.template.txt. Typically, this means that the server threw a 500 when trying to load the homepage."
echo "Displaying the contents of the server's error log:" echo "Displaying the contents of the server's error log:"
echo echo
cat /var/log/zulip/errors.log cat /var/log/zulip/errors.log

View File

@@ -1,28 +0,0 @@
Self-signed certificate encountered.
WARNING: certificate common name 127.0.0.1 doesn't match requested host name localhost.
HTTP/1.1 302 Found
Server: nginx/1.18.0 (Ubuntu)
Content-Type: text/html; charset=utf-8
Content-Length: 0
Connection: keep-alive
Location: /login/
Strict-Transport-Security: max-age=15768000
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Location: /login/ [following]
Reusing existing connection to localhost:443.
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Content-Type: text/html; charset=utf-8
Content-Length: 6361
Connection: keep-alive
Strict-Transport-Security: max-age=15768000
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Length: 6361 (6.2K) [text/html]
Saving to: /tmp/index.html

View File

@@ -1,7 +1,7 @@
Self-signed certificate encountered. Self-signed certificate encountered.
WARNING: certificate common name 127.0.0.1 doesn't match requested host name localhost. WARNING: certificate common name 127.0.0.1 doesn't match requested host name localhost.
HTTP/1.1 302 Found HTTP/1.1 302 Found
Server: nginx/1.14.0 (Ubuntu) Server: {nginx_version_string}
Content-Type: text/html; charset=utf-8 Content-Type: text/html; charset=utf-8
Content-Length: 0 Content-Length: 0
Connection: keep-alive Connection: keep-alive
@@ -13,7 +13,7 @@
Location: /login/ [following] Location: /login/ [following]
Reusing existing connection to localhost:443. Reusing existing connection to localhost:443.
HTTP/1.1 200 OK HTTP/1.1 200 OK
Server: nginx/1.14.0 (Ubuntu) Server: {nginx_version_string}
Content-Type: text/html; charset=utf-8 Content-Type: text/html; charset=utf-8
Content-Length: 6361 Content-Length: 6361
Connection: keep-alive Connection: keep-alive

View File

@@ -65,7 +65,7 @@ whitespace_rules: List["Rule"] = [
}, },
{'pattern': '\t', {'pattern': '\t',
'strip': '\n', 'strip': '\n',
'exclude': {'tools/ci/success-http-headers-bionic.txt', 'tools/ci/success-http-headers-focal.txt'}, 'exclude': {'tools/ci/success-http-headers.template.txt'},
'description': 'Fix tab-based whitespace'}, 'description': 'Fix tab-based whitespace'},
] ]
comma_whitespace_rule: List["Rule"] = [ comma_whitespace_rule: List["Rule"] = [