Add the pinned Laya HTTP ranker and production composition, configure the CPU Compose service and cache, and document operations. Cover protocol validation, generation orchestration, sanitized logging, and Compose wiring. Refs #17 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
77 lines
2.2 KiB
Go
77 lines
2.2 KiB
Go
package server
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
func TestStandardComposeRunsLayaOnCPUAndKeepsOllamaOptional(t *testing.T) {
|
|
data, err := os.ReadFile("../../../docker-compose.yml")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var compose struct {
|
|
Services map[string]struct {
|
|
Image string `yaml:"image"`
|
|
Build any `yaml:"build"`
|
|
Environment map[string]string `yaml:"environment"`
|
|
Profiles []string `yaml:"profiles"`
|
|
} `yaml:"services"`
|
|
}
|
|
if err := yaml.Unmarshal(data, &compose); err != nil {
|
|
t.Fatalf("parse docker-compose.yml: %v", err)
|
|
}
|
|
t.Run("laya is configured for CPU", func(t *testing.T) {
|
|
laya, ok := compose.Services["laya"]
|
|
if !ok {
|
|
t.Fatal("standard Compose is missing the Laya service")
|
|
}
|
|
if laya.Image == "" && laya.Build == nil {
|
|
t.Fatal("Laya service must declare an image or build")
|
|
}
|
|
if laya.Environment["LAYA_DEVICE"] != "cpu" {
|
|
t.Errorf("Laya environment=%v; want LAYA_DEVICE=cpu", laya.Environment)
|
|
}
|
|
})
|
|
t.Run("Ollama is optional", func(t *testing.T) {
|
|
ollama, ok := compose.Services["ollama"]
|
|
if !ok {
|
|
t.Fatal("optional summary Ollama service is missing")
|
|
}
|
|
if len(ollama.Profiles) == 0 {
|
|
t.Errorf("Ollama has no Compose profile and would run in the standard stack")
|
|
}
|
|
})
|
|
}
|
|
|
|
func TestProductionComposeBuildsBackendFromCurrentLocalCode(t *testing.T) {
|
|
data, err := os.ReadFile("../../../docker-compose.prod.yml")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var compose struct {
|
|
Services map[string]struct {
|
|
Image string `yaml:"image"`
|
|
Build *struct {
|
|
Context string `yaml:"context"`
|
|
Dockerfile string `yaml:"dockerfile"`
|
|
} `yaml:"build"`
|
|
} `yaml:"services"`
|
|
}
|
|
if err := yaml.Unmarshal(data, &compose); err != nil {
|
|
t.Fatalf("parse docker-compose.prod.yml: %v", err)
|
|
}
|
|
backend, ok := compose.Services["backend"]
|
|
if !ok {
|
|
t.Fatal("production Compose has no backend service")
|
|
}
|
|
if backend.Build == nil || backend.Build.Context != "./backend" {
|
|
t.Errorf("backend build=%+v; want an image built from local ./backend source", backend.Build)
|
|
}
|
|
if backend.Image == "gitea.anthonybouteiller.ovh/blomios/tradarr-backend:v1.1.0" {
|
|
t.Errorf("backend still pins historical v1.1.0 image instead of current ticket code")
|
|
}
|
|
}
|