Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0cdd9159b | ||
|
|
ee128d18bd | ||
|
|
4d7e4f932f | ||
|
|
699d509024 | ||
|
|
126dbb00b3 | ||
|
|
0cb5a34cc4 | ||
|
|
746b42b72b | ||
|
|
935eaa8624 |
@@ -1,6 +1,9 @@
|
||||
services:
|
||||
app:
|
||||
image: "{{ release_image }}"
|
||||
{% if target_env == 'staging' %}
|
||||
command: ["gunicorn", "--bind", "0.0.0.0:8001", "app:app"]
|
||||
{% endif %}
|
||||
restart: unless-stopped
|
||||
read_only: true
|
||||
tmpfs:
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version": "v1", "quantity3_total": 30}
|
||||
{"version": "v2", "quantity3_total": 36}
|
||||
|
||||
@@ -8,5 +8,5 @@ RUN python -m pip uninstall -y pip && rm -rf /usr/local/lib/python3.13/ensurepip
|
||||
COPY app.py .
|
||||
USER 10001:10001
|
||||
EXPOSE 8000
|
||||
HEALTHCHECK --interval=10s --timeout=3s --start-period=10s --retries=3 CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=2)"
|
||||
HEALTHCHECK --interval=10s --timeout=10s --start-period=10s --retries=3 CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=8)"
|
||||
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "1", "--worker-tmp-dir", "/tmp", "app:app"]
|
||||
|
||||
@@ -2,8 +2,8 @@ import os
|
||||
from flask import Flask, jsonify, request
|
||||
|
||||
app = Flask(__name__)
|
||||
VERSION = "v1"
|
||||
UNIT_PRICE = 10
|
||||
VERSION = "v2"
|
||||
UNIT_PRICE = 12
|
||||
COMMIT = os.environ.get("APP_COMMIT", "development")
|
||||
|
||||
|
||||
|
||||
@@ -7,17 +7,17 @@ class PricingTests(unittest.TestCase):
|
||||
self.client = app.test_client()
|
||||
|
||||
def test_price(self):
|
||||
self.assertEqual(total_price(3), 30)
|
||||
self.assertEqual(total_price(3), 36)
|
||||
response = self.client.get("/price?quantity=3")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.json["total"], 30)
|
||||
self.assertEqual(response.json["total"], 36)
|
||||
|
||||
def test_invalid_quantity(self):
|
||||
for value in ["0", "-1", "1001", "abc", "1.5"]:
|
||||
self.assertEqual(self.client.get("/price?quantity=" + value).status_code, 400)
|
||||
|
||||
def test_release_identity(self):
|
||||
self.assertEqual(self.client.get("/").json["version"], "v1")
|
||||
self.assertEqual(self.client.get("/").json["version"], "v2")
|
||||
self.assertEqual(self.client.get("/health").json["status"], "ok")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user