Test environment to support hygtfrde's delphi extractor project.
link to delphi: https://github.com/hygtfrde/delphi
Using docker.
- Create a docker network:
docker network create pythiaNetwork- Pull redis image:
docker pull redisdocker run --name pythiaOnRedis --network pythiaNetwork -d redisFrom the network_components/http_redis_client dir.
- Build the image:
docker build -t img_llvm_redispp_crow .- Then run the container:
docker run -it --network pythiaNetwork -v .:/workspace --name cont_llvm_redispp_crow img_llvm_redispp_crow /bin/bashFrom the network_components/nginx_load_balancer dir:
- Build the nginx image:
docker build -t my-nginx-load-balancer .- Run the nginx container:
docker run --name nginx-lb --network pythiaNetwork -p 80:80 my-nginx-load-balancerFrom the network_components/http_redis_client/build dir.
- Run Cmake to generate makefile:
cmake ..- Run make to compile:
make- Run the redis client:
./pythia- Remove current build:
make cleanFrom the project root dir.
- Remove
builddir before generating a new makefile:
rm -r build
mkdir buildflowchart TD
UserReq["User Request<br>Get Stats"]
lb["Load Balancer"]
subgraph HTTP_Servers
httpServer1["HTTP Server 1<br><br>Redis Client"]
httpServer2["HTTP Server 2<br><br>Redis Client"]
httpServer3["HTTP Server 3<br><br>Redis Client"]
httpServer4["...<br><br>..."]
end
redisServer["Redis Server"]
gtest["Redis Client<br>Google Test"]
delphi["Delphi<br>Extractor"]
UserReq --- lb
delphi --- lb
lb --- httpServer1
lb --- httpServer2
lb --- httpServer3
lb --- httpServer4
httpServer1 --- redisServer
httpServer2 --- redisServer
httpServer3 --- redisServer
httpServer4 --- redisServer
redisServer --- gtest
https://crowcpp.org/master/guides/routes/
We are using nginx so the connection needs to be non SSL
let's make some post and get request to our server via the load balancer !
(Don't forget to use the appropriate port)
If you have issues, try to add -X POST or -X GET in front of curl, but it should ne be necessary.
| Category | Redis | Arguments | Usage |
|---|---|---|---|
| POST | set | set | curl http://localhost:80/set \ -H "Content-Type: application/json" \ -d '{"key":"mykey", "value":"myvalue"}' |
| POST | lpush | lpush | curl http://localhost:80/lpush \ -H "Content-Type: application/json" \ -d '{"key":"mykey", "value":"myvalue"}' |
| POST | rpush | rpush | curl http://localhost:80/rpush \ -H "Content-Type: application/json" \ -d '{"key":"mykey", "value":"myvalue"}' |
| POST | hmset | hmset | curl http://localhost:80/rpush \ -H "Content-Type: application/json" \ -d '{"key":"myhash", "fields_values":{"field1":"value1", "field2":"value2"}}' |
| POST | hmget | hmget | curl http://localhost:80/hmget \ -H "Content-Type: application/json" \ -d '{"key":"myhash", "fields":["field1", "field2"]}' |
| GET | key | key/<string> | curl http://localhost:80/key/key_value |
| GET | get | key/<string> | curl http://localhost:80/get/key_value |
| GET | lpop | lpop/<string> | curl http://localhost:80/lpop/key_value |
| GET | rpop | rpop/<string> | curl http://localhost:80/rpop/key_value |
| GET | llen | llen/<string> | curl http://localhost:80/llen/key_value |
| GET | ping | ping | curl http://localhost:80/ping |
| GET | echo | echo/<string> | curl http://localhost:80/echo/msg |
| GET | flushall | flushall | curl http://localhost:80/flushall |
| GET | info | info | curl http://localhost:80/info |
post request :
curl http://localhost:80/post \
-H "Content-Type: application/json" \
-d '{"key":"mykey", "value":"myvalue"}'get request:
curl http://localhost:80/get/mykeyhttps://github.com/sewenew/redis-plus-plus/blob/master/src/sw/redis%2B%2B/redis.h
https://google.github.io/googletest/ https://github.com/google/googletest/tree/main/googletest/samples