mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
Adds the last three checks from #342 to test_plugin: an InstanceEcho request handled on a running instance, a Lua module with a remote interface that the request calls over RCON, and log tagging checks for the plugin field and host/instance ids on the controller, host and instance log lines. test_plugin now has a module, so the create_scenario and patch unit tests that relied on it having none use global_chat instead. Closes #342 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
76 lines
1.9 KiB
JavaScript
76 lines
1.9 KiB
JavaScript
import { JsonBoolean, JsonString } from "@clusterio/lib";
|
|
|
|
// Sent from ctl to the controller, which answers with the text it was given
|
|
// and broadcasts a HostEcho to the hosts.
|
|
export class ControllerEcho {
|
|
static type = "request";
|
|
static src = "control";
|
|
static dst = "controller";
|
|
static plugin = "test_plugin";
|
|
static permission = null;
|
|
static Response = JsonString;
|
|
|
|
constructor(text) {
|
|
this.text = text;
|
|
}
|
|
|
|
static jsonSchema = { type: "string" };
|
|
toJSON() { return this.text; }
|
|
static fromJSON(json) { return new this(json); }
|
|
}
|
|
|
|
// Broadcast from the controller to the hosts by broadcastEventToHosts.
|
|
export class HostEcho {
|
|
static type = "event";
|
|
static src = "controller";
|
|
static dst = "host";
|
|
static plugin = "test_plugin";
|
|
static permission = null;
|
|
|
|
constructor(text) {
|
|
this.text = text;
|
|
}
|
|
|
|
static jsonSchema = { type: "string" };
|
|
toJSON() { return this.text; }
|
|
static fromJSON(json) { return new this(json); }
|
|
}
|
|
|
|
// Sent from ctl to a host, which answers with whether it received the given
|
|
// text via a HostEcho.
|
|
export class HostEchoReceived {
|
|
static type = "request";
|
|
static src = "control";
|
|
static dst = "host";
|
|
static plugin = "test_plugin";
|
|
static permission = null;
|
|
static Response = JsonBoolean;
|
|
|
|
constructor(text) {
|
|
this.text = text;
|
|
}
|
|
|
|
static jsonSchema = { type: "string" };
|
|
toJSON() { return this.text; }
|
|
static fromJSON(json) { return new this(json); }
|
|
}
|
|
|
|
// Sent from ctl to an instance, which answers with the text echoed back by
|
|
// the remote interface of the plugin's Lua module.
|
|
export class InstanceEcho {
|
|
static type = "request";
|
|
static src = "control";
|
|
static dst = "instance";
|
|
static plugin = "test_plugin";
|
|
static permission = null;
|
|
static Response = JsonString;
|
|
|
|
constructor(text) {
|
|
this.text = text;
|
|
}
|
|
|
|
static jsonSchema = { type: "string" };
|
|
toJSON() { return this.text; }
|
|
static fromJSON(json) { return new this(json); }
|
|
}
|