Merge fix/alte-server-handles in main
This commit is contained in:
commit
479962dc8d
2 files changed
+18
-4
No files matched your search
@@ -378,8 +378,11 @@ export class DockerHostPool {
|
|||||||
adapterFor(handle) {
|
adapterFor(handle) {
|
||||||
const name = handle?.hostName ?? this.hosts[0].name;
|
const name = handle?.hostName ?? this.hosts[0].name;
|
||||||
const adapter = this.adapters.get(name);
|
const adapter = this.adapters.get(name);
|
||||||
if (!adapter) throw new Error(`Docker-Host "${name}" ist nicht (mehr) konfiguriert`);
|
if (adapter) return adapter;
|
||||||
return adapter;
|
// Server aus der Zeit vor der Host-Liste (Name "default") oder nach einer Umbenennung: über die Adresse finden
|
||||||
|
const byAddress = handle?.rconHost && this.hosts.find((h) => h.rconHost === handle.rconHost || h.publicHost === handle.rconHost);
|
||||||
|
if (byAddress) return this.adapters.get(byAddress.name);
|
||||||
|
throw new Error(`Docker-Host "${name}" ist nicht (mehr) konfiguriert`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async status(handle) {
|
async status(handle) {
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ test('Status, Stopp und Befehle gehen an den Host des Matches', async () => {
|
|||||||
await p.stop(r.handle);
|
await p.stop(r.handle);
|
||||||
assert.deepEqual(calls.at(-1)[0], 'rm');
|
assert.deepEqual(calls.at(-1)[0], 'rm');
|
||||||
assert.equal(calls.at(-1).at(-1), r.handle.container);
|
assert.equal(calls.at(-1).at(-1), r.handle.container);
|
||||||
// Ein Handle von einem Host, der nicht mehr konfiguriert ist, wird abgelehnt
|
// Ein Handle von einem Host, der weder per Name noch per Adresse bekannt ist, wird abgelehnt
|
||||||
await assert.rejects(p.status({ ...r.handle, hostName: 'gelöscht' }), /nicht \(mehr\) konfiguriert/);
|
await assert.rejects(p.status({ ...r.handle, hostName: 'gelöscht', rconHost: '10.9.9.9' }), /nicht \(mehr\) konfiguriert/);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Alte Handles ohne Host-Namen laufen auf dem ersten Host', () => {
|
test('Alte Handles ohne Host-Namen laufen auf dem ersten Host', () => {
|
||||||
@@ -96,3 +96,14 @@ test('df-Ausgabe wird in Gesamt- und freien Speicher zerlegt', async () => {
|
|||||||
});
|
});
|
||||||
assert.equal(parseDf('kaputt'), null);
|
assert.equal(parseDf('kaputt'), null);
|
||||||
});
|
});
|
||||||
|
test('Alter Handle ohne passenden Host-Namen wird über die Adresse dem richtigen Host zugeordnet', async () => {
|
||||||
|
const docker = fakeDocker();
|
||||||
|
const p = new DockerHostPool(options([
|
||||||
|
{ ...hostA, rconHost: '10.0.0.1' },
|
||||||
|
{ ...hostB, rconHost: '10.0.0.2' },
|
||||||
|
]), { runDocker: docker.run });
|
||||||
|
await p.stop({ container: 'cs2mv-alt', hostName: 'default', rconHost: '10.0.0.2', port: 27100 });
|
||||||
|
assert.deepEqual(docker.calls.at(-1), ['rm', '-f', 'cs2mv-alt']);
|
||||||
|
assert.equal(p.adapterFor({ hostName: 'default', rconHost: '10.0.0.2' }).options.name, 'b');
|
||||||
|
assert.throws(() => p.adapterFor({ hostName: 'weg', rconHost: '10.9.9.9' }), /nicht \(mehr\) konfiguriert/);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user