-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OPIK-194 Sanity end-to-end tests - UI tests (#357)
* sanity tests batch 1 - traces spans basic * Update sanity.yml * Update sanity.yml * Update conftest.py * Update conftest.py * proper datatype for inputs outputs * run on demand --------- Co-authored-by: Andrei Căutișanu <[email protected]>
- Loading branch information
1 parent
21215ad
commit 3749d11
Showing
8 changed files
with
175 additions
and
20 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,63 @@ | ||
name: Install Local Version of Opik | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test_installation: | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.ref }} | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: Install Opik | ||
run: pip install ${{ github.workspace }}/sdks/python | ||
|
||
- name: Install Test Dependencies | ||
run: | | ||
pip install -r ${{ github.workspace }}/tests_end_to_end/test_requirements.txt | ||
playwright install | ||
- name: Install Opik | ||
env: | ||
OPIK_USAGE_REPORT_ENABLED: false | ||
run: | | ||
cd ${{ github.workspace }}/deployment/docker-compose | ||
docker compose up -d --build | ||
- name: Check Docker pods are up | ||
run: | | ||
chmod +x ./tests_end_to_end/installer/check_docker_compose_pods.sh | ||
./tests_end_to_end/installer/check_docker_compose_pods.sh | ||
shell: bash | ||
|
||
- name: Check backend health | ||
run: | | ||
chmod +x ./tests_end_to_end/installer/check_backend.sh | ||
./tests_end_to_end/installer/check_backend.sh | ||
shell: bash | ||
|
||
- name: Check app is up via the UI | ||
run: | | ||
pytest -v -s ${{ github.workspace }}/tests_end_to_end/installer/test_app_status.py | ||
- name: Run sanity suite | ||
run: | | ||
cd ${{ github.workspace }}/tests_end_to_end | ||
export PYTHONPATH='.' | ||
pytest -s application_sanity/test_sanity.py --browser chromium --base-url http://localhost:5173 --setup-show | ||
- name: Stop Opik server | ||
if: always() | ||
run: | | ||
cd ${{ github.workspace }}/deployment/docker-compose | ||
docker compose down | ||
cd - |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import pytest | ||
from playwright.sync_api import Page, expect | ||
from page_objects.ProjectsPage import ProjectsPage | ||
from page_objects.TracesPage import TracesPage | ||
from page_objects.TracesPageSpansMenu import TracesPageSpansMenu | ||
|
||
|
||
def test_project_name(page: Page, log_traces_and_spans_decorator, log_traces_and_spans_low_level): | ||
projects_page = ProjectsPage(page) | ||
projects_page.go_to_page() | ||
projects_page.check_project_exists('test-project') | ||
|
||
|
||
def test_traces_created(page, config, log_traces_and_spans_low_level, log_traces_and_spans_decorator): | ||
#navigate to project | ||
projects_page = ProjectsPage(page) | ||
projects_page.go_to_page() | ||
|
||
#wait for data to actually arrive to the frontend | ||
#TODO: replace this with a smarter waiting mechanism | ||
page.wait_for_timeout(5000) | ||
projects_page.click_project(config['project']['name']) | ||
|
||
#grab all traces of project | ||
traces_page = TracesPage(page) | ||
trace_names = traces_page.get_all_trace_names() | ||
|
||
client_prefix = config['traces']['client']['prefix'] | ||
decorator_prefix = config['traces']['decorator']['prefix'] | ||
|
||
for count in range(config['traces']['count']): | ||
for prefix in [client_prefix, decorator_prefix]: | ||
assert prefix+str(count) in trace_names | ||
|
||
|
||
def test_spans_of_traces(page, config, log_traces_and_spans_low_level, log_traces_and_spans_decorator): | ||
projects_page = ProjectsPage(page) | ||
projects_page.go_to_page() | ||
|
||
#wait for data to actually arrive to the frontend | ||
#TODO: replace this with a smarter waiting mechanism | ||
projects_page.click_project(config['project']['name']) | ||
|
||
#grab all traces of project | ||
traces_page = TracesPage(page) | ||
trace_names = traces_page.get_all_trace_names() | ||
|
||
for trace in trace_names: | ||
page.get_by_text(trace).click() | ||
spans_menu = TracesPageSpansMenu(page) | ||
trace_type = trace.split('-')[0] # 'client' or 'decorator' | ||
for count in range(config['spans']['count']): | ||
prefix = config['spans'][trace_type]['prefix'] | ||
spans_menu.check_span_exists_by_name(f'{prefix}{count}') | ||
|
||
|
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,16 @@ | ||
from playwright.sync_api import Page, expect | ||
|
||
class ProjectsPage: | ||
def __init__(self, page: Page): | ||
self.page = page | ||
self.url = '/projects' | ||
self.projects_table = page.get_by_role('table') | ||
|
||
def go_to_page(self): | ||
self.page.goto(self.url) | ||
|
||
def click_project(self, project_name): | ||
self.page.get_by_role('cell', name=project_name).click() | ||
|
||
def check_project_exists(self, project_name): | ||
expect(self.projects_table.get_by_role('cell', name=project_name)).to_be_visible() |
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,13 @@ | ||
from playwright.sync_api import Page, expect | ||
|
||
class TracesPage: | ||
def __init__(self, page: Page): | ||
self.page = page | ||
self.traces_table = self.page.get_by_role('table') | ||
self.trace_names_selector = 'tr td:nth-child(2) div span' | ||
|
||
def get_all_trace_names(self): | ||
self.page.wait_for_selector(self.trace_names_selector) | ||
|
||
names = self.page.locator(self.trace_names_selector).all_inner_texts() | ||
return names |
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,8 @@ | ||
from playwright.sync_api import Page, expect | ||
|
||
class TracesPageSpansMenu: | ||
def __init__(self, page: Page): | ||
self.page = page | ||
|
||
def check_span_exists_by_name(self, name): | ||
expect(self.page.get_by_role('button', name=name)).to_be_visible() |
Empty file.