From 52ce44cc237935a7d7c65b6415bf588080aa9c9b Mon Sep 17 00:00:00 2001 From: Harry Le Date: Wed, 5 Mar 2025 14:29:11 +0700 Subject: [PATCH 01/11] test: add e2e files --- engine/e2e-test/api/files/blank.txt | 0 .../api/files/test_api_create_file.py | 63 ++++++++++ .../api/files/test_api_delete_file.py | 84 +++++++++++++ .../e2e-test/api/files/test_api_get_file.py | 102 ++++++++++++++++ .../api/files/test_api_get_list_file.py | 112 ++++++++++++++++++ .../runner/cortex-llamacpp-e2e-nightly.py | 4 + engine/e2e-test/runner/main.py | 4 + 7 files changed, 369 insertions(+) create mode 100644 engine/e2e-test/api/files/blank.txt create mode 100644 engine/e2e-test/api/files/test_api_create_file.py create mode 100644 engine/e2e-test/api/files/test_api_delete_file.py create mode 100644 engine/e2e-test/api/files/test_api_get_file.py create mode 100644 engine/e2e-test/api/files/test_api_get_list_file.py diff --git a/engine/e2e-test/api/files/blank.txt b/engine/e2e-test/api/files/blank.txt new file mode 100644 index 000000000..e69de29bb diff --git a/engine/e2e-test/api/files/test_api_create_file.py b/engine/e2e-test/api/files/test_api_create_file.py new file mode 100644 index 000000000..dbb3e3bb9 --- /dev/null +++ b/engine/e2e-test/api/files/test_api_create_file.py @@ -0,0 +1,63 @@ +import pytest +import requests +from utils.test_runner import start_server, stop_server +import os +import jsonschema +from utils.logger import log_response +from utils.assertion import assert_equal +import fnmatch + + +class TestApiCreateFile: + + @pytest.fixture(autouse=True) + def setup_and_teardown(self): + # Setup + success = start_server() + if not success: + raise Exception("Failed to start server") + + yield + + # Teardown + stop_server() + + def test_api_create_file_successfully(self): + # Define file path + file_path = os.path.join("e2e-test", "api", "files", "blank.txt") + + # Prepare request data + files = { + "file": ("blank.txt", open(file_path, "rb"), "text/plain") + } + data = { + "purpose": "assistants" + } + + post_file_url = "http://127.0.0.1:3928/v1/files" + response = requests.post(post_file_url, files=files, data=data) + + json_data = response.json() + log_response(json_data, "test_api_create_file_successfully") + assert_equal(response.status_code, 200) + + # Schema to validate + schema = { + "type": "object", + "properties": { + "bytes": {"type": "integer"}, + "created_at": {"type": "integer"}, + "filename": {"type": "string"}, + "id": {"type": "string"}, + "object": {"type": "string"}, + "purpose": {"type": "string"} + }, + "required": ["bytes", "created_at", "filename", "id", "object", "purpose"] + } + + # Validate response schema + jsonschema.validate(instance=json_data, schema=schema) + + # Assert content + assert fnmatch.fnmatch(json_data["filename"], "blank_*.txt"), f"Filename {json_data["filename"]} does not match pattern blank_*.txt" + assert_equal(json_data["purpose"], "assistants") \ No newline at end of file diff --git a/engine/e2e-test/api/files/test_api_delete_file.py b/engine/e2e-test/api/files/test_api_delete_file.py new file mode 100644 index 000000000..b59ce17e2 --- /dev/null +++ b/engine/e2e-test/api/files/test_api_delete_file.py @@ -0,0 +1,84 @@ +import pytest +import requests +from utils.test_runner import start_server, stop_server +import os +import jsonschema +from utils.logger import log_response +from utils.assertion import assert_equal +import fnmatch + + +class TestApiDeleteFile: + + @pytest.fixture(autouse=True) + def setup_and_teardown(self): + # Setup + success = start_server() + if not success: + raise Exception("Failed to start server") + + yield + + # Teardown + stop_server() + + def test_api_del_file_successfully(self): + # Define file path + file_path = os.path.join("e2e-test", "api", "files", "blank.txt") + + # Upload file first + files = { + "file": ("blank.txt", open(file_path, "rb"), "text/plain") + } + data = { + "purpose": "assistants" + } + + file_url = "http://127.0.0.1:3928/v1/files" + response = requests.post(file_url, files=files, data=data) + + json_data = response.json() + log_response(json_data, "test_api_del_file_successfully") + assert_equal(response.status_code, 200) + + file_id=json_data["id"] + + # Delete message with id + file_id_url = f"http://127.0.0.1:3928/v1/files/{file_id}" + file_response = requests.delete(file_id_url) + json_data_file = file_response.json() + log_response(json_data_file, "test_api_del_file_successfully") + assert_equal(file_response.status_code,200) + + + # Schema to validate + schema = { + "properties": { + "deleted": { + "description": "Indicates if the file was successfully deleted", + "type": "boolean" + }, + "id": { + "description": "The ID of the deleted file", + "type": "string" + }, + "object": { + "description": "Type of object, always 'file'", + "type": "string" + } + }, + "required": [ + "deleted", + "id", + "object" + ], + "type": "object" + } + + # Validate response schema + jsonschema.validate(instance=json_data_file, schema=schema) + + # Assert content + assert_equal(json_data_file["deleted"], True) + assert_equal(json_data_file["id"], file_id) + assert_equal(json_data_file["object"], "file") \ No newline at end of file diff --git a/engine/e2e-test/api/files/test_api_get_file.py b/engine/e2e-test/api/files/test_api_get_file.py new file mode 100644 index 000000000..40ec77437 --- /dev/null +++ b/engine/e2e-test/api/files/test_api_get_file.py @@ -0,0 +1,102 @@ +import pytest +import requests +from utils.test_runner import start_server, stop_server +import os +import jsonschema +from utils.logger import log_response +from utils.assertion import assert_equal +import fnmatch + + +class TestApiGetFile: + + @pytest.fixture(autouse=True) + def setup_and_teardown(self): + # Setup + success = start_server() + if not success: + raise Exception("Failed to start server") + + yield + + # Teardown + stop_server() + + def test_api_get_file_successfully(self): + # Define file path + file_path = os.path.join("e2e-test", "api", "files", "blank.txt") + + # Upload file first + files = { + "file": ("blank.txt", open(file_path, "rb"), "text/plain") + } + data = { + "purpose": "assistants" + } + + file_url = "http://127.0.0.1:3928/v1/files" + response = requests.post(file_url, files=files, data=data) + + json_data = response.json() + log_response(json_data, "test_api_get_file_successfully") + assert_equal(response.status_code, 200) + + file_id=json_data["id"] + + # Get message with id + file_id_url = f"http://127.0.0.1:3928/v1/files/{file_id}" + file_response = requests.get(file_id_url) + json_data_file = file_response.json() + log_response(json_data_file, "test_api_get_file_successfully") + assert_equal(file_response.status_code,200) + + + # Schema to validate + schema = { + "properties": { + "bytes": { + "type": "integer", + "examples": [ + 3211109 + ] + }, + "created_at": { + "type": "integer", + "examples": [ + 1733942093 + ] + }, + "filename": { + "type": "string", + "examples": [ + "Enterprise_Application_Infrastructure_v2_20140903_toCTC_v1.0.pdf" + ] + }, + "id": { + "type": "string", + "examples": [ + "file-0001KNKPTDDAQSDVEQGRBTCTNJ" + ] + }, + "object": { + "type": "string", + "examples": [ + "file" + ] + }, + "purpose": { + "type": "string", + "examples": [ + "assistants" + ] + } + }, + "type": "object" + } + + # Validate response schema + jsonschema.validate(instance=json_data_file, schema=schema) + + # Assert content + assert fnmatch.fnmatch(json_data_file["filename"], "blank_*.txt"), f"Filename {json_data["filename"]} does not match pattern blank_*.txt" + assert_equal(json_data_file["id"], file_id) \ No newline at end of file diff --git a/engine/e2e-test/api/files/test_api_get_list_file.py b/engine/e2e-test/api/files/test_api_get_list_file.py new file mode 100644 index 000000000..2de114734 --- /dev/null +++ b/engine/e2e-test/api/files/test_api_get_list_file.py @@ -0,0 +1,112 @@ +import pytest +import requests +from utils.test_runner import start_server, stop_server +import os +import jsonschema +from utils.logger import log_response +from utils.assertion import assert_equal +import fnmatch + + +class TestApiGetListFile: + + @pytest.fixture(autouse=True) + def setup_and_teardown(self): + # Setup + success = start_server() + if not success: + raise Exception("Failed to start server") + + yield + + # Teardown + stop_server() + + def test_api_get_list_file_successfully(self): + # Define file path + file_path = os.path.join("e2e-test", "api", "files", "blank.txt") + + # Upload file first + files = { + "file": ("blank.txt", open(file_path, "rb"), "text/plain") + } + data = { + "purpose": "assistants" + } + + file_url = "http://127.0.0.1:3928/v1/files" + response = requests.post(file_url, files=files, data=data) + + json_data = response.json() + log_response(json_data, "test_api_get_list_file_successfully") + assert_equal(response.status_code, 200) + + # Get list message + list_file_response = requests.get(file_url) + json_data_list_file = list_file_response.json() + log_response(json_data_list_file, "test_api_get_list_file_successfully") + assert_equal(list_file_response.status_code,200) + + + # Schema to validate + schema = { + "properties": { + "data": { + "items": { + "properties": { + "bytes": { + "type": "integer", + "examples": [ + 3211109 + ] + }, + "created_at": { + "type": "integer", + "examples": [ + 1733942093 + ] + }, + "filename": { + "type": "string", + "examples": [ + "Enterprise_Application_Infrastructure_v2_20140903_toCTC_v1.0.pdf" + ] + }, + "id": { + "type": "string", + "examples": [ + "file-0001KNKPTDDAQSDVEQGRBTCTNJ" + ] + }, + "object": { + "type": "string", + "examples": [ + "file" + ] + }, + "purpose": { + "type": "string", + "examples": [ + "assistants" + ] + } + }, + "type": "object" + }, + "type": "array" + }, + "object": { + "type": "string", + "examples": [ + "list" + ] + } + }, + "type": "object" + } + + # Validate response schema + jsonschema.validate(instance=json_data_list_file, schema=schema) + + # Assert content + assert fnmatch.fnmatch(json_data_list_file["data"][0]["filename"], "blank_*.txt"), f"Filename {json_data["filename"]} does not match pattern blank_*.txt" \ No newline at end of file diff --git a/engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py b/engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py index 2bf3af09b..02afe1c76 100644 --- a/engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py +++ b/engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py @@ -24,6 +24,10 @@ from test_api_post_default_engine import TestApiSetDefaultEngine from api.model.test_api_model import TestApiModel from api.model.test_api_model_import import TestApiModelImport +from api.files.test_api_create_file import TestApiCreateFile +from api.files.test_api_get_file import TestApiGetFile +from api.files.test_api_get_list_file import TestApiGetListFile +from api.files.test_api_create_file import TestApiCreateFile ### from cli.engines.test_cli_engine_get import TestCliEngineGet diff --git a/engine/e2e-test/runner/main.py b/engine/e2e-test/runner/main.py index 009f4d718..354e61799 100644 --- a/engine/e2e-test/runner/main.py +++ b/engine/e2e-test/runner/main.py @@ -24,6 +24,10 @@ from test_api_post_default_engine import TestApiSetDefaultEngine from api.model.test_api_model import TestApiModel from api.model.test_api_model_import import TestApiModelImport +from api.files.test_api_create_file import TestApiCreateFile +from api.files.test_api_get_file import TestApiGetFile +from api.files.test_api_get_list_file import TestApiGetListFile +from api.files.test_api_create_file import TestApiCreateFile ### from cli.engines.test_cli_engine_get import TestCliEngineGet From f5a31c55aef0c3427f8c8b38851845128b6c8b01 Mon Sep 17 00:00:00 2001 From: Harry Le Date: Wed, 5 Mar 2025 16:51:55 +0700 Subject: [PATCH 02/11] test: fix ci --- engine/e2e-test/api/files/test_api_create_file.py | 2 +- engine/e2e-test/api/files/test_api_get_file.py | 2 +- engine/e2e-test/api/files/test_api_get_list_file.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/e2e-test/api/files/test_api_create_file.py b/engine/e2e-test/api/files/test_api_create_file.py index dbb3e3bb9..a840fe5e8 100644 --- a/engine/e2e-test/api/files/test_api_create_file.py +++ b/engine/e2e-test/api/files/test_api_create_file.py @@ -59,5 +59,5 @@ def test_api_create_file_successfully(self): jsonschema.validate(instance=json_data, schema=schema) # Assert content - assert fnmatch.fnmatch(json_data["filename"], "blank_*.txt"), f"Filename {json_data["filename"]} does not match pattern blank_*.txt" + assert fnmatch.fnmatch(json_data["filename"], "blank_*.txt"), f"Filename {json_data['filename']} does not match pattern blank_*.txt" assert_equal(json_data["purpose"], "assistants") \ No newline at end of file diff --git a/engine/e2e-test/api/files/test_api_get_file.py b/engine/e2e-test/api/files/test_api_get_file.py index 40ec77437..36adb8963 100644 --- a/engine/e2e-test/api/files/test_api_get_file.py +++ b/engine/e2e-test/api/files/test_api_get_file.py @@ -98,5 +98,5 @@ def test_api_get_file_successfully(self): jsonschema.validate(instance=json_data_file, schema=schema) # Assert content - assert fnmatch.fnmatch(json_data_file["filename"], "blank_*.txt"), f"Filename {json_data["filename"]} does not match pattern blank_*.txt" + assert fnmatch.fnmatch(json_data_file["filename"], "blank_*.txt"), f"Filename {json_data['filename']} does not match pattern blank_*.txt" assert_equal(json_data_file["id"], file_id) \ No newline at end of file diff --git a/engine/e2e-test/api/files/test_api_get_list_file.py b/engine/e2e-test/api/files/test_api_get_list_file.py index 2de114734..ac494ab8c 100644 --- a/engine/e2e-test/api/files/test_api_get_list_file.py +++ b/engine/e2e-test/api/files/test_api_get_list_file.py @@ -109,4 +109,4 @@ def test_api_get_list_file_successfully(self): jsonschema.validate(instance=json_data_list_file, schema=schema) # Assert content - assert fnmatch.fnmatch(json_data_list_file["data"][0]["filename"], "blank_*.txt"), f"Filename {json_data["filename"]} does not match pattern blank_*.txt" \ No newline at end of file + assert fnmatch.fnmatch(json_data_list_file["data"][0]["filename"], "blank_*.txt"), f"Filename {json_data['filename']} does not match pattern blank_*.txt" \ No newline at end of file From c837a1390deba60189304b236e473ce9a20fca12 Mon Sep 17 00:00:00 2001 From: Harry Le Date: Wed, 5 Mar 2025 17:20:58 +0700 Subject: [PATCH 03/11] test: fix ci, update match condition --- engine/e2e-test/api/files/test_api_create_file.py | 2 +- engine/e2e-test/api/files/test_api_get_file.py | 2 +- engine/e2e-test/api/files/test_api_get_list_file.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/e2e-test/api/files/test_api_create_file.py b/engine/e2e-test/api/files/test_api_create_file.py index a840fe5e8..00c9862a0 100644 --- a/engine/e2e-test/api/files/test_api_create_file.py +++ b/engine/e2e-test/api/files/test_api_create_file.py @@ -59,5 +59,5 @@ def test_api_create_file_successfully(self): jsonschema.validate(instance=json_data, schema=schema) # Assert content - assert fnmatch.fnmatch(json_data["filename"], "blank_*.txt"), f"Filename {json_data['filename']} does not match pattern blank_*.txt" + assert (fnmatch.fnmatch(json_data["filename"], "blank_*.txt") or json_data["filename"] == "blank.txt"), f"Filename {json_data['filename']} does not match pattern blank_*.txt or blank.txt" assert_equal(json_data["purpose"], "assistants") \ No newline at end of file diff --git a/engine/e2e-test/api/files/test_api_get_file.py b/engine/e2e-test/api/files/test_api_get_file.py index 36adb8963..a737de560 100644 --- a/engine/e2e-test/api/files/test_api_get_file.py +++ b/engine/e2e-test/api/files/test_api_get_file.py @@ -98,5 +98,5 @@ def test_api_get_file_successfully(self): jsonschema.validate(instance=json_data_file, schema=schema) # Assert content - assert fnmatch.fnmatch(json_data_file["filename"], "blank_*.txt"), f"Filename {json_data['filename']} does not match pattern blank_*.txt" + assert (fnmatch.fnmatch(json_data["filename"], "blank_*.txt") or json_data["filename"] == "blank.txt"), f"Filename {json_data['filename']} does not match pattern blank_*.txt or blank.txt" assert_equal(json_data_file["id"], file_id) \ No newline at end of file diff --git a/engine/e2e-test/api/files/test_api_get_list_file.py b/engine/e2e-test/api/files/test_api_get_list_file.py index ac494ab8c..e36b79722 100644 --- a/engine/e2e-test/api/files/test_api_get_list_file.py +++ b/engine/e2e-test/api/files/test_api_get_list_file.py @@ -109,4 +109,4 @@ def test_api_get_list_file_successfully(self): jsonschema.validate(instance=json_data_list_file, schema=schema) # Assert content - assert fnmatch.fnmatch(json_data_list_file["data"][0]["filename"], "blank_*.txt"), f"Filename {json_data['filename']} does not match pattern blank_*.txt" \ No newline at end of file + assert (fnmatch.fnmatch(json_data["filename"], "blank_*.txt") or json_data["filename"] == "blank.txt"), f"Filename {json_data['filename']} does not match pattern blank_*.txt or blank.txt" \ No newline at end of file From dcc96896b0e467abe7d880c668cb6ef84b2ced2d Mon Sep 17 00:00:00 2001 From: Harry Le Date: Wed, 5 Mar 2025 17:48:45 +0700 Subject: [PATCH 04/11] test: print log ci --- engine/e2e-test/api/files/test_api_create_file.py | 1 + engine/e2e-test/api/files/test_api_get_file.py | 1 + engine/e2e-test/api/files/test_api_get_list_file.py | 1 + 3 files changed, 3 insertions(+) diff --git a/engine/e2e-test/api/files/test_api_create_file.py b/engine/e2e-test/api/files/test_api_create_file.py index 00c9862a0..0cb0c6982 100644 --- a/engine/e2e-test/api/files/test_api_create_file.py +++ b/engine/e2e-test/api/files/test_api_create_file.py @@ -36,6 +36,7 @@ def test_api_create_file_successfully(self): post_file_url = "http://127.0.0.1:3928/v1/files" response = requests.post(post_file_url, files=files, data=data) + print(response.text) json_data = response.json() log_response(json_data, "test_api_create_file_successfully") diff --git a/engine/e2e-test/api/files/test_api_get_file.py b/engine/e2e-test/api/files/test_api_get_file.py index a737de560..c20841c1d 100644 --- a/engine/e2e-test/api/files/test_api_get_file.py +++ b/engine/e2e-test/api/files/test_api_get_file.py @@ -36,6 +36,7 @@ def test_api_get_file_successfully(self): file_url = "http://127.0.0.1:3928/v1/files" response = requests.post(file_url, files=files, data=data) + print(response.text) json_data = response.json() log_response(json_data, "test_api_get_file_successfully") diff --git a/engine/e2e-test/api/files/test_api_get_list_file.py b/engine/e2e-test/api/files/test_api_get_list_file.py index e36b79722..a6e339940 100644 --- a/engine/e2e-test/api/files/test_api_get_list_file.py +++ b/engine/e2e-test/api/files/test_api_get_list_file.py @@ -36,6 +36,7 @@ def test_api_get_list_file_successfully(self): file_url = "http://127.0.0.1:3928/v1/files" response = requests.post(file_url, files=files, data=data) + print(response.text) json_data = response.json() log_response(json_data, "test_api_get_list_file_successfully") From e1932078ba8a1d7c20cbea5c9233d622bba5d8a3 Mon Sep 17 00:00:00 2001 From: Harry Le Date: Wed, 5 Mar 2025 18:02:44 +0700 Subject: [PATCH 05/11] test: print log ci --- .github/workflows/cortex-cpp-quality-gate.yml | 3 ++- engine/e2e-test/api/files/test_api_create_file.py | 2 +- engine/e2e-test/api/files/test_api_get_file.py | 2 +- engine/e2e-test/api/files/test_api_get_list_file.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cortex-cpp-quality-gate.yml b/.github/workflows/cortex-cpp-quality-gate.yml index 2918840b6..64841bb4d 100644 --- a/.github/workflows/cortex-cpp-quality-gate.yml +++ b/.github/workflows/cortex-cpp-quality-gate.yml @@ -248,10 +248,11 @@ jobs: make package - name: Upload Artifact + if: always() uses: actions/upload-artifact@v4 with: name: cortex-${{ matrix.os }}-${{ matrix.name }} - path: ./engine/cortex + path: ./engine/e2e-test/logs - name: Upload windows ccache to s3 continue-on-error: true diff --git a/engine/e2e-test/api/files/test_api_create_file.py b/engine/e2e-test/api/files/test_api_create_file.py index 0cb0c6982..1fc05fd7e 100644 --- a/engine/e2e-test/api/files/test_api_create_file.py +++ b/engine/e2e-test/api/files/test_api_create_file.py @@ -36,7 +36,7 @@ def test_api_create_file_successfully(self): post_file_url = "http://127.0.0.1:3928/v1/files" response = requests.post(post_file_url, files=files, data=data) - print(response.text) + log_response(response.text, "test_api_create_file_successfully") json_data = response.json() log_response(json_data, "test_api_create_file_successfully") diff --git a/engine/e2e-test/api/files/test_api_get_file.py b/engine/e2e-test/api/files/test_api_get_file.py index c20841c1d..04543d59f 100644 --- a/engine/e2e-test/api/files/test_api_get_file.py +++ b/engine/e2e-test/api/files/test_api_get_file.py @@ -36,7 +36,7 @@ def test_api_get_file_successfully(self): file_url = "http://127.0.0.1:3928/v1/files" response = requests.post(file_url, files=files, data=data) - print(response.text) + log_response(response.text, "test_api_get_file_successfully") json_data = response.json() log_response(json_data, "test_api_get_file_successfully") diff --git a/engine/e2e-test/api/files/test_api_get_list_file.py b/engine/e2e-test/api/files/test_api_get_list_file.py index a6e339940..ee9cf32e5 100644 --- a/engine/e2e-test/api/files/test_api_get_list_file.py +++ b/engine/e2e-test/api/files/test_api_get_list_file.py @@ -36,7 +36,7 @@ def test_api_get_list_file_successfully(self): file_url = "http://127.0.0.1:3928/v1/files" response = requests.post(file_url, files=files, data=data) - print(response.text) + log_response(response.text, "test_api_get_list_file_successfully") json_data = response.json() log_response(json_data, "test_api_get_list_file_successfully") From 9125e3e42d51238ae5d0e3979ec4d5bc49529b80 Mon Sep 17 00:00:00 2001 From: Harry Le Date: Thu, 6 Mar 2025 11:06:58 +0700 Subject: [PATCH 06/11] test: print path --- engine/e2e-test/api/files/test_api_create_file.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engine/e2e-test/api/files/test_api_create_file.py b/engine/e2e-test/api/files/test_api_create_file.py index 1fc05fd7e..55880d745 100644 --- a/engine/e2e-test/api/files/test_api_create_file.py +++ b/engine/e2e-test/api/files/test_api_create_file.py @@ -25,6 +25,8 @@ def setup_and_teardown(self): def test_api_create_file_successfully(self): # Define file path file_path = os.path.join("e2e-test", "api", "files", "blank.txt") + log_response(file_path, "test_api_create_file_successfully") + # Prepare request data files = { @@ -37,6 +39,7 @@ def test_api_create_file_successfully(self): post_file_url = "http://127.0.0.1:3928/v1/files" response = requests.post(post_file_url, files=files, data=data) log_response(response.text, "test_api_create_file_successfully") + log_response(response.status_code, "test_api_create_file_successfully") json_data = response.json() log_response(json_data, "test_api_create_file_successfully") From e5a34b83a0749703da30b47a1e3c5ff6744cadc8 Mon Sep 17 00:00:00 2001 From: Harry Le Date: Thu, 6 Mar 2025 11:22:31 +0700 Subject: [PATCH 07/11] test: debug --- .../api/files/test_api_create_file.py | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/engine/e2e-test/api/files/test_api_create_file.py b/engine/e2e-test/api/files/test_api_create_file.py index 55880d745..692f8f2e2 100644 --- a/engine/e2e-test/api/files/test_api_create_file.py +++ b/engine/e2e-test/api/files/test_api_create_file.py @@ -24,22 +24,28 @@ def setup_and_teardown(self): def test_api_create_file_successfully(self): # Define file path - file_path = os.path.join("e2e-test", "api", "files", "blank.txt") + file_path_rel = os.path.join("e2e-test", "api", "files", "blank.txt") + file_path = os.path.join(os.getcwd(), file_path_rel) + log_response(file_path, "test_api_create_file_successfully") - # Prepare request data - files = { - "file": ("blank.txt", open(file_path, "rb"), "text/plain") - } - data = { - "purpose": "assistants" - } + # # Prepare request data + # files = { + # "file": ("blank.txt", open(file_path, "rb"), "text/plain") + # } + # data = { + # "purpose": "assistants" + # } post_file_url = "http://127.0.0.1:3928/v1/files" - response = requests.post(post_file_url, files=files, data=data) - log_response(response.text, "test_api_create_file_successfully") - log_response(response.status_code, "test_api_create_file_successfully") + # response = requests.post(post_file_url, files=files, data=data) + with open(file_path, "rb") as file: + files = {"file": ("blank.txt", file, "text/plain")} + data = {"purpose": "assistants"} + response = requests.post(post_file_url, files=files, data=data) + log_response(response.text, "test_api_create_file_successfully") + log_response(response.status_code, "test_api_create_file_successfully") json_data = response.json() log_response(json_data, "test_api_create_file_successfully") From a081f3ac55df18618b657e01a02c0d408eab065d Mon Sep 17 00:00:00 2001 From: Harry Le Date: Thu, 6 Mar 2025 11:36:43 +0700 Subject: [PATCH 08/11] test: skip --- engine/e2e-test/api/files/test_api_create_file.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/engine/e2e-test/api/files/test_api_create_file.py b/engine/e2e-test/api/files/test_api_create_file.py index 692f8f2e2..b1b517ce1 100644 --- a/engine/e2e-test/api/files/test_api_create_file.py +++ b/engine/e2e-test/api/files/test_api_create_file.py @@ -2,6 +2,7 @@ import requests from utils.test_runner import start_server, stop_server import os +import platform import jsonschema from utils.logger import log_response from utils.assertion import assert_equal @@ -22,24 +23,14 @@ def setup_and_teardown(self): # Teardown stop_server() + @pytest.mark.skipif(platform.system() != "Linux", reason="Need to load engine on Mac machine") def test_api_create_file_successfully(self): # Define file path file_path_rel = os.path.join("e2e-test", "api", "files", "blank.txt") file_path = os.path.join(os.getcwd(), file_path_rel) - log_response(file_path, "test_api_create_file_successfully") - - # # Prepare request data - # files = { - # "file": ("blank.txt", open(file_path, "rb"), "text/plain") - # } - # data = { - # "purpose": "assistants" - # } - post_file_url = "http://127.0.0.1:3928/v1/files" - # response = requests.post(post_file_url, files=files, data=data) with open(file_path, "rb") as file: files = {"file": ("blank.txt", file, "text/plain")} data = {"purpose": "assistants"} From 528b8d0d1a8b97574201a6e81095a59ca5905700 Mon Sep 17 00:00:00 2001 From: Harry Le Date: Thu, 6 Mar 2025 11:59:30 +0700 Subject: [PATCH 09/11] test: fix --- engine/e2e-test/api/files/test_api_create_file.py | 2 +- engine/e2e-test/api/files/test_api_get_file.py | 4 +++- engine/e2e-test/api/files/test_api_get_list_file.py | 2 ++ engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py | 2 +- engine/e2e-test/runner/main.py | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/engine/e2e-test/api/files/test_api_create_file.py b/engine/e2e-test/api/files/test_api_create_file.py index b1b517ce1..7c7226f50 100644 --- a/engine/e2e-test/api/files/test_api_create_file.py +++ b/engine/e2e-test/api/files/test_api_create_file.py @@ -23,7 +23,7 @@ def setup_and_teardown(self): # Teardown stop_server() - @pytest.mark.skipif(platform.system() != "Linux", reason="Need to load engine on Mac machine") + @pytest.mark.skipif(platform.system() != "Linux", reason="Todo: fix later on Mac and Window") def test_api_create_file_successfully(self): # Define file path file_path_rel = os.path.join("e2e-test", "api", "files", "blank.txt") diff --git a/engine/e2e-test/api/files/test_api_get_file.py b/engine/e2e-test/api/files/test_api_get_file.py index 04543d59f..28ec38dda 100644 --- a/engine/e2e-test/api/files/test_api_get_file.py +++ b/engine/e2e-test/api/files/test_api_get_file.py @@ -1,6 +1,7 @@ import pytest import requests from utils.test_runner import start_server, stop_server +import platform import os import jsonschema from utils.logger import log_response @@ -21,7 +22,8 @@ def setup_and_teardown(self): # Teardown stop_server() - + + @pytest.mark.skipif(platform.system() != "Linux", reason="Todo: fix later on Mac and Window") def test_api_get_file_successfully(self): # Define file path file_path = os.path.join("e2e-test", "api", "files", "blank.txt") diff --git a/engine/e2e-test/api/files/test_api_get_list_file.py b/engine/e2e-test/api/files/test_api_get_list_file.py index ee9cf32e5..151a17837 100644 --- a/engine/e2e-test/api/files/test_api_get_list_file.py +++ b/engine/e2e-test/api/files/test_api_get_list_file.py @@ -2,6 +2,7 @@ import requests from utils.test_runner import start_server, stop_server import os +import platform import jsonschema from utils.logger import log_response from utils.assertion import assert_equal @@ -22,6 +23,7 @@ def setup_and_teardown(self): # Teardown stop_server() + @pytest.mark.skipif(platform.system() != "Linux", reason="Todo: fix later on Mac and Window") def test_api_get_list_file_successfully(self): # Define file path file_path = os.path.join("e2e-test", "api", "files", "blank.txt") diff --git a/engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py b/engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py index 02afe1c76..a7d511ffd 100644 --- a/engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py +++ b/engine/e2e-test/runner/cortex-llamacpp-e2e-nightly.py @@ -27,7 +27,7 @@ from api.files.test_api_create_file import TestApiCreateFile from api.files.test_api_get_file import TestApiGetFile from api.files.test_api_get_list_file import TestApiGetListFile -from api.files.test_api_create_file import TestApiCreateFile +from api.files.test_api_delete_file import TestApiDeleteFile ### from cli.engines.test_cli_engine_get import TestCliEngineGet diff --git a/engine/e2e-test/runner/main.py b/engine/e2e-test/runner/main.py index 354e61799..a10bf012f 100644 --- a/engine/e2e-test/runner/main.py +++ b/engine/e2e-test/runner/main.py @@ -27,7 +27,7 @@ from api.files.test_api_create_file import TestApiCreateFile from api.files.test_api_get_file import TestApiGetFile from api.files.test_api_get_list_file import TestApiGetListFile -from api.files.test_api_create_file import TestApiCreateFile +from api.files.test_api_delete_file import TestApiDeleteFile ### from cli.engines.test_cli_engine_get import TestCliEngineGet From c69414fb86eebbaf143727f7d310fecb6e864952 Mon Sep 17 00:00:00 2001 From: Harry Le Date: Thu, 6 Mar 2025 12:28:04 +0700 Subject: [PATCH 10/11] test: fix --- engine/e2e-test/api/files/test_api_delete_file.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/e2e-test/api/files/test_api_delete_file.py b/engine/e2e-test/api/files/test_api_delete_file.py index b59ce17e2..9cd651833 100644 --- a/engine/e2e-test/api/files/test_api_delete_file.py +++ b/engine/e2e-test/api/files/test_api_delete_file.py @@ -5,7 +5,7 @@ import jsonschema from utils.logger import log_response from utils.assertion import assert_equal -import fnmatch +import platform class TestApiDeleteFile: @@ -21,7 +21,8 @@ def setup_and_teardown(self): # Teardown stop_server() - + + @pytest.mark.skipif(platform.system() != "Linux", reason="Todo: fix later on Mac and Window") def test_api_del_file_successfully(self): # Define file path file_path = os.path.join("e2e-test", "api", "files", "blank.txt") From 98b809adcee4d20395e04ddf08561c467163e0a7 Mon Sep 17 00:00:00 2001 From: Harry Le Date: Thu, 6 Mar 2025 15:49:22 +0700 Subject: [PATCH 11/11] test: update workflow --- .github/workflows/cortex-cpp-quality-gate.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cortex-cpp-quality-gate.yml b/.github/workflows/cortex-cpp-quality-gate.yml index 64841bb4d..39c5e7b42 100644 --- a/.github/workflows/cortex-cpp-quality-gate.yml +++ b/.github/workflows/cortex-cpp-quality-gate.yml @@ -247,12 +247,18 @@ jobs: cd engine make package + - name: Upload E2E Log + if: failure() + uses: actions/upload-artifact@v4 + with: + name: e2e-log-${{ matrix.os }}-${{ matrix.name }} + path: ./engine/e2e-test/logs + - name: Upload Artifact - if: always() uses: actions/upload-artifact@v4 with: name: cortex-${{ matrix.os }}-${{ matrix.name }} - path: ./engine/e2e-test/logs + path: ./engine/cortex - name: Upload windows ccache to s3 continue-on-error: true