Conversation
Plan for adding unit and integration tests to the grpcw module, which currently has no test coverage. Follows existing patterns from other wire protocol modules (MongoDB, PostgreSQL). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Step-by-step implementation plan with 13 tasks covering: - pom.xml dependency updates - GrpcAdminServiceIT integration tests - GrpcServerIT integration tests (CRUD, queries, transactions, streaming, bulk) - GrpcServerPluginTest unit tests - GrpcAuthInterceptorTest unit tests Each task includes exact code, commands, and expected outputs. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add integration tests for the gRPC Admin Service ping endpoint: - pingWithValidCredentials: verifies successful auth and response - pingWithoutCredentialsFails: verifies UNAUTHENTICATED error - pingWithInvalidCredentialsFails: verifies UNAUTHENTICATED error Also fix authentication in ArcadeDbGrpcAdminService to authenticate against server security (not just validate format), and update GrpcAuthInterceptor to skip auth for admin service methods since they handle their own authentication via request body. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 5 new tests to GrpcAdminServiceIT: - createAndDropDatabase: tests full lifecycle of database creation and deletion - createDatabaseIsIdempotent: verifies creating existing database is idempotent - dropNonExistentDatabaseIsIdempotent: verifies dropping non-existent database is idempotent - getDatabaseInfoReturnsValidData: tests database info retrieval - getDatabaseInfoForNonExistentFails: verifies proper NOT_FOUND error for missing database Also fixes bugs in ArcadeDbGrpcAdminService: - Remove try-with-resources for server databases (they are shared and cannot be closed) - Fix dropDatabasePhysical to use correct server API (getEmbedded().drop() + removeDatabase()) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 8 unit tests for the CompressionAwareService helper class: - Test setResponseCompression sets compression on call - Test isCurrentRequestCompressed returns true when compressed - Test isCurrentRequestCompressed returns false when not compressed - Test getCurrentRequestEncoding returns the encoding - Test getCurrentRequestEncoding returns null when no context - Test CompressionStats initialization - Test CompressionStats percentage calculation - Test CompressionStats multiple requests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comprehensive analysis of the grpcw module covering: - Architecture assessment (layered design, interceptor chain) - Code quality issues (main service size, incomplete security) - 5 refactoring proposals with priority and risk assessment Key findings: - ArcadeDbGrpcService.java at 3,120 lines needs decomposition - Token validation is a placeholder (always returns true) - Propose extracting GrpcTypeConverter and GrpcStreamingHandler Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Detailed TDD plan to extract type conversion logic from ArcadeDbGrpcService: - 10 tasks with step-by-step instructions - ~38 new unit tests for the converter - Expected to reduce main service by ~220 lines - Maintains all existing functionality Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
New utility class for gRPC type conversions: - tsToMillis: convert protobuf Timestamp to epoch milliseconds - msToTimestamp: convert epoch milliseconds to protobuf Timestamp Includes 3 unit tests with round-trip verification. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Converts GrpcValue protobuf to Java objects: - Primitives: boolean, int32, int64, float, double, string, bytes - Complex: timestamp→Date, link→RID, decimal→BigDecimal - Containers: list→ArrayList, map/embedded→LinkedHashMap Adds 10 unit tests for the conversion logic. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds 5 tests for fromGrpcValue complex types: - Decimal (GrpcDecimal → BigDecimal) - Link (GrpcLink → RID) - List (GrpcList → ArrayList) - Map (GrpcMap → LinkedHashMap) - Embedded (GrpcEmbedded → LinkedHashMap) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Converts Java objects to GrpcValue protobuf: - Primitives: boolean, int, long, float, double, string, bytes - Complex: Date→timestamp, RID→link, BigDecimal→decimal - Containers: List→GrpcList, Map→GrpcMap - Fallback to string for unknown types Adds 9 unit tests for the conversion logic. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for toGrpcValue with RID, BigDecimal, List, Map types and round-trip verification for primitives. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add method to convert Map<String, GrpcValue> to Map<String, Object> for query parameter handling. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add utility method for calculating UTF-8 byte length of strings. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace calls to local utility methods with GrpcTypeConverter: - convertParameters() - 5 usages - bytesOf() - 3 usages - tsToMillis() - 3 usages - msToTimestamp() - 1 usage Remove duplicate method definitions that are now unused. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary of ChangesHello @robfrank, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the gRPC module's architecture by extracting complex type conversion logic into a dedicated, testable utility class. Concurrently, it introduces a comprehensive suite of unit and integration tests across various components of the gRPC module, ensuring robustness and preventing regressions. These changes collectively improve the module's maintainability, testability, and overall code quality without altering existing API behavior. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
🧪 CI InsightsHere's what we observed from your CI run for a5d7f97. 🟢 All jobs passed!But CI Insights is watching 👀 |
Code Review: gRPC Tests and RefactorThis PR adds comprehensive test coverage and refactoring to the gRPC module. Overall, this is solid work that significantly improves code quality and maintainability. Below are my findings organized by category. ✅ Strengths1. Excellent Refactoring - GrpcTypeConverter Extraction
2. Comprehensive Test Coverage
3. Code Style Adherence
4. Dependency Management
|
There was a problem hiding this comment.
Code Review
This pull request introduces a significant and valuable set of changes. The primary refactoring, which extracts type conversion logic into a dedicated GrpcTypeConverter class, greatly improves the maintainability and testability of the grpcw module. The addition of a comprehensive suite of unit and integration tests is a massive step forward for the module's reliability. Furthermore, the PR includes critical fixes, such as correcting resource management in ArcadeDbGrpcAdminService to prevent closing shared database instances and implementing proper authentication where it was previously missing. My review includes a few suggestions for improving maintainability by reducing the use of reflection and making exception handling more specific. Overall, this is an excellent contribution that substantially enhances the quality of the codebase.
| <groupId>org.mockito</groupId> | ||
| <artifactId>mockito-core</artifactId> | ||
| <version>${mockito-core.version}</version> | ||
| <scope>test</scope> |
There was a problem hiding this comment.
The version for the mockito-core dependency is specified as ${mockito-core.version}. Please ensure this property is defined in the parent pom.xml. If it's a typo and should be ${mockito.version} (which is a more common property name for Mockito), please correct it. An undefined property will cause build failures.
| try { | ||
| server.getSecurity().authenticate(user, pass, null); | ||
| } catch (Exception e) { | ||
| throw new SecurityException("Invalid credentials"); | ||
| } |
There was a problem hiding this comment.
While adding authentication is a critical improvement, catching a generic Exception is a bit broad. If server.getSecurity().authenticate() throws a more specific, documented exception for authentication failures (like javax.security.auth.login.LoginException or a custom one), it would be better to catch that specific exception. This would make the code more robust and prevent accidentally catching unrelated runtime exceptions (like NullPointerException) and misreporting them as an authentication failure.
| private void dropDatabasePhysical(String name) throws Exception { | ||
| try { | ||
| var m = server.getClass().getMethod("dropDatabase", String.class, boolean.class); | ||
| m.invoke(server, name, Boolean.TRUE); | ||
| } catch (NoSuchMethodException nsme) { | ||
| // Fallback: dropDatabase(String) if present | ||
| var m2 = server.getClass().getMethod("dropDatabase", String.class); | ||
| m2.invoke(server, name); | ||
| } | ||
| // Get the server database | ||
| var getDbMethod = server.getClass().getMethod("getDatabase", String.class); | ||
| Object serverDb = getDbMethod.invoke(server, name); | ||
|
|
||
| // Get the embedded database and call drop() | ||
| var getEmbeddedMethod = serverDb.getClass().getMethod("getEmbedded"); | ||
| Object embeddedDb = getEmbeddedMethod.invoke(serverDb); | ||
| var dropMethod = embeddedDb.getClass().getMethod("drop"); | ||
| dropMethod.invoke(embeddedDb); | ||
|
|
||
| // Remove from server's database cache | ||
| var getNameMethod = serverDb.getClass().getMethod("getName"); | ||
| String dbName = (String) getNameMethod.invoke(serverDb); | ||
| var removeMethod = server.getClass().getMethod("removeDatabase", String.class); | ||
| removeMethod.invoke(server, dbName); | ||
| } |
There was a problem hiding this comment.
The new implementation of dropDatabasePhysical uses reflection extensively to perform a multi-step operation (get database, get embedded, drop, get name, remove from cache). This makes the code brittle and hard to maintain, as it will break at runtime if any of the underlying method signatures in ArcadeDBServer or related classes change. It would be more robust to use a direct public API on ArcadeDBServer that encapsulates this logic. If such an API doesn't exist, consider adding one to avoid this fragile reflection-based approach.
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
- Use ServerSecurityException instead of generic Exception for authentication error handling (more specific exception type) - Replace reflection-based method calls with direct ArcadeDBServer API: - getDatabaseNames() - use server.getDatabaseNames() directly - createDatabasePhysical() - use server.createDatabase() directly - dropDatabasePhysical() - use server.getDatabase().getEmbedded().drop() - openDatabase() - use server.getDatabase() directly - Remove unused imports (Arrays, Collections) This makes the code more maintainable and less fragile to API changes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PR Review: GRPc Tests and RefactorSummaryThis is an excellent PR that significantly improves the grpcw module through comprehensive test coverage and important code quality refactoring. The extraction of type conversion logic into a dedicated utility class and the addition of extensive test coverage are both valuable improvements. ✅ Strengths1. Excellent Code Organization
2. Comprehensive Test Coverage
3. Proper Dependency Management
4. Code Quality Improvements
|
Security fixes: - validateToken() now returns false and logs warning since Bearer token authentication is not yet implemented (was always returning true) - extractUserFromToken() now throws UnsupportedOperationException since it should never be called when token validation fails Documentation: - Remove implementation planning documents from docs/plans/ as they are development artifacts, not user documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review for PR #3306: gRPC Tests and RefactorThis PR adds comprehensive test coverage and refactoring to the grpcw module. Overall, this is excellent work that significantly improves the codebase quality. Here's my detailed feedback: ✅ Strengths1. Excellent Test Coverage
2. Clean Refactoring
3. Security Improvements
4. Code Quality
|
| Category | Score | Notes |
|---|---|---|
| Code Quality | ⭐⭐⭐⭐⭐ | Clean, well-structured, follows conventions |
| Test Coverage | ⭐⭐⭐⭐⭐ | Comprehensive unit and integration tests |
| Security | ⭐⭐⭐⭐☆ | Much improved, minor unreachable code issue |
| Performance | ⭐⭐⭐⭐☆ | Good, minor reflection overhead |
| Documentation | ⭐⭐⭐⭐☆ | Well-commented, could add more Javadoc |
✅ Approval Recommendation
Status: Approved with Minor Suggestions
This PR significantly improves the grpcw module quality. The issues identified are minor and could be addressed in a follow-up PR if desired. The test coverage alone makes this a valuable contribution.
Critical Items:
- None blocking merge
Before Merge (Optional but Recommended):
- Remove unreachable code in GrpcAuthInterceptor (lines 119-125)
- Add comment explaining reflection usage in Admin Service
Post-Merge Improvements:
- Consider refactoring reflection-based methods
- Add the suggested edge case tests
- Implement token authentication
Great work! 🎉
Design enables gRPC clients to authenticate using Bearer tokens obtained from HTTP /api/v1/auth/login, reusing HttpAuthSessionManager. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…nstructor Add a two-argument constructor to GrpcAuthInterceptor that accepts HttpAuthSessionManager in preparation for token-based authentication. The existing single-argument constructor delegates to the new one with null session manager for backward compatibility. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement getValidSession() method that validates Bearer tokens by looking up sessions via HttpAuthSessionManager.getSessionByToken(). The method returns the session if valid, allowing extraction of the authenticated user for the gRPC context. - Add HttpAuthSession import - Rename validateToken() to getValidSession() returning HttpAuthSession - Extract username from session.getUser().getName() for context - Remove unused extractUserFromToken() method - Add tests for valid/invalid token scenarios Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update GrpcServerPlugin.configureServer() to obtain HttpAuthSessionManager from the HTTP server and pass it to GrpcAuthInterceptor. This enables token-based authentication for gRPC requests by reusing the same session manager used by the HTTP server. When the HTTP server is not available, a log message is emitted and token authentication is disabled (but basic auth still works). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add 3 integration tests: authenticateWithHttpTokenOverGrpc, tokenRejectedAfterLogout, invalidTokenRejected - Add HTTP login/logout helpers for token-based auth flow - Add TokenAuthClientInterceptor for Bearer token authentication - Update ArcadeDbGrpcService.validateCredentials() to check for already-authenticated users from the interceptor context Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Overview of gRPC benefits (streaming, binary protocol, multiplexing) - Authentication: username/password and Bearer token methods - ArcadeDbService: streaming queries, commands, CRUD, bulk insert, transactions - ArcadeDbAdminService: server and database administration - Data types: GrpcValue, GrpcRecord mappings - Error handling with gRPC status codes - Performance considerations: connection pooling, streaming patterns - TLS configuration Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implementation is complete and documented in docs/gRPC-API.md Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
COMPREHENSIVE CODE REVIEW: gRPC Tests and Refactor (PR #3306) Thank you for this substantial enhancement to the gRPC module! STRENGTHS: CRITICAL ISSUES:
HIGH PRIORITY:
MEDIUM PRIORITY:
SECURITY REVIEW: PERFORMANCE: SUMMARY: RECOMMENDATION: Request changes for critical issues #1 and #2, then approve. Other issues can be follow-up PRs. Great work overall! |
…ENTED for user management CRITICAL FIXES from PR review: 1. Replaced reflection-based server info methods: - getServerVersion() now uses Constants.getVersion() directly - getHttpPort() uses server.getHttpServer().getPort() directly - getGrpcPort() iterates server.getPlugins() to find GrpcServerPlugin - getServerStartMs() and getBinaryPort() return sentinel values (not exposed by server) 2. Fixed user management methods (createUser, deleteUser): - Previously returned fake success with TODO comments - Now properly return Status.UNIMPLEMENTED with clear message - Directs users to HTTP API or configuration files Benefits: - No more reflection overhead or silent failures - Compile-time safety (method renames will cause build failures) - Honest API contract (UNIMPLEMENTED vs fake success) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review - PR #3306: gRPC Tests and RefactorThank you for this comprehensive refactoring of the gRPC module! This PR significantly improves the codebase with extensive test coverage and better code organization. Here's my detailed review: ✅ Strengths1. Excellent Test Coverage
2. Good Code Organization
3. Security Improvements
4. Documentation
|
- Fix grpcService field never being assigned (critical NPE on shutdown) - Add null check for database in getDatabaseInfo() - Simplify vertex type check using anyMatch() instead of redundant stream null check Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
PR Review: gRPC Tests and RefactoringSummaryThis is an excellent and comprehensive PR that adds significant test coverage to the grpcw module (going from 0 to ~52 tests) and performs important refactoring to improve code quality. The changes follow TDD principles and ArcadeDB's coding standards well. ✅ Strengths1. Comprehensive Test Coverage
2. Smart Refactoring: GrpcTypeConverter
3. Security Improvements
4. API Improvements
5. Documentation
|
PR Review: gRPC Tests and RefactorI've reviewed this PR which adds comprehensive test coverage and refactors the gRPC module. Here's my detailed feedback: ✅ Strengths1. Excellent Test Coverage
2. Code Quality & Organization
3. Security Implementation
4. Documentation
5. Dependency Management
|
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
PR Review: gRPC Tests and RefactorThank you for this comprehensive PR adding test coverage and refactoring the gRPC module! Overall, this is excellent work with strong test coverage and good code quality. Below is my detailed feedback. ✅ Strengths1. Excellent Test Coverage (2,113 lines added across 9 test files)
2. Dependency Management ✓
3. Code Quality Improvements
4. Security ✓
5. Documentation
🔴 Critical Issue - Resource LeakLocation: // Line 227 - PROBLEM: Database opened but never closed
final Database db = openDatabase(name);
// ... uses db but NEVER closes itIssue: The comment on line 167 says "don't close it" but there's inconsistent handling:
Root Cause Analysis: Recommendation:
Action Required: Please clarify the lifecycle management of 🟡 Minor Issues1. Performance Consideration (Low Priority)// Line 257-259: Iterates all schema types to find VertexType
final boolean hasVertexTypes = schema.getTypes().stream()
.anyMatch(t -> t instanceof VertexType);This could be slow on large schemas, but acceptable for admin operations. Consider caching if this becomes a bottleneck in the future. 2. Javadoc Coverage (Nice to Have)Consider adding Javadoc to public methods in 📋 Code Style Compliance✅ All CLAUDE.md guidelines followed:
🧪 Testing Verification RecommendationBefore merge, please run: # Compile entire project
mvn clean install -DskipTests
# Run all gRPC tests
mvn test -pl grpcw
# Run integration tests
mvn test -pl grpcw -DskipITs=falseFinal VerdictOverall Assessment: STRONG APPROVE with ONE CRITICAL FIX NEEDED This PR represents solid engineering work with excellent test coverage (87% new code is tests), proper refactoring, and good security practices. The only blocker is clarifying and fixing the resource management inconsistency in Once the resource leak is addressed, this is ready to merge. Great work on the comprehensive testing! 🎉 Files Reviewed:
|
No description provided.