feat(boot-test): test.yaml unboundPorts for ports opened only when a player connects
Some servers open a published port only once a player connects (through a proxy, for example), so the boot test's port check can't see it after boot. A template lists those ports as unboundPorts in its test.yaml, with the reason. The first template that needs it lists one UDP port, until a real client confirms how players reach it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0dc784dfa2
commit
d225e49a8a
4 files changed
+34
No files matched your search
@@ -136,12 +136,22 @@ func bootTestPayload(gamesDir, id string, fillBlank bool) (map[string]any, error
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Once up, the server must listen on what nodes publish: the container side of every default port
|
// Once up, the server must listen on what nodes publish: the container side of every default port
|
||||||
|
// test.yaml's unboundPorts are published but only opened once a player connects; each is listed by
|
||||||
|
// hand, with the reason in a comment
|
||||||
|
unbound := map[string]bool{}
|
||||||
|
if list, ok := test["unboundPorts"].([]any); ok {
|
||||||
|
for _, p := range list {
|
||||||
|
unbound[fmt.Sprint(p)] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
expectPorts := []any{}
|
expectPorts := []any{}
|
||||||
if ports, ok := g["defaultPorts"].([]any); ok {
|
if ports, ok := g["defaultPorts"].([]any); ok {
|
||||||
for _, p := range ports {
|
for _, p := range ports {
|
||||||
|
if !unbound[fmt.Sprint(p)] {
|
||||||
expectPorts = append(expectPorts, fmt.Sprint(p))
|
expectPorts = append(expectPorts, fmt.Sprint(p))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return map[string]any{
|
return map[string]any{
|
||||||
"command": "DEPLOY_SERVER",
|
"command": "DEPLOY_SERVER",
|
||||||
|
|||||||
@@ -106,3 +106,18 @@ func TestBootTestPayloadAsksForPublishedPortsAndHold(t *testing.T) {
|
|||||||
t.Errorf("missing secret: %v", err)
|
t.Errorf("missing secret: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBootTestPayloadLeavesOutUnboundPorts(t *testing.T) {
|
||||||
|
dir := t.TempDir()
|
||||||
|
game := filepath.Join(dir, "example")
|
||||||
|
os.MkdirAll(game, 0o755)
|
||||||
|
os.WriteFile(filepath.Join(game, "game.yaml"), []byte("id: example\nname: Example\ndefaultDockerImage: x\ndefaultPorts:\n - 30000/tcp\n - 30001/udp\n"), 0o644)
|
||||||
|
os.WriteFile(filepath.Join(game, "test.yaml"), []byte("unboundPorts:\n - 30001/udp\n"), 0o644)
|
||||||
|
p, err := bootTestPayload(dir, "example", false)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if ports := p["expectPorts"].([]any); len(ports) != 1 || ports[0] != "30000/tcp" {
|
||||||
|
t.Errorf("expectPorts %v", ports)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,3 +4,7 @@ config:
|
|||||||
EULA: true
|
EULA: true
|
||||||
readyExample: '[21:37:42 INFO]: Done (16.390s)! For help, type "help"'
|
readyExample: '[21:37:42 INFO]: Done (16.390s)! For help, type "help"'
|
||||||
timeoutSec: 900
|
timeoutSec: 900
|
||||||
|
# Bedrock players go through Geyser's NetherNet transport (see JVM_OPTS), which opens no UDP socket at
|
||||||
|
# startup: after boot the server listens on 25565/tcp and 19132/tcp only. To verify with a Bedrock client.
|
||||||
|
unboundPorts:
|
||||||
|
- 19132/udp
|
||||||
@@ -33,6 +33,11 @@
|
|||||||
"minimum": 10,
|
"minimum": 10,
|
||||||
"maximum": 3600
|
"maximum": 3600
|
||||||
},
|
},
|
||||||
|
"unboundPorts": {
|
||||||
|
"description": "Published ports the server only opens once a player connects, so the boot test doesn't expect them open. Each one exactly as in defaultPorts, with the reason in a comment.",
|
||||||
|
"type": "array",
|
||||||
|
"items": { "type": "string" }
|
||||||
|
},
|
||||||
"holdSec": {
|
"holdSec": {
|
||||||
"description": "How long the server must stay up after its ready line to pass (default 60). Its published ports are checked after it.",
|
"description": "How long the server must stay up after its ready line to pass (default 60). Its published ports are checked after it.",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
|||||||
Reference in new issue
Block a user