README ¶
maestro-e2e
e2e testing for maestro project
Prerequisites
Get Started
You have two options to run the e2e testing:
- Using existing Kubernetes cluster
For example, you can create a KinD cluster using configuration file kind-config.yaml
:
kind create cluster --config e2e/kind-config.yaml
Then, run the testing with the following command:
REAL_CLUSTER=true go test ./e2e
- Creating new KinD cluster for testing
go test ./e2e
Note: By default, the cluster and testing resources will not be deleted after the testing. If you want to delete them after the testing, you can set the environment variable CLEAN_ENV
to true
:
CLEAN_ENV=true go test ./e2e
- You can easily skip specific tests based on labels using the following command:
go test ./e2e -args --skip-labels="type=rest"
To skip GRPC tests, use the label type=grpc
:
go test ./e2e -args --skip-labels="type=grpc"
To skip tests for the manifest (cloudevent) API, use the label res=manifest
:
go test ./e2e -args --skip-labels="res=manifest"
Note: you can't skip consumer tests, as they are required for the other tests to run.
By utilizing these labels, you can easily customize your testing suite to exclude specific test types as needed.
Manual Testing
To streamline the process of setting up the testing environment, you can simply follow these steps.
- Clone the repository:
git clone git@github.com:morvencao/maestro-e2e.git
cd maestro-e2e
- Set up the environment by deploying Maestro and Work-Agent into a KinD cluster:
go test -v ./env-setup
The output should resemble this:
# go test -v ./env-setup
database deployment availability: 100.00%
database table created: Consumers
database table created: Resources
maestro deployment availability: 100.00%
consumer created: f7384ef8-37bf-4cb2-8682-9b2f00b6f457
consumer retrieved: f7384ef8-37bf-4cb2-8682-9b2f00b6f457
work-agent deployment availability: 100.00%
testing: warning: no tests to run
PASS
ok github.com/morvencao/maestro-e2e/env-setup 94.504s [no tests to run]
- You can then access the Maestro API server REST endpoint at http://localhost:31330 and the GRPC endpoint at
localhost:31320
. The consumer ID is obtained from the output of the previous step.
CONSUMER_ID="f7384ef8-37bf-4cb2-8682-9b2f00b6f457"
- To create, retrieve, and update a resource for testing, utilize the following commands:
# create resource
curl -X POST localhost:31330/v1/consumers/$CONSUMER_ID/resources -H "Content-Type: application/json" --data-binary @examples/deployment.json
{
"id": "11ddef7f-2816-4779-a25a-496660005cff",
"consumerId": "f7384ef8-37bf-4cb2-8682-9b2f00b6f457",
"generationId": "1",
"object": {
"apiVersion": "apps/v1",
"kind": "Deployment",
...
},
"status": null
}
# retrieve resource
RESOURCE_ID="11ddef7f-2816-4779-a25a-496660005cff"
curl localhost:31330/v1/resources/$RESOURCE_ID
# update resource
curl -X PUT localhost:31330/v1/resources/$RESOURCE_ID -H "Content-Type: application/json" --data-binary @examples/deployment.v2.json