-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
139 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: build app | ||
|
||
on: | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
ui: | ||
permissions: | ||
contents: write | ||
uses: bavix/.github/.github/workflows/[email protected] | ||
secrets: inherit |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# GripMock User Documentation | ||
|
||
--- | ||
|
||
![GripMock](https://placehold.co/1120x440/EEE/31343C) | ||
|
||
`GripMock` is a mock server for GRPC services. | ||
|
||
## Support | ||
|
||
Please ask questions on the [Github issues page](https://github.com/bavix/gripmock/issues). | ||
|
||
--- | ||
Supported by | ||
|
||
[![Supported by JetBrains](https://cdn.rawgit.com/bavix/development-through/46475b4b/jetbrains.svg)](https://www.jetbrains.com/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
- Getting started | ||
- [Introduction](README) | ||
- [Overview](overview) | ||
- [Quick Usage](quick-usage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Overview | ||
|
||
GripMock is a **mock server** for **GRPC** services. It's using a `.proto` file to generate implementation of gRPC service for you. | ||
You can use gripmock for setting up end-to-end testing or as a dummy server in a software development phase. | ||
The server implementation is in GoLang but the client can be any programming language that support gRPC. | ||
|
||
This service is a fork of the service [tokopedia/gripmock](https://github.com/tokopedia/gripmock). | ||
|
||
## Fork key features | ||
- Updated all deprecated dependencies [tokopedia#64](https://github.com/tokopedia/gripmock/issues/64); | ||
- Add yaml as json alternative for static stab's; | ||
- Add endpoint for healthcheck (/health); | ||
- Add grpc error code [tokopedia#125](https://github.com/tokopedia/gripmock/issues/125); | ||
- Added gzip encoding support for grpc server [tokopedia#134](https://github.com/tokopedia/gripmock/pull/134); | ||
- Fixed issues with int64/uint64 [tokopedia#67](https://github.com/tokopedia/gripmock/pull/148); | ||
- Add 404 error for stubs not found [tokopedia#142](https://github.com/tokopedia/gripmock/issues/142); | ||
- Support for deleting specific stub [tokopedia#123](https://github.com/tokopedia/gripmock/issues/123); | ||
- Reduced image size [tokopedia#91](https://github.com/tokopedia/gripmock/issues/91); | ||
- Active support [tokopedia#82](https://github.com/tokopedia/gripmock/issues/82); | ||
- Added documentation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
## Quick Usage | ||
|
||
I suspect if you have reached this page, then you already have a grpc server and a proto contract. Do not delay the contract far, now you will need it. | ||
|
||
Let's imagine that our contract `simple.proto` looks something like this: | ||
```protobuf | ||
syntax = "proto3"; | ||
option go_package = "github.com/bavix/gripmock/protogen/example/simple"; | ||
package simple; | ||
service Gripmock { | ||
rpc SayHello (Request) returns (Reply); | ||
} | ||
message Request { | ||
string name = 1; | ||
} | ||
message Reply { | ||
string message = 1; | ||
int32 return_code = 2; | ||
} | ||
``` | ||
|
||
At the moment, there is no standalone version of gripmock, only a docker image. | ||
|
||
I will skip the details of installing docker and using it. Read documentation: https://docs.docker.com/engine/install/. | ||
|
||
Let's start the GripMock server: | ||
```bash | ||
docker run -p 4770:4770 -p 4771:4771 -v ./simple.proto:/proto/simple.proto:ro bavix/gripmock /proto/simple.proto | ||
``` | ||
|
||
After launch, you will see something like this: | ||
```bash | ||
➜ simple git:(docs) ✗ docker run -p 4770:4770 -p 4771:4771 -v ./api:/proto:ro bavix/gripmock /proto/simple.proto | ||
Starting GripMock | ||
Serving stub admin on http://:4771 | ||
grpc server pid: 38 | ||
Serving gRPC on tcp://:4770 | ||
``` | ||
|
||
What is important to understand? | ||
1. GRPC Mock server started on port 4770; | ||
2. HTTP server for working with the stub server is running on port 4771; | ||
|
||
This means that everything went well. Now let's add the first stub: | ||
```bash | ||
curl -X POST -d '{"service":"Gripmock","method":"SayHello","input":{"equals":{"name":"gripmock"}},"output":{"data":{"message":"Hello GripMock"}}}' 127.0.0.1:4771/api/stubs | ||
``` | ||
|
||
The stub has been successfully added, you have received a stub ID: | ||
```bash | ||
["6c85b0fa-caaf-4640-a672-f56b7dd8074d"] | ||
``` | ||
|
||
You can check the added stubs at the link: http://127.0.0.1:4771/api/stubs. | ||
The result will not make you wait long, you should see the following: | ||
```json | ||
[ | ||
{ | ||
"id": "6c85b0fa-caaf-4640-a672-f56b7dd8074d", | ||
"service": "Gripmock", | ||
"method": "SayHello", | ||
"input": { | ||
"equals": { | ||
"name": "gripmock" | ||
}, | ||
"contains": null, | ||
"matches": null | ||
}, | ||
"output": { | ||
"data": { | ||
"message": "Hello GripMock" | ||
}, | ||
"error": "" | ||
} | ||
} | ||
] | ||
``` | ||
|
||
Now try to use the grpc client to our service with the data from the input. | ||
|
||
Happened? Well done. You are a fast learner. | ||
|
||
It worked! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters