Design and Implementation of the SCF RPC Service Testing Platform
This article describes the architecture, features, and implementation details of a self‑developed SCF RPC testing platform that provides interface testing, automatic documentation, mock services, and automated test case management to streamline RPC service development and testing.
Introduction: The article introduces a self‑developed RPC service testing platform for 58, covering interface testing, automatic documentation generation, service mocking, and automated case management.
Background: As the SCF (Service Container Framework) services mature, many business lines migrate to SCF, making RPC interface testing cumbersome; the platform aims to simplify testing similar to RESTful APIs.
Platform Architecture: The system consists of modules JARInterpreter, CLIENTBuilder, DataServices, USERUI, and a database layer using MySQL and WTable.
Interface Testing Design: Describes how request parameters are built via Java reflection, how the client is constructed using service, method, parameters, KEY or IP, and how OBJECT responses are formatted to JSON.
Problem and Solution – Class Name Matching: When the implementation class does not follow the "Interface+Impl" convention, the platform uses a Levenshtein distance algorithm to find the most similar class name. The Java implementation is shown below.
public static int levenshteinDistance(String str, String target) {
int s = str.length();
int t = target.length();
if (s == 0) { return t; }
if (t == 0) { return s; }
int[][] d;
int i, j;
char strChar, targetChar;
int temp;
d = new int[s + 1][t + 1];
for (i = 0; i <= s; i++) { d[i][0] = i; }
for (i = 1; i <= s; i++) {
strChar = str.charAt(i - 1);
for (j = 1; j <= t; j++) {
targetChar = target.charAt(j - 1);
temp = (strChar == targetChar) ? 0 : 1;
d[i][j] = min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + temp);
}
}
return d[s][t];
}Documentation Generation: Initially considered Swagger but switched to parsing Java source code with JavaParser to generate API docs from method signatures and comments, avoiding extra developer effort.
Automated Test Cases: The platform records request and response data during testing, allowing conversion into test cases, supports manual, scheduled, and code‑triggered execution, and provides a UI for case management and execution tracking.
SCF Mock: Describes two ways to create mocks – by specifying method and content, or by replaying historical responses, reducing effort for developers.
OpenAPI Interface: Provides HTTP‑based OpenAPI endpoints so external tools in various languages can invoke SCF services without dealing with proprietary protocols.
Platform Impact: Testing time reduced from over 10 minutes to under 1 minute, regression efficiency improved 1.5×, over 1800 test cases and 8000 interfaces managed, with daily growth.
Future Plans: Optimize existing features, improve user experience, and enable composition of new interfaces based on existing ones.
Author: Zhu Chuanbo, senior test engineer at Anjuke Quality Assurance, responsible for broker business testing and testing tool development.
58 Tech
Official tech channel of 58, a platform for tech innovation, sharing, and communication.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.