Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create CLI-Focused Integration Tests (Prioritized) #394

Closed
jkbrooks opened this issue Mar 23, 2025 · 2 comments
Closed

Create CLI-Focused Integration Tests (Prioritized) #394

jkbrooks opened this issue Mar 23, 2025 · 2 comments

Comments

@jkbrooks
Copy link

Description:

This ticket involves creating new integration tests for ElizaOS, focusing on developer-centric command-line interface workflows. The goal is to establish robust testing for core CLI functionalities and extensibility features.

Action Items:

  • Prioritize Test Cases: Implement integration tests in the following order, based on priority level:

    1. High Priority: Agent Lifecycle Tests (Test Cases 1-6)

      • Start Agent with Valid Character File (CLI)
      • Start Multiple Agents with Character Files (CLI)
      • Stop Running Agent (CLI)
      • Start Agent with Invalid Character File Path (CLI - Negative Test)
    2. Medium Priority: Custom Action and Provider Registration Tests (Test Cases 7-10)

      • Register Custom Action via Plugin (Integration Test)
      • Register Custom Provider via Plugin (Integration Test)
      • CLI Command Structure Tests (Test Cases 11-13)
      • elizaos create project <valid-project-name> (CLI)
      • elizaos create plugin <valid-plugin-name> (CLI)
      • elizaos create agent <valid-agent-name> (CLI)
    3. Low Priority (Initially): Database Adapter Integration Tests (Test Case 14)

      • Start Agent with PostgreSQL Adapter (Integration Test) (Defer unless SQL plugins are immediately critical)
  • Test Scope: Focus exclusively on CLI-based integration tests. Exclude UI testing for this initial phase.

  • Verification Focus: For each test case, verify:

    • Command execution success (no crashes).
    • Expected console log output (success messages, error messages).
    • Expected side effects (agent startup, file creation, etc.).
  • Collaboration: Share the list of prioritized tests with the Eliza team for feedback and potential adjustments, especially after completing medium-priority tests.

Context:

These integration tests will form the foundation for ensuring the reliability of ElizaOS developer workflows. Focusing on CLI commands allows for robust, automated testing without the complexities of UI testing at this stage. Prioritization helps allocate resources effectively and address the most critical functionalities first.

Deliverables:

  • New integration test files implementing the prioritized test cases (likely using Vitest).
  • Spreadsheet checklist to track the progress of test implementation and results.

Additional Notes for your Team:

  • Spreadsheet Checklist: Create a spreadsheet checklist (similar to the example provided) to track the status of each test case (Not Started, In Progress, Pass, Fail, Blocked).
  • Code Examples: Refer to existing tests like packages/core/test/bootstrap.test.ts and packages/plugin-bootstrap/src/actions/__tests__/actions.test.ts for examples of integration test structure and verification methods.
  • Programmatic Verification: Utilize the IAgentRuntime within tests to programmatically verify agent state and configurations.
  • Communication with Eliza Team: Share the test list and progress with the Eliza team for feedback and to ensure alignment on testing priorities and scope.
@jkbrooks
Copy link
Author

Okay, I understand your concerns. Let's refocus on the existing integration tests and prioritize CLI-based testing for developers, leaving out UI testing for now.

Analysis of Existing Integration Tests and Prioritization for CLI Test Extension

Here's a breakdown of what the existing integration tests likely cover and a prioritization for extending CLI-based integration tests:

I. Analysis of Existing Integration Tests

Based on the file names and scripts you provided, ElizaOS likely has some level of integration testing, primarily focused on the core and bootstrap functionalities. Here's what these tests likely cover:

  • packages/core/test/bootstrap.test.ts:

    • Likely Focus: Core ElizaOS bootstrap process.
    • What it probably tests:
      • Server Startup: Verifies if the AgentRuntime and core services can initialize and start without crashing.
      • Agent Initialization: Checks if agents can be loaded from character files and initialized within the runtime.
      • Basic Functionality (Implicit): May indirectly test some core functionalities like message processing and basic action handling, but likely not in a comprehensive or targeted way for each feature.
    • Limitations:
      • Probably doesn't test specific CLI commands directly.
      • Likely focuses on internal component initialization rather than full user workflows.
      • May not cover various startup options or error scenarios in detail.
  • packages/plugin-bootstrap/src/actions/__tests__/actions.test.ts:

    • Likely Focus: Bootstrap plugin actions (CONTINUE, IGNORE).
    • What it probably tests:
      • Action Registration: Verifies if the CONTINUE and IGNORE actions from the bootstrap plugin are correctly registered and loaded.
      • Action Handlers and Validators (Basic): May test the basic functionality of the validate and handler functions for these actions, likely through direct function calls within the test.
      • Action Examples (Limited): Might test if the examples defined for these actions are valid and can be executed in a basic scenario.
    • Limitations:
      • Focuses on a very specific set of actions within a single plugin.
      • May not test action invocation through the full ElizaOS message processing pipeline.
      • Likely not testing complex action interactions or state management.
  • test script in package.json:

    • Scope: Runs tests across multiple packages (excluding some explicitly filtered out like plugin-starter, the-org, docs, etc.).
    • Likely Coverage: A mix of unit and potentially some integration tests across various packages.
    • Limitations:
      • Coverage details depend heavily on the tests implemented within each package.
      • May not have comprehensive integration tests for all key workflows, especially CLI-driven scenarios.
  • test:app script in package.json:

    • Scope: Runs tests specifically for the packages/app (UI client).
    • Likely Coverage: Frontend-focused tests, potentially using Vitest for component testing, hook testing, or basic UI logic.
    • Limitations:
      • Based on your request, we are deprioritizing UI testing for now.

In summary: Existing tests provide a foundational level of coverage, primarily for core startup and basic action functionalities. However, they are not comprehensive integration tests that thoroughly validate CLI commands and developer workflows. They are more likely focused on internal component-level testing.


Prioritized Integration Test Extensions (CLI-Focused)

Given limited resources and focusing on CLI-based integration tests for developers, here's a prioritized list of test extensions to get the "most bang for your buck":

  1. Agent Lifecycle Tests (High Priority, Essential for Core Functionality)

    • Focus: Verifying the elizaos start and elizaos stop commands and their core functionalities.
    • Test Cases to Add:
      • Start Agent with Valid Character File (CLI):
        • Action: Run elizaos start --character <valid-character-file-path>.
        • Verification:
          • ElizaOS server starts without errors (check logs).
          • Agent is initialized and running (check logs for agent ID, character name).
          • API endpoints are accessible (basic HTTP request to /agents or /status).
      • Start Multiple Agents with Character Files (CLI):
        • Action: Run elizaos start --characters <valid-character-file-path1>,<valid-character-file-path2>.
        • Verification:
          • ElizaOS server starts without errors.
          • Multiple agents are initialized and running (check logs for multiple agent IDs, character names).
          • API endpoints show multiple agents.
      • Stop Running Agent (CLI):
        • Action: Run elizaos stop after starting an agent.
        • Verification:
          • ElizaOS server shuts down gracefully (check logs).
          • Agent processes are terminated.
          • API endpoints are no longer accessible.
      • Start Agent with Invalid Character File Path (CLI - Negative Test):
        • Action: Run elizaos start --character <invalid-path>.
        • Verification:
          • ElizaOS server fails to start (check logs for error messages).
          • Error message in console clearly indicates the invalid character file path.
  2. Custom Action and Provider Registration Tests (Medium Priority, Extensibility)

    • Focus: Verifying that custom Actions and Providers can be correctly registered via plugins in character files.
    • Test Cases to Add:
      • Register Custom Action via Plugin (Integration Test):
        • Setup: Create a minimal plugin registering a dummy action (as shown in previous example). Create a character file that includes this plugin.
        • Action: Run elizaos start --character <character-file-with-plugin>.
        • Verification:
          • ElizaOS server starts without errors.
          • Plugin is loaded successfully (check logs for plugin name).
          • Custom action is registered and available in the AgentRuntime (programmatically check runtime.actions or logs).
      • Register Custom Provider via Plugin (Integration Test):
        • Setup: Create a minimal plugin registering a dummy provider. Create a character file that includes this plugin.
        • Action: Run elizaos start --character <character-file-with-plugin>.
        • Verification:
          • ElizaOS server starts without errors.
          • Plugin is loaded successfully (check logs for plugin name).
          • Custom provider is registered and available in the AgentRuntime (programmatically check runtime.providers or logs).
  3. Basic CLI Command Structure Tests (Medium Priority, Developer Experience)

    • Focus: Validating the structure and basic functionality of create project, create plugin, and create agent commands.
    • Test Cases to Add:
      • elizaos create project <valid-project-name> (CLI):
        • Action: Run elizaos create project test-project-cli.
        • Verification:
          • Command executes without errors.
          • Project directory structure is created as expected.
          • Essential files (e.g., package.json, agent directory) are present.
      • elizaos create plugin <valid-plugin-name> (CLI):
        • Action: Run elizaos create plugin test-plugin-cli.
        • Verification:
          • Command executes without errors.
          • Plugin directory structure is created in packages as expected.
          • Essential plugin files (e.g., package.json, src directory) are present.
      • elizaos create agent <valid-agent-name> (CLI):
        • Action: Run elizaos create agent test-agent-cli.
        • Verification:
          • Command executes without errors.
          • Agent directory structure is created in agent (or packages/the-org/agent) as expected.
          • Essential agent files (e.g., .character.json, src directory) are present.
  4. Database Adapter Integration Tests (Low Priority initially, if SQL plugins are critical)

    • Focus: If SQL-based plugins (like plugin-sql) are a core part of your ElizaOS deployment, prioritize basic database integration tests. Otherwise, defer to later.
    • Test Cases to Add: (Example - PostgreSQL, adapt for other DBs)
      • Start Agent with PostgreSQL Adapter (Integration Test):
        • Setup: Ensure PostgreSQL Docker container (or local instance) is running. Configure .env with PostgreSQL connection details.
        • Action: Run bun start --character <character-file-with-postgres-plugin>.
        • Verification:
          • ElizaOS server starts without database connection errors (check logs).
          • Database adapter initializes successfully (check logs).
          • Basic database operations (e.g., creating a memory, retrieving a memory - using a test action) are functional.

Actionable Steps for Test Engineers:

  1. Start with High Priority Tests: Focus on implementing integration tests for Agent Lifecycle (Test Cases 1-6) to establish core stability.
  2. Implement Medium Priority Tests Next: Add tests for Custom Actions/Providers (Test Cases 7-10) and CLI Command Structure (Test Cases 11-13) to cover key extensibility features and developer workflows.
  3. Defer Database Tests (Initially): Unless SQL-based plugins are immediately critical, defer database integration tests to a later phase.
  4. Focus on CLI Command Verification: For each test case, focus on verifying:
    • Command Execution: The CLI command runs without crashing or throwing errors.
    • Log Output: Check console logs for expected messages, successful initialization, or error indications.
    • Side Effects: Verify expected side effects, such as agent startup, file creation, or database changes (if applicable).
  5. Review Existing Tests as Examples: Use packages/core/test/bootstrap.test.ts and packages/plugin-bootstrap/src/actions/__tests__/actions.test.ts as templates for writing new integration tests.
  6. Utilize IAgentRuntime for Programmatic Verification: Within tests, leverage the IAgentRuntime interface (or concrete AgentRuntime class) to programmatically inspect agent state, registered actions/providers, and other runtime aspects for detailed verification.

By following this prioritized approach, your test engineers can build a robust suite of CLI-focused integration tests that cover the most critical developer workflows and ensure the core functionality and extensibility of ElizaOS are working as intended. Let me know if you would like any of these test cases elaborated further with code examples or more specific verification steps!

@jkbrooks
Copy link
Author

this has been submitted by @Samarthsinghal28 and co as per https://docs.google.com/spreadsheets/d/1ECwDAsimps1_rP2EosGE8OPyuqCbg2fyZr_2RU0OXsU/edit?usp=drive_link I'll consider it done and create another ticket that clarifies next steps.

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

No branches or pull requests

1 participant