import from monorepo
This commit is contained in:
@ -1,16 +0,0 @@
|
||||
task_id: "summarizer"
|
||||
base_port: 5000
|
||||
max_rounds: 3
|
||||
|
||||
data_dir: data
|
||||
workers_config: workers.json
|
||||
|
||||
mongodb:
|
||||
database: summarizer_test
|
||||
collections:
|
||||
todos:
|
||||
data_file: todos.json
|
||||
required_count: 1
|
||||
issues:
|
||||
data_file: issues.json
|
||||
required_count: 1
|
@ -1,16 +0,0 @@
|
||||
[
|
||||
{
|
||||
"taskId": "summarizer",
|
||||
"githubUrl": "https://github.com/test_owner/test_repo/issues/1",
|
||||
"title": "Test Issue 1",
|
||||
"body": "This is a test issue for summarization",
|
||||
"status": "open"
|
||||
},
|
||||
{
|
||||
"taskId": "summarizer",
|
||||
"githubUrl": "https://github.com/test_owner/test_repo/issues/2",
|
||||
"title": "Test Issue 2",
|
||||
"body": "This is another test issue for summarization",
|
||||
"status": "open"
|
||||
}
|
||||
]
|
@ -1,20 +0,0 @@
|
||||
[
|
||||
{
|
||||
"taskId": "summarizer",
|
||||
"roundNumber": 1,
|
||||
"repo_owner": "test_owner",
|
||||
"repo_name": "test_repo",
|
||||
"prUrl": "https://github.com/test_owner/test_repo/pull/1",
|
||||
"status": "pending",
|
||||
"stakingKey": "test_key_1"
|
||||
},
|
||||
{
|
||||
"taskId": "summarizer",
|
||||
"roundNumber": 1,
|
||||
"repo_owner": "test_owner",
|
||||
"repo_name": "test_repo",
|
||||
"prUrl": "https://github.com/test_owner/test_repo/pull/2",
|
||||
"status": "pending",
|
||||
"stakingKey": "test_key_2"
|
||||
}
|
||||
]
|
@ -1,62 +0,0 @@
|
||||
"""End-to-end test for the summarizer task."""
|
||||
|
||||
from pathlib import Path
|
||||
from prometheus_test import TestRunner
|
||||
import dotenv
|
||||
import argparse
|
||||
import uuid
|
||||
|
||||
from .steps import steps
|
||||
|
||||
dotenv.load_dotenv()
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(description="Run summarizer test sequence")
|
||||
parser.add_argument(
|
||||
"--reset",
|
||||
action="store_true",
|
||||
help="Force reset of all databases before running tests",
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def post_load_callback(db):
|
||||
"""Post-load callback to process MongoDB data after JSON import"""
|
||||
# Process todos collection
|
||||
todos = list(db.todos.find({"taskId": runner.config.task_id}))
|
||||
for todo in todos:
|
||||
if "uuid" not in todo:
|
||||
todo["uuid"] = str(uuid.uuid4())
|
||||
db.todos.replace_one({"_id": todo["_id"]}, todo)
|
||||
|
||||
# Process issues collection
|
||||
issues = list(db.issues.find({"taskId": runner.config.task_id}))
|
||||
for issue in issues:
|
||||
if "uuid" not in issue:
|
||||
issue["uuid"] = str(uuid.uuid4())
|
||||
db.issues.replace_one({"_id": issue["_id"]}, issue)
|
||||
|
||||
|
||||
# Global reference to the test runner
|
||||
runner = None
|
||||
|
||||
|
||||
def main():
|
||||
global runner
|
||||
args = parse_args()
|
||||
|
||||
# Create test runner with config from YAML
|
||||
base_dir = Path(__file__).parent
|
||||
runner = TestRunner(
|
||||
steps=steps,
|
||||
config_file=base_dir / "config.yaml",
|
||||
config_overrides={"post_load_callback": post_load_callback},
|
||||
)
|
||||
|
||||
# Run test sequence
|
||||
runner.run(force_reset=args.reset)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -1,51 +0,0 @@
|
||||
"""Test stage for auditing summary."""
|
||||
|
||||
import requests
|
||||
from prometheus_test import Context
|
||||
|
||||
|
||||
async def prepare(context: Context, target_name: str):
|
||||
"""Prepare for auditing summary."""
|
||||
staking_key = context.env.get("WORKER_ID")
|
||||
target_submission = await context.storeGet(f"submission-{target_name}")
|
||||
|
||||
return {
|
||||
"staking_key": staking_key,
|
||||
"round_number": context.round_number,
|
||||
"target_submission": target_submission,
|
||||
"target_name": target_name,
|
||||
}
|
||||
|
||||
|
||||
async def execute(context: Context, prepare_data: dict):
|
||||
"""Execute summary audit test."""
|
||||
staking_key = prepare_data["staking_key"]
|
||||
round_number = prepare_data["round_number"]
|
||||
target_submission = prepare_data["target_submission"]
|
||||
target_name = prepare_data["target_name"]
|
||||
|
||||
# Mock response for audit
|
||||
response = requests.post(
|
||||
"http://localhost:5000/api/builder/summarizer/audit",
|
||||
json={
|
||||
"taskId": context.config.task_id,
|
||||
"roundNumber": round_number,
|
||||
"stakingKey": staking_key,
|
||||
"submitterKey": target_name,
|
||||
"cid": target_submission.get("cid"),
|
||||
"prUrl": target_submission.get("pr_url"),
|
||||
"githubUsername": target_submission.get("github_username"),
|
||||
},
|
||||
)
|
||||
|
||||
if response.status_code != 200:
|
||||
raise Exception(f"Failed to audit summary: {response.text}")
|
||||
|
||||
result = response.json()
|
||||
if not result.get("success"):
|
||||
raise Exception("Failed to audit summary")
|
||||
|
||||
# Store audit result
|
||||
await context.storeSet(f"audit-{staking_key}-{target_name}", result.get("data"))
|
||||
|
||||
return True
|
@ -1,39 +0,0 @@
|
||||
"""Test stage for fetching summarizer todo."""
|
||||
|
||||
import requests
|
||||
from prometheus_test import Context
|
||||
|
||||
|
||||
async def prepare(context: Context):
|
||||
"""Prepare for fetching summarizer todo."""
|
||||
return {
|
||||
"staking_key": context.env.get("WORKER_ID"),
|
||||
"round_number": context.round_number,
|
||||
}
|
||||
|
||||
|
||||
async def execute(context: Context, prepare_data: dict):
|
||||
"""Execute fetch summarizer todo test."""
|
||||
staking_key = prepare_data["staking_key"]
|
||||
round_number = prepare_data["round_number"]
|
||||
|
||||
# Mock response for fetching todo
|
||||
response = requests.post(
|
||||
"http://localhost:5000/api/builder/summarizer/fetch-summarizer-todo",
|
||||
json={
|
||||
"stakingKey": staking_key,
|
||||
"roundNumber": round_number,
|
||||
},
|
||||
)
|
||||
|
||||
if response.status_code != 200:
|
||||
raise Exception(f"Failed to fetch summarizer todo: {response.text}")
|
||||
|
||||
result = response.json()
|
||||
if not result.get("success"):
|
||||
raise Exception("Failed to fetch summarizer todo")
|
||||
|
||||
# Store todo data for next steps
|
||||
await context.storeSet(f"todo-{staking_key}", result.get("data"))
|
||||
|
||||
return True
|
@ -1,47 +0,0 @@
|
||||
"""Test stage for generating repository summary."""
|
||||
|
||||
import requests
|
||||
from prometheus_test import Context
|
||||
|
||||
|
||||
async def prepare(context: Context):
|
||||
"""Prepare for generating summary."""
|
||||
staking_key = context.env.get("WORKER_ID")
|
||||
todo = await context.storeGet(f"todo-{staking_key}")
|
||||
|
||||
return {
|
||||
"staking_key": staking_key,
|
||||
"round_number": context.round_number,
|
||||
"repo_owner": todo.get("repo_owner"),
|
||||
"repo_name": todo.get("repo_name"),
|
||||
}
|
||||
|
||||
|
||||
async def execute(context: Context, prepare_data: dict):
|
||||
"""Execute summary generation test."""
|
||||
staking_key = prepare_data["staking_key"]
|
||||
round_number = prepare_data["round_number"]
|
||||
repo_owner = prepare_data["repo_owner"]
|
||||
repo_name = prepare_data["repo_name"]
|
||||
|
||||
# Mock response for repo summary generation
|
||||
response = requests.post(
|
||||
"http://localhost:5000/api/builder/summarizer/generate-summary",
|
||||
json={
|
||||
"taskId": context.config.task_id,
|
||||
"round_number": str(round_number),
|
||||
"repo_url": f"https://github.com/{repo_owner}/{repo_name}",
|
||||
},
|
||||
)
|
||||
|
||||
if response.status_code != 200:
|
||||
raise Exception(f"Failed to generate summary: {response.text}")
|
||||
|
||||
result = response.json()
|
||||
if not result.get("success"):
|
||||
raise Exception("Failed to generate summary")
|
||||
|
||||
# Store PR URL for next steps
|
||||
await context.storeSet(f"pr-{staking_key}", result.get("data", {}).get("pr_url"))
|
||||
|
||||
return True
|
@ -1,56 +0,0 @@
|
||||
"""Test stage for submitting summary."""
|
||||
|
||||
import requests
|
||||
from prometheus_test import Context
|
||||
|
||||
|
||||
async def prepare(context: Context):
|
||||
"""Prepare for submitting summary."""
|
||||
staking_key = context.env.get("WORKER_ID")
|
||||
pr_url = await context.storeGet(f"pr-{staking_key}")
|
||||
|
||||
return {
|
||||
"staking_key": staking_key,
|
||||
"round_number": context.round_number,
|
||||
"pr_url": pr_url,
|
||||
"github_username": context.env.get("GITHUB_USERNAME"),
|
||||
}
|
||||
|
||||
|
||||
async def execute(context: Context, prepare_data: dict):
|
||||
"""Execute summary submission test."""
|
||||
staking_key = prepare_data["staking_key"]
|
||||
round_number = prepare_data["round_number"]
|
||||
pr_url = prepare_data["pr_url"]
|
||||
github_username = prepare_data["github_username"]
|
||||
|
||||
# Mock response for submission
|
||||
response = requests.post(
|
||||
"http://localhost:5000/api/builder/summarizer/submit",
|
||||
json={
|
||||
"taskId": context.config.task_id,
|
||||
"roundNumber": round_number,
|
||||
"prUrl": pr_url,
|
||||
"stakingKey": staking_key,
|
||||
"githubUsername": github_username,
|
||||
},
|
||||
)
|
||||
|
||||
if response.status_code != 200:
|
||||
raise Exception(f"Failed to submit summary: {response.text}")
|
||||
|
||||
result = response.json()
|
||||
if not result.get("success"):
|
||||
raise Exception("Failed to submit summary")
|
||||
|
||||
# Store submission data for audit
|
||||
await context.storeSet(
|
||||
f"submission-{staking_key}",
|
||||
{
|
||||
"cid": result.get("data", {}).get("cid"),
|
||||
"pr_url": pr_url,
|
||||
"github_username": github_username,
|
||||
},
|
||||
)
|
||||
|
||||
return True
|
@ -1,31 +0,0 @@
|
||||
"""Test stage for validating API keys."""
|
||||
|
||||
import requests
|
||||
from prometheus_test import Context
|
||||
|
||||
|
||||
async def prepare(context: Context):
|
||||
"""Prepare for API key validation test."""
|
||||
return {
|
||||
"api_key": context.env.get("ANTHROPIC_API_KEY"),
|
||||
}
|
||||
|
||||
|
||||
async def execute(context: Context, prepare_data: dict):
|
||||
"""Execute API key validation test."""
|
||||
api_key = prepare_data["api_key"]
|
||||
|
||||
# Mock response for Anthropic API validation
|
||||
response = requests.post(
|
||||
"http://localhost:5000/api/builder/summarizer/validate-api-key",
|
||||
json={"api_key": api_key},
|
||||
)
|
||||
|
||||
if response.status_code != 200:
|
||||
raise Exception(f"API key validation failed: {response.text}")
|
||||
|
||||
result = response.json()
|
||||
if not result.get("valid"):
|
||||
raise Exception("API key is not valid")
|
||||
|
||||
return True
|
@ -1,33 +0,0 @@
|
||||
"""Test stage for validating GitHub credentials."""
|
||||
|
||||
import requests
|
||||
from prometheus_test import Context
|
||||
|
||||
|
||||
async def prepare(context: Context):
|
||||
"""Prepare for GitHub validation test."""
|
||||
return {
|
||||
"github_username": context.env.get("GITHUB_USERNAME"),
|
||||
"github_token": context.env.get("GITHUB_TOKEN"),
|
||||
}
|
||||
|
||||
|
||||
async def execute(context: Context, prepare_data: dict):
|
||||
"""Execute GitHub validation test."""
|
||||
username = prepare_data["github_username"]
|
||||
token = prepare_data["github_token"]
|
||||
|
||||
# Mock response for GitHub validation
|
||||
response = requests.post(
|
||||
"http://localhost:5000/api/builder/summarizer/validate-github",
|
||||
json={"username": username, "token": token},
|
||||
)
|
||||
|
||||
if response.status_code != 200:
|
||||
raise Exception(f"GitHub validation failed: {response.text}")
|
||||
|
||||
result = response.json()
|
||||
if not result.get("valid"):
|
||||
raise Exception("GitHub credentials are not valid")
|
||||
|
||||
return True
|
@ -1,85 +0,0 @@
|
||||
"""Test step definitions."""
|
||||
|
||||
from prometheus_test import TestStep
|
||||
from functools import partial
|
||||
from .stages import (
|
||||
validate_api_keys,
|
||||
validate_github,
|
||||
fetch_summarizer_todo,
|
||||
generate_summary,
|
||||
submit_summary,
|
||||
audit_summary,
|
||||
)
|
||||
|
||||
steps = [
|
||||
TestStep(
|
||||
name="validate_api_keys",
|
||||
description="Validate Anthropic API key",
|
||||
prepare=validate_api_keys.prepare,
|
||||
execute=validate_api_keys.execute,
|
||||
worker="worker1",
|
||||
),
|
||||
TestStep(
|
||||
name="validate_github",
|
||||
description="Validate GitHub credentials",
|
||||
prepare=validate_github.prepare,
|
||||
execute=validate_github.execute,
|
||||
worker="worker1",
|
||||
),
|
||||
TestStep(
|
||||
name="fetch_todo_worker1",
|
||||
description="Fetch summarizer todo for worker1",
|
||||
prepare=fetch_summarizer_todo.prepare,
|
||||
execute=fetch_summarizer_todo.execute,
|
||||
worker="worker1",
|
||||
),
|
||||
TestStep(
|
||||
name="fetch_todo_worker2",
|
||||
description="Fetch summarizer todo for worker2",
|
||||
prepare=fetch_summarizer_todo.prepare,
|
||||
execute=fetch_summarizer_todo.execute,
|
||||
worker="worker2",
|
||||
),
|
||||
TestStep(
|
||||
name="generate_summary_worker1",
|
||||
description="Generate summary for worker1's todo",
|
||||
prepare=generate_summary.prepare,
|
||||
execute=generate_summary.execute,
|
||||
worker="worker1",
|
||||
),
|
||||
TestStep(
|
||||
name="generate_summary_worker2",
|
||||
description="Generate summary for worker2's todo",
|
||||
prepare=generate_summary.prepare,
|
||||
execute=generate_summary.execute,
|
||||
worker="worker2",
|
||||
),
|
||||
TestStep(
|
||||
name="submit_summary_worker1",
|
||||
description="Submit summary for worker1",
|
||||
prepare=submit_summary.prepare,
|
||||
execute=submit_summary.execute,
|
||||
worker="worker1",
|
||||
),
|
||||
TestStep(
|
||||
name="submit_summary_worker2",
|
||||
description="Submit summary for worker2",
|
||||
prepare=submit_summary.prepare,
|
||||
execute=submit_summary.execute,
|
||||
worker="worker2",
|
||||
),
|
||||
TestStep(
|
||||
name="audit_worker1",
|
||||
description="Worker1 audits Worker2's submission",
|
||||
prepare=partial(audit_summary.prepare, target_name="worker2"),
|
||||
execute=audit_summary.execute,
|
||||
worker="worker1",
|
||||
),
|
||||
TestStep(
|
||||
name="audit_worker2",
|
||||
description="Worker2 audits Worker1's submission",
|
||||
prepare=partial(audit_summary.prepare, target_name="worker1"),
|
||||
execute=audit_summary.execute,
|
||||
worker="worker2",
|
||||
),
|
||||
]
|
Reference in New Issue
Block a user