make test-unit TARGET=emailer
go test -v -short
go test -v -short ./service/emailer/service
Run only Integration Tests: Useful for smoke testing canaries in production.
make test-inte TARGET=emailer
make test-inte TARGET=emailer TIMEOUT=300ms
go test -v -run Integration ./service/emailer/service
we can use one of the option below. They are various options for manual testing
- add
~/go/src
to import paths, also add any other paths to shared proto files. - click (+) and import proto file you want to test.
- add optional metadata in the JSON format in the
Metadata Section
. e.g., Authorization Headers etc
grpcurl -plaintext -proto service/greeter/proto/greeter/greeter.proto list
grpcurl -plaintext -proto service/greeter/proto/greeter/greeter.proto describe
grpcurl -plaintext -proto service/greeter/proto/greeter/greeter.proto -d '{"name": "sumo"}' \
localhost:8080 gkit.service.greeter.Greeter/Hello
test with gRPC clients such as Micro CLI, BloomRPC or grpcurl
micro list services
micro get service gkit.service.account
micro get service gkit.service.emailer
micro call gkit.service.account UserService.Create \
'{"username": "sumo", "firstName": "sumo", "lastName": "demo", "email": "[email protected]"}'
micro call gkit.service.account UserService.Create \
'{"username": "sumo1", "firstName": "sumo1", "lastName": "demo1", "email": "[email protected]"}'
micro call gkit.service.account UserService.List '{}'
micro call gkit.service.account UserService.List '{ "limit": 10, "page": 1}'
micro call gkit.service.account UserService.Get '{"id": "UserIdFromList"}'
micro call gkit.service.account UserService.Exist '{"username": "sumo", "email": "[email protected]"}'
micro call gkit.service.account UserService.Update \
'{"id": "UserIdFromGet", "firstName": "sumoto222","email": "[email protected]"}'
micro call gkit.service.account UserService.Delete '{ "id": "UserIdFromGet" }'
For k8s: SSH to gateway container and run micro cli....
kubectl exec -it -c service gateway-service-c86cb8667-g2rmc -- busybox sh
micro call gkit.service.account UserService.List '{}'
# Start Web UI for testing
micro web
open http://localhost:8082
create new user from
Micro Web UI
and see if an email is send
{
"username": "sumo",
"firstName": "sumo",
"lastName": "demo",
"email": "[email protected]"
}
Start API Gateway
Start API Gateway
and run REST Client tests
# micro --network=local # this start all
micro api --enable_rpc=true
Assume, you are running all microservices on local k8s cluster with one of the profiles(
e2e
,production
)
# with `grpcurl`
# micro proxy --protocol=grpc
grpcurl -plaintext -proto service/greeter/proto/greeter/greeter.proto -d '{"name": "sumo"}' localhost:8081 gkit.service.greeter.GreeterService/Hello
# with Micro CLI
MICRO_PROXY_ADDRESS=localhost:8081 micro list services
MICRO_PROXY_ADDRESS=localhost:8081 micro call gkit.service.greeter GreeterService.Hello '{"name": "John"}'
MICRO_PROXY_ADDRESS=localhost:8081 micro call --metadata trans-id=1234 gkit.service.greeter GreeterService.Hello '{"name": "John"}'
MICRO_PROXY_ADDRESS=localhost:8081 micro call gkit.service.account UserService.List '{}'
MICRO_PROXY_ADDRESS=localhost:8081 micro health gkit.service.greeter
MICRO_PROXY_ADDRESS=localhost:8081 micro publish gkit.service.emailer '{ "to" : "[email protected]", "from": "[email protected]", "subject": "sub", "body": "mybody" }'
MICRO_PROXY_ADDRESS="localhost:8081" \
make test-e2e
TODO
fuzz testing with fuzzit