mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 07:24:52 +09:00
Rename Slave to Host
The role of a slave as a host for Factorio servers is not well reflected in its name and has caused confusion among users. Rename slave to host to better reflect its role as a host of Factorio servers.
This commit is contained in:
1 parent
70ad295a89
commit
6fc3abafd5
101 files changed
+1168
-1168
No files matched your search
@@ -92,7 +92,7 @@ describe("Integration of Clusterio", function() {
|
||||
let result = await libLink.messages.queryLog.send(getControl(), {
|
||||
all: true,
|
||||
controller: false,
|
||||
slave_ids: [],
|
||||
host_ids: [],
|
||||
instance_ids: [],
|
||||
max_level: null,
|
||||
limit: 10,
|
||||
@@ -104,7 +104,7 @@ describe("Integration of Clusterio", function() {
|
||||
let first = await libLink.messages.queryLog.send(getControl(), {
|
||||
all: true,
|
||||
controller: false,
|
||||
slave_ids: [],
|
||||
host_ids: [],
|
||||
instance_ids: [],
|
||||
max_level: null,
|
||||
limit: 1,
|
||||
@@ -113,7 +113,7 @@ describe("Integration of Clusterio", function() {
|
||||
let last = await libLink.messages.queryLog.send(getControl(), {
|
||||
all: true,
|
||||
controller: false,
|
||||
slave_ids: [],
|
||||
host_ids: [],
|
||||
instance_ids: [],
|
||||
max_level: null,
|
||||
limit: 1,
|
||||
@@ -124,41 +124,41 @@ describe("Integration of Clusterio", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("clusterioslave", function() {
|
||||
describe("slaveUpdateEventHandler()", function() {
|
||||
it("should trigger when a new slave is added", async function() {
|
||||
// On windows there's currently no way to automate graceful shutdown of the slave
|
||||
describe("clusteriohost", function() {
|
||||
describe("hostUpdateEventHandler()", function() {
|
||||
it("should trigger when a new host is added", async function() {
|
||||
// On windows there's currently no way to automate graceful shutdown of the host
|
||||
// process as CTRL+C is some weird terminal thing and SIGINT isn't a thing.
|
||||
if (process.platform === "win32") {
|
||||
this.skip();
|
||||
}
|
||||
|
||||
slowTest(this);
|
||||
getControl().slaveUpdates = [];
|
||||
let config = "alt-slave-config.json";
|
||||
getControl().hostUpdates = [];
|
||||
let config = "alt-host-config.json";
|
||||
let configPath = path.join("temp", "test", config);
|
||||
await fs.remove(configPath);
|
||||
await fs.remove(path.join("temp", "test", "alt-instances"));
|
||||
await execCtl(`slave create-config --id 5 --name alt-slave --generate-token --output ${config}`);
|
||||
await execCtl(`host create-config --id 5 --name alt-host --generate-token --output ${config}`);
|
||||
await exec(
|
||||
`node ../../packages/slave --config ${config} config set slave.tls_ca ../../test/file/tls/cert.pem`
|
||||
`node ../../packages/host --config ${config} config set host.tls_ca ../../test/file/tls/cert.pem`
|
||||
);
|
||||
await exec(
|
||||
`node ../../packages/slave --config ${config} config set slave.instances_directory alt-instances`
|
||||
`node ../../packages/host --config ${config} config set host.instances_directory alt-instances`
|
||||
);
|
||||
|
||||
let slaveProcess;
|
||||
let hostProcess;
|
||||
try {
|
||||
slaveProcess = await spawn(
|
||||
"alt-slave:", `node ../../packages/slave run --config ${config}`, /Started slave/
|
||||
hostProcess = await spawn(
|
||||
"alt-host:", `node ../../packages/host run --config ${config}`, /Started host/
|
||||
);
|
||||
// Add instance to test the unknown status afterwards
|
||||
await execCtl("instance create alt-test --id 99");
|
||||
await execCtl("instance assign alt-test 5");
|
||||
} finally {
|
||||
if (slaveProcess) {
|
||||
slaveProcess.kill("SIGINT");
|
||||
await events.once(slaveProcess, "exit");
|
||||
if (hostProcess) {
|
||||
hostProcess.kill("SIGINT");
|
||||
await events.once(hostProcess, "exit");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,8 +166,8 @@ describe("Integration of Clusterio", function() {
|
||||
let sawConnected = false;
|
||||
let sawDisconnected = false;
|
||||
|
||||
for (let update of getControl().slaveUpdates) {
|
||||
if (update.name !== "alt-slave") {
|
||||
for (let update of getControl().hostUpdates) {
|
||||
if (update.name !== "alt-host") {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -179,13 +179,13 @@ describe("Integration of Clusterio", function() {
|
||||
}
|
||||
}
|
||||
|
||||
assert(sawUpdate, "No slave update was sent");
|
||||
assert(sawConnected, "No slave update with status connected was sent");
|
||||
assert(sawDisconnected, "No slave update with status disconnected was sent");
|
||||
assert(sawUpdate, "No host update was sent");
|
||||
assert(sawConnected, "No host update with status connected was sent");
|
||||
assert(sawDisconnected, "No host update with status disconnected was sent");
|
||||
|
||||
let result = await libLink.messages.listSlaves.send(getControl());
|
||||
let slaves = new Map(result.list.map(instance => [instance.id, instance]));
|
||||
assert(slaves.has(5), "Slave list was not updated");
|
||||
let result = await libLink.messages.listHosts.send(getControl());
|
||||
let hosts = new Map(result.list.map(instance => [instance.id, instance]));
|
||||
assert(hosts.has(5), "Host list was not updated");
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -233,17 +233,17 @@ describe("Integration of Clusterio", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("slave list", function() {
|
||||
describe("host list", function() {
|
||||
it("runs", async function() {
|
||||
await execCtl("slave list");
|
||||
await execCtl("host list");
|
||||
});
|
||||
});
|
||||
describe("slave generate-token", function() {
|
||||
describe("host generate-token", function() {
|
||||
it("runs", async function() {
|
||||
await execCtl("slave generate-token --id 42");
|
||||
await execCtl("host generate-token --id 42");
|
||||
});
|
||||
it("runs without an id", async function() {
|
||||
await execCtl("slave generate-token");
|
||||
await execCtl("host generate-token");
|
||||
});
|
||||
});
|
||||
describe("instance list", function() {
|
||||
@@ -370,7 +370,7 @@ describe("Integration of Clusterio", function() {
|
||||
let { log } = await libLink.messages.queryLog.send(getControl(), {
|
||||
all: false,
|
||||
controller: false,
|
||||
slave_ids: [],
|
||||
host_ids: [],
|
||||
instance_ids: [44],
|
||||
max_level: null,
|
||||
limit: 10,
|
||||
@@ -683,24 +683,24 @@ describe("Integration of Clusterio", function() {
|
||||
;
|
||||
describe(remote ? "remote" : "local", function() {
|
||||
if (remote) {
|
||||
let slaveProcess;
|
||||
let hostProcess;
|
||||
before(async function() {
|
||||
// On windows there's currently no way to automate graceful shutdown of the slave
|
||||
// On windows there's currently no way to automate graceful shutdown of the host
|
||||
// process as CTRL+C is some weird terminal thing and SIGINT isn't a thing.
|
||||
if (process.platform === "win32") {
|
||||
this.skip();
|
||||
}
|
||||
slowTest(this);
|
||||
// Reuse from the clusterioslave test
|
||||
let config = "alt-slave-config.json";
|
||||
slaveProcess = await spawn(
|
||||
"alt-slave:", `node ../../packages/slave run --config ${config}`, /Started slave/
|
||||
// Reuse from the clusteriohost test
|
||||
let config = "alt-host-config.json";
|
||||
hostProcess = await spawn(
|
||||
"alt-host:", `node ../../packages/host run --config ${config}`, /Started host/
|
||||
);
|
||||
});
|
||||
after(async function() {
|
||||
if (slaveProcess) {
|
||||
slaveProcess.kill("SIGINT");
|
||||
await events.once(slaveProcess, "exit");
|
||||
if (hostProcess) {
|
||||
hostProcess.kill("SIGINT");
|
||||
await events.once(hostProcess, "exit");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1036,14 +1036,14 @@ describe("Integration of Clusterio", function() {
|
||||
assert.deepEqual(newRole, { id: 5, name: "new", description: "A new role", permissions: [] });
|
||||
});
|
||||
it("should add permissions with --add-perms", async function() {
|
||||
let args = "--name new --add-perms core.slave.list core.instance.list";
|
||||
let args = "--name new --add-perms core.host.list core.instance.list";
|
||||
await execCtl(`role edit new ${args}`);
|
||||
let result = await libLink.messages.listRoles.send(getControl());
|
||||
let newRole = result.list.find(role => role.name === "new");
|
||||
assert.deepEqual(newRole.permissions, ["core.slave.list", "core.instance.list"]);
|
||||
assert.deepEqual(newRole.permissions, ["core.host.list", "core.instance.list"]);
|
||||
});
|
||||
it("should remove permissions with --remove-perms", async function() {
|
||||
let args = "--name new --remove-perms core.slave.list";
|
||||
let args = "--name new --remove-perms core.host.list";
|
||||
await execCtl(`role edit new ${args}`);
|
||||
let result = await libLink.messages.listRoles.send(getControl());
|
||||
let newRole = result.list.find(role => role.name === "new");
|
||||
|
||||
+19
-19
@@ -26,7 +26,7 @@ class TestControl extends libLink.Link {
|
||||
constructor(connector) {
|
||||
super("control", "controller", connector);
|
||||
libLink.attachAllMessages(this);
|
||||
this.slaveUpdates = [];
|
||||
this.hostUpdates = [];
|
||||
this.instanceUpdates = [];
|
||||
this.saveListUpdates = [];
|
||||
this.modUpdates = [];
|
||||
@@ -34,9 +34,9 @@ class TestControl extends libLink.Link {
|
||||
this.userUpdates = [];
|
||||
|
||||
this.connector.on("connect", () => {
|
||||
libLink.messages.setSlaveSubscriptions.send(
|
||||
this, { all: true, slave_ids: [] }
|
||||
).catch(err => logger.error(`Error setting slave subscriptions:\n${err.stack}`));
|
||||
libLink.messages.setHostSubscriptions.send(
|
||||
this, { all: true, host_ids: [] }
|
||||
).catch(err => logger.error(`Error setting host subscriptions:\n${err.stack}`));
|
||||
libLink.messages.setInstanceSubscriptions.send(
|
||||
this, { all: true, instance_ids: [] }
|
||||
).catch(err => logger.error(`Error setting instance subscriptions:\n${err.stack}`));
|
||||
@@ -61,8 +61,8 @@ class TestControl extends libLink.Link {
|
||||
|
||||
async accountUpdateEventHandler() { }
|
||||
|
||||
async slaveUpdateEventHandler(message) {
|
||||
this.slaveUpdates.push(message.data);
|
||||
async hostUpdateEventHandler(message) {
|
||||
this.hostUpdates.push(message.data);
|
||||
}
|
||||
|
||||
async instanceUpdateEventHandler(message) {
|
||||
@@ -118,7 +118,7 @@ async function get(urlPath) {
|
||||
}
|
||||
|
||||
let controllerProcess;
|
||||
let slaveProcess;
|
||||
let hostProcess;
|
||||
let control;
|
||||
|
||||
let url = "https://localhost:4443/";
|
||||
@@ -127,7 +127,7 @@ let instancesDir = path.join("temp", "test", "instances");
|
||||
let databaseDir = path.join("temp", "test", "database");
|
||||
let pluginListPath = path.join("temp", "test", "plugin-list.json");
|
||||
let controllerConfigPath = path.join("temp", "test", "config-controller.json");
|
||||
let slaveConfigPath = path.join("temp", "test", "config-slave.json");
|
||||
let hostConfigPath = path.join("temp", "test", "config-host.json");
|
||||
let controlConfigPath = path.join("temp", "test", "config-control.json");
|
||||
|
||||
async function exec(command, options = {}) {
|
||||
@@ -185,7 +185,7 @@ before(async function() {
|
||||
|
||||
await fs.remove(pluginListPath);
|
||||
await fs.remove(controllerConfigPath);
|
||||
await fs.remove(slaveConfigPath);
|
||||
await fs.remove(hostConfigPath);
|
||||
await fs.remove(controlConfigPath);
|
||||
|
||||
await fs.ensureDir(path.join("temp", "test"));
|
||||
@@ -210,11 +210,11 @@ before(async function() {
|
||||
|
||||
controllerProcess = await spawn("controller:", "node ../../packages/controller run", /Started controller/);
|
||||
|
||||
await execCtl("slave create-config --id 4 --name slave --generate-token");
|
||||
await exec(`node ../../packages/slave config set slave.factorio_directory ${path.join("..", "..", "factorio")}`);
|
||||
await exec("node ../../packages/slave config set slave.tls_ca ../../test/file/tls/cert.pem");
|
||||
await execCtl("host create-config --id 4 --name host --generate-token");
|
||||
await exec(`node ../../packages/host config set host.factorio_directory ${path.join("..", "..", "factorio")}`);
|
||||
await exec("node ../../packages/host config set host.tls_ca ../../test/file/tls/cert.pem");
|
||||
|
||||
slaveProcess = await spawn("slave:", "node ../../packages/slave run", /Started slave/);
|
||||
hostProcess = await spawn("host:", "node ../../packages/host run", /Started host/);
|
||||
|
||||
let tlsCa = await fs.readFile("test/file/tls/cert.pem");
|
||||
let controlConnector = new TestControlConnector(url, 2, tlsCa);
|
||||
@@ -236,10 +236,10 @@ before(async function() {
|
||||
|
||||
after(async function() {
|
||||
this.timeout(20000);
|
||||
if (slaveProcess) {
|
||||
console.log("Shutting down slave");
|
||||
slaveProcess.kill("SIGINT");
|
||||
await events.once(slaveProcess, "exit");
|
||||
if (hostProcess) {
|
||||
console.log("Shutting down host");
|
||||
hostProcess.kill("SIGINT");
|
||||
await events.once(hostProcess, "exit");
|
||||
}
|
||||
if (controllerProcess) {
|
||||
console.log("Shutting down controller");
|
||||
@@ -253,7 +253,7 @@ after(async function() {
|
||||
|
||||
// Ensure the test processes are stopped.
|
||||
process.on("exit", () => {
|
||||
if (slaveProcess) { slaveProcess.kill(); }
|
||||
if (hostProcess) { hostProcess.kill(); }
|
||||
if (controllerProcess) { controllerProcess.kill(); }
|
||||
});
|
||||
|
||||
@@ -274,6 +274,6 @@ module.exports = {
|
||||
instancesDir,
|
||||
databaseDir,
|
||||
controllerConfigPath,
|
||||
slaveConfigPath,
|
||||
hostConfigPath,
|
||||
controlConfigPath,
|
||||
};
|
||||
Reference in new issue
Block a user