The auth benchmark is a simple token-based authorizer example to demonstrate how to use an authorization token to allow or deny a request. In this example, the caller named 'user' is allowed to invoke a request if the client-supplied token value is 'allow'. The caller is not allowed to invoke the request if the token value is 'deny'. If the token value is 'unauthorized' or an empty string, the authorizer function returns an HTTP 401 status code. For any other token value, the authorizer returns an HTTP 500 status code. Note that token values are case-sensitive.
The same functionality is implemented in different runtimes, namely Python, NodeJS and golang.
The detailed and general description how to run benchmarks local you can find here. The following steps show it on the auth-python function.
- Build or pull the function images using
make all-images
ormake pull
.
- Start the function with docker-compose
docker-compose -f ./yamls/docker-compose/dc-auth-python.yaml up
- In a new terminal, invoke the interface function with grpcurl.
./tools/bin/grpcurl -plaintext localhost:50000 helloworld.Greeter.SayHello
- Run the invoker
# build the invoker binary cd ../../tools/invoker make invoker # Specify the hostname through "endpoints.json" echo '[ { "hostname": "localhost" } ]' > endpoints.json # Start the invoker with a chosen RPS rate and time ./invoker -port 50000 -dbg -time 10 -rps 1
The detailed and general description on how to run benchmarks on knative clusters you can find here. The following steps show it on the auth-python function.
- Build or pull the function images using
make all-images
ormake pull
. - Start the function with knative
kn service apply -f ./yamls/knative/kn-auth-python.yaml
- Note the URL provided in the output. The part without the
http://
we'll call$URL
. Replace any instance of$URL
in the code below with it.
- In a new terminal, invoke the interface function with test-client.
./test-client --addr $URL:80 --name "Example text for Auth"
- Run the invoker
# build the invoker binary cd ../../tools/invoker make invoker # Specify the hostname through "endpoints.json" echo '[ { "hostname": "$URL" } ]' > endpoints.json # Start the invoker with a chosen RPS rate and time ./invoker -port 80 -dbg -time 10 -rps 1
This Benchmark supports distributed tracing for all runtimes. For the general use see vSwarm docs for tracing locally and with knative.