mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 08:03:13 +09:00
Rename Master to Controller
The role of the master server as the party controlling every part of the cluster is not well reflected in its name and has caused confusion among users on several occasions. Rename master to controller to better reflects its role.
This commit is contained in:
1 parent
6ae4c8ef46
commit
70ad295a89
119 files changed
+1394
-1376
No files matched your search
+2
-2
@@ -47,7 +47,7 @@ describe("lib/command", function() {
|
||||
it("should pass an integer like string back", async function() {
|
||||
assert.equal(await libCommand.resolveSlave(null, "123"), 123);
|
||||
});
|
||||
it("should resolve a slave name with the master server", async function() {
|
||||
it("should resolve a slave name with the controller", async function() {
|
||||
assert.equal(await libCommand.resolveSlave(testControl, "Test Slave"), 11);
|
||||
});
|
||||
it("should throw if slave is not found", async function() {
|
||||
@@ -61,7 +61,7 @@ describe("lib/command", function() {
|
||||
it("should pass an integer like string back", async function() {
|
||||
assert.equal(await libCommand.resolveInstance(null, "123"), 123);
|
||||
});
|
||||
it("should resolve an instance name with the master server", async function() {
|
||||
it("should resolve an instance name with the controller", async function() {
|
||||
assert.equal(await libCommand.resolveInstance(testControl, "Test Instance"), 57);
|
||||
});
|
||||
it("should throw if instance is not found", async function() {
|
||||
|
||||
@@ -108,8 +108,8 @@ describe("lib/logging_utils.js", function() {
|
||||
info => ["fatal"].includes(info.level)
|
||||
));
|
||||
});
|
||||
it("should filter by master", async function() {
|
||||
let log = await libLoggingUtils.queryLog(logDir, { master: true }, index());
|
||||
it("should filter by controller", async function() {
|
||||
let log = await libLoggingUtils.queryLog(logDir, { controller: true }, index());
|
||||
assert.deepEqual(log, allLines.filter(
|
||||
info => info.slave_id === undefined && info.instance_id === undefined
|
||||
));
|
||||
|
||||
+13
-13
@@ -19,8 +19,8 @@ describe("lib/plugin", function() {
|
||||
await instancePlugin.onStop();
|
||||
instancePlugin.onExit();
|
||||
await instancePlugin.onOutput({});
|
||||
instancePlugin.onMasterConnectionEvent("connect");
|
||||
await instancePlugin.onPrepareMasterDisconnect();
|
||||
instancePlugin.onControllerConnectionEvent("connect");
|
||||
await instancePlugin.onPrepareControllerDisconnect();
|
||||
});
|
||||
describe("sendRcon", function() {
|
||||
it("should send commands out of order", async function() {
|
||||
@@ -54,20 +54,20 @@ describe("lib/plugin", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("class BaseMasterPlugin", function() {
|
||||
let masterPlugin;
|
||||
describe("class BaseControllerPlugin", function() {
|
||||
let controllerPlugin;
|
||||
it("should be constructible", async function() {
|
||||
masterPlugin = new libPlugin.BaseMasterPlugin({}, {}, {}, new mock.MockLogger());
|
||||
await masterPlugin.init();
|
||||
controllerPlugin = new libPlugin.BaseControllerPlugin({}, {}, {}, new mock.MockLogger());
|
||||
await controllerPlugin.init();
|
||||
});
|
||||
it("should define defaults for hooks", async function() {
|
||||
await masterPlugin.onInstanceStatusChanged({}, "running", "initialized");
|
||||
await masterPlugin.onMasterConfigFieldChanged({}, "foo", null);
|
||||
await masterPlugin.onInstanceConfigFieldChanged({}, {}, "foo", null);
|
||||
await masterPlugin.onMetrics();
|
||||
await masterPlugin.onShutdown();
|
||||
masterPlugin.onSlaveConnectionEvent({}, "connect");
|
||||
await masterPlugin.onPrepareSlaveDisconnect({});
|
||||
await controllerPlugin.onInstanceStatusChanged({}, "running", "initialized");
|
||||
await controllerPlugin.onControllerConfigFieldChanged({}, "foo", null);
|
||||
await controllerPlugin.onInstanceConfigFieldChanged({}, {}, "foo", null);
|
||||
await controllerPlugin.onMetrics();
|
||||
await controllerPlugin.onShutdown();
|
||||
controllerPlugin.onSlaveConnectionEvent({}, "connect");
|
||||
await controllerPlugin.onPrepareSlaveDisconnect({});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+14
-12
@@ -64,43 +64,45 @@ describe("lib/plugin_loader", function() {
|
||||
);
|
||||
});
|
||||
});
|
||||
describe("loadMasterPluginClass()", function() {
|
||||
describe("loadControllerPluginClass()", function() {
|
||||
let baseDir = path.join("temp", "test", "plugin");
|
||||
let missingClass = path.join(baseDir, "missing_class_plugin");
|
||||
let wrongParentClass = path.join(baseDir, "wrong_parent_class_plugin");
|
||||
before(async function() {
|
||||
async function writeEntrypoint(pluginPath, content) {
|
||||
await fs.outputFile(path.join(pluginPath, "master.js"), content);
|
||||
await fs.outputFile(path.join(pluginPath, "controller.js"), content);
|
||||
}
|
||||
|
||||
await writeEntrypoint(missingClass, "");
|
||||
await writeEntrypoint(wrongParentClass, "class MasterPlugin {}\n module.exports = { MasterPlugin };\n");
|
||||
await writeEntrypoint(
|
||||
wrongParentClass, "class ControllerPlugin {}\n module.exports = { ControllerPlugin };\n"
|
||||
);
|
||||
});
|
||||
it("should throw if class is missing from entrypoint", async function() {
|
||||
await assert.rejects(
|
||||
libPluginLoader.loadMasterPluginClass({
|
||||
libPluginLoader.loadControllerPluginClass({
|
||||
name: "test",
|
||||
masterEntrypoint: "master",
|
||||
controllerEntrypoint: "controller",
|
||||
requirePath: path.resolve(missingClass),
|
||||
}),
|
||||
{
|
||||
message:
|
||||
`PluginError: Expected ${path.resolve(missingClass, "master")} ` +
|
||||
"to export a class named MasterPlugin",
|
||||
`PluginError: Expected ${path.resolve(missingClass, "controller")} ` +
|
||||
"to export a class named ControllerPlugin",
|
||||
}
|
||||
);
|
||||
});
|
||||
it("should throw if class is not a subclass of BaseMasterPlugin", async function() {
|
||||
it("should throw if class is not a subclass of BaseControllerPlugin", async function() {
|
||||
await assert.rejects(
|
||||
libPluginLoader.loadMasterPluginClass({
|
||||
libPluginLoader.loadControllerPluginClass({
|
||||
name: "test",
|
||||
masterEntrypoint: "master",
|
||||
controllerEntrypoint: "controller",
|
||||
requirePath: path.resolve(wrongParentClass),
|
||||
}),
|
||||
{
|
||||
message:
|
||||
"PluginError: Expected MasterPlugin exported from " +
|
||||
`${path.resolve(wrongParentClass, "master")} to be a subclass of BaseMasterPlugin`,
|
||||
"PluginError: Expected ControllerPlugin exported from " +
|
||||
`${path.resolve(wrongParentClass, "controller")} to be a subclass of BaseControllerPlugin`,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user