mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-15 12:25:50 +00:00
debbug 4
This commit is contained in:
parent
da5cb7e45d
commit
81e3895c0e
1 changed files with 141 additions and 75 deletions
216
.github/workflows/pipeline.yml
vendored
216
.github/workflows/pipeline.yml
vendored
|
@ -81,42 +81,62 @@ jobs:
|
||||||
# Mesure de la consommation d'énergie avec PowerAPI
|
# Mesure de la consommation d'énergie avec PowerAPI
|
||||||
python3 -c "
|
python3 -c "
|
||||||
import powerapi
|
import powerapi
|
||||||
from powerapi import database
|
import csv
|
||||||
|
from datetime import datetime
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
# Configuration de la base de données
|
def log_power_metrics(output_file='metrics/power/build_power_metrics.csv', duration=60):
|
||||||
db = database.InfluxDatabase(
|
os.makedirs(os.path.dirname(output_file), exist_ok=True)
|
||||||
host='localhost',
|
|
||||||
port=8086,
|
|
||||||
database='powerapi'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Configuration du monitoring
|
with open(output_file, 'w', newline='') as csvfile:
|
||||||
monitor = powerapi.monitor.PowerMonitor(
|
csv_writer = csv.writer(csvfile)
|
||||||
'rapl', # Utilisation de l'interface RAPL
|
csv_writer.writerow([
|
||||||
db,
|
'Timestamp',
|
||||||
1 # Période de mesure en secondes
|
'Power_Watts',
|
||||||
)
|
'Energy_Joules',
|
||||||
|
'Device_Name'
|
||||||
|
])
|
||||||
|
|
||||||
# Démarrer le monitoring
|
class CSVPowerReporter(powerapi.reporter.Reporter):
|
||||||
monitor.start()
|
def __init__(self, output_file):
|
||||||
|
super().__init__()
|
||||||
|
self.output_file = output_file
|
||||||
|
|
||||||
# Enregistrer le début du monitoring
|
def report(self, data):
|
||||||
print('Monitoring started')
|
with open(self.output_file, 'a', newline='') as csvfile:
|
||||||
" &
|
csv_writer = csv.writer(csvfile)
|
||||||
POWERAPI_PID=$!
|
csv_writer.writerow([
|
||||||
|
datetime.now().isoformat(),
|
||||||
|
getattr(data, 'power', 'N/A'),
|
||||||
|
getattr(data, 'energy', 'N/A'),
|
||||||
|
getattr(data, 'device_name', 'N/A')
|
||||||
|
])
|
||||||
|
|
||||||
# Build optimisé
|
reporter = CSVPowerReporter(output_file)
|
||||||
./mvnw -B verify \
|
|
||||||
-Dmaven.test.skip=true \
|
monitor = powerapi.monitor.PowerMonitor(
|
||||||
-Dcheckstyle.skip=true \
|
'rapl', # Utilisation de l'interface RAPL
|
||||||
-T 1C
|
reporter,
|
||||||
|
1 # Période de mesure en secondes
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
monitor.start()
|
||||||
|
result = subprocess.run(['./mvnw', '-B', 'verify', '-Dmaven.test.skip=true', '-Dcheckstyle.skip=true', '-T', '1C'], capture_output=True, text=True)
|
||||||
|
print(result.stdout)
|
||||||
|
print(result.stderr, file=sys.stderr)
|
||||||
|
time.sleep(5) # Période supplémentaire après le build
|
||||||
|
finally:
|
||||||
|
monitor.stop()
|
||||||
|
|
||||||
|
log_power_metrics()
|
||||||
|
"
|
||||||
|
|
||||||
build_status=$?
|
build_status=$?
|
||||||
end_time=$(date +%s%N)
|
end_time=$(date +%s%N)
|
||||||
|
|
||||||
# Arrêter PowerAPI
|
|
||||||
kill $POWERAPI_PID
|
|
||||||
|
|
||||||
# Collecter les métriques post-build
|
# Collecter les métriques post-build
|
||||||
free -m > metrics/system/post_build_memory.txt
|
free -m > metrics/system/post_build_memory.txt
|
||||||
|
|
||||||
|
@ -140,39 +160,62 @@ jobs:
|
||||||
# Mesure de la consommation d'énergie avec PowerAPI
|
# Mesure de la consommation d'énergie avec PowerAPI
|
||||||
python3 -c "
|
python3 -c "
|
||||||
import powerapi
|
import powerapi
|
||||||
from powerapi import database
|
import csv
|
||||||
|
from datetime import datetime
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
# Configuration de la base de données
|
def log_power_metrics(output_file='metrics/power/test_power_metrics.csv', duration=60):
|
||||||
db = database.InfluxDatabase(
|
os.makedirs(os.path.dirname(output_file), exist_ok=True)
|
||||||
host='localhost',
|
|
||||||
port=8086,
|
|
||||||
database='powerapi'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Configuration du monitoring
|
with open(output_file, 'w', newline='') as csvfile:
|
||||||
monitor = powerapi.monitor.PowerMonitor(
|
csv_writer = csv.writer(csvfile)
|
||||||
'rapl', # Utilisation de l'interface RAPL
|
csv_writer.writerow([
|
||||||
db,
|
'Timestamp',
|
||||||
1 # Période de mesure en secondes
|
'Power_Watts',
|
||||||
)
|
'Energy_Joules',
|
||||||
|
'Device_Name'
|
||||||
|
])
|
||||||
|
|
||||||
# Démarrer le monitoring
|
class CSVPowerReporter(powerapi.reporter.Reporter):
|
||||||
monitor.start()
|
def __init__(self, output_file):
|
||||||
|
super().__init__()
|
||||||
|
self.output_file = output_file
|
||||||
|
|
||||||
# Enregistrer le début du monitoring
|
def report(self, data):
|
||||||
print('Monitoring started')
|
with open(self.output_file, 'a', newline='') as csvfile:
|
||||||
" &
|
csv_writer = csv.writer(csvfile)
|
||||||
POWERAPI_PID=$!
|
csv_writer.writerow([
|
||||||
|
datetime.now().isoformat(),
|
||||||
|
getattr(data, 'power', 'N/A'),
|
||||||
|
getattr(data, 'energy', 'N/A'),
|
||||||
|
getattr(data, 'device_name', 'N/A')
|
||||||
|
])
|
||||||
|
|
||||||
# Tests optimisés
|
reporter = CSVPowerReporter(output_file)
|
||||||
./mvnw test -T 1C
|
|
||||||
|
monitor = powerapi.monitor.PowerMonitor(
|
||||||
|
'rapl', # Utilisation de l'interface RAPL
|
||||||
|
reporter,
|
||||||
|
1 # Période de mesure en secondes
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
monitor.start()
|
||||||
|
result = subprocess.run(['./mvnw', 'test', '-T', '1C'], capture_output=True, text=True)
|
||||||
|
print(result.stdout)
|
||||||
|
print(result.stderr, file=sys.stderr)
|
||||||
|
time.sleep(5) # Période supplémentaire après les tests
|
||||||
|
finally:
|
||||||
|
monitor.stop()
|
||||||
|
|
||||||
|
log_power_metrics()
|
||||||
|
"
|
||||||
|
|
||||||
test_status=$?
|
test_status=$?
|
||||||
end_time=$(date +%s%N)
|
end_time=$(date +%s%N)
|
||||||
|
|
||||||
# Arrêter PowerAPI
|
|
||||||
kill $POWERAPI_PID
|
|
||||||
|
|
||||||
# Collecter les métriques post-tests
|
# Collecter les métriques post-tests
|
||||||
free -m > metrics/system/post_test_memory.txt
|
free -m > metrics/system/post_test_memory.txt
|
||||||
|
|
||||||
|
@ -197,39 +240,62 @@ jobs:
|
||||||
# Mesure de la consommation d'énergie avec PowerAPI
|
# Mesure de la consommation d'énergie avec PowerAPI
|
||||||
python3 -c "
|
python3 -c "
|
||||||
import powerapi
|
import powerapi
|
||||||
from powerapi import database
|
import csv
|
||||||
|
from datetime import datetime
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
# Configuration de la base de données
|
def log_power_metrics(output_file='metrics/power/docker_build_power_metrics.csv', duration=60):
|
||||||
db = database.InfluxDatabase(
|
os.makedirs(os.path.dirname(output_file), exist_ok=True)
|
||||||
host='localhost',
|
|
||||||
port=8086,
|
|
||||||
database='powerapi'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Configuration du monitoring
|
with open(output_file, 'w', newline='') as csvfile:
|
||||||
monitor = powerapi.monitor.PowerMonitor(
|
csv_writer = csv.writer(csvfile)
|
||||||
'rapl', # Utilisation de l'interface RAPL
|
csv_writer.writerow([
|
||||||
db,
|
'Timestamp',
|
||||||
1 # Période de mesure en secondes
|
'Power_Watts',
|
||||||
)
|
'Energy_Joules',
|
||||||
|
'Device_Name'
|
||||||
|
])
|
||||||
|
|
||||||
# Démarrer le monitoring
|
class CSVPowerReporter(powerapi.reporter.Reporter):
|
||||||
monitor.start()
|
def __init__(self, output_file):
|
||||||
|
super().__init__()
|
||||||
|
self.output_file = output_file
|
||||||
|
|
||||||
# Enregistrer le début du monitoring
|
def report(self, data):
|
||||||
print('Monitoring started')
|
with open(self.output_file, 'a', newline='') as csvfile:
|
||||||
" &
|
csv_writer = csv.writer(csvfile)
|
||||||
POWERAPI_PID=$!
|
csv_writer.writerow([
|
||||||
|
datetime.now().isoformat(),
|
||||||
|
getattr(data, 'power', 'N/A'),
|
||||||
|
getattr(data, 'energy', 'N/A'),
|
||||||
|
getattr(data, 'device_name', 'N/A')
|
||||||
|
])
|
||||||
|
|
||||||
# Build Docker optimisé
|
reporter = CSVPowerReporter(output_file)
|
||||||
docker build -t app:latest -f .devcontainer/Dockerfile . --no-cache
|
|
||||||
|
monitor = powerapi.monitor.PowerMonitor(
|
||||||
|
'rapl', # Utilisation de l'interface RAPL
|
||||||
|
reporter,
|
||||||
|
1 # Période de mesure en secondes
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
monitor.start()
|
||||||
|
result = subprocess.run(['docker', 'build', '-t', 'app:latest', '-f', '.devcontainer/Dockerfile', '.', '--no-cache'], capture_output=True, text=True)
|
||||||
|
print(result.stdout)
|
||||||
|
print(result.stderr, file=sys.stderr)
|
||||||
|
time.sleep(5) # Période supplémentaire après le build Docker
|
||||||
|
finally:
|
||||||
|
monitor.stop()
|
||||||
|
|
||||||
|
log_power_metrics()
|
||||||
|
"
|
||||||
|
|
||||||
build_status=$?
|
build_status=$?
|
||||||
end_time=$(date +%s%N)
|
end_time=$(date +%s%N)
|
||||||
|
|
||||||
# Arrêter PowerAPI
|
|
||||||
kill $POWERAPI_PID
|
|
||||||
|
|
||||||
# Collecter les métriques post-docker
|
# Collecter les métriques post-docker
|
||||||
free -m > metrics/system/post_docker_memory.txt
|
free -m > metrics/system/post_docker_memory.txt
|
||||||
df -h > metrics/system/post_docker_disk.txt
|
df -h > metrics/system/post_docker_disk.txt
|
||||||
|
|
Loading…
Reference in a new issue