#!/usr/bin/env python3 """ Test batch — 100 artiklar för att verifiera grunduppbyggnad """ import subprocess import concurrent.futures import time from datetime import datetime, timezone def log(msg): ts = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC") print(f"[{ts}] {msg}", flush=True) def kor_batch(batch_id, cap=10): agent_id = f"test-{batch_id:03d}" cmd = f"cd /home/bernt/.openclaw/workspace/projects/landvex/20-automation && python3 kor_agent_kimi.py --agent-id {agent_id} --cap {cap}" result = subprocess.run(cmd, shell=True, capture_output=True, text=True) success = result.returncode == 0 if not success: log(f"Batch {batch_id} stderr: {result.stderr[:200]}") return success def main(): log("=== TEST BATCH — 100 artiklar ===") start_time = time.time() num_batches = 10 batch_size = 10 max_workers = 5 completed = 0 with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor: futures = {executor.submit(kor_batch, i, batch_size): i for i in range(num_batches)} for future in concurrent.futures.as_completed(futures): batch_id = futures[future] try: success = future.result() if success: completed += 1 log(f"✓ Batch {batch_id} klar ({completed}/{num_batches})") else: log(f"✗ Batch {batch_id} misslyckades") except Exception as e: log(f"✗ Batch {batch_id} fel: {e}") total_time = time.time() - start_time total_articles = completed * batch_size log("=== TEST KLAR ===") log(f"Artiklar: {total_articles}") log(f"Tid: {total_time:.1f} sekunder ({total_time/60:.1f} min)") log(f"Takt: {total_articles / (total_time/3600):.0f} artiklar/timme") if __name__ == "__main__": main()