Intro

Unit Test

make test-unit TARGET=emailer
go test -v -short
go test -v -short ./service/emailer/service

Integration Test

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

UAT Test

we can use one of the option below. They are various options for manual testing

BloomRPC UI Client

  1. add ~/go/src to import paths, also add any other paths to shared proto files.

  2. click (+) and import proto file you want to test.

  3. add optional metadata in the JSON format in the Metadata Section. e.g., Authorization Headers etc

gRPC CLI Client

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

Micro CLI

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 '{}'

Micro Web UI

# 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"
}

Micro API Gateway

Start API Gateway

Start API Gateway and run REST Client tests

#  micro --network=local # this start all
micro api --enable_rpc=true

E2E Testing

Assume, you are running all microservices on local k8s cluster with one of the profiles(e2e, production)

E2E tests with tools

# 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" }'

E2E tests via code

MICRO_PROXY_ADDRESS="localhost:8081" \
make test-e2e

Fuzzing

TODO

fuzz testing with fuzzit

Last updated