Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging main to production branch #14

Merged
merged 8 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ WORKDIR /app
ADD . /app
RUN pip install -r requirements.txt
RUN git clone https://github.com/sdgtt/telemetry.git
RUN cd telemetry && pip install -r requirements.txt && python setup.py install && cd ..
RUN cd telemetry && pip install -r requirements.txt && pip install . && cd ..
RUN chmod u+x ./entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]
EXPOSE 5000
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,35 @@
# constellation
Web UI for testing
Constellation is a landing page to display all of the results of Kuiper Linux testing on hardware.

Requirements on running:

cloned constellation
cloned telemetry
virtual environment of constellation


--> Constellation setup <--
(Recommended: Run to vm)
1. Create owner folder or go to your preferred folder in your linux server.
mkrdir <owner_folder> or cd <owner_folder>
2. Clone Constellation and Telemetry
git clone https://github.com/sdgtt/constellation.git
git clone https://github.com/sdgtt/telemetry.git
3. Create virtual environment, to create type this to your terminal:
python3 -m virtualenv <env_folder_name>
4. Go to Telemetry cloned folder and install requirements
cd telemetry/
pip install -r requirements.txt
pip install -r requirements_dev.txt
cd ..
5. Run or activate your virtualenv
source envConstellation/bin/activate

6. Go to Constellation cloned folder and install requirements
pip install telemetry
pip install -r requirements.txt
pip install -r requirements_dev.txt
7. Once installed, run the in development mode.
export FLASK_ENV=development
export ES=192.168.10.12
flask run --host=0.0.0.0 --port=5002
1 change: 0 additions & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def register_dashapps(server):
"name": "viewport",
"content": "width=device-width, initial-scale=1, shrink-to-fit=no",
}

score_card = Dash(
__name__,
server=server,
Expand Down
27 changes: 19 additions & 8 deletions app/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from urllib.parse import unquote, urlparse

from app.models import boards as b
Expand All @@ -7,7 +8,13 @@
from app.pages.hwtests import allboards as ab
from app.pages.publicci.dashboard import Dashboard
from app.pages.pyadi.plots import gen_line_plot_html
from app.utility import artifact_url_gen, filter_gen, url_gen
from app.utility import (
append_url_to_dict,
artifact_url_gen,
filter_gen,
result_json_url,
url_gen,
)
from flask import (
Blueprint,
Flask,
Expand All @@ -26,7 +33,9 @@
# app = Flask(__name__)
server_bp = Blueprint("constellation", __name__)

JENKINS_SERVER = "gateway.englab"
JENKINS_SERVER = (
"jenkinsci" if "JENKINS_SERVER" not in os.environ else os.environ["JENKINS_SERVER"]
)
JENKINS_PORT = None

pci_dash = Dashboard(
Expand Down Expand Up @@ -77,7 +86,7 @@ def api(param=None):
else:
kwargs.update({f: el})
result_json = DB().search(size=size, order=order, agg_field=agg_field, **kwargs)
return result_json
return result_json_url(result_json, jenkins_url=JENKINS_SERVER)


@server_bp.route("api/board/<board_name>/")
Expand All @@ -96,17 +105,19 @@ def board_api(board_name, param=None):
for k, v in boot_test.items():
if k not in ["boot_test_failure", "raw_boot_test_result"]:
new_dict.update({k: v})
boot_test_filtered.append(new_dict)
boot_test_filtered.append(
append_url_to_dict(new_dict, jenkins_url=JENKINS_SERVER)
)
return {"hits": boot_test_filtered}


@server_bp.route("api/sc/")
@server_bp.route("api/sc/<param>")
def score_api(param=None):
default_jenkins_project = "HW_tests/HW_test_multiconfig"
default_branch = "boot_partition_master"
default_branch = ""
default_size = 7
default_offset = 0
default_offset = 0
filters = filter_gen(urlparse(unquote(request.url)).query)
jenkins_project = (
filters["jenkins_project"][0]
Expand All @@ -124,7 +135,7 @@ def score_api(param=None):
branch=branch,
board=board,
deprecated=deprecated,
offset = int(offset)
offset=int(offset),
)
return sc.to_json()

Expand All @@ -134,7 +145,7 @@ def allboards():
# retrieve boards from elastic server
# filter by jenkins_project_name
jenkins_project_name = "HW_tests/HW_test_multiconfig"
source_adjacency_matrix = "boot_partition_master"
source_adjacency_matrix = "boot_partition_main"
deprecated = []
boards_ref = b.Boards(
jenkins_project_name, source_adjacency_matrix, deprecated
Expand Down
4 changes: 2 additions & 2 deletions app/models/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Artifact:
"job_build_parameters",
"file_name",
"target_board",
"artifact_info_type"
"artifact_info_type",
]

def __init__(self, raw_artifact_result=None):
Expand Down Expand Up @@ -48,7 +48,7 @@ def display(self):
class Artifacts:
def __init__(self, **filters):

self.db = DB(index_name="artifacts",keywords=Artifact.KEYWORDS)
self.db = DB(index_name="artifacts", keywords=Artifact.KEYWORDS)
db_res = self.db.search(sort="archive_date", **filters)
# create boards object from raw db_res
self._artifacts = [Artifact(row) for row in db_res["hits"]]
Expand Down
1 change: 0 additions & 1 deletion app/models/boot_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ def latest_builds(self, size, offset=0):
}
)
return builds_dict


def latest_builds_boards(self, size, offset=0):
boards = []
Expand Down
20 changes: 13 additions & 7 deletions app/models/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
"last_failing_stage",
]


class DB:
def __init__(
self,
elastic_server=ELASTIC_SERVER,
username=USERNAME,
password=PASSWORD,
index_name=INDEX,
keywords=KEYWORDS
keywords=KEYWORDS,
):
retries = 0
while True:
Expand All @@ -42,7 +43,7 @@ def __init__(
password=password,
index_name=index_name,
)
self.keywords=keywords
self.keywords = keywords
break
except Exception as e:
print("Server not yet ready")
Expand All @@ -57,7 +58,7 @@ def search(
sort="jenkins_job_date",
order="desc",
agg_field=None,
**kwargs
**kwargs,
):
result = {"hits": [], "aggregates": [], "aggregates_top": []}
if kwargs:
Expand Down Expand Up @@ -85,11 +86,15 @@ def search(
if agg_field:
for row in res["aggregations"][agg_field]["buckets"]:
result["aggregates"].append(row["key"])

agg_field_data = {}
# get top data for the aggregated field
for row_data in result["hits"]:
agg_field = agg_field.split(".keyword")[0] if "keyword" in agg_field else agg_field
agg_field = (
agg_field.split(".keyword")[0]
if "keyword" in agg_field
else agg_field
)
if row_data[agg_field] == row["key"]:
agg_field_data = row_data
break
Expand All @@ -114,11 +119,12 @@ def test_db_search():
elastic_server="primary.englab",
username="",
password="",
index_name="boot_tests"
index_name="boot_tests",
)
result = db.search(
size=1,
sort="jenkins_job_date",
order="desc",
agg_field="boot_folder_name.keyword",
)
)
assert result
10 changes: 6 additions & 4 deletions app/models/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(
self,
jenkins_project="HW_tests/HW_test_multiconfig",
size=2,
branch="boot_partition_master",
branch="boot_partition_main",
board=None,
deprecated=[],
offset=0,
Expand Down Expand Up @@ -200,7 +200,9 @@ def get_test_results(self): # noqa: C901
]:
if isinstance(report[bn][test]["data"], list):
try:
assert report[bn][test]["count"] == len(report[bn][test]["data"])
assert report[bn][test]["count"] == len(
report[bn][test]["data"]
)
except Exception as e:
print(f"Inconsistency in build {bn} on test {test}")
print(report[bn][test])
Expand All @@ -210,7 +212,7 @@ def get_test_results(self): # noqa: C901
for k, boards in report[bn][test]["data"].items():
for board in boards:
count += 1
try:
try:
assert report[bn][test]["count"] == count
except Exception as e:
print(f"Inconsistency in build {bn} on test {test}")
Expand Down Expand Up @@ -361,7 +363,7 @@ def to_dict(self):


if __name__ == "__main__":
sc = Score(size=7, branch="boot_partition_master")
sc = Score(size=7, branch="boot_partition_main")
# print(sc.boot_tests)
# print(sc.boards)
# print(sc.builds)
Expand Down
Loading
Loading