mirror of
https://github.com/lordmathis/llamactl.git
synced 2025-11-05 16:44:22 +00:00
Fix manager tests
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestInstanceTimeoutLogic(t *testing.T) {
|
func TestInstanceTimeoutLogic(t *testing.T) {
|
||||||
testManager := createTestManager()
|
testManager := createTestManager(t)
|
||||||
defer testManager.Shutdown()
|
defer testManager.Shutdown()
|
||||||
|
|
||||||
idleTimeout := 1 // 1 minute
|
idleTimeout := 1 // 1 minute
|
||||||
@@ -42,7 +42,7 @@ func TestInstanceTimeoutLogic(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestInstanceWithoutTimeoutNeverExpires(t *testing.T) {
|
func TestInstanceWithoutTimeoutNeverExpires(t *testing.T) {
|
||||||
testManager := createTestManager()
|
testManager := createTestManager(t)
|
||||||
defer testManager.Shutdown()
|
defer testManager.Shutdown()
|
||||||
|
|
||||||
noTimeoutInst := createInstanceWithTimeout(t, testManager, "no-timeout-test", "/path/to/model.gguf", nil)
|
noTimeoutInst := createInstanceWithTimeout(t, testManager, "no-timeout-test", "/path/to/model.gguf", nil)
|
||||||
@@ -64,7 +64,7 @@ func TestInstanceWithoutTimeoutNeverExpires(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEvictLRUInstance_Success(t *testing.T) {
|
func TestEvictLRUInstance_Success(t *testing.T) {
|
||||||
manager := createTestManager()
|
manager := createTestManager(t)
|
||||||
defer manager.Shutdown()
|
defer manager.Shutdown()
|
||||||
|
|
||||||
// Create 3 instances with idle timeout enabled (value doesn't matter for LRU logic)
|
// Create 3 instances with idle timeout enabled (value doesn't matter for LRU logic)
|
||||||
@@ -121,7 +121,7 @@ func TestEvictLRUInstance_Success(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEvictLRUInstance_NoRunningInstances(t *testing.T) {
|
func TestEvictLRUInstance_NoRunningInstances(t *testing.T) {
|
||||||
manager := createTestManager()
|
manager := createTestManager(t)
|
||||||
defer manager.Shutdown()
|
defer manager.Shutdown()
|
||||||
|
|
||||||
err := manager.EvictLRUInstance()
|
err := manager.EvictLRUInstance()
|
||||||
@@ -134,7 +134,7 @@ func TestEvictLRUInstance_NoRunningInstances(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEvictLRUInstance_OnlyEvictsTimeoutEnabledInstances(t *testing.T) {
|
func TestEvictLRUInstance_OnlyEvictsTimeoutEnabledInstances(t *testing.T) {
|
||||||
manager := createTestManager()
|
manager := createTestManager(t)
|
||||||
defer manager.Shutdown()
|
defer manager.Shutdown()
|
||||||
|
|
||||||
// Create mix of instances: some with timeout enabled, some disabled
|
// Create mix of instances: some with timeout enabled, some disabled
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ func TestDeleteInstance_RemovesPersistenceFile(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestConcurrentAccess(t *testing.T) {
|
func TestConcurrentAccess(t *testing.T) {
|
||||||
mgr := createTestManager()
|
mgr := createTestManager(t)
|
||||||
defer mgr.Shutdown()
|
defer mgr.Shutdown()
|
||||||
|
|
||||||
// Test concurrent operations
|
// Test concurrent operations
|
||||||
@@ -162,29 +162,8 @@ func createTestAppConfig(instancesDir string) *config.AppConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTestManager() manager.InstanceManager {
|
func createTestManager(t *testing.T) manager.InstanceManager {
|
||||||
appConfig := &config.AppConfig{
|
tempDir := t.TempDir()
|
||||||
Backends: config.BackendConfig{
|
appConfig := createTestAppConfig(tempDir)
|
||||||
LlamaCpp: config.BackendSettings{
|
|
||||||
Command: "sleep",
|
|
||||||
},
|
|
||||||
MLX: config.BackendSettings{
|
|
||||||
Command: "sleep",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Instances: config.InstancesConfig{
|
|
||||||
PortRange: [2]int{8000, 9000},
|
|
||||||
LogsDir: "/tmp/test",
|
|
||||||
InstancesDir: "/tmp/test",
|
|
||||||
MaxInstances: 10,
|
|
||||||
MaxRunningInstances: 10,
|
|
||||||
DefaultAutoRestart: true,
|
|
||||||
DefaultMaxRestarts: 3,
|
|
||||||
DefaultRestartDelay: 5,
|
|
||||||
TimeoutCheckInterval: 5,
|
|
||||||
},
|
|
||||||
LocalNode: "main",
|
|
||||||
Nodes: map[string]config.NodeConfig{},
|
|
||||||
}
|
|
||||||
return manager.New(appConfig)
|
return manager.New(appConfig)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestCreateInstance_FailsWithDuplicateName(t *testing.T) {
|
func TestCreateInstance_FailsWithDuplicateName(t *testing.T) {
|
||||||
mngr := createTestManager()
|
mngr := createTestManager(t)
|
||||||
options := &instance.Options{
|
options := &instance.Options{
|
||||||
BackendOptions: backends.Options{
|
BackendOptions: backends.Options{
|
||||||
BackendType: backends.BackendTypeLlamaCpp,
|
BackendType: backends.BackendTypeLlamaCpp,
|
||||||
@@ -36,6 +36,7 @@ func TestCreateInstance_FailsWithDuplicateName(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateInstance_FailsWhenMaxInstancesReached(t *testing.T) {
|
func TestCreateInstance_FailsWhenMaxInstancesReached(t *testing.T) {
|
||||||
|
tempDir := t.TempDir()
|
||||||
appConfig := &config.AppConfig{
|
appConfig := &config.AppConfig{
|
||||||
Backends: config.BackendConfig{
|
Backends: config.BackendConfig{
|
||||||
LlamaCpp: config.BackendSettings{
|
LlamaCpp: config.BackendSettings{
|
||||||
@@ -44,6 +45,7 @@ func TestCreateInstance_FailsWhenMaxInstancesReached(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Instances: config.InstancesConfig{
|
Instances: config.InstancesConfig{
|
||||||
PortRange: [2]int{8000, 9000},
|
PortRange: [2]int{8000, 9000},
|
||||||
|
InstancesDir: tempDir,
|
||||||
MaxInstances: 1, // Very low limit for testing
|
MaxInstances: 1, // Very low limit for testing
|
||||||
TimeoutCheckInterval: 5,
|
TimeoutCheckInterval: 5,
|
||||||
},
|
},
|
||||||
@@ -77,7 +79,7 @@ func TestCreateInstance_FailsWhenMaxInstancesReached(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateInstance_FailsWithPortConflict(t *testing.T) {
|
func TestCreateInstance_FailsWithPortConflict(t *testing.T) {
|
||||||
manager := createTestManager()
|
manager := createTestManager(t)
|
||||||
|
|
||||||
options1 := &instance.Options{
|
options1 := &instance.Options{
|
||||||
BackendOptions: backends.Options{
|
BackendOptions: backends.Options{
|
||||||
@@ -115,7 +117,7 @@ func TestCreateInstance_FailsWithPortConflict(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestInstanceOperations_FailWithNonExistentInstance(t *testing.T) {
|
func TestInstanceOperations_FailWithNonExistentInstance(t *testing.T) {
|
||||||
manager := createTestManager()
|
manager := createTestManager(t)
|
||||||
|
|
||||||
options := &instance.Options{
|
options := &instance.Options{
|
||||||
BackendOptions: backends.Options{
|
BackendOptions: backends.Options{
|
||||||
@@ -143,7 +145,7 @@ func TestInstanceOperations_FailWithNonExistentInstance(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleteInstance_RunningInstanceFails(t *testing.T) {
|
func TestDeleteInstance_RunningInstanceFails(t *testing.T) {
|
||||||
mgr := createTestManager()
|
mgr := createTestManager(t)
|
||||||
defer mgr.Shutdown()
|
defer mgr.Shutdown()
|
||||||
|
|
||||||
options := &instance.Options{
|
options := &instance.Options{
|
||||||
@@ -171,7 +173,7 @@ func TestDeleteInstance_RunningInstanceFails(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateInstance(t *testing.T) {
|
func TestUpdateInstance(t *testing.T) {
|
||||||
mgr := createTestManager()
|
mgr := createTestManager(t)
|
||||||
defer mgr.Shutdown()
|
defer mgr.Shutdown()
|
||||||
|
|
||||||
options := &instance.Options{
|
options := &instance.Options{
|
||||||
@@ -220,7 +222,7 @@ func TestUpdateInstance(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateInstance_ReleasesOldPort(t *testing.T) {
|
func TestUpdateInstance_ReleasesOldPort(t *testing.T) {
|
||||||
mgr := createTestManager()
|
mgr := createTestManager(t)
|
||||||
defer mgr.Shutdown()
|
defer mgr.Shutdown()
|
||||||
|
|
||||||
options := &instance.Options{
|
options := &instance.Options{
|
||||||
|
|||||||
Reference in New Issue
Block a user