mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
Send instance status in listInstances request
Send the status of the instance in the repsonse to the listInstances request and use this status in the integration tests to check if the instance was started/stopped.
This commit is contained in:
1 parent
b82de23876
commit
003b035abd
4 files changed
+29
-7
No files matched your search
@@ -290,11 +290,14 @@ messages.listInstances = new Request({
|
|||||||
type: "array",
|
type: "array",
|
||||||
items: {
|
items: {
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
required: ["name", "id", "assigned_slave"],
|
required: ["name", "id", "assigned_slave", "status"],
|
||||||
properties: {
|
properties: {
|
||||||
"name": { type: "string" },
|
"name": { type: "string" },
|
||||||
"id": { type: "integer" },
|
"id": { type: "integer" },
|
||||||
"assigned_slave": { type: ["null", "integer"] },
|
"assigned_slave": { type: ["null", "integer"] },
|
||||||
|
"status": { enum: [
|
||||||
|
"unknown", "unassigned", "stopped", "starting", "running", "creating_save", "exporting_data",
|
||||||
|
]},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -612,6 +612,7 @@ class ControlConnection extends BaseConnection {
|
|||||||
id: instance.config.get("instance.id"),
|
id: instance.config.get("instance.id"),
|
||||||
name: instance.config.get("instance.name"),
|
name: instance.config.get("instance.name"),
|
||||||
assigned_slave: instance.config.get("instance.assigned_slave"),
|
assigned_slave: instance.config.get("instance.assigned_slave"),
|
||||||
|
status: instance.status,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return { list };
|
return { list };
|
||||||
|
|||||||
@@ -8,6 +8,16 @@ const link = require("@clusterio/lib/link");
|
|||||||
const { slowTest, get, execCtl, sendRcon, getControl, instancesDir } = require("./index");
|
const { slowTest, get, execCtl, sendRcon, getControl, instancesDir } = require("./index");
|
||||||
|
|
||||||
|
|
||||||
|
async function getInstances() {
|
||||||
|
let result = await link.messages.listInstances.send(getControl());
|
||||||
|
return new Map(result.list.map(instance => [instance.id, instance]));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkInstanceStatus(id, status) {
|
||||||
|
let instances = await getInstances();
|
||||||
|
assert.equal(instances.get(44).status, status, "incorrect instance status");
|
||||||
|
}
|
||||||
|
|
||||||
describe("Integration of Clusterio", function() {
|
describe("Integration of Clusterio", function() {
|
||||||
describe("clusterioctl", function() {
|
describe("clusterioctl", function() {
|
||||||
describe("slave list", function() {
|
describe("slave list", function() {
|
||||||
@@ -22,15 +32,19 @@ describe("Integration of Clusterio", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("instance create", function() {
|
describe("instance create", function() {
|
||||||
it("runs", async function() {
|
it("creates the instance", async function() {
|
||||||
await execCtl("instance create test --id 44");
|
await execCtl("instance create test --id 44");
|
||||||
|
let instances = await getInstances();
|
||||||
|
assert(instances.has(44), "instance was not created");
|
||||||
|
assert.equal(instances.get(44).status, "unassigned", "incorrect instance status");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("instance assign", function() {
|
describe("instance assign", function() {
|
||||||
it("creates the instance files", async function() {
|
it("creates the instance files", async function() {
|
||||||
await execCtl("instance assign test 4");
|
await execCtl("instance assign test 4");
|
||||||
assert(await fs.exists(path.join(instancesDir, "test")), "Instance was not created");
|
assert(await fs.exists(path.join(instancesDir, "test")), "Instance directory was not created");
|
||||||
|
await checkInstanceStatus(44, "stopped");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -38,6 +52,7 @@ describe("Integration of Clusterio", function() {
|
|||||||
it("creates a save", async function() {
|
it("creates a save", async function() {
|
||||||
slowTest(this);
|
slowTest(this);
|
||||||
await execCtl("instance create-save test");
|
await execCtl("instance create-save test");
|
||||||
|
await checkInstanceStatus(44, "stopped");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -46,6 +61,7 @@ describe("Integration of Clusterio", function() {
|
|||||||
slowTest(this);
|
slowTest(this);
|
||||||
await execCtl("instance export-data test");
|
await execCtl("instance export-data test");
|
||||||
assert(await fs.exists(path.join("static", "export", "locale.json")), "Export was not created");
|
assert(await fs.exists(path.join("static", "export", "locale.json")), "Export was not created");
|
||||||
|
await checkInstanceStatus(44, "stopped");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -53,7 +69,7 @@ describe("Integration of Clusterio", function() {
|
|||||||
it("starts the instance", async function() {
|
it("starts the instance", async function() {
|
||||||
slowTest(this);
|
slowTest(this);
|
||||||
await execCtl("instance start test");
|
await execCtl("instance start test");
|
||||||
// TODO check that the instance actually started
|
await checkInstanceStatus(44, "running");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -200,7 +216,7 @@ describe("Integration of Clusterio", function() {
|
|||||||
it("stops the instance", async function() {
|
it("stops the instance", async function() {
|
||||||
slowTest(this);
|
slowTest(this);
|
||||||
await execCtl("instance stop test");
|
await execCtl("instance stop test");
|
||||||
// TODO check that the instance actually stopped
|
await checkInstanceStatus(44, "stopped");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -208,7 +224,9 @@ describe("Integration of Clusterio", function() {
|
|||||||
it("deletes the instance", async function() {
|
it("deletes the instance", async function() {
|
||||||
slowTest(this);
|
slowTest(this);
|
||||||
await execCtl("instance delete test");
|
await execCtl("instance delete test");
|
||||||
assert(!await fs.exists(path.join(instancesDir, "test")), "Instance was not deleted");
|
assert(!await fs.exists(path.join(instancesDir, "test")), "Instance files was not deleted");
|
||||||
|
let instances = await getInstances();
|
||||||
|
assert(!instances.has(44), "instance was not deleted from master");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ describe("lib/command", function() {
|
|||||||
seq: 1, type: "list_instances_response",
|
seq: 1, type: "list_instances_response",
|
||||||
data: {
|
data: {
|
||||||
seq: message.seq,
|
seq: message.seq,
|
||||||
list: [{ id: 57, assigned_slave: 4, name: "Test Instance" }],
|
list: [{ id: 57, assigned_slave: 4, name: "Test Instance", status: "stopped" }],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else if (message.type === "list_roles_request") {
|
} else if (message.type === "list_roles_request") {
|
||||||
|
|||||||
Reference in new issue
Block a user