From ba0f877185441650ab5f73ef81f3d99163d76493 Mon Sep 17 00:00:00 2001 From: LordMathis Date: Wed, 24 Sep 2025 21:35:44 +0200 Subject: [PATCH] Fix tests --- pkg/instance/instance_test.go | 84 +++++++++++++++++++++++++++++----- pkg/instance/timeout_test.go | 48 ++++++++++++++----- pkg/manager/manager_test.go | 24 +++++++--- pkg/manager/operations_test.go | 8 +++- pkg/manager/timeout_test.go | 4 +- 5 files changed, 134 insertions(+), 34 deletions(-) diff --git a/pkg/instance/instance_test.go b/pkg/instance/instance_test.go index 9ce2d61..fc41a94 100644 --- a/pkg/instance/instance_test.go +++ b/pkg/instance/instance_test.go @@ -12,8 +12,18 @@ import ( func TestNewInstance(t *testing.T) { backendConfig := &config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{ + Command: "llama-server", + Args: []string{}, + }, + MLX: config.BackendSettings{ + Command: "mlx_lm.server", + Args: []string{}, + }, + VLLM: config.BackendSettings{ + Command: "vllm", + Args: []string{"serve"}, + }, } globalSettings := &config.InstancesConfig{ @@ -66,8 +76,18 @@ func TestNewInstance(t *testing.T) { func TestNewInstance_WithRestartOptions(t *testing.T) { backendConfig := &config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{ + Command: "llama-server", + Args: []string{}, + }, + MLX: config.BackendSettings{ + Command: "mlx_lm.server", + Args: []string{}, + }, + VLLM: config.BackendSettings{ + Command: "vllm", + Args: []string{"serve"}, + }, } globalSettings := &config.InstancesConfig{ @@ -112,8 +132,18 @@ func TestNewInstance_WithRestartOptions(t *testing.T) { func TestSetOptions(t *testing.T) { backendConfig := &config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{ + Command: "llama-server", + Args: []string{}, + }, + MLX: config.BackendSettings{ + Command: "mlx_lm.server", + Args: []string{}, + }, + VLLM: config.BackendSettings{ + Command: "vllm", + Args: []string{"serve"}, + }, } globalSettings := &config.InstancesConfig{ @@ -163,8 +193,18 @@ func TestSetOptions(t *testing.T) { func TestGetProxy(t *testing.T) { backendConfig := &config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{ + Command: "llama-server", + Args: []string{}, + }, + MLX: config.BackendSettings{ + Command: "mlx_lm.server", + Args: []string{}, + }, + VLLM: config.BackendSettings{ + Command: "vllm", + Args: []string{"serve"}, + }, } globalSettings := &config.InstancesConfig{ @@ -205,8 +245,18 @@ func TestGetProxy(t *testing.T) { func TestMarshalJSON(t *testing.T) { backendConfig := &config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{ + Command: "llama-server", + Args: []string{}, + }, + MLX: config.BackendSettings{ + Command: "mlx_lm.server", + Args: []string{}, + }, + VLLM: config.BackendSettings{ + Command: "vllm", + Args: []string{"serve"}, + }, } globalSettings := &config.InstancesConfig{ @@ -364,8 +414,18 @@ func TestCreateInstanceOptionsValidation(t *testing.T) { } backendConfig := &config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{ + Command: "llama-server", + Args: []string{}, + }, + MLX: config.BackendSettings{ + Command: "mlx_lm.server", + Args: []string{}, + }, + VLLM: config.BackendSettings{ + Command: "vllm", + Args: []string{"serve"}, + }, } globalSettings := &config.InstancesConfig{ diff --git a/pkg/instance/timeout_test.go b/pkg/instance/timeout_test.go index 21e3584..1171c6a 100644 --- a/pkg/instance/timeout_test.go +++ b/pkg/instance/timeout_test.go @@ -34,8 +34,12 @@ func (m *MockTimeProvider) SetTime(t time.Time) { func TestUpdateLastRequestTime(t *testing.T) { backendConfig := &config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{ + Command: "llama-server", + }, + MLX: config.BackendSettings{ + Command: "mlx_lm.server", + }, } globalSettings := &config.InstancesConfig{ @@ -60,8 +64,12 @@ func TestUpdateLastRequestTime(t *testing.T) { func TestShouldTimeout_NotRunning(t *testing.T) { backendConfig := &config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{ + Command: "llama-server", + }, + MLX: config.BackendSettings{ + Command: "mlx_lm.server", + }, } globalSettings := &config.InstancesConfig{ @@ -90,8 +98,12 @@ func TestShouldTimeout_NotRunning(t *testing.T) { func TestShouldTimeout_NoTimeoutConfigured(t *testing.T) { backendConfig := &config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{ + Command: "llama-server", + }, + MLX: config.BackendSettings{ + Command: "mlx_lm.server", + }, } globalSettings := &config.InstancesConfig{ @@ -133,8 +145,12 @@ func TestShouldTimeout_NoTimeoutConfigured(t *testing.T) { func TestShouldTimeout_WithinTimeLimit(t *testing.T) { backendConfig := &config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{ + Command: "llama-server", + }, + MLX: config.BackendSettings{ + Command: "mlx_lm.server", + }, } globalSettings := &config.InstancesConfig{ @@ -167,8 +183,12 @@ func TestShouldTimeout_WithinTimeLimit(t *testing.T) { func TestShouldTimeout_ExceedsTimeLimit(t *testing.T) { backendConfig := &config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{ + Command: "llama-server", + }, + MLX: config.BackendSettings{ + Command: "mlx_lm.server", + }, } globalSettings := &config.InstancesConfig{ @@ -207,8 +227,12 @@ func TestShouldTimeout_ExceedsTimeLimit(t *testing.T) { func TestTimeoutConfiguration_Validation(t *testing.T) { backendConfig := &config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{ + Command: "llama-server", + }, + MLX: config.BackendSettings{ + Command: "mlx_lm.server", + }, } globalSettings := &config.InstancesConfig{ diff --git a/pkg/manager/manager_test.go b/pkg/manager/manager_test.go index e022c5f..c629c63 100644 --- a/pkg/manager/manager_test.go +++ b/pkg/manager/manager_test.go @@ -16,8 +16,12 @@ import ( func TestNewInstanceManager(t *testing.T) { backendConfig := config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{ + Command: "llama-server", + }, + MLX: config.BackendSettings{ + Command: "mlx_lm.server", + }, } cfg := config.InstancesConfig{ @@ -49,8 +53,12 @@ func TestPersistence(t *testing.T) { tempDir := t.TempDir() backendConfig := config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{ + Command: "llama-server", + }, + MLX: config.BackendSettings{ + Command: "mlx_lm.server", + }, } cfg := config.InstancesConfig{ @@ -182,8 +190,12 @@ func TestShutdown(t *testing.T) { // Helper function to create a test manager with standard config func createTestManager() manager.InstanceManager { backendConfig := config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{ + Command: "llama-server", + }, + MLX: config.BackendSettings{ + Command: "mlx_lm.server", + }, } cfg := config.InstancesConfig{ diff --git a/pkg/manager/operations_test.go b/pkg/manager/operations_test.go index 87c37d4..97358c5 100644 --- a/pkg/manager/operations_test.go +++ b/pkg/manager/operations_test.go @@ -63,8 +63,12 @@ func TestCreateInstance_ValidationAndLimits(t *testing.T) { // Test max instances limit backendConfig := config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{ + Command: "llama-server", + }, + MLX: config.BackendSettings{ + Command: "mlx_lm.server", + }, } cfg := config.InstancesConfig{ PortRange: [2]int{8000, 9000}, diff --git a/pkg/manager/timeout_test.go b/pkg/manager/timeout_test.go index 91b3ad7..08d500c 100644 --- a/pkg/manager/timeout_test.go +++ b/pkg/manager/timeout_test.go @@ -14,8 +14,8 @@ import ( func TestTimeoutFunctionality(t *testing.T) { // Test timeout checker initialization backendConfig := config.BackendConfig{ - LlamaExecutable: "llama-server", - MLXLMExecutable: "mlx_lm.server", + LlamaCpp: config.BackendSettings{Command: "llama-server"}, + MLX: config.BackendSettings{Command: "mlx_lm.server"}, } cfg := config.InstancesConfig{ PortRange: [2]int{8000, 9000},