Skip to content

Commit

Permalink
Section "Getting started".
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 committed Sep 2, 2023
1 parent 97a1719 commit 123e22f
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/compile-assets.yml
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
1 change: 0 additions & 1 deletion docs/README.md

This file was deleted.

16 changes: 16 additions & 0 deletions docs/README.md
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/)
3 changes: 2 additions & 1 deletion docs/_sidebar.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- Getting started
- [Introduction](README)
- [Overview](overview)
- [Quick Usage](quick-usage)
20 changes: 20 additions & 0 deletions docs/overview.md
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;
87 changes: 87 additions & 0 deletions docs/quick-usage.md
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!
2 changes: 2 additions & 0 deletions docs/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ import 'docsify'
import 'docsify/lib/plugins/emoji'
import 'docsify/lib/plugins/search'
import 'prismjs/components/prism-go'
import 'prismjs/components/prism-json'
import 'prismjs/components/prism-bash'
import 'prismjs/components/prism-protobuf'
import 'docsify/lib/themes/vue.css'

0 comments on commit 123e22f

Please sign in to comment.