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 mkit.service.greeter.Greeter/Hello
test with gRPC clients such as Micro CLI, BloomRPC or grpcurl
micro list services
micro get service mkit.service.account
micro get service mkit.service.emailer
micro call mkit.service.account UserService.Create \
'{"username": "sumo", "firstName": "sumo", "lastName": "demo", "email": "sumo@demo.com"}'
micro call mkit.service.account UserService.Create \
'{"username": "sumo1", "firstName": "sumo1", "lastName": "demo1", "email": "sumo1@demo.com"}'
micro call mkit.service.account UserService.List '{}'
micro call mkit.service.account UserService.List '{ "limit": 10, "page": 1}'
micro call mkit.service.account UserService.Get '{"id": "UserIdFromList"}'
micro call mkit.service.account UserService.Exist '{"username": "sumo", "email": "sumo@demo.com"}'
micro call mkit.service.account UserService.Update \
'{"id": "UserIdFromGet", "firstName": "sumoto222","email": "sumo222@demo.com"}'
micro call mkit.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 mkit.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": "sumo@demo.com"
}
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 mkit.service.greeter.GreeterService/Hello
# with Micro CLI
MICRO_PROXY_ADDRESS=localhost:8081 micro list services
MICRO_PROXY_ADDRESS=localhost:8081 micro call mkit.service.greeter GreeterService.Hello '{"name": "John"}'
MICRO_PROXY_ADDRESS=localhost:8081 micro call --metadata trans-id=1234 mkit.service.greeter GreeterService.Hello '{"name": "John"}'
MICRO_PROXY_ADDRESS=localhost:8081 micro call mkit.service.account UserService.List '{}'
MICRO_PROXY_ADDRESS=localhost:8081 micro health mkit.service.greeter
MICRO_PROXY_ADDRESS=localhost:8081 micro publish mkit.service.emailer '{ "to" : "sumo@demo.com", "from": "demo@sumo.com", "subject": "sub", "body": "mybody" }'
MICRO_PROXY_ADDRESS="localhost:8081" \
make test-e2e
TODO
fuzz testing with fuzzit