Skip to content

Commit 1e042fa

Browse files
gladystonfrancafabiowmmrquiduteantonio-amjrccruzagralopes
authored
Utilities stress stability (#146)
* draft 1 * Update * Fixing error related to multiple commissioning executions + enhancing logs * total, readcommissionininfo and discovery plots * added PASE plot and percentiles * Update PoC with support to Utility screen. * Adding support to analytics + enhancing container interface to support detach option. * Added backend service to generate summary for logDisplay * Removed unsued code * Addes URL report in response for performance_summary endpoint * Minor fixes * Fixing util method for the repeat feature of the performance tests * Merge alembic heads * Cast project config * Update method according to merged changes * Make logs directory if it doesn't exist * Add performance-logs to .gitignore * Adding the Log Display web application scripts for install, uninstall, start and stop operations * Adding support to Python Virtual Environment for the LogDisplay app scripts, plus minor changes * Fixing the repeat test feature for regular tests with more than one iteration * Removing configuration option for log folder in the LogDisplay tool for easier UX in the cost of less flexibility * Force the creation of logs/ directory as well for the LogDisplay output folder * Updating scripts and log generation to use environment variables for paths * Changing the container's log output folder for path binded with host * Updating the start script's path of the LogDisplay * Disabling SIGINT trap from the start script so the python script inside receive the Ctrl+C interruption * Adjustments on simulator script + moving matter_qa to outside endpoint + handling stress script location * Fixing lint issues. * Fix lint * fix additional lint issues * lint * fixing migration issues * Removing unnecessary code. * update log display feature. * adjustments --------- Co-authored-by: Fabio Maia <fabio_maia@apple.com> Co-authored-by: Romulo Quidute Filho <rquidute@apple.com> Co-authored-by: Antonio Melo Jr <a_junior@apple.com> Co-authored-by: Carolina Lopes <ccruzagralopes@apple.com>
1 parent 235543d commit 1e042fa

42 files changed

Lines changed: 2792 additions & 65 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ per-file-ignores =
88
test_collections/manual_tests/**/*:E501,W291
99
test_collections/app1_tests/**/*:E501
1010
test_collections/semi_automated_tests/**/*:E501
11+
alembic/versions/**/*:E128,W293,F401

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ test_environment.config
1212
SerialTests.lock
1313
test_db_creation.lock
1414
.sha_information
15-
test_collections/matter/sdk_tests/sdk_checkout
15+
test_collections/matter/sdk_tests/sdk_checkout
16+
performance-logs

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"editor.defaultFormatter": "ms-python.black-formatter", // black
1313
"editor.formatOnSave": true, // black
1414
"editor.codeActionsOnSave": {
15-
"source.organizeImports": true // isort
15+
"source.organizeImports": "explicit"
1616
},
1717
},
1818
// black
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""Adding count on metadata to support Performance Test
2+
3+
Revision ID: 0a251edfd975
4+
Revises: 96ee37627a48
5+
Create Date: 2024-05-16 06:36:51.663230
6+
7+
"""
8+
9+
from alembic import op
10+
import sqlalchemy as sa
11+
12+
13+
# revision identifiers, used by Alembic.
14+
revision = "0a251edfd975"
15+
down_revision = "e2c185af1226"
16+
branch_labels = None
17+
depends_on = None
18+
19+
20+
def upgrade():
21+
# ### commands auto generated by Alembic - please adjust! ###
22+
op.add_column("testcasemetadata", sa.Column("count", sa.Text(), nullable=True))
23+
# ### end Alembic commands ###
24+
25+
26+
def downgrade():
27+
# ### commands auto generated by Alembic - please adjust! ###
28+
op.drop_column("testcasemetadata", "count")
29+
# ### end Alembic commands ###

alembic/versions/96ee37627a48_adding_the_new_column_collection_id.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Create Date: 2023-08-15 14:42:39.893126
66
77
"""
8+
89
import sqlalchemy as sa
910

1011
from alembic import op

alembic/versions/9df8004ad9bb_migrate_python_test_legacy_suite_.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Create Date: 2024-04-24 17:26:26.770729
66
77
"""
8+
89
from alembic import op
910

1011

alembic/versions/e2c185af1226_pics_v2_support.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Create Date: 2024-06-19 11:46:15.158526
66
77
"""
8+
89
from alembic import op
910
import sqlalchemy as sa
1011

app/api/api_v1/endpoints/test_run_executions.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
# limitations under the License.
1515
#
1616
import json
17+
import os
18+
from datetime import datetime
1719
from http import HTTPStatus
1820
from typing import Any, Dict, List, Optional
1921

22+
import requests
2023
from fastapi import APIRouter, BackgroundTasks, Depends, File, HTTPException, UploadFile
2124
from fastapi.encoders import jsonable_encoder
2225
from fastapi.responses import JSONResponse, StreamingResponse
@@ -37,6 +40,10 @@
3740
selected_tests_from_execution,
3841
)
3942
from app.version import version_information
43+
from test_collections.matter.sdk_tests.support.performance_tests.utils import (
44+
create_summary_report,
45+
)
46+
from test_collections.matter.test_environment_config import TestEnvironmentConfigMatter
4047

4148
router = APIRouter()
4249

@@ -479,3 +486,87 @@ def import_test_run_execution(
479486
status_code=HTTPStatus.UNPROCESSABLE_ENTITY,
480487
detail=str(error),
481488
)
489+
490+
491+
date_pattern_out_file = "%Y_%m_%d_%H_%M_%S"
492+
493+
494+
@router.post("/{id}/performance_summary")
495+
def generate_summary_log(
496+
*,
497+
db: Session = Depends(get_db),
498+
id: int,
499+
project_id: int,
500+
) -> JSONResponse:
501+
"""
502+
Imports a test run execution to the the given project_id.
503+
"""
504+
505+
project = crud.project.get(db=db, id=project_id)
506+
507+
if not project:
508+
raise HTTPException(
509+
status_code=HTTPStatus.NOT_FOUND, detail="Project not found"
510+
)
511+
512+
project_config = TestEnvironmentConfigMatter(**project.config)
513+
matter_qa_url = None
514+
LOGS_FOLDER = "/test_collections/logs"
515+
HOST_BACKEND = os.getenv("BACKEND_FILEPATH_ON_HOST") or ""
516+
HOST_OUT_FOLDER = HOST_BACKEND + LOGS_FOLDER
517+
518+
if (
519+
project_config.test_parameters
520+
and "matter_qa_url" in project_config.test_parameters
521+
):
522+
matter_qa_url = project_config.test_parameters["matter_qa_url"]
523+
else:
524+
raise HTTPException(
525+
status_code=HTTPStatus.UNPROCESSABLE_ENTITY,
526+
detail="matter_qa_url must be configured",
527+
)
528+
529+
page = requests.get(f"{matter_qa_url}/home")
530+
if page.status_code is not int(HTTPStatus.OK):
531+
raise HTTPException(
532+
status_code=page.status_code,
533+
detail=(
534+
"The LogDisplay server is not responding.\n"
535+
"Verify if the tool was installed, configured and initiated properly"
536+
),
537+
)
538+
539+
commissioning_method = project_config.dut_config.pairing_mode
540+
541+
test_run_execution = crud.test_run_execution.get(db=db, id=id)
542+
if not test_run_execution:
543+
raise HTTPException(
544+
status_code=HTTPStatus.NOT_FOUND, detail="Test Run Execution not found"
545+
)
546+
547+
log_lines_list = log_utils.convert_execution_log_to_list(
548+
log=test_run_execution.log, json_entries=False
549+
)
550+
551+
timestamp = ""
552+
if test_run_execution.started_at:
553+
timestamp = test_run_execution.started_at.strftime(date_pattern_out_file)
554+
else:
555+
timestamp = datetime.now().strftime(date_pattern_out_file)
556+
557+
tc_name, execution_time_folder = create_summary_report(
558+
timestamp, log_lines_list, commissioning_method
559+
)
560+
561+
target_dir = f"{HOST_OUT_FOLDER}/{execution_time_folder}/{tc_name}"
562+
url_report = f"{matter_qa_url}/home/displayLogFolder?dir_path={target_dir}"
563+
564+
summary_report: dict = {}
565+
summary_report["url"] = url_report
566+
567+
options: dict = {"media_type": "application/json"}
568+
569+
return JSONResponse(
570+
jsonable_encoder(summary_report),
571+
**options,
572+
)

app/models/test_case_metadata.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class TestCaseMetadata(Base):
3131
id: Mapped[int] = mapped_column(primary_key=True, index=True)
3232
public_id: Mapped[str] = mapped_column(nullable=False)
3333

34+
count: Mapped[str] = mapped_column(Text, nullable=True)
35+
3436
title: Mapped[str] = mapped_column(nullable=False)
3537
description: Mapped[str] = mapped_column(Text, nullable=False)
3638
version: Mapped[str] = mapped_column(nullable=False)

app/test_engine/models/test_case.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def __init__(self, test_case_execution: TestCaseExecution):
6262
self.create_test_steps()
6363
self.__state = TestStateEnum.PENDING
6464
self.errors: List[str] = []
65+
self.analytics: dict[str, str] = {} # Move to dictionary
6566

6667
# Make pics a class method as they are mostly needed at class level.
6768
@classmethod

0 commit comments

Comments
 (0)