v1
This commit is contained in:
363
TESTING.md
Normal file
363
TESTING.md
Normal file
@@ -0,0 +1,363 @@
|
|||||||
|
# Testing Guide - Linux BenchTools
|
||||||
|
|
||||||
|
Guide de test pour vérifier que tout fonctionne correctement.
|
||||||
|
|
||||||
|
## ✅ Checklist de test
|
||||||
|
|
||||||
|
### 1. Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Cloner le projet
|
||||||
|
git clone https://gitea.maison43.duckdns.org/gilles/linux-benchtools.git
|
||||||
|
cd linux-benchtools
|
||||||
|
|
||||||
|
# Vérifier les fichiers
|
||||||
|
ls -la
|
||||||
|
|
||||||
|
# Exécuter l'installation
|
||||||
|
./install.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
**Résultat attendu** :
|
||||||
|
- ✅ Docker images construites
|
||||||
|
- ✅ Conteneurs démarrés
|
||||||
|
- ✅ Fichier `.env` créé avec un token
|
||||||
|
- ✅ Message de succès avec les URLs
|
||||||
|
|
||||||
|
### 2. Vérification des services
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Vérifier que les conteneurs tournent
|
||||||
|
docker compose ps
|
||||||
|
|
||||||
|
# Devrait afficher :
|
||||||
|
# linux_benchtools_backend running 0.0.0.0:8007->8007/tcp
|
||||||
|
# linux_benchtools_frontend running 0.0.0.0:8087->80/tcp
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Tester le backend
|
||||||
|
curl http://localhost:8007/api/health
|
||||||
|
|
||||||
|
# Résultat attendu : {"status":"ok"}
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Tester le frontend
|
||||||
|
curl -I http://localhost:8087
|
||||||
|
|
||||||
|
# Résultat attendu : HTTP/1.1 200 OK
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Test de l'API Backend
|
||||||
|
|
||||||
|
#### Health Check
|
||||||
|
```bash
|
||||||
|
curl http://localhost:8007/api/health
|
||||||
|
# {"status":"ok"}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Stats (base vide)
|
||||||
|
```bash
|
||||||
|
curl http://localhost:8007/api/stats
|
||||||
|
# {"total_devices":0,"total_benchmarks":0,"avg_global_score":0,"last_benchmark_at":null}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Liste devices (vide)
|
||||||
|
```bash
|
||||||
|
curl http://localhost:8007/api/devices
|
||||||
|
# {"items":[],"total":0,"page":1,"page_size":20}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Test du Frontend
|
||||||
|
|
||||||
|
Ouvrir dans un navigateur :
|
||||||
|
```
|
||||||
|
http://localhost:8087
|
||||||
|
```
|
||||||
|
|
||||||
|
**Vérifications** :
|
||||||
|
- ✅ Dashboard s'affiche avec le thème Monokai dark
|
||||||
|
- ✅ Stats affichent "0" partout
|
||||||
|
- ✅ Message "Aucun device trouvé"
|
||||||
|
- ✅ Commande de benchmark est affichée
|
||||||
|
- ✅ Navigation fonctionne (Dashboard, Devices, Settings)
|
||||||
|
|
||||||
|
### 5. Test du script bench.sh
|
||||||
|
|
||||||
|
#### Test d'aide
|
||||||
|
```bash
|
||||||
|
./scripts/bench.sh --help
|
||||||
|
```
|
||||||
|
|
||||||
|
**Résultat attendu** :
|
||||||
|
- Affiche l'usage
|
||||||
|
- Liste toutes les options
|
||||||
|
|
||||||
|
#### Test avec erreur (sans paramètres)
|
||||||
|
```bash
|
||||||
|
./scripts/bench.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
**Résultat attendu** :
|
||||||
|
- Message d'erreur clair
|
||||||
|
- Indique qu'il manque --server et --token
|
||||||
|
|
||||||
|
#### Test complet (simulation)
|
||||||
|
|
||||||
|
Sur la machine serveur (ou n'importe quelle machine Linux) :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Récupérer le token
|
||||||
|
TOKEN=$(grep API_TOKEN .env | cut -d= -f2)
|
||||||
|
|
||||||
|
# Exécuter le benchmark
|
||||||
|
curl -s http://localhost:8087/scripts/bench.sh | bash -s -- \
|
||||||
|
--server http://localhost:8007/api/benchmark \
|
||||||
|
--token "$TOKEN" \
|
||||||
|
--short
|
||||||
|
```
|
||||||
|
|
||||||
|
**Résultat attendu** :
|
||||||
|
```
|
||||||
|
[INFO] Linux BenchTools Client v1.0.0
|
||||||
|
[INFO] Checking dependencies...
|
||||||
|
[INFO] All dependencies satisfied
|
||||||
|
[INFO] Collecting hardware information...
|
||||||
|
[INFO] Running benchmarks...
|
||||||
|
[INFO] Running CPU benchmark...
|
||||||
|
[INFO] Running memory benchmark...
|
||||||
|
[INFO] Running disk benchmark...
|
||||||
|
[INFO] Building JSON payload...
|
||||||
|
[INFO] Sending results to server...
|
||||||
|
[INFO] Benchmark submitted successfully!
|
||||||
|
[INFO] Response: {"status":"ok","device_id":1,"benchmark_id":1,...}
|
||||||
|
[INFO] Benchmark completed!
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Vérifier dans l'interface
|
||||||
|
|
||||||
|
1. Rafraîchir le Dashboard (F5)
|
||||||
|
2. Vérifier que :
|
||||||
|
- Total Devices : 1
|
||||||
|
- Total Benchmarks : 1
|
||||||
|
- Le device apparaît dans le tableau
|
||||||
|
- Le score global est affiché
|
||||||
|
|
||||||
|
3. Cliquer sur "Voir" pour le device
|
||||||
|
4. Vérifier que :
|
||||||
|
- Informations hardware affichées
|
||||||
|
- Dernier benchmark visible
|
||||||
|
- Onglets fonctionnent
|
||||||
|
|
||||||
|
### 6. Test Upload de document
|
||||||
|
|
||||||
|
1. Aller sur la page détail d'un device
|
||||||
|
2. Onglet "Documents"
|
||||||
|
3. Sélectionner un fichier PDF
|
||||||
|
4. Choisir un type (ex: "manual")
|
||||||
|
5. Cliquer "Upload"
|
||||||
|
|
||||||
|
**Résultat attendu** :
|
||||||
|
- ✅ Toast de confirmation
|
||||||
|
- ✅ Document apparaît dans la liste
|
||||||
|
- ✅ Bouton "Télécharger" fonctionne
|
||||||
|
|
||||||
|
### 7. Test Liens constructeur
|
||||||
|
|
||||||
|
1. Page détail device → Onglet "Liens"
|
||||||
|
2. Ajouter un lien :
|
||||||
|
- Label : "Support HP"
|
||||||
|
- URL : "https://support.hp.com"
|
||||||
|
3. Cliquer "Ajouter"
|
||||||
|
|
||||||
|
**Résultat attendu** :
|
||||||
|
- ✅ Lien apparaît
|
||||||
|
- ✅ Lien cliquable
|
||||||
|
- ✅ Bouton supprimer fonctionne
|
||||||
|
|
||||||
|
### 8. Test Multiple Benchmarks
|
||||||
|
|
||||||
|
Exécuter 3 fois le script bench.sh sur la même machine :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Bench 1
|
||||||
|
curl -s http://localhost:8087/scripts/bench.sh | bash -s -- \
|
||||||
|
--server http://localhost:8007/api/benchmark \
|
||||||
|
--token "$TOKEN" --short
|
||||||
|
|
||||||
|
# Attendre 30s
|
||||||
|
|
||||||
|
# Bench 2
|
||||||
|
curl -s http://localhost:8087/scripts/bench.sh | bash -s -- \
|
||||||
|
--server http://localhost:8007/api/benchmark \
|
||||||
|
--token "$TOKEN" --short
|
||||||
|
|
||||||
|
# Attendre 30s
|
||||||
|
|
||||||
|
# Bench 3
|
||||||
|
curl -s http://localhost:8087/scripts/bench.sh | bash -s -- \
|
||||||
|
--server http://localhost:8007/api/benchmark \
|
||||||
|
--token "$TOKEN" --short
|
||||||
|
```
|
||||||
|
|
||||||
|
**Vérifications** :
|
||||||
|
- ✅ Total Benchmarks : 3
|
||||||
|
- ✅ Onglet "Historique Benchmarks" affiche 3 entrées
|
||||||
|
- ✅ Scores peuvent varier légèrement
|
||||||
|
|
||||||
|
### 9. Test Logs
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Voir les logs backend
|
||||||
|
docker compose logs backend
|
||||||
|
|
||||||
|
# Vérifier qu'il n'y a pas d'erreurs Python
|
||||||
|
# Devrait afficher les requêtes API
|
||||||
|
```
|
||||||
|
|
||||||
|
### 10. Test Persistance
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Arrêter les conteneurs
|
||||||
|
docker compose down
|
||||||
|
|
||||||
|
# Vérifier que les données persistent
|
||||||
|
ls -la backend/data/
|
||||||
|
# Devrait afficher data.db
|
||||||
|
|
||||||
|
ls -la uploads/
|
||||||
|
# Devrait afficher les documents uploadés
|
||||||
|
|
||||||
|
# Redémarrer
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
|
# Attendre quelques secondes
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
# Vérifier que les données sont toujours là
|
||||||
|
curl http://localhost:8007/api/devices
|
||||||
|
# Devrait afficher les devices précédents
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🧪 Tests avancés
|
||||||
|
|
||||||
|
### Test avec iperf3
|
||||||
|
|
||||||
|
Si vous avez un serveur iperf3 :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Sur le serveur de bench, lancer iperf3
|
||||||
|
docker run -d --name iperf3-server -p 5201:5201 networkstatic/iperf3 -s
|
||||||
|
|
||||||
|
# Exécuter le benchmark avec tests réseau
|
||||||
|
curl -s http://localhost:8087/scripts/bench.sh | bash -s -- \
|
||||||
|
--server http://localhost:8007/api/benchmark \
|
||||||
|
--token "$TOKEN" \
|
||||||
|
--iperf-server localhost
|
||||||
|
|
||||||
|
# Vérifier que network_score n'est pas null
|
||||||
|
```
|
||||||
|
|
||||||
|
### Test sur différentes machines
|
||||||
|
|
||||||
|
1. Machine 1 (serveur puissant)
|
||||||
|
2. Machine 2 (Raspberry Pi)
|
||||||
|
3. Machine 3 (vieille machine)
|
||||||
|
|
||||||
|
**Vérifier** :
|
||||||
|
- Scores différents selon les performances
|
||||||
|
- Classement cohérent dans le Dashboard
|
||||||
|
|
||||||
|
### Test de charge
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Envoyer 10 benchmarks en parallèle
|
||||||
|
for i in {1..10}; do
|
||||||
|
curl -s http://localhost:8087/scripts/bench.sh | bash -s -- \
|
||||||
|
--server http://localhost:8007/api/benchmark \
|
||||||
|
--token "$TOKEN" \
|
||||||
|
--device "test-machine-$i" \
|
||||||
|
--short &
|
||||||
|
done
|
||||||
|
|
||||||
|
wait
|
||||||
|
|
||||||
|
# Vérifier que tous ont été enregistrés
|
||||||
|
curl http://localhost:8007/api/stats
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🐛 Tests d'erreur
|
||||||
|
|
||||||
|
### Token invalide
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X POST http://localhost:8007/api/benchmark \
|
||||||
|
-H "Authorization: Bearer INVALID_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{}'
|
||||||
|
|
||||||
|
# Résultat attendu : HTTP 401
|
||||||
|
```
|
||||||
|
|
||||||
|
### JSON invalide
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X POST http://localhost:8007/api/benchmark \
|
||||||
|
-H "Authorization: Bearer $TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d 'invalid json'
|
||||||
|
|
||||||
|
# Résultat attendu : HTTP 400
|
||||||
|
```
|
||||||
|
|
||||||
|
### Device inexistant
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl http://localhost:8007/api/devices/99999
|
||||||
|
|
||||||
|
# Résultat attendu : HTTP 404
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📊 Résumé des tests
|
||||||
|
|
||||||
|
| Test | Commande | Résultat attendu |
|
||||||
|
|------|----------|------------------|
|
||||||
|
| Installation | `./install.sh` | Services démarrés |
|
||||||
|
| Health check | `curl localhost:8007/api/health` | `{"status":"ok"}` |
|
||||||
|
| Frontend | Navigateur | Dashboard visible |
|
||||||
|
| Benchmark | `./scripts/bench.sh` | Succès + device créé |
|
||||||
|
| Upload doc | Interface web | Document uploadé |
|
||||||
|
| Lien | Interface web | Lien ajouté |
|
||||||
|
| Persistance | `docker compose down/up` | Données conservées |
|
||||||
|
|
||||||
|
## ✅ Tous les tests passent ?
|
||||||
|
|
||||||
|
Si oui : **Félicitations ! L'application fonctionne parfaitement** 🎉
|
||||||
|
|
||||||
|
Si non : Consultez [DEPLOYMENT.md](DEPLOYMENT.md) section Troubleshooting
|
||||||
|
|
||||||
|
## 📞 Problèmes courants
|
||||||
|
|
||||||
|
### Backend ne démarre pas
|
||||||
|
```bash
|
||||||
|
docker compose logs backend
|
||||||
|
```
|
||||||
|
Vérifier les erreurs Python
|
||||||
|
|
||||||
|
### Port déjà utilisé
|
||||||
|
```bash
|
||||||
|
ss -tulpn | grep 8007
|
||||||
|
# Changer le port dans .env
|
||||||
|
```
|
||||||
|
|
||||||
|
### Benchmark échoue
|
||||||
|
```bash
|
||||||
|
# Vérifier les dépendances sur la machine cliente
|
||||||
|
sysbench --version
|
||||||
|
fio --version
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Happy Testing!** 🧪
|
||||||
Reference in New Issue
Block a user