Merge "E2E Test: Docker image for E2E Test"
This commit is contained in:
commit
b9a9e94c26
3
docker/e2e_test/.dockerignore
Normal file
3
docker/e2e_test/.dockerignore
Normal file
@ -0,0 +1,3 @@
|
||||
*.md
|
||||
*.pyc
|
||||
*.swp
|
15
docker/e2e_test/Dockerfile
Normal file
15
docker/e2e_test/Dockerfile
Normal file
@ -0,0 +1,15 @@
|
||||
# Dockerfile for Origin Flask E2E Test Site
|
||||
|
||||
FROM ubuntu
|
||||
|
||||
RUN apt-get update && apt-get upgrade -y
|
||||
RUN apt-get install -y python-dev python-pip
|
||||
RUN pip install pip --upgrade
|
||||
|
||||
ADD flasksite /opt/flasksite
|
||||
|
||||
RUN pip install -r /opt/flasksite/requirements.txt
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD python /opt/flasksite/test_app.py
|
15
docker/e2e_test/README.md
Normal file
15
docker/e2e_test/README.md
Normal file
@ -0,0 +1,15 @@
|
||||
Building the E2E Test Site Image
|
||||
--------------------------------
|
||||
|
||||
From the docker/e2e_test folder:
|
||||
|
||||
$ docker build -t e2e_flasksite_1 .
|
||||
|
||||
|
||||
Running the E2E Test Site Docker Container
|
||||
------------------------------------------
|
||||
|
||||
Name the container 'e2e_flasksite':
|
||||
|
||||
$ docker run -d -p 80:80 --name e2e_flasksite e2e_flasksite_1
|
||||
|
3
docker/e2e_test/flasksite/requirements.txt
Normal file
3
docker/e2e_test/flasksite/requirements.txt
Normal file
@ -0,0 +1,3 @@
|
||||
flask
|
||||
flask_wtf
|
||||
flask-headers
|
BIN
docker/e2e_test/flasksite/static/images/XXgorilla.jpeg
Normal file
BIN
docker/e2e_test/flasksite/static/images/XXgorilla.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
docker/e2e_test/flasksite/static/images/cache-control.jpg
Normal file
BIN
docker/e2e_test/flasksite/static/images/cache-control.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
BIN
docker/e2e_test/flasksite/static/images/camera.jpg
Normal file
BIN
docker/e2e_test/flasksite/static/images/camera.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
docker/e2e_test/flasksite/static/images/expire-cache-control.jpg
Normal file
BIN
docker/e2e_test/flasksite/static/images/expire-cache-control.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 68 KiB |
BIN
docker/e2e_test/flasksite/static/images/expires.jpg
Normal file
BIN
docker/e2e_test/flasksite/static/images/expires.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
Binary file not shown.
After Width: | Height: | Size: 91 KiB |
BIN
docker/e2e_test/flasksite/static/lm2k11.zip
Normal file
BIN
docker/e2e_test/flasksite/static/lm2k11.zip
Normal file
Binary file not shown.
65007
docker/e2e_test/flasksite/static/pg2600.txt
Normal file
65007
docker/e2e_test/flasksite/static/pg2600.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<h4>Imagine your picture here {{ name }}!</h4>
|
||||
</head>
|
||||
<body>
|
||||
<img src='../../static/images/cache-control-expires.jpg'>
|
||||
</body>
|
||||
</html>
|
9
docker/e2e_test/flasksite/templates/cache-control.html
Normal file
9
docker/e2e_test/flasksite/templates/cache-control.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<h4>Imagine your picture here {{ name }}!</h4>
|
||||
</head>
|
||||
<body>
|
||||
<img src='../../static/images/cache-control.jpg'>
|
||||
</body>
|
||||
</html>
|
9
docker/e2e_test/flasksite/templates/expires.html
Normal file
9
docker/e2e_test/flasksite/templates/expires.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<h4>Imagine your picture here {{ name }}!</h4>
|
||||
</head>
|
||||
<body>
|
||||
<img src='../../static/images/expires.jpg'>
|
||||
</body>
|
||||
</html>
|
9
docker/e2e_test/flasksite/templates/gorilla.html
Normal file
9
docker/e2e_test/flasksite/templates/gorilla.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<h4>Imagine your picture here {{ name }}!</h4>
|
||||
</head>
|
||||
<body>
|
||||
<img src='../static/images/gorilla.jpeg'>
|
||||
</body>
|
||||
</html>
|
6
docker/e2e_test/flasksite/templates/hello.html
Normal file
6
docker/e2e_test/flasksite/templates/hello.html
Normal file
@ -0,0 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<h4>Halo halo {{ name }}!</h4>
|
||||
</head>
|
||||
</html>
|
9
docker/e2e_test/flasksite/templates/jpg.html
Normal file
9
docker/e2e_test/flasksite/templates/jpg.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<h4>Imagine your picture here {{ name }}!</h4>
|
||||
</head>
|
||||
<body>
|
||||
<img src='../../static/images/camera.jpg'>
|
||||
</body>
|
||||
</html>
|
9
docker/e2e_test/flasksite/templates/text.html
Normal file
9
docker/e2e_test/flasksite/templates/text.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<h4>Imagine your picture here {{ name }}!</h4>
|
||||
</head>
|
||||
<body>
|
||||
<img src='../../static/pg2600.txt'>
|
||||
</body>
|
||||
</html>
|
9
docker/e2e_test/flasksite/templates/zip.html
Normal file
9
docker/e2e_test/flasksite/templates/zip.html
Normal file
@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<h4>Imagine your picture here {{ name }}!</h4>
|
||||
</head>
|
||||
<body>
|
||||
<img src='../../static/lm2k11.zip'>
|
||||
</body>
|
||||
</html>
|
105
docker/e2e_test/flasksite/test_app.py
Normal file
105
docker/e2e_test/flasksite/test_app.py
Normal file
@ -0,0 +1,105 @@
|
||||
# Copyright (c) 2015 Rackspace, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
# implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import datetime
|
||||
|
||||
from flask import Flask
|
||||
from flask import make_response
|
||||
from flask import render_template
|
||||
from flask import request
|
||||
from flask_wtf import form
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return 'Test Flask Site from 23.253.156.204'
|
||||
|
||||
|
||||
@app.route('/hello/', strict_slashes=False)
|
||||
def hello():
|
||||
return 'halo halo from 23.253.156.204'
|
||||
|
||||
|
||||
@app.route('/hello/<user_name>/')
|
||||
def hello_user(user_name):
|
||||
print(request.headers)
|
||||
return render_template('hello.html', name=user_name)
|
||||
|
||||
|
||||
@app.route('/test/host-header/')
|
||||
def test_host_header():
|
||||
print(request.headers)
|
||||
return render_template('hello.html', name=request.headers['Host'])
|
||||
|
||||
|
||||
@app.route('/hello/<user_name>/upload/', methods=['GET', 'POST'])
|
||||
def upload_file(user_name):
|
||||
if request.method == 'POST':
|
||||
form.photo.data.save('/var/www/uploads/{0}.jpg'.format(user_name))
|
||||
else:
|
||||
return render_template('gorilla.html', name=user_name)
|
||||
|
||||
|
||||
@app.route('/test/camera.jpg', strict_slashes=False)
|
||||
def test_jpg():
|
||||
response = make_response(render_template('jpg.html', name='jpg'))
|
||||
return response
|
||||
|
||||
|
||||
@app.route('/test/text.txt', strict_slashes=False)
|
||||
def test_txt():
|
||||
response = app.send_static_file('pg2600.txt')
|
||||
return response
|
||||
|
||||
|
||||
@app.route('/test/line.zip', strict_slashes=False)
|
||||
def test_zip():
|
||||
response = app.send_static_file('lm2k11.zip')
|
||||
return response
|
||||
|
||||
|
||||
@app.route('/test/cache-control/cache-control.jpg', strict_slashes=False)
|
||||
def test_cache_control():
|
||||
response = make_response(render_template('cache-control.html',
|
||||
name='cache-control'))
|
||||
response.headers['Cache-Control'] = 'public, max-age=10'
|
||||
return response
|
||||
|
||||
|
||||
@app.route('/test/expires/expires.jpg', strict_slashes=False)
|
||||
def test_expires():
|
||||
expiry_time = datetime.datetime.utcnow() + datetime.timedelta(0, 20)
|
||||
response_expires = make_response('Expires test')
|
||||
response_expires.headers['Expires'] = expiry_time.strftime(
|
||||
"%a, %d %b %Y %H:%M:%S GMT")
|
||||
return response_expires
|
||||
|
||||
|
||||
@app.route('/test/expires-cache-control/expires-cache-control.jpg',
|
||||
strict_slashes=False)
|
||||
def test_expires_and_cache_control():
|
||||
expiry_time = datetime.datetime.utcnow() + datetime.timedelta(0, 20)
|
||||
response = make_response('Expires & Cache Control - test')
|
||||
response.headers['Expires'] = expiry_time.strftime(
|
||||
"%a, %d %b %Y %H:%M:%S GMT")
|
||||
response.headers['Cache-Control'] = 'public, max-age=10'
|
||||
return response
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.debug = True
|
||||
app.run(host='0.0.0.0', port=80)
|
Loading…
x
Reference in New Issue
Block a user