test(deploy): pin that install.sh generates config through archied setup
The bead behind this is already satisfied on main -- install.sh renders no TOML, splices nothing, calls the archied binary it just built for a fresh install, leaves an existing config alone, and fails loudly rather than writing a partial one. What was missing is that nothing checked any of it, which is how the generating branch grew back the first time it drifted: it hardcoded the GitHub token key and the Gitea host, so choosing Gitea produced a config naming a token the installer never wrote (archie-core-1786637491134-51-17a55e60). TestInstallerDelegatesConfigGenerationToArchiedSetup now pins all four, with the splice and redirection checks scoped per line so a legitimate sed or awk elsewhere in the installer stays allowed. Red-proofed in both directions: re-adding a forge table fails with "install.sh carries a TOML template", and re-adding a sed splice on config.toml fails with "install.sh splices config.toml". The non-interactive arm of the criterion was verified by running it rather than reading it: the exact invocation install.sh builds, with stdin closed, exits 0 and writes a config the real loader accepts. That run also surfaced a separate defect, filed as archie-core-6omt rather than folded in here: the cloud path pairs the ollama baseline model with provider openai, so an unattended install names openai/llama3 -- loadable, but not a model OpenAI serves, and it fails at the first chat turn long after the install reported success. Fixing that needs a decision about where an attended-free install gets its model, so it is not a patch. Verified: task check exit 0 including test:tools and test:ui.
This commit is contained in:
1 file changed
+53
@@ -2,6 +2,7 @@ package configtemplate
|
||||
|
||||
import (
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -183,3 +184,55 @@ func TestSupportedProfilesUseOneExecutionTopology(t *testing.T) {
|
||||
t.Error("systemd runbook still requires an external Compose NATS service")
|
||||
}
|
||||
}
|
||||
|
||||
// TestInstallerDelegatesConfigGenerationToArchiedSetup pins the contract the
|
||||
// installer already drifted from once: it hand-rolled a config.toml, hardcoded
|
||||
// the GitHub token key and the Gitea host, and choosing Gitea then produced a
|
||||
// config naming a token it never wrote. The durable fix is that the code writing
|
||||
// the config is the code reading it -- archied setup renders it, archied loads it
|
||||
// (docs/architecture/configuration.md) -- and nothing stopped the generating
|
||||
// branch growing back until this.
|
||||
func TestInstallerDelegatesConfigGenerationToArchiedSetup(t *testing.T) {
|
||||
source := readDeploymentFile(t, "install.sh")
|
||||
|
||||
for _, required := range []string{
|
||||
// It runs the binary it just built, so the installer cannot hold a
|
||||
// second idea of what a valid config looks like.
|
||||
`"${ARCHIE_BIN_DIR}/archied" setup`,
|
||||
// For a fresh install only: an existing config is the operator's.
|
||||
`if [ ! -f "${ARCHIE_CONFIG_DIR}/config.toml" ]; then`,
|
||||
"already exists (preserving user config)",
|
||||
// The setup run is allowed to fail, and a failure is loud. A config that
|
||||
// never gets written is the only honest outcome after that.
|
||||
"could not generate",
|
||||
} {
|
||||
if !strings.Contains(source, required) {
|
||||
t.Errorf("install.sh is missing %q", required)
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing here renders TOML or splices it afterwards. The splice check is
|
||||
// per line so a legitimate sed/awk elsewhere in the installer stays allowed.
|
||||
if strings.Contains(source, "forge_block") {
|
||||
t.Error("install.sh still carries the forge_block helper: it is what hardcoded the GitHub token key and Gitea host")
|
||||
}
|
||||
redirection := regexp.MustCompile(`>>?\s*"?[^"'\s]*config\.toml`)
|
||||
for index, line := range strings.Split(source, "\n") {
|
||||
if !strings.Contains(line, "config.toml") {
|
||||
continue
|
||||
}
|
||||
if strings.Contains(line, "sed ") || strings.Contains(line, "awk ") {
|
||||
t.Errorf("install.sh:%d splices config.toml (%s)", index+1, strings.TrimSpace(line))
|
||||
}
|
||||
if redirection.MatchString(line) {
|
||||
t.Errorf("install.sh:%d writes config.toml itself (%s)", index+1, strings.TrimSpace(line))
|
||||
}
|
||||
}
|
||||
// A TOML table header in the installer is a template by definition. The
|
||||
// systemd unit it also writes is INI, whose only sections are Unit/Service/
|
||||
// Install, so those are no part of this list.
|
||||
template := regexp.MustCompile(`(?m)^\s*\[(forge|models|providers|runners|containers|nats|web|budgets|notify|identit|chat)\]`)
|
||||
if found := template.FindString(source); found != "" {
|
||||
t.Errorf("install.sh carries a TOML template (%q): the installer must not hold its own idea of the config schema", strings.TrimSpace(found))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user