This repository has been archived by the owner on Sep 1, 2024. It is now read-only.
-
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.
Merge branch 'main' of https://github.com/att/qujata into api_prefix
# Conflicts: # portal/mock-server/src/router.ts # portal/src/setupProxy.js
- Loading branch information
Showing
158 changed files
with
2,810 additions
and
674 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,40 @@ | ||
name: Build and Deploy to GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build Docker image | ||
run: docker build ./portal --file ./portal/Dockerfile --tag my-website-image | ||
|
||
- name: Run Docker container | ||
run: | | ||
docker run --name my-website-container -d my-website-image | ||
# Wait a few seconds to ensure the web server inside the container is fully up and running | ||
sleep 10 | ||
- name: Copy static content from Docker container | ||
run: | | ||
mkdir -p static-content | ||
docker cp my-website-container:/usr/share/nginx/html/qujata ./static-content | ||
- name: Stop and remove Docker container | ||
run: | | ||
docker stop my-website-container | ||
docker rm my-website-container | ||
- name: Deploy to GitHub Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./static-content/qujata |
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
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
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 |
---|---|---|
@@ -1,24 +1,57 @@ | ||
import logging | ||
|
||
from flask import current_app | ||
from src.models.test_run_metric import TestRunMetric | ||
from src.utils.metrics_collector import MetricsCollector | ||
import logging | ||
from src.enums.metric import Metric | ||
import pytz | ||
from dateutil import parser | ||
|
||
|
||
def create(test_run, client_metrics, server_metrics, requests_size, start_time, end_time): | ||
__save_resources_metrics(Metric.CLIENT_AVERAGE_CPU, Metric.CLIENT_AVERAGE_MEMORY, client_metrics, test_run) | ||
__save_resources_metrics(Metric.SERVER_AVERAGE_CPU, Metric.SERVER_AVERAGE_MEMORY, server_metrics, test_run) | ||
__save_throughput_metrics(Metric.MESSAGES_THROUGHPUT_PER_SECOND, Metric.BYTES_THROUGHPUT_PER_SECOND, start_time, | ||
end_time, requests_size, test_run) | ||
|
||
|
||
def __save_resources_metrics(cpu_metric_name, memory_metric_name, metrics, test_run): | ||
cpu, memory = __calculate_average(metrics, test_run.start_time) | ||
__save_metric_to_db(test_run, cpu_metric_name, cpu) | ||
__save_metric_to_db(test_run, memory_metric_name, memory) | ||
|
||
|
||
def __save_throughput_metrics(requests_metric_name, bytes_metric_name, start_time, end_time, requests_size, test_run): | ||
requests_throughput, bytes_throughput = __calculate_throughput(test_run.iterations, start_time, end_time, requests_size) | ||
__save_metric_to_db(test_run, requests_metric_name, requests_throughput) | ||
__save_metric_to_db(test_run, bytes_metric_name, bytes_throughput) | ||
|
||
|
||
def __save_metric_to_db(test_run, metric_name, metric_value): | ||
test_run_metric = TestRunMetric( | ||
test_run_id=test_run.id, | ||
metric_name=metric_name, | ||
value=metric_value | ||
) | ||
current_app.database_manager.create(test_run_metric) | ||
|
||
|
||
def __calculate_average(metrics, start_time): | ||
cpu, memory = 0, 0 | ||
counter = 0 | ||
for ts, value in metrics.items(): | ||
if parser.parse(ts) >= start_time.astimezone(pytz.UTC): | ||
cpu += value["cpu"] | ||
memory += value["memory"] | ||
counter += 1 | ||
|
||
if counter == 0: | ||
return 0, 0 | ||
return round(cpu/counter, 2), round(memory/counter, 0) | ||
|
||
|
||
def __calculate_throughput(iterations, start_time, end_time, requests_size): | ||
seconds = (end_time - start_time).total_seconds() | ||
request_throughput = 0 if seconds == 0 else iterations / seconds | ||
bytes_throughput = 0 if seconds == 0 or requests_size is None else int(requests_size) / seconds | ||
return round(request_throughput, 0), round(bytes_throughput, 0) | ||
|
||
client_collector = MetricsCollector("qujata-curl") | ||
server_collector = MetricsCollector("qujata-nginx") | ||
|
||
# TODO: add lock validation | ||
def start_collecting(): | ||
client_collector.start() | ||
server_collector.start() | ||
|
||
def stop_collecting(): | ||
client_collector.stop() | ||
server_collector.stop() | ||
# print collectors results | ||
logging.info(client_collector.to_pretty_table()) | ||
logging.info(server_collector.to_pretty_table()) | ||
|
||
def get_metrics(): | ||
client_data = client_collector.get_data() | ||
server_data = server_collector.get_data() | ||
return client_data, server_data |
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
Oops, something went wrong.