generated from nyu-devops/project-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from CSCI-GA-2820-FA23-001/47_support_bdd_ci
47 support bdd ci
- Loading branch information
Showing
12 changed files
with
514 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,60 @@ | ||
// cSpell: disable | ||
{ | ||
"name": "NYU Project", | ||
"dockerComposeFile": "docker-compose.yml", | ||
"service": "app", | ||
"workspaceFolder": "/app", | ||
"remoteUser": "vscode", | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"[python]": { | ||
"editor.defaultFormatter": "ms-python.black-formatter", | ||
"editor.formatOnSave": true | ||
}, | ||
"markdown-preview-github-styles.colorTheme": "light", | ||
"files.exclude": { | ||
"**/.git": true, | ||
"**/.DS_Store": true, | ||
"**/*.pyc": true, | ||
"**/__pycache__": true, | ||
"**/.pytest_cache": true | ||
} | ||
}, | ||
"extensions": [ | ||
"VisualStudioExptTeam.vscodeintellicode", | ||
"ms-python.python", | ||
"ms-python.pylint", | ||
"ms-python.vscode-pylance", | ||
"ms-python.black-formatter", | ||
// "alexkrechik.cucumberautocomplete", | ||
"cstrap.flask-snippets", | ||
"yzhang.markdown-all-in-one", | ||
"bierner.github-markdown-preview", | ||
"hnw.vscode-auto-open-markdown-preview", | ||
"DavidAnson.vscode-markdownlint", | ||
"donjayamanne.githistory", | ||
"GitHub.vscode-pull-request-github", | ||
"hbenl.vscode-test-explorer", | ||
"LittleFoxTeam.vscode-python-test-adapter", | ||
"njpwerner.autodocstring", | ||
"redhat.vscode-yaml", | ||
"wholroyd.jinja", | ||
"Zignd.html-css-class-completion", | ||
"bbenoist.vagrant", | ||
"rangav.vscode-thunder-client", | ||
"ms-azuretools.vscode-docker", | ||
"ms-kubernetes-tools.vscode-kubernetes-tools", | ||
"streetsidesoftware.code-spell-checker" | ||
] | ||
} | ||
}, | ||
//"postCreateCommand": "", | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": 8080, | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": {}, | ||
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {} | ||
} | ||
} | ||
"name": "NYU Project", | ||
"dockerComposeFile": "docker-compose.yml", | ||
"service": "app", | ||
"workspaceFolder": "/app", | ||
"remoteUser": "vscode", | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"[python]": { | ||
"editor.defaultFormatter": "ms-python.black-formatter", | ||
"editor.formatOnSave": true | ||
}, | ||
"markdown-preview-github-styles.colorTheme": "light", | ||
"files.exclude": { | ||
"**/.git": true, | ||
"**/.DS_Store": true, | ||
"**/*.pyc": true, | ||
"**/__pycache__": true, | ||
"**/.pytest_cache": true | ||
} | ||
}, | ||
"extensions": [ | ||
"VisualStudioExptTeam.vscodeintellicode", | ||
"ms-python.python", | ||
"ms-python.pylint", | ||
"ms-python.vscode-pylance", | ||
"ms-python.black-formatter", | ||
"alexkrechik.cucumberautocomplete", | ||
"cstrap.flask-snippets", | ||
"yzhang.markdown-all-in-one", | ||
"bierner.github-markdown-preview", | ||
"hnw.vscode-auto-open-markdown-preview", | ||
"DavidAnson.vscode-markdownlint", | ||
"donjayamanne.githistory", | ||
"GitHub.vscode-pull-request-github", | ||
"hbenl.vscode-test-explorer", | ||
"LittleFoxTeam.vscode-python-test-adapter", | ||
"njpwerner.autodocstring", | ||
"redhat.vscode-yaml", | ||
"wholroyd.jinja", | ||
"Zignd.html-css-class-completion", | ||
"bbenoist.vagrant", | ||
"rangav.vscode-thunder-client", | ||
"ms-azuretools.vscode-docker", | ||
"ms-kubernetes-tools.vscode-kubernetes-tools", | ||
"streetsidesoftware.code-spell-checker" | ||
] | ||
} | ||
}, | ||
//"postCreateCommand": "", | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": 8080, | ||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": {}, | ||
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
PORT=8000 | ||
FLASK_APP=service:app | ||
WAIT_SECONDS=5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: BDD Tests | ||
on: | ||
push: | ||
branches: | ||
- master | ||
paths-ignore: | ||
- "README.md" | ||
- ".vscode/**" | ||
- "**.md" | ||
pull_request: | ||
branches: | ||
- master | ||
paths-ignore: | ||
- "README.md" | ||
- ".vscode/**" | ||
- "**.md" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
container: rofrano/pipeline-selenium:latest | ||
|
||
services: | ||
postgres: | ||
image: postgres | ||
env: | ||
POSTGRES_PASSWORD: pgs3cr3t | ||
POSTGRES_DB: testdb | ||
ports: | ||
- 5432:5432 | ||
# Set health checks to wait until postgres has started | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install OS dependencies | ||
run: | | ||
apt-get update | ||
apt-get install -y gcc libpq-dev | ||
- name: Install Python packages | ||
run: | | ||
python -m pip install --upgrade pip wheel | ||
pip install -r requirements.txt | ||
- name: Run the service locally | ||
run: | | ||
echo "\n*** STARTING APPLICATION ***\n" | ||
gunicorn --log-level=critical --bind=0.0.0.0:8000 service:app & | ||
sleep 5 | ||
curl -i http://localhost:8000/health | ||
echo "\n*** SERVER IS RUNNING ***" | ||
env: | ||
DATABASE_URI: "postgresql://postgres:pgs3cr3t@postgres:5432/testdb" | ||
|
||
- name: Run Integration Tests | ||
run: behave |
5 changes: 3 additions & 2 deletions
5
.github/workflows/workflow.yml → .github/workflows/tdd-tests.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" | ||
Environment for Behave Testing | ||
""" | ||
from os import getenv | ||
from selenium import webdriver | ||
|
||
WAIT_SECONDS = int(getenv("WAIT_SECONDS", "60")) | ||
BASE_URL = getenv("BASE_URL", "http://localhost:8000") | ||
DRIVER = getenv("DRIVER", "chrome").lower() | ||
|
||
|
||
def before_all(context): | ||
"""Executed once before all tests""" | ||
context.base_url = BASE_URL | ||
context.wait_seconds = WAIT_SECONDS | ||
# Select either Chrome or Firefox | ||
if "firefox" in DRIVER: | ||
context.driver = get_firefox() | ||
else: | ||
context.driver = get_chrome() | ||
context.driver.implicitly_wait(context.wait_seconds) | ||
context.config.setup_logging() | ||
|
||
|
||
def after_all(context): | ||
"""Executed after all tests""" | ||
context.driver.quit() | ||
|
||
|
||
###################################################################### | ||
# Utility functions to create web drivers | ||
###################################################################### | ||
|
||
|
||
def get_chrome(): | ||
"""Creates a headless Chrome driver""" | ||
options = webdriver.ChromeOptions() | ||
options.add_argument("--no-sandbox") | ||
options.add_argument("--headless") | ||
return webdriver.Chrome(options=options) | ||
|
||
|
||
def get_firefox(): | ||
"""Creates a headless Firefox driver""" | ||
options = webdriver.FirefoxOptions() | ||
options.add_argument("--headless") | ||
return webdriver.Firefox(options=options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
Feature: The recommendation service back-end | ||
As a Product Manager | ||
I need a RESTful catalog service | ||
So that I can keep track of all recommendations | ||
|
||
Background: | ||
Given the following recommendations | ||
|
||
| id | source_item_id | target_item_id | type | weight | status | number_of_likes | | ||
| 1 | 123 | 456 | UP_SELL | 0.5 | VALID | 10 | | ||
| 2 | 789 | 101 | CROSS_SELL | 0.8 | OUT_OF_STOCK | 5 | | ||
| 3 | 222 | 333 | ACCESSORY | 0.2 | DEPRECATED | 2 | | ||
|
||
|
||
Scenario: The server is running | ||
When I visit the "Home Page" | ||
Then I should see "Recommendation Demo RESTful Service" in the title | ||
And I should not see "404 Not Found" | ||
|
||
# Scenario: Create a Pet | ||
# When I visit the "Home Page" | ||
# And I set the "Name" to "Happy" | ||
# And I set the "Category" to "Hippo" | ||
# And I select "False" in the "Available" dropdown | ||
# And I select "Male" in the "Gender" dropdown | ||
# And I set the "Birthday" to "06-16-2022" | ||
# And I press the "Create" button | ||
# Then I should see the message "Success" | ||
# When I copy the "Id" field | ||
# And I press the "Clear" button | ||
# Then the "Id" field should be empty | ||
# And the "Name" field should be empty | ||
# And the "Category" field should be empty | ||
# When I paste the "Id" field | ||
# And I press the "Retrieve" button | ||
# Then I should see the message "Success" | ||
# And I should see "Happy" in the "Name" field | ||
# And I should see "Hippo" in the "Category" field | ||
# And I should see "False" in the "Available" dropdown | ||
# And I should see "Male" in the "Gender" dropdown | ||
# And I should see "2022-06-16" in the "Birthday" field | ||
|
||
# Scenario: List all pets | ||
# When I visit the "Home Page" | ||
# And I press the "Search" button | ||
# Then I should see the message "Success" | ||
# And I should see "fido" in the results | ||
# And I should see "kitty" in the results | ||
# And I should not see "leo" in the results | ||
|
||
# Scenario: Search for dogs | ||
# When I visit the "Home Page" | ||
# And I set the "Category" to "dog" | ||
# And I press the "Search" button | ||
# Then I should see the message "Success" | ||
# And I should see "fido" in the results | ||
# And I should not see "kitty" in the results | ||
# And I should not see "leo" in the results | ||
|
||
# Scenario: Search for available | ||
# When I visit the "Home Page" | ||
# And I select "True" in the "Available" dropdown | ||
# And I press the "Search" button | ||
# Then I should see the message "Success" | ||
# And I should see "fido" in the results | ||
# And I should see "kitty" in the results | ||
# And I should see "sammy" in the results | ||
# And I should not see "leo" in the results | ||
|
||
# Scenario: Update a Pet | ||
# When I visit the "Home Page" | ||
# And I set the "Name" to "fido" | ||
# And I press the "Search" button | ||
# Then I should see the message "Success" | ||
# And I should see "fido" in the "Name" field | ||
# And I should see "dog" in the "Category" field | ||
# When I change "Name" to "Loki" | ||
# And I press the "Update" button | ||
# Then I should see the message "Success" | ||
# When I copy the "Id" field | ||
# And I press the "Clear" button | ||
# And I paste the "Id" field | ||
# And I press the "Retrieve" button | ||
# Then I should see the message "Success" | ||
# And I should see "Loki" in the "Name" field | ||
# When I press the "Clear" button | ||
# And I press the "Search" button | ||
# Then I should see the message "Success" | ||
# And I should see "Loki" in the results | ||
# And I should not see "fido" in the results | ||
|
||
# Scenario: Delete a Pet | ||
# When I visit the "Home Page" | ||
# And I set the "Name" to "sammy" | ||
# And I press the "Search" button | ||
# Then I should see the message "Success" | ||
# And I should see "sammy" in the "Name" field | ||
# And I should see "snake" in the "Category" field | ||
# When I press the "Delete" button | ||
# Then I should see the message "Pet has been Deleted!" |
Oops, something went wrong.