Skip to content

Commit 622f77c

Browse files
committed
Add test for quickstart scripts
1 parent f85d1b1 commit 622f77c

File tree

11 files changed

+179
-10
lines changed

11 files changed

+179
-10
lines changed

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
66
"image": "mcr.microsoft.com/devcontainers/base:jammy",
77
"features": {
8-
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
8+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
9+
"ghcr.io/devcontainers/features/python:1": {}
910
},
1011

1112
// Features to add to the dev container. More info: https://containers.dev/features.

.github/workflows/observability-docker.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,52 @@ jobs:
6666
push: true
6767
tags: ${{ steps.meta.outputs.tags }}
6868
labels: ${{ steps.meta.outputs.labels }}
69+
70+
71+
72+
73+
test-observability-quickstart-scripts:
74+
runs-on: ubuntu-latest
75+
name: Test observability Quickstart scripts
76+
77+
steps:
78+
- name: Checkout repository
79+
uses: actions/checkout@v4
80+
81+
- name: Set up Python
82+
uses: actions/setup-python@v4
83+
with:
84+
python-version: '3.9'
85+
86+
- name: Install Python dependencies
87+
run: pip install -r observability/test/requirements.txt
88+
89+
- name: Run Simple quickstart test
90+
run: |
91+
echo "🧪 Running Simple quickstart test..."
92+
bash observability/test/test-quickstart-simple.sh
93+
94+
- name: Report test result
95+
if: always()
96+
run: |
97+
if [ $? -eq 0 ]; then
98+
echo "✅ Full quickstart test PASSED"
99+
else
100+
echo "❌ Full quickstart test FAILED"
101+
exit 1
102+
fi
103+
104+
- name: Run full quickstart test
105+
run: |
106+
echo "🧪 Running full quickstart test..."
107+
./observability/test/test-quickstart-full.sh
108+
109+
- name: Report test result
110+
if: always()
111+
run: |
112+
if [ $? -eq 0 ]; then
113+
echo "✅ Full quickstart test PASSED"
114+
else
115+
echo "❌ Full quickstart test FAILED"
116+
exit 1
117+

observability/examples/full/full-quickstart.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@ download_to docker-compose.yml
2020
download_to exporters.docker-compose.yml
2121
download_to exporters.elastic.docker-compose.yml
2222

23-
download_to alloy/probers/probe-internal.yml
23+
download_to alloy/probers/probe-observability.yml
2424
download_to alloy/probers/probe-external.yml
2525
download_to prometheus/scrape-configs/exporters/exporters.yml
2626
download_to prometheus/scrape-configs/recording-rules/slo.yml
2727

28-
2928
echo "Setup complete in cogstack-observability/"
29+
30+
echo "Starting the observability stack"
31+
32+
docker compose up -d
33+
34+
echo "Please open http://localhost/grafana in your browser"
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Scrape metrics from any targets that are exposing Prometheus formatted data. Default is to call the /metrics API.
2-
- targets:
3-
- cogstack-observability-node-exporter-1:9100
4-
labels:
5-
job: node_exporter
6-
host: localhost
2+
# - targets:
3+
# - cogstack-observability-node-exporter-1:9100
4+
# labels:
5+
# job: node_exporter
6+
# host: localhost

observability/examples/simple/quickstart.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ curl -fsSL -o docker-compose.yml \
99
https://raw.githubusercontent.com/CogStack/cogstack-platform-toolkit/main/observability/examples/simple/docker-compose.yml
1010

1111
echo "Downloading probe-simple.yml into alloy/probers/..."
12-
curl -fsSL -o probers/probe-observability.yml \
13-
https://raw.githubusercontent.com/CogStack/cogstack-platform-toolkit/main/observability/examples/simple/probers/probe-observability.yml
12+
curl -fsSL -o alloy/probers/probe-observability.yml \
13+
https://raw.githubusercontent.com/CogStack/cogstack-platform-toolkit/main/observability/examples/simple/alloy/probers/probe-observability.yml
1414

1515
echo "Setup complete in observability-simple/"
1616

observability/grafana-alloy/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ FROM grafana/alloy:latest
33
LABEL traefik.enable="true" \
44
traefik.http.routers.alloy.rule="PathPrefix(`/alloy`)"
55

6+
EXPOSE 12345
7+
68
RUN mkdir -p /etc/alloy/probers
79

810
COPY ./defaults /etc/alloy

observability/prometheus/Dockerfile.prometheus

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ FROM prom/prometheus
33
LABEL traefik.enable="true" \
44
traefik.http.routers.prometheus-path-router.rule="PathPrefix(`/prometheus`)"
55

6+
RUN mkdir -p /etc/prometheus/cogstack/site/scrape-targets/probers
7+
RUN mkdir -p /etc/prometheus/cogstack/site/scrape-targets/exporters
8+
69
COPY ./defaults /etc/prometheus/cogstack/defaults
710

811
CMD [ \

observability/test/health-check.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env python3
2+
import requests
3+
import time
4+
import sys
5+
from urllib3.exceptions import InsecureRequestWarning
6+
7+
# Disable SSL warnings for localhost
8+
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
9+
10+
def check_service_health(url, service_name, timeout=120):
11+
"""Check if a service is responding with HTTP 200"""
12+
print(f"🔍 Checking {service_name} at {url}...")
13+
14+
start_time = time.time()
15+
while time.time() - start_time < timeout:
16+
try:
17+
print(f"Calling {url}...")
18+
response = requests.get(url, timeout=10, verify=False)
19+
if response.status_code == 200:
20+
print(f"✅ {service_name} is responding (HTTP {response.status_code})")
21+
return True
22+
except requests.exceptions.RequestException as e:
23+
print("Failed to call URL", e)
24+
pass
25+
26+
print(f"⏳ Waiting for {service_name}... ({int(time.time() - start_time)}s)")
27+
time.sleep(5)
28+
29+
print(f"❌ {service_name} failed to respond after {timeout}s")
30+
return False
31+
32+
def main():
33+
services = [
34+
("http://host.docker.internal/grafana", "Grafana"),
35+
("http://host.docker.internal/prometheus", "Prometheus"),
36+
("http://host.docker.internal/alloy", "Prometheus"),
37+
]
38+
39+
all_healthy = True
40+
for url, name in services:
41+
if not check_service_health(url, name):
42+
all_healthy = False
43+
44+
if all_healthy:
45+
print("\n🎉 All services are running successfully!")
46+
print("\n📊 Access your services:")
47+
return 0
48+
else:
49+
print("\n❌ Some services failed to start properly")
50+
return 1
51+
52+
if __name__ == "__main__":
53+
sys.exit(main())
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
certifi==2025.4.26
2+
charset-normalizer==3.4.2
3+
idna==3.10
4+
requests==2.32.4
5+
urllib3==2.4.0
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -e
3+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4+
5+
echo "🚀 Starting deployment test..."
6+
7+
# Run the quickstart script
8+
echo "📦 Running quickstart..."
9+
cd ${SCRIPT_DIR}../examples/full/
10+
bash ./full-quickstart.sh
11+
12+
# Run the health check
13+
echo "🔍 Running health check..."
14+
python ../../test/health-check.py
15+
16+
# Check if health check was successful
17+
if [ $? -eq 0 ]; then
18+
echo "✅ Success! All services are running."
19+
docker compose down
20+
exit 0
21+
else
22+
echo "❌ Health check failed."
23+
exit 1
24+
fi
25+

0 commit comments

Comments
 (0)