https://github.com/automationhacks/grasp-grpc
Ports routeguide example service from grpc-java repository and adds functional and non functional API tests
https://github.com/automationhacks/grasp-grpc
api-testing grpc grpc-java testing
Last synced: 16 days ago
JSON representation
Ports routeguide example service from grpc-java repository and adds functional and non functional API tests
- Host: GitHub
- URL: https://github.com/automationhacks/grasp-grpc
- Owner: automationhacks
- License: mit
- Created: 2024-03-13T16:22:02.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-15T11:26:04.000Z (over 1 year ago)
- Last Synced: 2025-08-19T22:25:30.516Z (10 months ago)
- Topics: api-testing, grpc, grpc-java, testing
- Language: Java
- Homepage:
- Size: 154 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# grasp-grpc
## Setup
```zsh
# Clone repo (One time)
git clone https://github.com/automationhacks/grasp-grpc
# Generate source files
./gradlew installDist
# Start server
./build/install/grasp-grpc/bin/route-guide-server
# Install gRPC UI (One time)
brew install grpcui
# Start gRPC UI
grpcui -plaintext localhost:8980
```
## Unit testing
```zsh
# Run server unit tests via JUnit4
./gradlew clean test --tests io.automationhacks.routeguide.RouteGuideServerTest --info
# Run client unit tests via JUnit4
./gradlew clean test --tests io.automationhacks.routeguide.RouteGuideClientTest --info
```
## E2E testing
```zsh
# Run E2E tests via TestNG
./gradlew clean runTests
```
## Collect code coverage
```zsh
./gradlew clean build --info
```
If you only build without running the tests, you'll notice the code does not fail
```zsh
./gradlew clean build -x test --info
```
## Load testing
Start locust master on local
```zsh
pip3 install pipenv
# One time setup
# Set below in .zshrc or .bash_profile depending upon the type of shell you are using
export WORKON_HOME=~/virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
# Start pipenv shell such that a virtualenv is created which has locust python module already installed
pipenv shell
# Start locust master on local
locust -f locust_master.py --master --master-bind-host=127.0.0.1 --master-bind-port=5557
```
```zsh
[2024-05-26 12:22:02,412] Gauravs-Laptop/INFO/locust.main: Starting web interface at http://0.0.0.0:8089
[2024-05-26 12:22:02,416] Gauravs-Laptop/INFO/locust.main: Starting Locust 2.28.0
```
Ensure all relevant proto files are generated by executing below (you only need to run this if you've made some changes
to
the proto)
```zsh
./gradlew installDist
```
Start gRPC server
```zsh
./build/install/grasp-grpc/bin/route-guide-server
```
```zsh
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
May 25, 2024 10:39:06 PM io.automationhacks.routeguide.RouteGuideServer start
INFO: Server started, listening on 8980
```
Start locust slave by running the main function
[RouteGuideLoadGen.java](RouteGuideLoadGen.java)
```java
public static void main(String[] args) {
new RouteGuideLoadTest().getFeatureLoad();
}
```
Now you can go to the locust master URL and start your load test using locust UI
### References
- Locust python notes on Grpc testing https://docs.locust.io/en/stable/testing-other-systems.html#grpc
- Grpc Test Infra https://github.com/grpc/test-infra
- Distributed Load Testing of REST/gRPC APIs using Locust https://github.com/pedrodeoliveira/locust-rest-grpc
- Blog from blazemeter https://www.blazemeter.com/blog/locust-performance-testing
- Locust4j https://github.com/myzhan/locust4j
- Example Main.java file https://github.com/myzhan/locust4j/blob/master/examples/task/Main.java to start a locust test
- Locust Http load example project https://github.com/nejckorasa/locust4j-http-load
- Locust Http load another example project https://github.com/nejckorasa/locust4j-http-load
- wrk an example HTTP benchmarking tool https://github.com/wg/wrk