Testing Guide
Overview
This guide describes how to test EchoCenter.
Unit Testing
Backend Testing
bash
cd backend
go test ./...Frontend Testing
bash
cd frontend
npm testIntegration Testing
Start Services
bash
make run-mock RESET=1Test API
Login
bash
curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin123"}'Get Messages
bash
curl -X GET http://localhost:8080/api/messages \
-H "Authorization: Bearer YOUR_TOKEN"Register Agent
bash
curl -X POST http://localhost:8080/api/users/agents \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"username":"Test-Agent"}'Test WebSocket
Connection
javascript
const ws = new WebSocket('ws://localhost:8080/api/ws?token=YOUR_TOKEN');
ws.onopen = () => {
console.log('Connected');
};
ws.onmessage = (event) => {
console.log('Message:', event.data);
};
ws.onclose = () => {
console.log('Disconnected');
};Manual Testing
Testing Workflow
- Start Services
bash
make run-mock RESET=1- Login Visit
http://localhost:5173, use the following credentials to login:
- Username:
admin - Password:
admin123
- Test Messages
- Send a message to Butler.
- View the response.
- Test command execution.
- Test Agents
- View agent list.
- View agent status.
- Test agent communication.
Test Cases
1. User Login
gherkin
Given I am on the login page
When I enter valid credentials
Then I should be logged in successfully2. Send Message
gherkin
Given I am logged in
When I send a message to Butler
Then I should receive a response3. Command Execution
gherkin
Given I am logged in
When I request a command execution
Then I should receive an authorization request
When I approve the request
Then the command should be executed
And I should see the result4. Agent Registration
gherkin
Given I am logged in as admin
When I register a new agent
Then the agent should be registered
And I should see it in the agent listAutomated Testing
Backend Testing
Test Login
go
func TestLogin(t *testing.T) {
// Create test server
// Send login request
// Validate response
}Test Message Handling
go
func TestHandleUserMessage(t *testing.T) {
// Create test message
// Call handler function
// Validate result
}Frontend Testing
Test Login
javascript
it('should login successfully', () => {
cy.visit('/login');
cy.get('#username').type('admin');
cy.get('#password').type('admin123');
cy.get('button').click();
cy.url().should('include', '/dashboard');
});Test Message Sending
javascript
it('should send message', () => {
cy.visit('/chat');
cy.get('#message-input').type('Hello');
cy.get('#send-button').click();
cy.contains('Hello');
});Performance Testing
LLM Mock Stress Test (Dedicated Branch)
The main branch keeps core runtime/testing docs, while LLM pressure tooling is maintained in:
chore/mock-llm-loadtest
Use that branch when you need MOCK_MODE and make stress-llm:
bash
git checkout chore/mock-llm-loadtest
make stress-llmSee comparison notes:
/development/db-stress-comparison-20260308/zh/development/db-stress-comparison-20260308
WebSocket Long-Connection Capacity (C20K)
- Validation date:
2026-03-08 - Verified profile: idle long-lived WebSocket connections (no business-message traffic), periodic Ping keepalive
- Verified result:
20,000 / 20,000connections established and held (100%) - Observed backend process during hold:
- RSS around
401MB~415MB - Threads around
29
- RSS around
- Important:
- This validates connection-carrying capacity for idle clients/agents.
- It does not represent message throughput limits for heavy chat/business traffic.
- Tooling branch for executable stress code:
git fetch origingit checkout feat/ws-c10k-stress-test
WebSocket Long-Connection Capacity (C20K)
- Validation date:
2026-03-08 - Verified profile: idle long-lived WebSocket connections (no business-message traffic), periodic Ping keepalive
- Verified result:
20,000 / 20,000connections established and held (100%) - Observed backend process during hold:
- RSS around
401MB~415MB - Threads around
29
- RSS around
- Important:
- This validates connection-carrying capacity for idle clients/agents.
- It does not represent message throughput limits for heavy chat/business traffic.
- Tooling branch for executable stress code:
git fetch origingit checkout feat/ws-c10k-stress-test
Backend Performance Testing
bash
# Using wrk
wrk -t4 -c100 -d30s http://localhost:8080/api/ping
# Using ab
ab -n 1000 -c 100 http://localhost:8080/api/pingFrontend Performance Testing
bash
# Using Lighthouse
lighthouse http://localhost:5173 --viewTroubleshooting
Test Failed
Check:
- Test environment is correct.
- Test data is correct.
- Test code is correct.
Performance Issues
Check:
- Database queries are optimized.
- Too many WebSocket connections.
- Code has performance bottlenecks.
Best Practices
- Test Coverage: Ensure tests cover all key functions.
- Automated Testing: Integrate tests into the CI/CD pipeline.
- Performance Testing: Perform performance testing regularly.
- Security Testing: Perform security testing regularly.