Skip to content

Add DeliveryBot Robot Simulator project#38

Open
DakotaCondos wants to merge 1 commit into
mainfrom
bot-simulator
Open

Add DeliveryBot Robot Simulator project#38
DakotaCondos wants to merge 1 commit into
mainfrom
bot-simulator

Conversation

@DakotaCondos
Copy link
Copy Markdown

Pull Request Summary: Add DeliveryBot Robot Simulator

Summary

Adds the DeliveryBot Robot Simulator to the repo as a deployable .NET containerized service for testing robot-related workflows without physical robots.

The simulator hosts an in-memory fleet of simulated vending delivery bots, supports local and Docker execution, exposes management/testing endpoints, simulates delivery behavior, publishes robot events locally or to Azure Event Hubs, and includes an optional Event Hub input consumer for order assignment events.

What’s included

  • Added .NET robot simulator project structure:

    • DeliveryBot.RobotSimulator.Api
    • DeliveryBot.RobotSimulator.Core
    • DeliveryBot.RobotSimulator.Events
    • DeliveryBot.RobotSimulator.Infrastructure
    • DeliveryBot.RobotSimulator.Tests
  • Added simulated bot fleet behavior:

    • Config-driven initial bot creation
    • Independent bot state
    • Stock inventory and reserved stock tracking
    • Active order and queued order handling
    • GPS-style movement toward fake delivery destinations
    • Delivery completion and stock deduction
    • Telemetry generation
  • Added bot management endpoints:

    • GET /bots
    • GET /bots/{botId}
    • POST /bots
    • PATCH /bots/{botId}
    • DELETE /bots/{botId}
  • Added order assignment endpoint:

    • POST /orders/assignments
  • Added local event publishing:

    • GET /events/recent
    • Recent in-memory event store
    • Local event publisher
  • Added Azure Event Hub support:

    • Configurable event transport mode
    • Azure Event Hub publisher
    • Composite publisher so Azure mode can also retain recent local debug events
    • Optional Event Hub input consumer for RobotOrderAssignment events
    • Supports both same-hub and split-hub configurations
  • Added Docker support:

    • Dockerfile
    • Local container execution support
    • Environment-variable based configuration
  • Added automated tests for:

    • Stock reservation and fulfillment
    • Order acceptance, rejection, and queueing
    • Delivery simulation
    • Queued order handoff
    • Bot management
    • Config-driven fleet startup
  • Added project documentation:

    • README.md
    • docs/architecture.md
    • docs/api.md
    • docs/events.md
    • docs/development.md
    • docs/azure-event-hub-testing.md

Testing performed

Verified successfully with local execution:

dotnet build
dotnet test
dotnet run --project src/DeliveryBot.RobotSimulator.Api

Verified successfully with Docker:

docker build -f src/DeliveryBot.RobotSimulator.Api/Dockerfile -t deliverybot-robot-simulator .
docker run --rm -p 8080:8080 -e ASPNETCORE_ENVIRONMENT=Development -e EventTransport__Mode=Local deliverybot-robot-simulator

Verified simulator behavior through Swagger/API:

  • Health endpoint returns healthy status
  • Bot fleet initializes from configuration
  • Bots can be viewed, created, updated, and deleted
  • Bots with active or queued orders cannot be deleted
  • Orders can be assigned to target bots
  • Available bots accept orders and begin delivery
  • Busy bots queue valid orders
  • Bots reject orders with missing or insufficient stock
  • Stock is reserved on acceptance/queueing
  • Stock is deducted on delivery completion
  • Bot status remains OnDelivery when moving from a completed order to a queued order
  • Telemetry, status, stock, order response, delivery completion, and bot lifecycle events are generated

Verified successfully with temporary dummy Azure Event Hub resources:

  • Simulator published events to Azure Event Hub
  • Events were visible in Azure Portal Data Explorer
  • Event payloads contained the expected RobotEventEnvelope structure
  • Event Hub application properties included values such as eventType, schemaVersion, source, isSimulated, and botId
  • Dockerized simulator also published events to the dummy Event Hub successfully
  • Temporary Azure Event Hub resources were deleted after validation

Configuration notes

Default mode is local:

"EventTransport": {
  "Mode": "Local",
  "InputEventHubName": "",
  "OutputEventHubName": "",
  "ConsumerGroup": "$Default",
  "EnableInputConsumer": false
}

Azure output publishing mode:

$env:EventTransport__Mode="AzureEventHub"
$env:EventTransport__ConnectionString="<event-hub-connection-string>"
$env:EventTransport__OutputEventHubName="robot-output"

Optional Event Hub input consumer mode:

$env:EventTransport__Mode="AzureEventHub"
$env:EventTransport__ConnectionString="<event-hub-connection-string>"
$env:EventTransport__InputEventHubName="robot-input"
$env:EventTransport__OutputEventHubName="robot-output"
$env:EventTransport__ConsumerGroup='$Default'
$env:EventTransport__EnableInputConsumer="true"

The simulator supports both:

  • Separate input/output hubs:

    • robot-input
    • robot-output
  • Same hub for input and output:

    • robot-events

For same-hub setups, the input consumer ignores simulator-produced events and only processes RobotOrderAssignment events.

Known gaps / follow-up work

  • Confirm final Event Hub topology with the team:
    • Same Event Hub for all robot events, or separate input/output hubs.
  • Confirm final event schema contracts with Order Service and Robot Data Ingestion System.
  • Confirm whether input consumer should use simple ReadEventsAsync or production checkpointing with EventProcessorClient and Blob Storage.
  • Add durable checkpointing if the simulator needs reliable Event Hub consumption across restarts.
  • Add managed identity support for Azure Event Hub instead of connection strings.
  • Add CI/CD pipeline integration.
  • Add deployment manifests or Azure Container Apps deployment configuration.
  • Add API integration tests if needed.
  • Confirm whether Swagger should be enabled only in Development or controlled by configuration.
  • Confirm final container registry and deployment target.

Add a new DeliveryBot Robot Simulator solution and initial codebase. This commit introduces the solution file, projects (Api, Core, Events, Infrastructure), unit tests, comprehensive docs (README, API, architecture, development, events, Azure testing), Docker support (Dockerfile, docker-compose), and a .gitignore. The simulator supports local and Azure Event Hub modes, background simulation and assignment workers, event publishers/consumers, in-memory bot fleet and stock logic, and initial test coverage for bot management, stock, and delivery simulation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant