Skip to content

Commit 0220b35

Browse files
committed
feat: add install and uninstall e2e testing
1 parent 7d30680 commit 0220b35

File tree

6 files changed

+96
-15
lines changed

6 files changed

+96
-15
lines changed

engine/controllers/command_line_parser.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,13 @@ bool CommandLineParser::SetupCommand(int argc, char** argv) {
138138
});
139139

140140
auto install_cmd = engines_cmd->add_subcommand("install", "Install engine");
141-
install_cmd->callback([] { CLI_LOG("Engine name can't be empty!"); });
142141
for (auto& engine : engine_service_.kSupportEngines) {
143142
std::string engine_name{engine};
144143
EngineInstall(install_cmd, engine_name, version);
145144
}
146145

147146
auto uninstall_cmd =
148147
engines_cmd->add_subcommand("uninstall", "Uninstall engine");
149-
uninstall_cmd->callback([] { CLI_LOG("Engine name can't be empty!"); });
150148
for (auto& engine : engine_service_.kSupportEngines) {
151149
std::string engine_name{engine};
152150
EngineUninstall(uninstall_cmd, engine_name);

engine/e2e-test/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import pytest
22
from test_api_engine_list import TestApiEngineList
33
from test_cli_engine_get import TestCliEngineGet
4+
from test_cli_engine_install import TestCliEngineInstall
45
from test_cli_engine_list import TestCliEngineList
6+
from test_cli_engine_uninstall import TestCliEngineUninstall
57

68
if __name__ == "__main__":
79
pytest.main([__file__, "-v"])

engine/e2e-test/test_cli_engine_get.py

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,52 @@
55

66

77
class TestCliEngineGet:
8+
9+
@pytest.mark.skipif(platform.system() != "Windows", reason="Windows-specific test")
10+
def test_engines_get_tensorrt_llm_should_not_be_incompatible(self):
11+
exit_code, output, error = run(
12+
"Get engine", ["engines", "get", "cortex.tensorrt-llm"]
13+
)
14+
assert exit_code == 0, f"Get engine failed with error: {error}"
15+
assert (
16+
"Incompatible" not in output
17+
), "cortex.tensorrt-llm should be Ready or Not Installed on Windows"
18+
819
@pytest.mark.skipif(platform.system() != "Windows", reason="Windows-specific test")
9-
def test_engines_list_run_successfully_on_windows(self):
10-
# TODO: implement
11-
assert 0 == 0
20+
def test_engines_get_onnx_should_not_be_incompatible(self):
21+
exit_code, output, error = run("Get engine", ["engines", "get", "cortex.onnx"])
22+
assert exit_code == 0, f"Get engine failed with error: {error}"
23+
assert (
24+
"Incompatible" not in output
25+
), "cortex.onnx should be Ready or Not Installed on Windows"
26+
27+
def test_engines_get_llamacpp_should_not_be_incompatible(self):
28+
exit_code, output, error = run(
29+
"Get engine", ["engines", "get", "cortex.llamacpp"]
30+
)
31+
assert exit_code == 0, f"Get engine failed with error: {error}"
32+
assert (
33+
"Incompatible" not in output
34+
), "cortex.llamacpp should be compatible for Windows, MacOs and Linux"
1235

1336
@pytest.mark.skipif(platform.system() != "Darwin", reason="macOS-specific test")
14-
def test_engines_get_run_successfully_on_macos(self):
15-
exit_code, output, error = run("Get engine", ["engines", "get", "cortex.llamacpp"])
37+
def test_engines_get_tensorrt_llm_should_be_incompatible_on_macos(self):
38+
exit_code, output, error = run(
39+
"Get engine", ["engines", "get", "cortex.tensorrt-llm"]
40+
)
1641
assert exit_code == 0, f"Get engine failed with error: {error}"
42+
assert (
43+
"Incompatible" in output
44+
), "cortex.tensorrt-llm should be Incompatible on MacOS"
1745

1846
@pytest.mark.skipif(platform.system() != "Darwin", reason="macOS-specific test")
19-
def test_engines_get_llamacpp_on_macos(self):
20-
exit_code, output, error = run("Get engine", ["engines", "get", "cortex.llamacpp"])
47+
def test_engines_get_onnx_should_be_incompatible_on_macos(self):
48+
exit_code, output, error = run("Get engine", ["engines", "get", "cortex.onnx"])
2149
assert exit_code == 0, f"Get engine failed with error: {error}"
22-
assert "Incompatible" not in output, f"cortex.llamacpp can only be Ready or Not Installed"
50+
assert "Incompatible" in output, "cortex.onnx should be Incompatible on MacOS"
2351

2452
@pytest.mark.skipif(platform.system() != "Linux", reason="Linux-specific test")
25-
def test_engines_list_run_successfully_on_linux(self):
26-
# TODO: implement
27-
assert 0 == 0
53+
def test_engines_get_onnx_should_be_incompatible_on_linux(self):
54+
exit_code, output, error = run("Get engine", ["engines", "get", "cortex.onnx"])
55+
assert exit_code == 0, f"Get engine failed with error: {error}"
56+
assert "Incompatible" in output, "cortex.onnx should be Incompatible on Linux"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import platform
2+
3+
import pytest
4+
from test_runner import run
5+
6+
7+
class TestCliEngineInstall:
8+
9+
def test_engines_install_llamacpp_should_be_successfully(self):
10+
exit_code, output, error = run(
11+
"Install Engine", ["engines", "install", "cortex.llamacpp"]
12+
)
13+
assert "Download" in output, "Should display downloading message"
14+
assert exit_code == 0, f"Install engine failed with error: {error}"
15+
16+
@pytest.mark.skipif(platform.system() != "Darwin", reason="macOS-specific test")
17+
def test_engines_install_onnx_on_macos_should_be_failed(self):
18+
exit_code, output, error = run(
19+
"Install Engine", ["engines", "install", "cortex.onnx"]
20+
)
21+
assert "No variant found" in output, "Should display error message"
22+
assert exit_code == 0, f"Install engine failed with error: {error}"
23+
24+
@pytest.mark.skipif(platform.system() != "Darwin", reason="macOS-specific test")
25+
def test_engines_install_onnx_on_tensorrt_should_be_failed(self):
26+
exit_code, output, error = run(
27+
"Install Engine", ["engines", "install", "cortex.tensorrt-llm"]
28+
)
29+
assert "No variant found" in output, "Should display error message"
30+
assert exit_code == 0, f"Install engine failed with error: {error}"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import pytest
2+
from test_runner import run
3+
4+
5+
class TestCliEngineUninstall:
6+
7+
@pytest.fixture(autouse=True)
8+
def setup_and_teardown(self):
9+
# Setup
10+
# Preinstall llamacpp engine
11+
run("Install Engine", ["engines", "install", "cortex.llamacpp"])
12+
13+
yield
14+
15+
# Teardown
16+
# Clean up, removing installed engine
17+
run("Uninstall Engine", ["engines", "uninsatll", "cortex.llamacpp"])
18+
19+
def test_engines_uninstall_llamacpp_should_be_successfully(self):
20+
exit_code, output, error = run(
21+
"Uninstall engine", ["engines", "uninstall", "cortex.llamacpp"]
22+
)
23+
assert "Engine cortex.llamacpp uninstalled successfully!" in output
24+
assert exit_code == 0, f"Install engine failed with error: {error}"

engine/services/engine_service.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ std::vector<EngineInfo> EngineService::GetEngineInfoList() const {
7171
}
7272

7373
void EngineService::UninstallEngine(const std::string& engine) {
74-
CTL_INF("Uninstall engine " + engine);
75-
7674
// TODO: Unload the model which is currently running on engine_
7775

7876
// TODO: Unload engine if is loaded

0 commit comments

Comments
 (0)