Skip to content

Commit 190d62f

Browse files
committed
Testing graphql and crow endpoints
1 parent aa82f61 commit 190d62f

12 files changed

+2272
-0
lines changed
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
# Crow API Testing - Quick Reference
2+
3+
## 🚀 Quick Start
4+
5+
### Option 1: Simple Test (Recommended)
6+
```bash
7+
cd backend/scripts
8+
./run_crow_tests.sh simple
9+
```
10+
11+
### Option 2: Mock Test (No Network Required)
12+
```bash
13+
cd backend/scripts
14+
./run_crow_tests.sh mock
15+
```
16+
17+
### Option 3: Full Diagnostic
18+
```bash
19+
cd backend/scripts
20+
./run_crow_tests.sh all
21+
```
22+
23+
---
24+
25+
## 📁 Test Scripts Overview
26+
27+
| Script | Purpose | Location | Runtime |
28+
|--------|---------|----------|---------|
29+
| **test_crow_simple.py** | Quick 4-test suite | `backend/scripts/` | ~2-5 min |
30+
| **test_crow_endpoints.py** | Comprehensive 7 tests | `backend/tests/` | ~5-10 min |
31+
| **test_crow_connectivity.py** | Network diagnostics | `backend/scripts/` | ~1-2 min |
32+
| **test_crow_mock.py** | Local validation | `backend/scripts/` | ~1 sec |
33+
| **run_crow_tests.sh** | Unified test runner | `backend/scripts/` | Variable |
34+
35+
---
36+
37+
## 📋 Test Scenarios
38+
39+
### ✓ Basic Tests
40+
- [x] Simple key-value commit
41+
- [x] Transaction query/retrieval
42+
- [x] Canvas stroke simulation
43+
- [x] Multiple sequential commits
44+
45+
### ✓ Advanced Tests
46+
- [x] Complex nested JSON values
47+
- [x] Invalid payload rejection
48+
- [x] Large payload handling (~10KB+)
49+
- [x] Concurrent transaction commits
50+
- [x] Duplicate transaction detection
51+
52+
### ✓ Network Tests
53+
- [x] DNS resolution
54+
- [x] HTTPS connectivity
55+
- [x] Timeout handling
56+
- [x] Retry with backoff
57+
58+
---
59+
60+
## 🎯 Example Payloads
61+
62+
### Basic Commit
63+
```bash
64+
curl --location 'https://crow.resilientdb.com/v1/transactions/commit' \
65+
--header 'Content-Type: application/json' \
66+
--data '{
67+
"id": "key_test_1234567890",
68+
"value": "value_test"
69+
}'
70+
```
71+
72+
### Canvas Stroke
73+
```bash
74+
curl --location 'https://crow.resilientdb.com/v1/transactions/commit' \
75+
--header 'Content-Type: application/json' \
76+
--data '{
77+
"id": "stroke_1234567890",
78+
"value": "{\"roomId\": \"room123\", \"points\": [[0,0],[10,10]], \"color\": \"#FF0000\"}"
79+
}'
80+
```
81+
82+
### Query Transaction
83+
```bash
84+
curl --location 'https://crow.resilientdb.com/v1/transactions/key_test_1234567890'
85+
```
86+
87+
---
88+
89+
## 🔧 Shell Script Usage
90+
91+
```bash
92+
# Show help
93+
./run_crow_tests.sh help
94+
95+
# Run specific test
96+
./run_crow_tests.sh simple
97+
./run_crow_tests.sh comprehensive
98+
./run_crow_tests.sh connectivity
99+
./run_crow_tests.sh mock
100+
101+
# Run all tests
102+
./run_crow_tests.sh all
103+
```
104+
105+
---
106+
107+
## 📊 Expected Output
108+
109+
### ✓ Success (200/201)
110+
```
111+
✓ SUCCESS: Transaction committed successfully!
112+
Total: 4/4 tests passed (100%)
113+
```
114+
115+
### ✗ Timeout
116+
```
117+
✗ ERROR: HTTPSConnectionPool(...): Read timed out
118+
```
119+
**Solution:** Use mock tests or check connectivity
120+
121+
### ✗ Invalid Payload (400)
122+
```
123+
✗ FAILED: HTTP 400: Missing required fields
124+
```
125+
**Solution:** Ensure both `id` and `value` are present
126+
127+
---
128+
129+
## 🔍 Troubleshooting
130+
131+
### Test fails with timeout
132+
```bash
133+
# Check connectivity first
134+
./run_crow_tests.sh connectivity
135+
136+
# If Crow is down, use mock
137+
./run_crow_tests.sh mock
138+
```
139+
140+
### "python: command not found"
141+
```bash
142+
# Use python3 explicitly
143+
python3 test_crow_simple.py
144+
145+
# Or create alias
146+
alias python=python3
147+
```
148+
149+
### Permission denied
150+
```bash
151+
# Make scripts executable
152+
chmod +x backend/scripts/*.sh backend/scripts/*.py
153+
```
154+
155+
---
156+
157+
## 🔗 Related Files
158+
159+
- **Config:** `backend/config.py`
160+
- **GraphQL Service:** `backend/services/graphql_service.py`
161+
- **Environment:** `backend/.env`
162+
- **Full Documentation:** `backend/scripts/CROW_TESTING_README.md`
163+
- **Summary:** `backend/scripts/CROW_TEST_SUMMARY.md`
164+
165+
---
166+
167+
## 📝 Pytest Integration
168+
169+
```bash
170+
# Run all tests
171+
cd backend
172+
pytest tests/test_crow_endpoints.py -v
173+
174+
# Run specific test
175+
pytest tests/test_crow_endpoints.py::test_crow_basic_commit -v
176+
177+
# Run with coverage
178+
pytest tests/test_crow_endpoints.py --cov=services --cov-report=html
179+
```
180+
181+
---
182+
183+
## 🌐 Endpoints
184+
185+
| Endpoint | Method | Purpose |
186+
|----------|--------|---------|
187+
| `/v1/transactions/commit` | POST | Commit new transaction |
188+
| `/v1/transactions/{id}` | GET | Query transaction |
189+
190+
**Base URL:** `https://crow.resilientdb.com`
191+
192+
---
193+
194+
## ⚙️ Configuration
195+
196+
From `backend/.env`:
197+
```properties
198+
RESILIENTDB_BASE_URI=https://crow.resilientdb.com
199+
RESILIENTDB_GRAPHQL_URI=https://cloud.resilientdb.com/graphql
200+
SIGNER_PUBLIC_KEY=your_public_key
201+
SIGNER_PRIVATE_KEY=your_private_key
202+
```
203+
204+
---
205+
206+
## 📈 Current Status (2025-11-17)
207+
208+
| Component | Status | Notes |
209+
|-----------|--------|-------|
210+
| DNS Resolution | ✓ Working | Resolves to 172.67.196.246 |
211+
| TLS Handshake | ✓ Working | Connection establishes |
212+
| Commit Endpoint | ✗ Timeout | Requests timeout after 30s |
213+
| Mock Tests | ✓ Working | All 5 tests pass |
214+
215+
**Recommendation:** Use mock tests for development until Crow API is responsive.
216+
217+
---
218+
219+
## 🎓 Learn More
220+
221+
1. Read `CROW_TESTING_README.md` for detailed documentation
222+
2. Review `CROW_TEST_SUMMARY.md` for current status
223+
3. Check `backend/services/graphql_service.py` for integration examples
224+
4. See ResCanvas Copilot instructions for workflow guidelines
225+
226+
---
227+
228+
*Quick Reference v1.0 | Last Updated: 2025-11-17*

0 commit comments

Comments
 (0)