TestCtrl, written and pronounced "test control" in a Kubernetes fashion, provides an interface for scheduling and running benchmarks on Kubernetes.
The TestCtrl project is composed of three major components:
The server which implements two gRPC services: TestSessions and
google.longrunning.Operations. These services process incoming user
requests and status updates for the tests, respectively.
A store is created with information about test sessions. It contains the configuration for the tests components. By design, TestCtrl knows nothing about the tests themselves. TestCtrl stores their raw config, some metadata and the current status of the test sessions.
One controller is created which operates a work queue to limit the number of test sessions in progress. It spawns executors that process one test session at a time, provisioning and monitoring resources with Kubernetes. It continually updates the store with the status of the test.
To run benchmarks, a user calls the TestSessions service with the tests
they would like to run and the container images that these tests require. This
service saves information about the tests in a store, which assigns the test
session a globally unique name. This name is stored in the work queue, awaiting
an available executor. The server replies with the name in a
google.longrunning.Operation protobuf.
When a executor becomes available, it fetches the next session off of the work queue. It provisions the resources and receives updates from the Kubernetes API to monitor the status of the pods that the test requires. It updates the store with significant events and timestamps.
If a user desires to see progress of a test, they make a request with the name to TestCtrl's implementation of the google.longrunning.Operations service. This service queries the store to learn about the status of the test and where to locate test results or error logs upon completion.
To start the service without containers on your local machine, run:
$ go run ./cmd/svc/main.go -alsologtostderr
You can force the service to use a different port with the flag -port:
$ go run ./cmd/svc/main.go -port=4044 -alsologtostderr
When the service is started, it looks for an $APP_ENV environment variable.
If this variable is set to "production", it authenticates with the Kubernetes
API using in-cluster authentication.
Otherwise, the environment is assumed to be "development". In this case, the
service will fail if the $KUBE_CONFIG_FILE does not contain the absolute path
of a kubernetes config for authentication.
To build or contribute to this project, your system must be properly configured
with a version of Go that provides module support. Once navigated to the
testctrl directory, running make deps should install all the dependencies
specified in the go.mod file.
The protobufs are defined in the proto/ directory. Since they do not rely on a build system, they require an installation of the protobuf compiler and the go plugins.
To install the go plugin, navigate outside of the project directory and run:
$ go get -u -v github.com/golang/protobuf/protoc-gen-go
This binary will need to be added to your $PATH in order for a successful
build. It will be available wherever your system places go binaries.
To build the protos, you must navigate into the proto/ directory, then you
can run the ./build.sh script.
In order to inspect the gRPC service and make remote procedure calls on the command line, gRPC releases the grpc_cli. To build from source, navigate to the root of [grpc/grpc] and run:
$ make grpc_cli
The tool will become available as a binary under the bins/opt/ directory. For easy access, it may be helpful to create a shell alias that expands to it.
Finally, before submitting any code to GitHub, run it through gofmt to ensure
that it follows the external Go style guides and golint to point out any lint
errors.