Skip to content

Latest commit

 

History

History
102 lines (82 loc) · 4.02 KB

File metadata and controls

102 lines (82 loc) · 4.02 KB

ZeroApp Prototype - Testing Process & Verification Log

Overview

This document details the testing procedures, infrastructure setup, bug fixes, and verification results for the ZeroApp prototype backend.

Date: 2025-12-03 Status: ✅ Verified Stable

1. Infrastructure Setup

Restate Runtime

Started the Restate runtime using Docker (standalone container) as docker-compose was unavailable.

docker run -d --name restate_dev --rm \
  -p 8080:8080 -p 9070:9070 -p 9071:9071 \
  --add-host=host.docker.internal:host-gateway \
  docker.io/restatedev/restate:latest

Service Registration

Services were registered using the register-services.sh script.

  • Issue: Script initially failed due to incorrect path and permissions.
  • Fix: Fixed permissions (chmod +x) and ran from root directory.
  • Status: Successfully registered ShippingService, UserSession, and OrderFulfillmentWorkflow.

2. Bug Fixes & Improvements

During verification, the following critical issues were identified and resolved:

A. Ingress Port Configuration

  • Issue: ingress.go was configured to connect to localhost:9089 (the service port) instead of localhost:8080 (the Restate Runtime ingress port).
  • Error: connection reset by peer when calling Restate services.
  • Fix: Updated RESTATE_INGRESS_URL to http://localhost:8080.

B. Workflow Approval Return Type

  • Issue: The ApproveWorkflow handler failed with "unexpected end of JSON input".
  • Cause: The Restate client generic type was [bool, error], expecting a return value, but the handler returns void.
  • Fix: Changed client definition to restateingress.Workflow[bool, restate.Void].

C. Cart Price Calculation

  • Issue: Adding items to the cart resulted in a placeholder price (5000 cents) instead of the actual product price.
  • Fix: Modified UserSession.AddItem to fetch product details from SQLite using restate.Run (for determinism).
  • Improvement: Updated logic to refresh product details (Name, SKU, Price) even if the item already exists in the cart, ensuring data consistency.

3. Verified Test Scenarios

Scenario 1: Product Catalog (SQLite)

Action: Fetch product list.

curl -s http://localhost:8081/api/products

Result: ✅ Returns JSON list of products from SQLite.

Scenario 2: Cart Management (Restate Virtual Object)

Action: Add item to cart.

curl -X POST http://localhost:8081/api/cart/add \
  -H "X-User-ID: alice" \
  -H "Content-Type: application/json" \
  -d '{"product_id": 3, "quantity": 1}'

Result: ✅ Returns success. Verified price is correct (12000 cents).

Scenario 3: End-to-End Checkout Workflow

Flow: Checkout -> Payment -> Admin Approval -> Shipping

  1. Initiate Checkout:

    curl -X POST http://localhost:8081/api/checkout \
      -H "X-User-ID: alice" \
      -H "Content-Type: application/json" \
      -d '{"order_id": "order-test-2", "shipping_address": "123 Test St"}'

    Result: Returns 202 Accepted and creates an Awakeable.

  2. Resolve Payment (Simulated): Captured Awakeable ID from logs.

    curl -X POST http://localhost:8081/api/payment/callback \
      -H "Content-Type: application/json" \
      -d '{"awakeable_id": "<ID>", "transaction_id": "txn-123", "amount": 5000, "status": "success"}'

    Result: ✅ Payment accepted, Workflow launched.

  3. Admin Approval:

    curl -X POST http://localhost:8081/api/workflow/order-test-2/approve \
      -H "Content-Type: application/json" \
      -d '{"approved": true}'

    Result: ✅ Workflow proceeds to shipping and completes.

4. Current Configuration

  • HTTP Port: 8081 (Note: User recently updated code to 8082, requires restart)
  • Restate Service Port: 9089 (Note: User recently updated code to 9090, requires restart)
  • Restate Runtime Ingress: 8080

5. Next Steps

  • Restart backend to apply new port configuration (8082/9090).
  • Update register-services.sh to match port 9090.
  • Begin Frontend integration testing.