/sqaaas-api-server

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

SQAaaS OpenAPI server

Overview

API server implementation for the SQA-as-a-Service (SQAaaS) platform.

API First strategy

The SQAaaS API implementation follows an API First strategy, where changes in the specification are subsequently coded.

The OpenAPI specification

The SQAaaS API specification is maintained in a separate repository.

OpenAPI Generator

Whenever the specification changes the code is generated by the OpenAPI Generator project. The SQAaaS API uses Python's Connexion library on top of aiohttp.

The generator does not modify the set of files maintained in the .openapi-generator-ignore.

Requirements

Usage

To run the API server, please execute the following from the root directory:

$ pip3 install .
$ sqaaas_api_server --help
usage: sqaaas_api_server [-h] [-c CONFIG_FILE] [-p PORT] [-d]

SQAaaS API server.

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIG_FILE, --config CONFIG_FILE
                        Main configuration file (default: /etc/sqaaas/sqaaas.ini). For a complete example, please check </usr/local/lib/python3.8/dist-packages/etc/sqaaas.ini.sample>
  -p PORT, --port PORT  Port number to be used when exposing the API server (default: 8080)
  -d, --debug           Set DEBUG log level

In order to run successfully, the SQAaaS API server requires the presence of a general configuration file, by default in /etc/sqaaas/sqaaas.ini. The Python package is distributed with a sample configuration (sqaaas.ini.sample).

Assuming the default port 8080 is used, use Swagger UI by opening your browser to here:

http://localhost:8080/v1/ui/

The SQAaaS OpenAPI definition can be accessed through:

http://localhost:8080/v1/openapi.json

Docker

Different SQAaaS API server versions will be made available as Docker images through Docker Hub site.

The following command will execute the given version of the SQAaaS API server container, having the required files in the my-sqaaas-api-environ folder:

$ docker run -v <my-sqaaas-api-environ>:/etc/sqaaas -t eoscsynergy/sqaaas-api-server:<version>

Development

Deploy in editable mode

Within the root path, execute:

$ pip3 install -e .

Running tests

To launch the integration tests, use pytest:

sudo pip install -r test-requirements.txt
pytest

Building the Docker image

In the root path of the current repository, execute:

$ docker build -t eoscsynergy/sqaaas-api-server:<version> -f docker/Dockerfile .