# Guide for CQA Test Application
### 0. Requirements
* Recommend : Linux, MAC OS
* python3.x
* flask
* flask_restful
* flask_swagger_ui
### 1. Install & Run through Python code
* Download 'CQA Test App' codes by git clone
* $git clone https://git.linecorp.com/Cloud-QA/cqa-test-app.git
* Install requirements library
* $pip install -r requirements.txt
* Run CQA Test App with python
* $python run_cqa_test_app.py
### 2. Run through Docker image
* Install & Setup docker env
* Reference : https://wiki.linecorp.com/pages/viewpage.action?pageId=3307884383#TechnicalReviewDocker&K8S-DockerInstall
* Docker login to Verda Container Registry
```
$ docker login vcr.linecorp.com
Username: vcr-vrdqa
Password:
WARNING! Your password will be stored unencrypted in /home1/irteamsu/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
```
* Pull 'CQA Test App' image from Verda Container Registry
* CQA Test App Image Url : vcr.linecorp.com/vrdqa/cqa-test-app:latest
```
$ docker pull vcr.linecorp.com/vrdqa/cqa-test-app:latest
latest: Pulling from vrdqa/cqa-test-app
446f83f14b23: Already exists
1d76aadd217c: Already exists
82772770002a: Already exists
08ce07491246: Already exists
0a1d9c26dd72: Pull complete
4d1a799d8f8f: Pull complete
1603f27e9756: Pull complete
Digest: sha256:5ea4b8598aa3343f261f4942bb057fb1252b354cbfc2ee989904a174d9e5218b
Status: Downloaded newer image for vcr.linecorp.com/vrdqa/cqa-test-app:latest
vcr.linecorp.com/vrdqa/cqa-test-app:latest
```
* Run 'CQA Test App' image
* CQA Test App use port 10345, 10346, so need to port option with docker run.
```
$ docker run -d --name cqa-test-app -p 10345:10345 -p 10346:10346 vcr.linecorp.com/vrdqa/cqa-test-app
$ docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
24c0772845e1 vcr.linecorp.com/vrdqa/cqa-test-app "python3 run_cqa_tes…" About a minute ago Up About a minute 0.0.0.0:10345-10346->10345-10346/tcp cqa-test-app
$ curl localhost:10345/test
{"client_ip":"172.17.0.1","code":200,"host":"localhost:10345","host_ip":"172.17.0.2","host_name":"24c0772845e1","method":"GET","msg":"Test OK","path":"/test","version":"v1.0.0"}
```
### 3. Run CQA Test App through AppRunner
* AppRunner Guide : https://verda-doc.linecorp.com/compute/apprunner/overview/
* Create App by CQA Test App's ImageUrl or Repository
* ImageUrl : vcr.linecorp.com/vrdqa/cqa-test-app:latest

* Repository : Cloud-QA/cqa-test-app

* Need to set "Container Port" is '10345'

### 4. Check "CQA Test App" Running
* After run "CQA Test App", Access 'Swagger UI'(http://{your server ip}:10345/swagger) for check testing CQA Test App API

### 5. Etc
#### About Log file
* CQA Test App records Server 'API method, path, code, client, host, and msg' information as logfile.
* log file path : {cqa-test-app path}/cqa-test-app.log
* log format : "[timestamp] [loglevel] app_version=, request_host=, http_method=, request_path=, response_status=, client_ip=, host_ip=, host_name, messsage="
```
[2024-12-11 08:45:07,491] [INFO] app_version=v1.0.0, request_host=127.0.0.1:10345, http_method=GET, request_path=/test, response_status=200, client_ip=127.0.0.1, host_ip=172.24.193.193, host_name=vqa-test-node-00044-deployment-5c6c4999f7-94m4v, message=Test OK
```
* You can show log file by 'File Explorer' UI
* Access File Explorer : http://{your server ip}:10345/explorer/cqa-test-app.log
