Skip to content

Commit 1d5f7ad

Browse files
committed
added delete topic functionality to terminate cluster, modified comments on integration test file
1 parent 85071ea commit 1d5f7ad

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

__tests__/integrationtests.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ const ksqljs = require('../ksqljs/ksqlJS.js');
22

33
// Pre-requisite: start a docker container
44
/* To add to README: Prior to running test with 'npm test', please start the ksqlDB
5-
server using the command 'docker compose-up'. This will spin up a ksqlDB server on
6-
'http://localhost:8088'
5+
server using the command 'docker-compose up'. This will spin up a ksqlDB server on
6+
'http://localhost:8088'. If the command was run before, the created container might
7+
need to be removed first.
78
*/
89

910
describe('--Integration Tests--', () => {
@@ -31,7 +32,7 @@ describe('--Integration Tests--', () => {
3132
}
3233
expect(streamExists).toEqual(true);
3334
})
34-
35+
3536
it('.push properly creates a push query', () => {
3637
let pushActive = false;
3738
client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 1;', async (data) => {
@@ -41,14 +42,14 @@ describe('--Integration Tests--', () => {
4142
expect(pushActive).toEqual(true)
4243
});
4344
})
44-
45+
4546
it('.terminate properly terminates a push query', () => {
4647
client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 3;', async (data) => {
4748
const terminateRes = await client.terminate(JSON.parse(data).queryId);
4849
expect(terminateRes.wasTerminated).toEqual(true);
4950
})
5051
})
51-
52+
5253
it('.insertStream properly inserts a row into a stream', async () => {
5354
const response = await client.insertStream('TESTJESTSTREAM', [
5455
{ "name": "stab-rabbit", "email": "123@mail.com", "age": 100 }
@@ -63,7 +64,7 @@ describe('--Integration Tests--', () => {
6364
}
6465
});
6566
})
66-
67+
6768
it('.pull receives the correct data from a pull query', async () => {
6869
const pullData = await client.pull("SELECT * FROM TESTJESTSTREAM;");
6970
console.log(pullData[1]);
@@ -84,7 +85,7 @@ describe('--Integration Tests--', () => {
8485
client = new ksqljs({ ksqldbURL: 'http://localhost:8088' });
8586
done();
8687
});
87-
88+
8889
afterAll(async () => {
8990
await client.ksql('DROP STREAM IF EXISTS TESTSTREAM2;');
9091
})
@@ -109,7 +110,7 @@ describe('--Integration Tests--', () => {
109110
queryId: null
110111
}));
111112
})
112-
113+
113114
it('.inspectServerInfo returns the server info and status', async () => {
114115
const status = await client.inspectServerInfo();
115116
// should return something like: {
@@ -128,7 +129,7 @@ describe('--Integration Tests--', () => {
128129
})
129130
}));
130131
})
131-
132+
132133
it('.inspectServerHealth returns the server health', async () => {
133134
const status = await client.inspectServerHealth();
134135
// should return something like: {
@@ -149,7 +150,7 @@ describe('--Integration Tests--', () => {
149150
})
150151
);
151152
})
152-
153+
153154
it('.inspectClusterStatus returns the cluster status', async () => {
154155
const status = await client.inspectClusterStatus();
155156
// should return something like: {
@@ -166,13 +167,13 @@ describe('--Integration Tests--', () => {
166167
})
167168
);
168169
})
169-
170+
170171
it('.isValidProperty returns true if a server configuration property is not prohibited from setting', async () => {
171172
const status = await client.isValidProperty('test');
172173
// should return true
173174
expect(status.data).toEqual(true);
174175
})
175-
176+
176177
// it('isValidProperty returns an error if the server property is prohibited from setting', async () => {
177178
// const status = await client.isValidProperty('ksql.connect.url');
178179
// // should return something like
@@ -188,4 +189,4 @@ describe('--Integration Tests--', () => {
188189
// }));
189190
// })
190191
})
191-
})
192+
})

ksqljs/ksqlJS.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,9 @@ class ksqljs {
492492
* @return {Promise} this method returns a promise that returns a response object.
493493
*/
494494
terminateCluster(topicsToDelete = []) {
495-
return axios.post(this.ksqldbURL + `/ksql/terminate`, {}, {
495+
return axios.post(this.ksqldbURL + `/ksql/terminate`, {
496+
"deleteTopicList": topicsToDelete
497+
}, {
496498
headers: {
497499
// 'application/json' is the modern content-type for JSON, but some
498500
// older servers may use 'text/json'.

0 commit comments

Comments
 (0)