Skip to content

Commit

Permalink
feat: add semantic versioning (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
LakiG authored Feb 17, 2023
1 parent 395972f commit 433db86
Show file tree
Hide file tree
Showing 24 changed files with 71 additions and 31 deletions.
8 changes: 3 additions & 5 deletions compliance_suite/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def main() -> None:

@main.command(help='Run TES compliance tests against the servers')
@click.option('--server', '-s', help='server URL on which the compliance tests are run. Format - https://<url>/')
@click.option('--version', '-v', help='TES version. Example - "v1.0"')
@click.option('--version', '-v', help='TES version. Example - "1.0.0"')
@click.option('--tag', '-t', multiple=True, help='Tag', default=['All'])
@click.option('--output_path', '-o', help='path to output the JSON report')
@click.option('--serve', default=False, is_flag=True, help='spin up a server')
Expand All @@ -38,8 +38,7 @@ def report(server: str,
Args:
server (str): The server URL on which the compliance suite will be run. Format - https://<url>/
version (str): The compliance suite will be run against this TES version.
Default - Latest version. Example - "v1.0"
version (str): The compliance suite will be run against this TES version. Example - "1.0.0"
tag (List[str]): The list of the tags for which the compliance suite will be run. Default - All
output_path (str): The output path to store the JSON compliance report
serve (bool): If true, runs a local server and displays the JSON report in webview
Expand All @@ -51,8 +50,7 @@ def report(server: str,
raise Exception("No server provided. Please provide a server URL.")

if version is None:
logger.info("No version provided. Latest version is used as default value.")
version = "v1.0" # Hardcode the latest version here. TODO - Future versions
raise Exception("No version provided. Please provide a version.")

tag = [val.lower() for val in tag] # Convert the tags into lowercase to allow case-insensitive tags
logger.info(f"Input tag is - {tag}")
Expand Down
7 changes: 0 additions & 7 deletions compliance_suite/constants/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@
TesTaskMinimal,
)

# YAML Constants

VERSION_INFO = {
'v1.0': 'v1',
'v1.1': 'v1'
}

# Utility Constants

LOGGING_LEVEL = {
Expand Down
3 changes: 3 additions & 0 deletions compliance_suite/functions/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def send_request(
for key in uri_params.keys():
endpoint = endpoint.replace(f"{{{key}}}", uri_params[key])

version = "v" + version.split(".")[0] # Convert SemVer into Major API version
base_url: str = str(server) + version + endpoint
request_headers: dict = REQUEST_HEADERS[service]
response = None
Expand Down Expand Up @@ -137,7 +138,9 @@ def poll_request(

for key in uri_params.keys():
endpoint = endpoint.replace(f"{{{key}}}", uri_params[key])

self.check_cancel = check_cancel_val
version = "v" + version.split(".")[0] # Convert SemVer into Major API version
base_url: str = str(server) + version + endpoint
request_headers: dict = REQUEST_HEADERS[service]

Expand Down
7 changes: 2 additions & 5 deletions compliance_suite/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
from pydantic import ValidationError
from requests.models import Response

from compliance_suite.constants.constants import (
ENDPOINT_TO_MODEL,
VERSION_INFO,
)
from compliance_suite.constants.constants import ENDPOINT_TO_MODEL
from compliance_suite.exceptions.compliance_exception import (
JobValidationException,
TestFailureException
Expand All @@ -43,7 +40,7 @@ def __init__(self, service: str, server: str, version: str):

self.service: str = service
self.server: str = server
self.version: str = VERSION_INFO[version]
self.version: str = version
self.job_data: Any = None
self.auxiliary_space: Dict = {} # Dictionary to store the sub-job results
self.report_test: Any = None # Test object to store the result
Expand Down
20 changes: 10 additions & 10 deletions docs/utility.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ env_vars:

The following command line parameters can be run:

| Parameter | Short Name | Required |Description |
|---------------|------------|----------|---|
| --server | -s | Yes |The server URL on which the compliance suite will be run. Format - `https://<url>/`|
| --version | -v | No |The compliance suite will be run against this TES version. Default - Latest version. Example - `"v1.0"`|
| --tag | -t | No |Tag for which the compliance suite will be run. It is case insensitive. Default - `"all"` |
| --output_path | -o | No |The output path to store the JSON compliance report |
| --serve | NA | No |If set, runs a local server and displays the JSON report in HTML web page |
| --port | NA | No |The port at which the local server is run. Default - 15800 |
| --uptime | -u | No |The local server duration in seconds. Default - 3600 seconds |
| Parameter | Short Name | Required | Description |
|---------------|------------|----------|-------------------------------------------------------------------------------------------------|
| --server | -s | Yes | The server URL on which the compliance suite will be run. Format - `https://<url>/` |
| --version | -v | Yes | The compliance suite will be run against this TES version. Format - SemVer. Example - `"1.0.0"` |
| --tag | -t | No | Tag for which the compliance suite will be run. It is case insensitive. Default - `"all"` |
| --output_path | -o | No | The output path to store the JSON compliance report |
| --serve | NA | No | If set, runs a local server and displays the JSON report in HTML web page |
| --port | NA | No | The port at which the local server is run. Default - 15800 |
| --uptime | -u | No | The local server duration in seconds. Default - 3600 seconds |

Multiple tags can be set by providing multiple `--tag` or `-t` parameter.
```base
Expand All @@ -87,7 +87,7 @@ tes-compliance-suite report --server "https://test.com/" --tag "cancel task" --t
1. Some examples for command line are:
```base
tes-compliance-suite report --server "https://test.com/" --tag "all"
tes-compliance-suite report --server "https://test.com/" --version "v1.0" --tag "all" --output_path "path/to/store" --serve --port 9090 --uptime 1000
tes-compliance-suite report --server "https://test.com/" --version "1.0.0" --tag "all" --output_path "path/to/store" --serve --port 9090 --uptime 1000
```

2. If the HOME python version is different than 3.8, then absolute path with reference to 3.8 should be used.
Expand Down
2 changes: 2 additions & 0 deletions tests/cancel_task.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Cancel Tes Task Job
description: Job to cancel a TES Task
service: TES
versions:
- 1.0.0
tags:
- logical
- cancel task
Expand Down
2 changes: 2 additions & 0 deletions tests/cancel_task_functional.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Cancel Tes Task Job
description: Job to cancel a TES Task
service: TES
versions:
- 1.0.0
tags:
- functional
- cancel task
Expand Down
2 changes: 2 additions & 0 deletions tests/create_task.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Create Tes Task Job
description: Job to create a new TES Task
service: TES
versions:
- 1.0.0
tags:
- logical
- create task
Expand Down
2 changes: 2 additions & 0 deletions tests/create_task_functional.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Create Tes Task Functional Job
description: Job to create a new TES Task and test functionality
service: TES
versions:
- 1.0.0
tags:
- functional
- create task
Expand Down
2 changes: 2 additions & 0 deletions tests/get_task_basic.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Get Basic Task Job
description: Job to retrieve the Basic view of TES Task
service: TES
versions:
- 1.0.0
tags:
- logical
- get task
Expand Down
2 changes: 2 additions & 0 deletions tests/get_task_full.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Get Full Task Job
description: Job to retrieve the Full view of TES Task
service: TES
versions:
- 1.0.0
tags:
- logical
- get task
Expand Down
2 changes: 2 additions & 0 deletions tests/get_task_minimal.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Get Minimal Task Job
description: Job to retrieve the Minimal view of TES Task
service: TES
versions:
- 1.0.0
tags:
- logical
- get task
Expand Down
2 changes: 2 additions & 0 deletions tests/list_tasks_basic.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: List Basic Tasks Job
description: Job to retrieve the list of Basic view of TES tasks
service: TES
versions:
- 1.0.0
tags:
- logical
- list tasks
Expand Down
2 changes: 2 additions & 0 deletions tests/list_tasks_full.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: List Full Tasks Job
description: Job to retrieve the list of Full view of TES tasks
service: TES
versions:
- 1.0.0
tags:
- logical
- list tasks
Expand Down
2 changes: 2 additions & 0 deletions tests/list_tasks_minimal.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: List Minimal Tasks Job
description: Job to retrieve the list of Minimal view of TES tasks
service: TES
versions:
- 1.0.0
tags:
- logical
- list tasks
Expand Down
2 changes: 2 additions & 0 deletions tests/service_info.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Service Info Job
description: Job to retrieve the service info
service: TES
versions:
- 1.0.0
tags:
- logical
- service info
Expand Down
2 changes: 2 additions & 0 deletions tests/template/test_template.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: <Job Name>
description: <Job Description> # Optional
service: <GA4GH Service Name> # enum - [TES]
versions:
- <Version>
tags:
- <Tag Name> # Logical - No Polling needed, Functional - Polling needed. Always add 3 tags - Individual tag based on test name, TES endpoint tag and "All" tag
jobs:
Expand Down
8 changes: 8 additions & 0 deletions tests/template/test_template_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
"TES"
]
},
"versions": {
"type": "array",
"description": "The list of API versions against which the test file can be run",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"description": "The list of tags which define the test file. Example. Logical - No Polling needed, Functional - Polling needed. Always add 3 tags - Individual tag based on test name, TES endpoint tag and All tag",
Expand Down Expand Up @@ -123,6 +130,7 @@
"required": [
"name",
"service",
"versions",
"tags",
"jobs"
]
Expand Down
3 changes: 2 additions & 1 deletion unittests/data/run_job_tests/fail_service_info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Service Info Job
description: Job to retrieve the service info
service: TES
#server: https://invalid-url
versions:
- 1.0.0
tags:
- logical
- service info
Expand Down
2 changes: 2 additions & 0 deletions unittests/data/run_job_tests/invalid_yaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Invalid YAML
name: Service Info Job
description: Job to retrieve the service info
service: TES
versions:
- 1.0.0
tags:
- logical
- service info
Expand Down
2 changes: 2 additions & 0 deletions unittests/data/run_job_tests/skip_01.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Service Info Job
description: Job to retrieve the service info
service: TES
versions:
- 1.0.0
tags:
- logical
jobs:
Expand Down
2 changes: 2 additions & 0 deletions unittests/data/run_job_tests/success_01.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Service Info Job
description: Job to retrieve the service info
service: TES
versions:
- 1.0.0
tags:
- logical
- service info
Expand Down
2 changes: 2 additions & 0 deletions unittests/data/tests/wrong_schema_yaml.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
description: Job to retrieve the service info
service: TES
versions:
- 1.0.0
tags:
- logical
- service info
Expand Down
14 changes: 11 additions & 3 deletions unittests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ def test_report_no_server(self):
result = runner.invoke(report, [])
assert result.exit_code == 1

def test_report_no_version(self):
""" asserts if the application raises Exception if no server is provided"""

runner = CliRunner()
result = runner.invoke(report, ['--server', 'https://test.com/'])
assert result.exit_code == 1

@patch.object(JobRunner, "generate_report")
@patch.object(JobRunner, "run_jobs")
def test_report_no_tag(self, mock_run_jobs, mock_generate_reports):
Expand All @@ -42,7 +49,7 @@ def test_report_no_tag(self, mock_run_jobs, mock_generate_reports):
mock_run_jobs.return_value = {}
mock_generate_reports.return_value = '{"test": "test"}'
runner = CliRunner()
result = runner.invoke(report, ['--server', 'https://test.com/'])
result = runner.invoke(report, ['--server', 'https://test.com/', '--version', '1.0.0'])
assert result.exit_code == 0

@patch.object(ReportServer, 'serve_thread')
Expand All @@ -56,6 +63,7 @@ def test_report(self, mock_run_jobs, mock_generate_reports, mock_report_server):
mock_generate_reports.return_value = '{"test": "test"}'
mock_report_server.return_value = MagicMock()
runner = CliRunner()
result = runner.invoke(report, ['--server', 'https://test.com/', '--tag', 'All', '--output_path',
"path/to/output", '--serve', '--port', 9090, '--uptime', 1000])
result = runner.invoke(report, ['--server', 'https://test.com/', '--version', '1.0.0', '--tag', 'All',
'--output_path', "path/to/output", '--serve', '--port', 9090,
'--uptime', 1000])
assert result.exit_code == 0

0 comments on commit 433db86

Please sign in to comment.