Compare commits
10
Commits
4277e0774e
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e8816def9 | ||
|
|
a313e57777 | ||
|
|
7b8282df75 | ||
|
|
7227afb3dc | ||
|
|
67ccd237a8 | ||
|
|
3dc7e946cd | ||
|
|
07be88a783 | ||
|
|
359b1c6ba4 | ||
|
|
0aecadb699 | ||
|
|
0e2e5cba34 |
Vendored
+7
-6
@@ -1,7 +1,7 @@
|
|||||||
// Pull requests run tests and checks only. On main, a change under pricing/
|
// Pull requests run tests and checks only. On main, a change to pricing/,
|
||||||
// builds one image and promotes its digest from staging to production after a
|
// ansible/ or this file builds one image and promotes its digest from staging
|
||||||
// human approval. Setting RELEASE_RECORD redeploys an existing release without
|
// to production after a human approval. Setting RELEASE_RECORD redeploys an
|
||||||
// building, which is how rollback and recovery run.
|
// existing release without building, which is how rollback and recovery run.
|
||||||
|
|
||||||
// Applies one release record with Ansible on the delivery agent.
|
// Applies one release record with Ansible on the delivery agent.
|
||||||
def deploy(String record, String label) {
|
def deploy(String record, String label) {
|
||||||
@@ -108,8 +108,8 @@ pipeline {
|
|||||||
when { allOf { branch 'main'; expression { !params.RELEASE_RECORD } } }
|
when { allOf { branch 'main'; expression { !params.RELEASE_RECORD } } }
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
env.DELIVER = sh(returnStatus: true, script: 'git diff --quiet HEAD^1 HEAD -- pricing') != 0 ? 'true' : 'false'
|
env.DELIVER = sh(returnStatus: true, script: 'git diff --quiet HEAD^1 HEAD -- pricing ansible Jenkinsfile') != 0 ? 'true' : 'false'
|
||||||
echo "pricing/ changed: ${env.DELIVER}"
|
echo "pricing/, ansible/ or Jenkinsfile changed: ${env.DELIVER}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,6 +143,7 @@ pipeline {
|
|||||||
withCredentials([usernamePassword(credentialsId: 'registry-write', usernameVariable: 'REG_USER', passwordVariable: 'REG_TOKEN')]) {
|
withCredentials([usernamePassword(credentialsId: 'registry-write', usernameVariable: 'REG_USER', passwordVariable: 'REG_TOKEN')]) {
|
||||||
sh '''#!/bin/bash
|
sh '''#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
mkdir -p releases reports
|
||||||
export DOCKER_CONFIG=$(mktemp -d)
|
export DOCKER_CONFIG=$(mktemp -d)
|
||||||
trap 'rm -rf "$DOCKER_CONFIG"' EXIT
|
trap 'rm -rf "$DOCKER_CONFIG"' EXIT
|
||||||
printf '%s' "$REG_TOKEN" | docker login "${IMAGE%%/*}" -u "$REG_USER" --password-stdin
|
printf '%s' "$REG_TOKEN" | docker login "${IMAGE%%/*}" -u "$REG_USER" --password-stdin
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
},
|
},
|
||||||
"schemaVersion": 39,
|
"schemaVersion": 39,
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"description": "ssw-590 droplet health and Gitea/Jenkins HTTPS availability. Source: deploy/monitoring in SeatBackTrivia/seat-back-trivia.",
|
"description": "ssw-590 droplet health and Gitea, Jenkins, and production pricing HTTPS availability. Source: deploy/monitoring in SeatBackTrivia/seat-back-trivia.",
|
||||||
"annotations": {
|
"annotations": {
|
||||||
"list": [
|
"list": [
|
||||||
{
|
{
|
||||||
@@ -600,6 +600,91 @@
|
|||||||
"instant": true
|
"instant": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 8,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Production pricing availability",
|
||||||
|
"description": "probe_success for https://app.pollefeys.dev/health: 1 when DNS, TLS, and an HTTP 200 health response succeed within 10 s through Caddy, 0 otherwise. Scraped every 30 s, so a failure shorter than that can fall between samples. Version and price are checked by the pipeline smoke test, not by this probe.",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 19,
|
||||||
|
"w": 24,
|
||||||
|
"h": 7
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"custom": {
|
||||||
|
"lineWidth": 2,
|
||||||
|
"fillOpacity": 10,
|
||||||
|
"showPoints": "never",
|
||||||
|
"spanNulls": false,
|
||||||
|
"lineInterpolation": "stepAfter",
|
||||||
|
"thresholdsStyle": {
|
||||||
|
"mode": "off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"unit": "none",
|
||||||
|
"color": {
|
||||||
|
"mode": "palette-classic"
|
||||||
|
},
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"min": 0,
|
||||||
|
"max": 1,
|
||||||
|
"mappings": [
|
||||||
|
{
|
||||||
|
"type": "value",
|
||||||
|
"options": {
|
||||||
|
"0": {
|
||||||
|
"text": "DOWN",
|
||||||
|
"color": "red"
|
||||||
|
},
|
||||||
|
"1": {
|
||||||
|
"text": "UP",
|
||||||
|
"color": "green"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom",
|
||||||
|
"showLegend": true
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"mode": "multi",
|
||||||
|
"sort": "none"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"refId": "A",
|
||||||
|
"datasource": {
|
||||||
|
"type": "prometheus",
|
||||||
|
"uid": "prometheus"
|
||||||
|
},
|
||||||
|
"expr": "probe_success{job=\"https\",instance=\"https://app.pollefeys.dev/health\"}",
|
||||||
|
"legendFormat": "Pricing (production)",
|
||||||
|
"range": true,
|
||||||
|
"instant": false
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ scrape_configs:
|
|||||||
- targets:
|
- targets:
|
||||||
- https://git.pollefeys.dev/user/login
|
- https://git.pollefeys.dev/user/login
|
||||||
- https://ci.pollefeys.dev/login
|
- https://ci.pollefeys.dev/login
|
||||||
|
# Production pricing service (Assignment 8).
|
||||||
|
- https://app.pollefeys.dev/health
|
||||||
relabel_configs:
|
relabel_configs:
|
||||||
- source_labels: [__address__]
|
- source_labels: [__address__]
|
||||||
target_label: __param_target
|
target_label: __param_target
|
||||||
|
|||||||
+2
-2
@@ -2,8 +2,8 @@ import os
|
|||||||
from flask import Flask, jsonify, request
|
from flask import Flask, jsonify, request
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
VERSION = "v1"
|
VERSION = "v2"
|
||||||
UNIT_PRICE = 10
|
UNIT_PRICE = 12
|
||||||
COMMIT = os.environ.get("APP_COMMIT", "development")
|
COMMIT = os.environ.get("APP_COMMIT", "development")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -7,17 +7,17 @@ class PricingTests(unittest.TestCase):
|
|||||||
self.client = app.test_client()
|
self.client = app.test_client()
|
||||||
|
|
||||||
def test_price(self):
|
def test_price(self):
|
||||||
self.assertEqual(total_price(3), 30)
|
self.assertEqual(total_price(3), 36)
|
||||||
response = self.client.get("/price?quantity=3")
|
response = self.client.get("/price?quantity=3")
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(response.json["total"], 30)
|
self.assertEqual(response.json["total"], 36)
|
||||||
|
|
||||||
def test_invalid_quantity(self):
|
def test_invalid_quantity(self):
|
||||||
for value in ["0", "-1", "1001", "abc", "1.5"]:
|
for value in ["0", "-1", "1001", "abc", "1.5"]:
|
||||||
self.assertEqual(self.client.get("/price?quantity=" + value).status_code, 400)
|
self.assertEqual(self.client.get("/price?quantity=" + value).status_code, 400)
|
||||||
|
|
||||||
def test_release_identity(self):
|
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")
|
self.assertEqual(self.client.get("/health").json["status"], "ok")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
target_env: production
|
||||||
|
release_image: git.pollefeys.dev/seatbacktrivia/pricing@sha256:53b4f06375d3b704d7bf86051aae4cbccf5dc9a85b233076fed238496ac916c6
|
||||||
|
expected_version: v1
|
||||||
|
expected_commit: 0aecadb699d65c3275e38079308b389c2ce53db0
|
||||||
|
expected_total: 30
|
||||||
|
public_url: https://app.pollefeys.dev
|
||||||
|
proxy_network: gitea_gitea-net
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
target_env: staging
|
||||||
|
release_image: git.pollefeys.dev/seatbacktrivia/pricing@sha256:53b4f06375d3b704d7bf86051aae4cbccf5dc9a85b233076fed238496ac916c6
|
||||||
|
expected_version: v1
|
||||||
|
expected_commit: 0aecadb699d65c3275e38079308b389c2ce53db0
|
||||||
|
expected_total: 30
|
||||||
|
public_url: https://staging.pollefeys.dev
|
||||||
|
proxy_network: gitea_gitea-net
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
target_env: production
|
||||||
|
release_image: git.pollefeys.dev/seatbacktrivia/pricing@sha256:5c9cd0243b2d3a7712926909a9a942d082fafc87a662e26b4b69ce3b35e22e65
|
||||||
|
expected_version: v2
|
||||||
|
expected_commit: 67ccd237a88a2b6f8df11351e7f02ef6bd673fa4
|
||||||
|
expected_total: 36
|
||||||
|
public_url: https://app.pollefeys.dev
|
||||||
|
proxy_network: gitea_gitea-net
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
target_env: staging
|
||||||
|
release_image: git.pollefeys.dev/seatbacktrivia/pricing@sha256:5c9cd0243b2d3a7712926909a9a942d082fafc87a662e26b4b69ce3b35e22e65
|
||||||
|
expected_version: v2
|
||||||
|
expected_commit: 67ccd237a88a2b6f8df11351e7f02ef6bd673fa4
|
||||||
|
expected_total: 36
|
||||||
|
public_url: https://staging.pollefeys.dev
|
||||||
|
proxy_network: gitea_gitea-net
|
||||||
Reference in New Issue
Block a user