4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
91 lines
2.1 KiB
Python
91 lines
2.1 KiB
Python
"""S3 upload and validation utilities."""
|
|
|
|
import json
|
|
from datetime import UTC, datetime
|
|
from typing import NamedTuple
|
|
|
|
import boto3
|
|
from botocore.exceptions import ClientError
|
|
|
|
|
|
class TestData(NamedTuple):
|
|
"""Test data uploaded to S3."""
|
|
|
|
key: str
|
|
correlation_id: str
|
|
|
|
|
|
def upload_test_data(
|
|
bucket: str,
|
|
payload: dict,
|
|
s3_client=None,
|
|
) -> TestData:
|
|
"""Upload test data to S3 bucket."""
|
|
s3 = s3_client or boto3.client("s3")
|
|
timestamp = datetime.now(UTC).strftime("%Y%m%d-%H%M%S")
|
|
key = f"ingested/{timestamp}/data.json"
|
|
correlation_id = f"local-test-{timestamp}"
|
|
|
|
s3.put_object(
|
|
Bucket=bucket,
|
|
Key=key,
|
|
Body=json.dumps(payload),
|
|
ContentType="application/json",
|
|
Metadata={"correlation_id": correlation_id},
|
|
)
|
|
|
|
print(f"📤 Uploaded: s3://{bucket}/{key}")
|
|
return TestData(key, correlation_id)
|
|
|
|
|
|
def verify_output(
|
|
bucket: str,
|
|
input_key: str,
|
|
s3_client=None,
|
|
) -> bool:
|
|
"""Verify processed output exists in S3."""
|
|
s3 = s3_client or boto3.client("s3")
|
|
output_key = input_key.replace("ingested/", "processed/")
|
|
|
|
try:
|
|
response = s3.get_object(Bucket=bucket, Key=output_key)
|
|
data = json.loads(response["Body"].read())
|
|
record_count = len(data.get("data", []))
|
|
|
|
print(f"✓ Verified: s3://{bucket}/{output_key} ({record_count} records)")
|
|
return True
|
|
|
|
except ClientError as e:
|
|
if e.response["Error"]["Code"] == "NoSuchKey":
|
|
print(f"✗ Missing: s3://{bucket}/{output_key}")
|
|
else:
|
|
print(f"✗ Error: {e}")
|
|
return False
|
|
|
|
|
|
TEST_TIMESTAMP = "20260101-120000"
|
|
|
|
# Fixed payloads for local testing
|
|
VALID_PAYLOAD = {
|
|
"data": [
|
|
{
|
|
"customer_id": "CUST-001",
|
|
"order_id": "ORD-001",
|
|
"amount": 99.99,
|
|
"timestamp": TEST_TIMESTAMP,
|
|
},
|
|
{
|
|
"customer_id": "CUST-002",
|
|
"order_id": "ORD-002",
|
|
"amount": 149.50,
|
|
"timestamp": TEST_TIMESTAMP,
|
|
},
|
|
]
|
|
}
|
|
|
|
INVALID_PAYLOAD = {
|
|
"data": [
|
|
{"order_id": "ORD-001", "amount": 99.99, "timestamp": TEST_TIMESTAMP},
|
|
]
|
|
}
|