Split gateway control and dataplane into separate services
This commit is contained in:
23
test/server/dataplane-client.test.js
Normal file
23
test/server/dataplane-client.test.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createDataplaneClient } from '../../src/server/dataplaneClient.js';
|
||||
|
||||
test('control uses the dataplane socket protocol', async () => {
|
||||
const requests = [];
|
||||
const send = async (socketPath, pathname, method) => {
|
||||
requests.push(`${method} ${pathname} ${socketPath}`);
|
||||
return { running: pathname !== '/stop', startedAt: 'now' };
|
||||
};
|
||||
|
||||
const client = createDataplaneClient('/run/dataplane.sock', send);
|
||||
assert.equal((await client.refresh()).running, true);
|
||||
await client.apply();
|
||||
await client.restart();
|
||||
assert.equal((await client.stop()).running, false);
|
||||
assert.deepEqual(requests, [
|
||||
'GET /status /run/dataplane.sock',
|
||||
'POST /apply /run/dataplane.sock',
|
||||
'POST /restart /run/dataplane.sock',
|
||||
'POST /stop /run/dataplane.sock',
|
||||
]);
|
||||
});
|
||||
Reference in New Issue
Block a user