aep-e2e-validator covers the gap of validation of runtime functionality defined in aep.dev.
The code is written Go, leveraging the shared functionality in the aep-lib-go repository.
The code is organized under individual rules, which can be referenced by the AEP that they are validating, along with the semantic behavior (e.g. aep-133-create). Each individual test is located inside of it's own file.
Each test is composed of precondition, setup, test, and teardown function calls and hooks, mapped to a common struct.
The various common exit codes (precondition failed, teardown failed, etc.) are defined in the pkg/validator/exit_codes.go file.
The tester will be available as a binary, and will be invoked as follows:
aep-e2e-validator validate --config <path-to-openapi-spec> --collection <collection-name>All collections can be validated using the --all-collections flag:
aep-e2e-validator validate --config <path-to-openapi-spec> --all-collections--all-collections is mutually exclusive with --collection.
By default all tests will be run for a given collection. This can be overridden using the --tests flag, which will allow the user to specify a list of tests to run.
aep-e2e-validator validate --config <path-to-openapi-spec> --collection <collection-name> --tests aep-133-create,aep-133-duplicate-creation-checkThe validator, by necessity, must operate on the resources that are exposed by an API. Therefore, the validator should be run against a staging or testing API.
The test suite runs in a single pass, due to the prerequisites for the state of the backing data (e.g. to delete a resource, a resource must already exist). If a specific test fails and success is a prerequisite for the next test, execution will stop there.
The e2e test can be run on a per-collection basis. The API payload is generated by examining the openapi schema of the resource, and constructing a payload that only contains the required values.
Some collections are children of a separate collection, requiring a parent resource to be specified in order to be tested properly.
In this case, the user specifies a parent resource directly:
aep-e2e-validator validate --config "http://localhost:8000/openapi.json" --collection books --parent "shelves/horror"Many of the tests require changes to the backend to run. For these tests, the preconditions of the test (e.g. a resource doesn't exist) will be verified before the test is run. If the precondition is not met, the test will fail with exit code 2 (precondition not met).
At the end of the test, the mutations applied on the collection will be attempted to be reversed (e.g. if a resource was created, it will be deleted). If that is not possible, the test fails with exit code 3 (teardown failed).
- Test failed.
- Precondition not met.
- Teardown failed.
- Setup failed
To start with, the following tests will be created:
- aep-132-list-resources-limit-1: Attempt to list resources with a limit of 1.
- aep-132-list-resources-page-token: Verify a list request that does not
- aep-133-create: Create a resource and verify it was created.
- aep-133-duplicate-creation-check: Attempt to create a resource with the same ID twice, and verify it fails. enumerate the full list returns a page token, and the page token can be used to submit a subsequent request to list the rest of the resources.
- aep-134-update-resource: Update a resource and verify it was updated.
- aep-135-delete-resource: Delete a resource and verify it was deleted.
- aep-135-delete-nonexistent-resource: Attempt to delete a non-existent resource and verify it returns 404 not found.
When running the test suite over and over again, improper cleanup may result in garbage being collected in the collection-under-test.
To avoid the friction with having to clean up the collection manually, a global setup and teardown will be run once before and after the test suite is run.
The global setup and teardown would include, but not be limited to:
- List, then delete all resources in the collection.