-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
96 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Proxy Schema Test | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
NETWORK: | ||
description: 'Network to run test on' | ||
required: true | ||
default: 'local' | ||
type: choice | ||
options: | ||
- local | ||
- dev | ||
- qa | ||
- test | ||
- main | ||
push: | ||
|
||
|
||
jobs: | ||
api-tests: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: grid-proxy | ||
services: | ||
postgres: | ||
image: postgres | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: tfgrid-graphql | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432:5432 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.21 | ||
|
||
- name: Setting up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Installing all necessary packages | ||
run: pip install -r tests/schema_test/requirments.txt | ||
|
||
- name: Build | ||
run: | | ||
export PATH=/home/runner/go/bin:$PATH | ||
export GIT_COMMIT=$(git rev-list -1 HEAD) | ||
go build -ldflags "-X main.GitCommit=$GIT_COMMIT" cmds/proxy_server/main.go | ||
env: | ||
GO111MODULE: on | ||
|
||
- name: Run tests | ||
run: NETWORK=${{ github.event.inputs.NETWORK }} python3 -m pytest -v ./tests/schema_test/ --html=./tests/schema_test/report.html | ||
|
||
- name: Upload pytest test results | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: schema-pytest-results | ||
path: | | ||
///home/runner/work/tfgrid-sdk-go/tfgrid-sdk-go/grid-proxy/tests/schema_test/report.html | ||
///home/runner/work/tfgrid-sdk-go/tfgrid-sdk-go/grid-proxy/tests/schema_test/assets | ||
if: ${{ always() }} |
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 @@ | ||
pytest==7.3.1 | ||
schemathesis==3.24.3 | ||
pytest-html==4.1.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,18 @@ | ||
import os | ||
import pytest | ||
import schemathesis | ||
from schemathesis.checks import not_a_server_error, status_code_conformance, content_type_conformance, response_schema_conformance, response_headers_conformance | ||
|
||
network = os.environ['NETWORK'] | ||
url = 'http://localhost:8080' | ||
if network == 'dev': | ||
url = 'https://gridproxy.dev.grid.tf' | ||
|
||
schema = schemathesis.from_path("docs/swagger.json", base_url = url) | ||
|
||
|
||
@pytest.mark.parametrize("check", [not_a_server_error, status_code_conformance, content_type_conformance, response_schema_conformance, response_headers_conformance]) | ||
@schema.parametrize() | ||
def test_api(case, check): | ||
response = case.call() | ||
case.validate_response(response, checks=(check,)) |