The project for mock the product application in test environment.
For mock the application run in the product, like http/bin
.
Already in build-on, for CI branch is develop.
- Support the Docker environment
- Support the Kubernetes environment
- Support the Istio with Kubernetes environment
- Support run directly on vm or pc.
- Support protocol mock
- support tcp protocol
pre-environment: golang support(v1.15+)
- Clone project to your environment.
- Use
go
to build binary-product. - Run it.
See the deployment.yaml.
To build image:
$ docker build -t example:v0.0.0 .
To run image:
$ docker run -itd --name=example -p 3000:3000 example:v0.0.0
Support tcp port:
# Tcp server default listen the 8000, change it on config/conf.yaml
$ docker run -itd --name=example -p 3000:3000 -p 8000:8000 example:v0.0.0
The example provide tcp
protocol mock server.
Set config.yaml server_config.enable_tcp_server = true
to enable tcp server.
Only the server_config.enable_tcp_server is true, the tcp will listen target port to accept the connect.
Make a post to create a tcp connection:
POST
http://{Server Ipaddress and Port}}/protocol/tcp
BODY
{
"connect_time": 10,
"remote_ip_address": "127.0.0.1",
"remote_ip_port": "8000",
"send_byte_count": 10,
"protocol": "tcp"
}
connect_time
: how long connect keepremote_ip_address
: target tcp server's ip addressremote_ip_port
: port of target tcp server listensend_byte_count
: the tcp client will send body size to target tcp serverprotocol
: support tcp protocols: tcp, tcp4, tcp6, unix, unixpacket
RESPONSE-200
{
"invoke_time": "2021-06-01T16:57:58.859541+08:00",
"end_time": "2021-06-01T16:58:09.860653+08:00",
"value_byte": "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ==",
"value_size": 100,
"request_protocol": "tcp",
"invoking_setting": {
"connect_time": 10,
"remote_ip_address": "127.0.0.1",
"remote_ip_port": "8000",
"send_byte_count": 10,
"protocol": "tcp"
}
}