diff --git a/scenario_execution.py b/scenario_execution.py index 4017fea..844afe1 100644 --- a/scenario_execution.py +++ b/scenario_execution.py @@ -1,14 +1,8 @@ import os import sys import json +import subprocess from scenario_exe_parser import parse_test_scenario -import subprocess -import os -import sys -import json -import subprocess -# Assuming parse_test_scenario is imported correctly -# from scenario_exe_parser import parse_test_scenario # --- Global Paths --- current_directory = os.path.dirname(os.path.abspath(__file__)) @@ -81,14 +75,26 @@ def run_test_suite(tasks): for task in tasks: print(f"--- Starting Task: {task['id']} ---") - result = subprocess.run( + + # Use Popen to stream output in real-time + process = subprocess.Popen( [shell_script, task['id'], task['cmd'], task['path'], REPO_PATH], - capture_output=True, text=True + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + bufsize=1, + universal_newlines=True ) - print(result.stdout) + + full_output = "" + for line in process.stdout: + print(line, end="") + full_output += line + + process.wait() json_found = False - for line in result.stdout.splitlines(): + for line in full_output.splitlines(): if line.startswith("FINAL_JSON_OUTPUT:"): json_string = line.replace("FINAL_JSON_OUTPUT:", "").strip() try: diff --git a/testarena_app/main.py b/testarena_app/main.py index ae51fb8..7b44721 100644 --- a/testarena_app/main.py +++ b/testarena_app/main.py @@ -138,6 +138,26 @@ async def list_queues(db: Session = Depends(database.get_db)): queues = db.query(models.Queue).order_by(models.Queue.created_at.desc()).all() return queues +@app.delete("/api/delete/{id}") +async def delete_queue(id: str, db: Session = Depends(database.get_db)): + # 1. Delete from database + queue = db.query(models.Queue).filter(models.Queue.id == id).first() + if queue: + # Delete associated tasks first + db.query(models.Task).filter(models.Task.queue_id == id).delete() + db.delete(queue) + db.commit() + + # 2. Delete folder + queue_dir = os.path.join(BASE_DATA_DIR, id) + if os.path.exists(queue_dir): + import shutil + shutil.rmtree(queue_dir) + + return {"id": id, "status": "Deleted"} + + raise HTTPException(status_code=404, detail="ID not found") + @app.get("/") async def root(): return FileResponse(os.path.join(static_dir, "index.html")) diff --git a/testarena_app/static/index.html b/testarena_app/static/index.html index ffb34c6..ac53ebc 100644 --- a/testarena_app/static/index.html +++ b/testarena_app/static/index.html @@ -295,21 +295,27 @@
| Queue ID | -Environment | -Status | +Queue ID ↕ | +Environment ↕ | +Status ↕ | Actions |
|---|