Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/abiydv/fastly-bdd-tests
BDD Testing example for CDN(Fastly) using Python Behave
https://github.com/abiydv/fastly-bdd-tests
bdd-tests behave-examples fastly fastly-api fastly-service python-behave terraform-fastly terraform-modules
Last synced: about 1 month ago
JSON representation
BDD Testing example for CDN(Fastly) using Python Behave
- Host: GitHub
- URL: https://github.com/abiydv/fastly-bdd-tests
- Owner: abiydv
- Created: 2020-07-05T18:50:47.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-30T17:17:10.000Z (5 months ago)
- Last Synced: 2024-07-30T21:39:12.874Z (5 months ago)
- Topics: bdd-tests, behave-examples, fastly, fastly-api, fastly-service, python-behave, terraform-fastly, terraform-modules
- Language: Gherkin
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Fastly BDD Tests
Fastly offers a huge opportunity of customizing user journeys using the VCL conditionals/flows. More details here - https://abiydv.github.io/posts/fastly-bdd/
## What is where?
* [terraform](terraform) - Terraform configs to create a sample Fastly service
* [vcl](vcl) - The VCL snippets
* [tests](tests) - Feature files and tests implementation## Pre-requisites
* Sign-up for a *limited* free Fastly account
* Terraform 12 or above## Deploy Fastly service and VCLs
1. Export `FASTLY_API_KEY`
```
export FASTLY_API_KEY=aabbccdd_01234
````1. Switch to `terraform` directory, initialize `terraform` and check plan
```
cd terraform
terraform plan
````1. Apply plan to create the Fastly service
```
terraform apply$ Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
````## Run Tests
1. Switch to `tests` directory and create a virtual py environment
```
cd tests
python3 -m venv env
````1. Activate the py virtual environment and install dependencies
```
source env/bin/activate
(env) pip3 install -r requirements.txt
````1. Execute `behave` tests
```
behave
.
.
1 feature passed, 0 failed, 0 skipped
1 scenario passed, 0 failed, 0 skipped
6 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m0.051s
````## Cleanup
1. Export `FASTLY_API_KEY`
```
export FASTLY_API_KEY=aabbccdd_01234
````1. Switch to `terraform` directory
```
cd terraform
terraform plan
````1. Delete the Fastly service
```
terraform destroy$ Apply complete! Resources: 0 added, 0 changed, 3 destroyed.
````## Note
This is a test/proof-of-concept. There are some configs to make it quick, which should be removed before actual implementation.1. `verify=False` flag in `requests.get()` call. File [steps.py](tests/features/steps/steps.py).
This is necessary because the Fastly shared certs will not have the test domain created (fastly-bdd-example.com) as part of this example. Without this flag the call will fail.1. Adding the Fastly shared domain fastly-bdd-example.com.global.prod.fastly.net in [feature files](tests/featues).