E2E Test: Docker image for E2E Test

Docker image for E2E test that will set up a
simple flask site running on port 80.
The contents of the flask site were provided
by Malini Kamalambal

Change-Id: I643c36480e033d0fe324c48d75872fedd6cc3af4
This commit is contained in:
Jorge Chai 2015-08-10 09:16:34 -04:00
parent 648c0c270e
commit 693f730489
22 changed files with 65217 additions and 0 deletions

View File

@ -0,0 +1,3 @@
*.md
*.pyc
*.swp

View 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
View 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

View File

@ -0,0 +1,3 @@
flask
flask_wtf
flask-headers

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

File diff suppressed because it is too large Load Diff

View 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-expires.jpg'>
</body>
</html>

View 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>

View 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>

View 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>

View File

@ -0,0 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>
<h4>Halo halo {{ name }}!</h4>
</head>
</html>

View 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>

View 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>

View 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>

View 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)