Phase2
Some checks failed
CI / Node — lint, typecheck, test, build (push) Failing after 10s
CI / Go — node-agent tests (push) Failing after 8s
CI / Go — edge-gateway build (push) Successful in 13s

This commit is contained in:
smueller
2026-06-26 12:01:25 +02:00
parent 58961000eb
commit c4077d4673
93 changed files with 4099 additions and 165 deletions

View File

@@ -120,6 +120,31 @@ type ServerStartPayload struct {
DesiredGeneration int64 `json:"desiredGeneration"`
}
// ServerProvisionPayload instructs the agent to create a Minecraft server container.
type ServerProvisionPayload struct {
OperationMeta
Edition string `json:"edition"`
SoftwareFamily string `json:"softwareFamily"`
MinecraftVersion string `json:"minecraftVersion"`
HostPort int `json:"hostPort"`
RamMb int `json:"ramMb"`
DataPath string `json:"dataPath"`
EulaAccepted bool `json:"eulaAccepted"`
}
// ServerStopPayload instructs the agent to stop a running game server.
type ServerStopPayload struct {
OperationMeta
}
// ServerOperationResultPayload reports the outcome of a lifecycle operation.
type ServerOperationResultPayload struct {
OperationMeta
ResultCode string `json:"resultCode"`
ErrorCode string `json:"errorCode,omitempty"`
ErrorMessage string `json:"errorMessage,omitempty"`
}
// ServerStatePayload reports the observed server state.
type ServerStatePayload struct {
OperationMeta

View File

@@ -136,6 +136,69 @@ func TestDecodeEnvelope(t *testing.T) {
}
}
func TestServerProvisionPayload_JSONRoundtrip(t *testing.T) {
deadline := time.Date(2026, 6, 26, 12, 0, 0, 0, time.UTC)
original := ServerProvisionPayload{
OperationMeta: OperationMeta{
ServerID: "srv-abc123",
Generation: 2,
Deadline: &deadline,
IdempotencyKey: "idem-001",
},
Edition: "JAVA",
SoftwareFamily: "PAPER",
MinecraftVersion: "1.21.1",
HostPort: 25565,
RamMb: 2048,
DataPath: "/var/lib/hexahost-gamecloud/srv-abc123",
EulaAccepted: true,
}
data, err := json.Marshal(original)
if err != nil {
t.Fatalf("marshal: %v", err)
}
var decoded ServerProvisionPayload
if err := json.Unmarshal(data, &decoded); err != nil {
t.Fatalf("unmarshal: %v", err)
}
if decoded.ServerID != original.ServerID {
t.Fatalf("serverId: got %q want %q", decoded.ServerID, original.ServerID)
}
if decoded.Generation != original.Generation {
t.Fatalf("generation: got %d want %d", decoded.Generation, original.Generation)
}
if decoded.Edition != original.Edition {
t.Fatalf("edition: got %q want %q", decoded.Edition, original.Edition)
}
if decoded.SoftwareFamily != original.SoftwareFamily {
t.Fatalf("softwareFamily: got %q want %q", decoded.SoftwareFamily, original.SoftwareFamily)
}
if decoded.MinecraftVersion != original.MinecraftVersion {
t.Fatalf("minecraftVersion: got %q want %q", decoded.MinecraftVersion, original.MinecraftVersion)
}
if decoded.HostPort != original.HostPort {
t.Fatalf("hostPort: got %d want %d", decoded.HostPort, original.HostPort)
}
if decoded.RamMb != original.RamMb {
t.Fatalf("ramMb: got %d want %d", decoded.RamMb, original.RamMb)
}
if decoded.DataPath != original.DataPath {
t.Fatalf("dataPath: got %q want %q", decoded.DataPath, original.DataPath)
}
if decoded.EulaAccepted != original.EulaAccepted {
t.Fatalf("eulaAccepted: got %v want %v", decoded.EulaAccepted, original.EulaAccepted)
}
if decoded.IdempotencyKey != original.IdempotencyKey {
t.Fatalf("idempotencyKey: got %q want %q", decoded.IdempotencyKey, original.IdempotencyKey)
}
if decoded.Deadline == nil || !decoded.Deadline.Equal(deadline) {
t.Fatalf("deadline mismatch: got %v want %v", decoded.Deadline, deadline)
}
}
func TestNewEnvelope(t *testing.T) {
env, err := NewEnvelope(TypeAgentHello, "msg-new", AgentHelloPayload{
NodeID: "n1",