Initial upload to Gitea
This commit is contained in:
1 parent
78193254ad
commit
8478998cae
1485 files changed
+461025
-42348
No files matched your search
+345
-59
@@ -1,11 +1,78 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestShellConsoleCommandBoundsOutput(t *testing.T) {
|
||||
binDir := t.TempDir()
|
||||
stub := "#!/bin/sh\n" +
|
||||
"[ \"$1\" = exec ] || exit 1\n" +
|
||||
"printf 'earliest stdout\\n%200000s latest stdout\\n' x\n" +
|
||||
"printf 'earliest stderr\\n%200000s latest stderr\\n' x >&2\n"
|
||||
if err := os.WriteFile(filepath.Join(binDir, "docker"), []byte(stub), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Setenv("PATH", binDir+string(os.PathListSeparator)+os.Getenv("PATH"))
|
||||
tail := &logTail{recentN: logTailRecentMaxLines}
|
||||
a := &Agent{logs: &logManager{tails: map[string]*logTail{"fixture": tail}}}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
if code, err := a.executeShellConsoleCommand(ctx, "fixture", "fixture command"); err != nil || code != 0 {
|
||||
t.Fatalf("command failed: exit=%d, err=%v", code, err)
|
||||
}
|
||||
output := strings.Join(tail.snapshotRecent(10), "\n")
|
||||
for _, expected := range []string{"command output truncated", "latest stdout", "latest stderr"} {
|
||||
if !strings.Contains(output, expected) {
|
||||
t.Errorf("missing %q from captured output", expected)
|
||||
}
|
||||
}
|
||||
if strings.Contains(output, "earliest") || len(output) > 2*consoleExecOutputLimit+128 {
|
||||
t.Errorf("captured output did not retain only the bounded tail (%d bytes)", len(output))
|
||||
}
|
||||
}
|
||||
|
||||
func TestShellConsoleCommandOnlyRetriesMissingShell(t *testing.T) {
|
||||
for _, scenario := range []struct {
|
||||
name string
|
||||
diagnostic string
|
||||
wantShells string
|
||||
wantExit int
|
||||
}{
|
||||
{"command exited", "sh: 1: example-command: not found", "sh\n", 127},
|
||||
{"shell missing", `OCI runtime exec failed: exec failed: unable to start container process: exec: "sh": executable file not found in $PATH: unknown`, "sh\n/bin/sh\n", 0},
|
||||
} {
|
||||
t.Run(scenario.name, func(t *testing.T) {
|
||||
binDir := t.TempDir()
|
||||
trace := filepath.Join(binDir, "calls")
|
||||
stub := "#!/bin/sh\nprintf '%s\\n' \"$3\" >> \"$CONSOLE_TEST_TRACE\"\n" +
|
||||
"[ \"$3\" = sh ] || exit 0\nprintf '%s\\n' \"$CONSOLE_TEST_STDERR\" >&2\nexit 127\n"
|
||||
if err := os.WriteFile(filepath.Join(binDir, "docker"), []byte(stub), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Setenv("PATH", binDir+string(os.PathListSeparator)+os.Getenv("PATH"))
|
||||
t.Setenv("CONSOLE_TEST_TRACE", trace)
|
||||
t.Setenv("CONSOLE_TEST_STDERR", scenario.diagnostic)
|
||||
a := &Agent{logs: &logManager{tails: map[string]*logTail{"fixture": {recentN: logTailRecentMaxLines}}}}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
if code, err := a.executeShellConsoleCommand(ctx, "fixture", "fixture command"); err != nil || code != scenario.wantExit {
|
||||
t.Fatalf("exit=%d, err=%v; want exit=%d", code, err, scenario.wantExit)
|
||||
}
|
||||
if got, err := os.ReadFile(trace); err != nil || string(got) != scenario.wantShells {
|
||||
t.Fatalf("shell attempts = %q (%v); want %q", got, err, scenario.wantShells)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsTransientDockerPullError(t *testing.T) {
|
||||
transient := []string{
|
||||
`failed to pull image eclipse-temurin:17-jre: failed to copy: httpReadSeeker: failed open: failed to do request: local error: tls: bad record MAC`,
|
||||
@@ -95,6 +162,88 @@ func TestParseDockerLogSnapshotEntriesKeepsTimestamps(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestConsoleHistoryBoundsPersistedBytes(t *testing.T) {
|
||||
filePath := filepath.Join(t.TempDir(), "fixture.log")
|
||||
oldLine := strings.Repeat("x", consolePersistMaxBytes+32)
|
||||
if err := os.WriteFile(filePath, []byte(oldLine+"\nlatest saved line\n"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tail := &logTail{persistPath: filePath, persistLines: 2, persistLineTotal: 2}
|
||||
if got, end := tail.readPersistedSnapshot(5000); len(got) != 1 || got[0] != "latest saved line" || end != 2 {
|
||||
t.Fatalf("bounded snapshot: got %d lines, want the most recent complete line", len(got))
|
||||
}
|
||||
tail.appendPersistedLines([]string{"new output"})
|
||||
info, err := os.Stat(filePath)
|
||||
if err != nil || info.Size() > consolePersistMaxBytes {
|
||||
t.Fatalf("persisted log was not rotated within its byte budget: %v (%v)", info, err)
|
||||
}
|
||||
lines, end := tail.readPersistedSnapshot(5000)
|
||||
if got := strings.Join(lines, "\n"); got != "latest saved line\nnew output" {
|
||||
t.Fatalf("persisted snapshot after rotation does not contain the two newest lines (got %d bytes)", len(got))
|
||||
}
|
||||
if end != 3 {
|
||||
t.Fatalf("rotation reused a persisted line position: got %d, want 3", end)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConsoleHistoryBoundsDockerBackfill(t *testing.T) {
|
||||
binDir := t.TempDir()
|
||||
stub := "#!/bin/sh\n" +
|
||||
"[ \"$1\" = logs ] && [ \"$2\" = --timestamps ] && [ \"$3\" = --tail ] || exit 1\n" +
|
||||
"printf '%1100000s\\nlatest stdout\\n' x\n" +
|
||||
"printf '%1100000s\\nlatest stderr\\n' x >&2\n"
|
||||
if err := os.WriteFile(filepath.Join(binDir, "docker"), []byte(stub), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Setenv("PATH", binDir+string(os.PathListSeparator)+os.Getenv("PATH"))
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
stdout, stderr := collectDockerLogTail(ctx, "fixture", 100, true)
|
||||
if stdout != "latest stdout\n" || stderr != "latest stderr\n" {
|
||||
t.Fatalf("backfill did not keep the newest complete lines: stdout=%d bytes, stderr=%d bytes", len(stdout), len(stderr))
|
||||
}
|
||||
}
|
||||
|
||||
func TestConsoleLogStreamClosesWhenTailRetires(t *testing.T) {
|
||||
const serverName = "fixture"
|
||||
tail := &logTail{name: serverName, clients: map[chan string]struct{}{}, stopCh: make(chan struct{})}
|
||||
agent := &Agent{logs: &logManager{tails: map[string]*logTail{serverName: tail}}}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||
defer cancel()
|
||||
response := httptest.NewRecorder()
|
||||
request := httptest.NewRequest("GET", "/v1/servers/fixture/logs?tail=0", nil).WithContext(ctx)
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer close(done)
|
||||
agent.handleLogsSSE(response, request, serverName)
|
||||
}()
|
||||
|
||||
tick := time.NewTicker(time.Millisecond)
|
||||
defer tick.Stop()
|
||||
for {
|
||||
tail.mu.Lock()
|
||||
subscribed := len(tail.clients) == 1
|
||||
tail.mu.Unlock()
|
||||
if subscribed {
|
||||
break
|
||||
}
|
||||
select {
|
||||
case <-tick.C:
|
||||
case <-ctx.Done():
|
||||
t.Fatal("Console stream did not subscribe")
|
||||
}
|
||||
}
|
||||
agent.logs.killTail(serverName)
|
||||
select {
|
||||
case <-done:
|
||||
if ctx.Err() != nil || !strings.Contains(response.Body.String(), "event: hello") {
|
||||
t.Fatal("Console stream did not close on retirement")
|
||||
}
|
||||
case <-ctx.Done():
|
||||
t.Fatal("retired log tail kept the Console stream open")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPterodactylRustKeepsHomeContainerVolume(t *testing.T) {
|
||||
cfg := imageConfig{
|
||||
Entrypoint: []string{"/bin/bash", "/entrypoint.sh"},
|
||||
@@ -153,6 +302,94 @@ func TestRustRestartRecreatesContainer(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestContainerStartupConfirmation(t *testing.T) {
|
||||
binDir := t.TempDir()
|
||||
stub := `#!/bin/sh
|
||||
[ "$1" = inspect ] || exit 1
|
||||
printf '%s\n' "$ADPANEL_TEST_DOCKER_STATUS"
|
||||
exit "$ADPANEL_TEST_DOCKER_EXIT_CODE"
|
||||
`
|
||||
if err := os.WriteFile(filepath.Join(binDir, "docker"), []byte(stub), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Setenv("PATH", binDir+string(os.PathListSeparator)+os.Getenv("PATH"))
|
||||
for _, testCase := range []struct {
|
||||
name string
|
||||
status string
|
||||
exitCode string
|
||||
wantErr string
|
||||
}{
|
||||
{name: "running", status: "running 0", exitCode: "0"},
|
||||
{name: "stuck in created", status: "created 0", exitCode: "0", wantErr: "status: created"},
|
||||
{name: "failed inspection", status: "running 0", exitCode: "1", wantErr: "could not be confirmed"},
|
||||
} {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
t.Setenv("ADPANEL_TEST_DOCKER_STATUS", testCase.status)
|
||||
t.Setenv("ADPANEL_TEST_DOCKER_EXIT_CODE", testCase.exitCode)
|
||||
ctx := context.WithValue(t.Context(), confirmDockerStartKey{}, true)
|
||||
err := (&Agent{}).verifyContainerHealthyAfterStart(ctx, "fixture")
|
||||
if testCase.wantErr == "" {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
} else if err == nil || !strings.Contains(err.Error(), testCase.wantErr) {
|
||||
t.Fatalf("got %v, want error containing %q", err, testCase.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestContainerResourceMinimums(testCtx *testing.T) {
|
||||
for _, testCase := range []struct {
|
||||
ramMb int
|
||||
cpu float64
|
||||
invalid bool
|
||||
}{
|
||||
{ramMb: 0, cpu: 0},
|
||||
{ramMb: 5, cpu: 1, invalid: true},
|
||||
{ramMb: 6, cpu: 0.005, invalid: true},
|
||||
{ramMb: 6, cpu: 0.01},
|
||||
} {
|
||||
limits := &resourceLimits{RamMb: &testCase.ramMb, CpuCores: &testCase.cpu}
|
||||
if reason := validateResourcePerformanceLimits(limits); (reason != "") != testCase.invalid {
|
||||
testCtx.Fatalf("RAM %d, CPU %g: got %q, invalid=%v", testCase.ramMb, testCase.cpu, reason, testCase.invalid)
|
||||
}
|
||||
if testCase.invalid || testCase.ramMb == 0 {
|
||||
continue
|
||||
}
|
||||
host := buildStructuredHostConfig(nil, nil, limits, "no", false)
|
||||
if host.Memory != 6*1024*1024 || host.MemoryReservation != host.Memory || host.CpuQuota != 1000 {
|
||||
testCtx.Fatalf("invalid Docker limits at minimums: %+v", host)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestServerNetworkQuotaSurvivesContainerRestartAndIdleCleanup(t *testing.T) {
|
||||
cache := newServerResourceStatsCache(0, 0)
|
||||
agent := &Agent{resourceStats: cache}
|
||||
meta := map[string]any{"resources": map[string]any{"networkInboundLimitMb": 1, "networkResetMinutes": 60}}
|
||||
entry := cache.get("fixture")
|
||||
now := time.Now()
|
||||
started := now.Add(-30 * time.Minute)
|
||||
entry.touchedAt = started
|
||||
entry.updateNetworkCounters("original", 1024*1024-1, 0, started, time.Hour)
|
||||
if err := agent.prepareServerResourceStart("fixture", meta); err != nil {
|
||||
t.Fatalf("restart before exhaustion refused: %v", err)
|
||||
}
|
||||
entry.updateNetworkCounters("replacement", 1, 0, started.Add(time.Minute), time.Hour)
|
||||
cache.cleanup(10 * time.Minute)
|
||||
if err := agent.prepareServerResourceStart("fixture", meta); !errors.Is(err, errNetworkQuotaExceeded) {
|
||||
t.Fatalf("restart after exhaustion: got %v, want %v", err, errNetworkQuotaExceeded)
|
||||
}
|
||||
if err := agent.verifyServerNetworkQuota("fixture", meta, started.Add(time.Hour)); err != nil {
|
||||
t.Fatalf("start after quota expiry refused: %v", err)
|
||||
}
|
||||
cache.forget("fixture")
|
||||
if err := agent.prepareServerResourceStart("fixture", meta); err != nil {
|
||||
t.Fatalf("new server inherited deleted server's quota: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRustGetsDefaultHighFileLimit(t *testing.T) {
|
||||
resources := withRuntimeDefaultFileLimit(nil, "rust", "ghcr.io/pterodactyl/games:rust")
|
||||
if resources == nil || resources.FileLimit == nil || *resources.FileLimit != maxFileLimit {
|
||||
@@ -171,67 +408,105 @@ func TestRustGetsDefaultHighFileLimit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCfxRuntimeLayoutStaysInsideMountedServerDir(t *testing.T) {
|
||||
serverDir := t.TempDir()
|
||||
if err := ensureDir(filepath.Join(serverDir, "serverfiles")); err != nil {
|
||||
t.Fatalf("failed to create nested legacy dir: %v", err)
|
||||
}
|
||||
if err := writeFileNoFollow(filepath.Join(serverDir, "serverfiles", "server.cfg"), []byte("sv_maxclients 32\n"), 0o644); err != nil {
|
||||
t.Fatalf("failed to create legacy cfg: %v", err)
|
||||
}
|
||||
|
||||
runtimeObj := map[string]any{
|
||||
"volumes": []any{"{BOT_DIR}:/serverdata"},
|
||||
"workdir": "/serverdata",
|
||||
"install": map[string]any{
|
||||
"runtimePath": "/serverdata",
|
||||
},
|
||||
"env": map[string]any{
|
||||
"DATA_DIR": "/serverdata",
|
||||
"SERVER_DIR": "/serverdata/serverfiles",
|
||||
"DATA_PERM": "770",
|
||||
"SERVER_KEY": "keep-me",
|
||||
"START_VARS": "+set gamename rdr3",
|
||||
"GAME_CONFIG": "old.cfg",
|
||||
},
|
||||
}
|
||||
|
||||
if !normalizeCfxRuntimeLayout("redm", runtimeObj, serverDir) {
|
||||
t.Fatalf("expected legacy CFX runtime to be normalized")
|
||||
}
|
||||
|
||||
volumes := runtimeObj["volumes"].([]any)
|
||||
if len(volumes) != 1 || volumes[0] != "{BOT_DIR}:/serverdata/serverfiles" {
|
||||
t.Fatalf("expected server root to be mounted directly to CFX server dir, got %#v", volumes)
|
||||
}
|
||||
if runtimeObj["workdir"] != "/serverdata/serverfiles" {
|
||||
t.Fatalf("expected CFX workdir inside mounted server dir, got %#v", runtimeObj["workdir"])
|
||||
}
|
||||
if runtimeObj["runAsRoot"] != true {
|
||||
t.Fatalf("expected CFX entrypoint to keep image root bootstrap enabled, got %#v", runtimeObj["runAsRoot"])
|
||||
}
|
||||
|
||||
env := runtimeObj["env"].(map[string]string)
|
||||
for key, want := range map[string]string{
|
||||
"DATA_DIR": "/serverdata/serverfiles",
|
||||
"SERVER_DIR": "/serverdata/serverfiles",
|
||||
"HOME": "/serverdata/serverfiles",
|
||||
"DATA_PERM": "777",
|
||||
"GAME_CONFIG": "server.cfg",
|
||||
} {
|
||||
if got := env[key]; got != want {
|
||||
t.Fatalf("expected env %s=%q, got %q", key, want, got)
|
||||
newFixture := func(t *testing.T) (string, map[string]any) {
|
||||
t.Helper()
|
||||
serverDir := t.TempDir()
|
||||
if err := ensureDir(filepath.Join(serverDir, "serverfiles")); err != nil {
|
||||
t.Fatalf("failed to create nested legacy dir: %v", err)
|
||||
}
|
||||
if err := writeFileNoFollow(filepath.Join(serverDir, "serverfiles", "server.cfg"), []byte("sv_maxclients 32\n"), 0o644); err != nil {
|
||||
t.Fatalf("failed to create legacy cfg: %v", err)
|
||||
}
|
||||
runtimeObj := map[string]any{
|
||||
"volumes": []any{"{BOT_DIR}:/serverdata"},
|
||||
"workdir": "/serverdata",
|
||||
"install": map[string]any{
|
||||
"runtimePath": "/serverdata",
|
||||
},
|
||||
"env": map[string]any{
|
||||
"DATA_DIR": "/serverdata",
|
||||
"SERVER_DIR": "/serverdata/serverfiles",
|
||||
"DATA_PERM": "770",
|
||||
"SERVER_KEY": "keep-me",
|
||||
"START_VARS": "+set gamename rdr3",
|
||||
"GAME_CONFIG": "old.cfg",
|
||||
},
|
||||
}
|
||||
return serverDir, runtimeObj
|
||||
}
|
||||
if env["SERVER_KEY"] != "keep-me" || env["START_VARS"] != "+set gamename rdr3" {
|
||||
t.Fatalf("expected CFX-specific user env to be preserved, got %#v", env)
|
||||
}
|
||||
install := runtimeObj["install"].(map[string]any)
|
||||
if install["runtimePath"] != "/serverdata/serverfiles" || install["mountPath"] != "/mnt/server" {
|
||||
t.Fatalf("expected CFX install paths to stay aligned to mounted dir, got %#v", install)
|
||||
}
|
||||
if !pathExists(filepath.Join(serverDir, "server.cfg")) {
|
||||
t.Fatalf("expected nested legacy serverfiles content to be migrated into server root")
|
||||
}
|
||||
|
||||
t.Run("default denies template root", func(t *testing.T) {
|
||||
serverDir, runtimeObj := newFixture(t)
|
||||
if !normalizeCfxRuntimeLayout("redm", runtimeObj, serverDir) {
|
||||
t.Fatalf("expected legacy CFX runtime to be normalized")
|
||||
}
|
||||
|
||||
volumes := runtimeObj["volumes"].([]any)
|
||||
if len(volumes) != 1 || volumes[0] != "{BOT_DIR}:/serverdata/serverfiles" {
|
||||
t.Fatalf("expected server root to be mounted directly to CFX server dir, got %#v", volumes)
|
||||
}
|
||||
if runtimeObj["workdir"] != "/serverdata/serverfiles" {
|
||||
t.Fatalf("expected CFX workdir inside mounted server dir, got %#v", runtimeObj["workdir"])
|
||||
}
|
||||
if runtimeObj["runAsRoot"] != nil {
|
||||
t.Fatalf("expected CFX layout normalization to stop granting root by default, got %#v", runtimeObj["runAsRoot"])
|
||||
}
|
||||
|
||||
env := runtimeObj["env"].(map[string]string)
|
||||
for key, want := range map[string]string{
|
||||
"DATA_DIR": "/serverdata/serverfiles",
|
||||
"SERVER_DIR": "/serverdata/serverfiles",
|
||||
"HOME": "/serverdata/serverfiles",
|
||||
"DATA_PERM": "777",
|
||||
"GAME_CONFIG": "server.cfg",
|
||||
} {
|
||||
if got := env[key]; got != want {
|
||||
t.Fatalf("expected env %s=%q, got %q", key, want, got)
|
||||
}
|
||||
}
|
||||
if env["SERVER_KEY"] != "keep-me" || env["START_VARS"] != "+set gamename rdr3" {
|
||||
t.Fatalf("expected CFX-specific user env to be preserved, got %#v", env)
|
||||
}
|
||||
install := runtimeObj["install"].(map[string]any)
|
||||
if install["runtimePath"] != "/serverdata/serverfiles" || install["mountPath"] != "/mnt/server" {
|
||||
t.Fatalf("expected CFX install paths to stay aligned to mounted dir, got %#v", install)
|
||||
}
|
||||
if !pathExists(filepath.Join(serverDir, "server.cfg")) {
|
||||
t.Fatalf("expected nested legacy serverfiles content to be migrated into server root")
|
||||
}
|
||||
if _, err := os.Lstat(filepath.Join(serverDir, "serverfiles")); !os.IsNotExist(err) {
|
||||
t.Fatalf("expected empty legacy directory to be removed: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("linked legacy directory is not migrated", func(t *testing.T) {
|
||||
serverDir, otherDir := t.TempDir(), t.TempDir()
|
||||
otherFile := filepath.Join(otherDir, "fixture.txt")
|
||||
if err := os.WriteFile(otherFile, []byte("unrelated"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Symlink(otherDir, filepath.Join(serverDir, "serverfiles")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
normalizeCfxRuntimeLayout("redm", map[string]any{}, serverDir)
|
||||
if data, err := os.ReadFile(otherFile); err != nil || string(data) != "unrelated" {
|
||||
t.Fatalf("migration must leave the unrelated directory untouched, got %q: %v", data, err)
|
||||
}
|
||||
if _, err := os.Lstat(filepath.Join(serverDir, "fixture.txt")); !os.IsNotExist(err) {
|
||||
t.Fatalf("migration must not copy files from a linked legacy directory: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("operator opt-in keeps legacy root bootstrap", func(t *testing.T) {
|
||||
t.Setenv("ADPANEL_ALLOW_TEMPLATE_ROOT", "1")
|
||||
serverDir, runtimeObj := newFixture(t)
|
||||
if !normalizeCfxRuntimeLayout("redm", runtimeObj, serverDir) {
|
||||
t.Fatalf("expected legacy CFX runtime to be normalized")
|
||||
}
|
||||
if runtimeObj["runAsRoot"] != true {
|
||||
t.Fatalf("expected image root bootstrap to be kept under ADPANEL_ALLOW_TEMPLATE_ROOT=1, got %#v", runtimeObj["runAsRoot"])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestLegacyRustRuntimeMigratesToPterodactyl(t *testing.T) {
|
||||
@@ -266,3 +541,14 @@ func TestLegacyRustRuntimeMigratesToPterodactyl(t *testing.T) {
|
||||
t.Fatalf("expected home/container volume, got %#v", volumes)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRustMigrationPreservesCustomTemplate(t *testing.T) {
|
||||
for _, template := range []string{"rust-custom", ""} {
|
||||
runtime := map[string]any{"image": "didstopia/rust-server", "tag": "full", "workdir": "/custom"}
|
||||
meta := map[string]any{"type": "rust-custom", "template": template, "runtime": runtime}
|
||||
if normalizeRustRuntimeForPterodactyl(meta) || meta["type"] != "rust-custom" || meta["template"] != template ||
|
||||
runtime["image"] != "didstopia/rust-server" || runtime["workdir"] != "/custom" {
|
||||
t.Fatalf("a shared image must not replace an installed custom runtime: %v", meta)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user