Skip to content

Commit 1779835

Browse files
committed
merged with dev and tested regular http, confluentcloud, and https
1 parent f5d8f15 commit 1779835

File tree

3 files changed

+99
-107
lines changed

3 files changed

+99
-107
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ dist
106106
# Local
107107
ksqljsTest.js
108108
package-lock.json
109+
local_ignore/
109110

110111
# KSQLDB docker server settings
111112
ksqldb_server_config/

__tests__/integrationtests.js

Lines changed: 95 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
const ksqljs = require('../ksqljs/ksqlJS.js');
22

33
// Pre-requisite: start a docker container
4-
/* 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'
7-
*/
84

95
describe('--Integration Tests--', () => {
106

@@ -31,7 +27,7 @@ describe('--Integration Tests--', () => {
3127
}
3228
expect(streamExists).toEqual(true);
3329
})
34-
30+
3531
it('.push properly creates a push query', () => {
3632
let pushActive = false;
3733
client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 1;', async (data) => {
@@ -41,18 +37,19 @@ describe('--Integration Tests--', () => {
4137
expect(pushActive).toEqual(true)
4238
});
4339
})
44-
40+
4541
it('.terminate properly terminates a push query', () => {
4642
client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 3;', async (data) => {
4743
const terminateRes = await client.terminate(JSON.parse(data).queryId);
4844
expect(terminateRes.wasTerminated).toEqual(true);
4945
})
5046
})
51-
47+
5248
it('.insertStream properly inserts a row into a stream', async () => {
5349
const response = await client.insertStream('TESTJESTSTREAM', [
5450
{ "name": "stab-rabbit", "email": "123@mail.com", "age": 100 }
5551
]);
52+
console.log(response);
5653
const data = [];
5754
await client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES;', async (chunk) => {
5855
data.push(JSON.parse(chunk));
@@ -62,7 +59,7 @@ describe('--Integration Tests--', () => {
6259
}
6360
});
6461
})
65-
62+
6663
it('.pull receives the correct data from a pull query', async () => {
6764
const pullData = await client.pull("SELECT * FROM TESTJESTSTREAM;");
6865
console.log(pullData[1]);
@@ -77,25 +74,20 @@ describe('--Integration Tests--', () => {
7774
expect(expectPullData).toEqual(expectData);
7875
})
7976
})
77+
8078
describe('--Health Tests--', () => {
8179
beforeAll((done) => {
8280
client = new ksqljs({ ksqldbURL: 'http://localhost:8088' });
8381
done();
8482
});
83+
84+
afterAll(async () => {
85+
await client.ksql('DROP STREAM IF EXISTS TESTSTREAM2;');
86+
})
8587

86-
describe('--Health Tests--', () => {
87-
beforeAll((done) => {
88-
client = new ksqljs({ ksqldbURL: 'http://localhost:8088' });
89-
done();
90-
});
91-
92-
afterAll(async () => {
93-
await client.ksql('DROP STREAM IF EXISTS TESTSTREAM2;');
94-
})
95-
96-
it('.inspectQueryStatus checks if a stream is created successfully', async () => {
97-
const streamName = 'TESTSTREAM2'
98-
const create = await client.ksql(`CREATE STREAM IF NOT EXISTS ${streamName}
88+
it('.inspectQueryStatus checks if a stream is created successfully', async () => {
89+
const streamName = 'TESTSTREAM2'
90+
const create = await client.ksql(`CREATE STREAM IF NOT EXISTS ${streamName}
9991
(name VARCHAR,
10092
email varchar,
10193
age INTEGER)
@@ -104,93 +96,92 @@ describe('--Integration Tests--', () => {
10496
VALUE_FORMAT = 'json',
10597
PARTITIONS = 1
10698
);`);
107-
const commandId = create ? create.commandId : `stream/${streamName}/create`;
108-
const status = await client.inspectQueryStatus(commandId);
109-
// response should be { status: 'SUCCESS', message: 'Stream created', queryId: null }
110-
expect(status.data).toEqual(expect.objectContaining({
111-
status: expect.any(String),
112-
message: expect.any(String),
113-
queryId: null
114-
}));
115-
})
116-
117-
it('.inspectServerInfo returns the server info and status', async () => {
118-
const status = await client.inspectServerInfo();
119-
// should return something like: {
120-
// KsqlServerInfo: {
121-
// version: '0.25.1',
122-
// kafkaClusterId: '0Yxd6N5OSKGDUalltPWvXg',
123-
// ksqlServiceId: 'default_',
124-
// serverStatus: 'RUNNING'
125-
// }
126-
// }
127-
expect(status.data).toEqual(expect.objectContaining({
128-
KsqlServerInfo: expect.objectContaining({
129-
version: expect.any(String),
130-
kafkaClusterId: expect.any(String),
131-
serverStatus: expect.any(String)
132-
})
133-
}));
134-
})
135-
136-
it('.inspectServerHealth returns the server health', async () => {
137-
const status = await client.inspectServerHealth();
138-
// should return something like: {
139-
// isHealthy: true,
140-
// details: {
141-
// metastore: { isHealthy: true },
142-
// kafka: { isHealthy: true },
143-
// commandRunner: { isHealthy: true }
144-
// }
145-
// }
146-
expect(status.data).toEqual(expect.objectContaining({
147-
isHealthy: expect.any(Boolean),
148-
details: expect.objectContaining({
149-
metastore: expect.anything(),
150-
kafka: expect.anything(),
151-
commandRunner: expect.anything()
152-
})
99+
const commandId = create ? create.commandId : `stream/${streamName}/create`;
100+
const status = await client.inspectQueryStatus(commandId);
101+
// response should be { status: 'SUCCESS', message: 'Stream created', queryId: null }
102+
expect(status.data).toEqual(expect.objectContaining({
103+
status: expect.any(String),
104+
message: expect.any(String),
105+
queryId: null
106+
}));
107+
})
108+
109+
it('.inspectServerInfo returns the server info and status', async () => {
110+
const status = await client.inspectServerInfo();
111+
// should return something like: {
112+
// KsqlServerInfo: {
113+
// version: '0.25.1',
114+
// kafkaClusterId: '0Yxd6N5OSKGDUalltPWvXg',
115+
// ksqlServiceId: 'default_',
116+
// serverStatus: 'RUNNING'
117+
// }
118+
// }
119+
expect(status.data).toEqual(expect.objectContaining({
120+
KsqlServerInfo: expect.objectContaining({
121+
version: expect.any(String),
122+
kafkaClusterId: expect.any(String),
123+
serverStatus: expect.any(String)
153124
})
154-
);
155-
})
156-
157-
it('.inspectClusterStatus returns the cluster status', async () => {
158-
const status = await client.inspectClusterStatus();
159-
// should return something like: {
160-
// clusterStatus: {
161-
// 'ksqldb-server:8088': {
162-
// hostAlive: true,
163-
// lastStatusUpdateMs: 1653164479237,
164-
// activeStandbyPerQuery: [Object],
165-
// hostStoreLags: [Object]
166-
// }
167-
// }}
168-
expect(status.data).toEqual(expect.objectContaining({
169-
clusterStatus: expect.anything()
125+
}));
126+
})
127+
128+
it('.inspectServerHealth returns the server health', async () => {
129+
const status = await client.inspectServerHealth();
130+
// should return something like: {
131+
// isHealthy: true,
132+
// details: {
133+
// metastore: { isHealthy: true },
134+
// kafka: { isHealthy: true },
135+
// commandRunner: { isHealthy: true }
136+
// }
137+
// }
138+
expect(status.data).toEqual(expect.objectContaining({
139+
isHealthy: expect.any(Boolean),
140+
details: expect.objectContaining({
141+
metastore: expect.anything(),
142+
kafka: expect.anything(),
143+
commandRunner: expect.anything()
170144
})
171-
);
172145
})
173-
174-
it('.isValidProperty returns true if a server configuration property is not prohibited from setting', async () => {
175-
const status = await client.isValidProperty('test');
176-
// should return true
177-
expect(status.data).toEqual(true);
146+
);
147+
})
148+
149+
it('.inspectClusterStatus returns the cluster status', async () => {
150+
const status = await client.inspectClusterStatus();
151+
// should return something like: {
152+
// clusterStatus: {
153+
// 'ksqldb-server:8088': {
154+
// hostAlive: true,
155+
// lastStatusUpdateMs: 1653164479237,
156+
// activeStandbyPerQuery: [Object],
157+
// hostStoreLags: [Object]
158+
// }
159+
// }}
160+
expect(status.data).toEqual(expect.objectContaining({
161+
clusterStatus: expect.anything()
178162
})
179-
180-
// it('isValidProperty returns an error if the server property is prohibited from setting', async () => {
181-
// const status = await client.isValidProperty('ksql.connect.url');
182-
// // should return something like
183-
// // {
184-
// // "@type": "generic_error",
185-
// // "error_code": 40000,
186-
// // "message": "One or more properties overrides set locally are prohibited by the KSQL server (use UNSET to reset their default value): [ksql.service.id]"
187-
// // }
188-
// expect(status.data).toEqual(expect.objectContaining({
189-
// type: expect.any(String),
190-
// error_code: expect.any(Number),
191-
// message: expect.any(String),
192-
// }));
193-
// })
163+
);
164+
})
165+
166+
it('.isValidProperty returns true if a server configuration property is not prohibited from setting', async () => {
167+
const status = await client.isValidProperty('test');
168+
// should return true
169+
expect(status.data).toEqual(true);
194170
})
171+
172+
// it('isValidProperty returns an error if the server property is prohibited from setting', async () => {
173+
// const status = await client.isValidProperty('ksql.connect.url');
174+
// // should return something like
175+
// // {
176+
// // "@type": "generic_error",
177+
// // "error_code": 40000,
178+
// // "message": "One or more properties overrides set locally are prohibited by the KSQL server (use UNSET to reset their default value): [ksql.service.id]"
179+
// // }
180+
// expect(status.data).toEqual(expect.objectContaining({
181+
// type: expect.any(String),
182+
// error_code: expect.any(Number),
183+
// message: expect.any(String),
184+
// }));
185+
// })
195186
})
196187
})

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ services:
4343
ports:
4444
- "8088:8088"
4545
environment:
46-
KSQL_LISTENERS: http://0.0.0.0:8088
46+
KSQL_LISTENERS: https://0.0.0.0:8088
4747
KSQL_BOOTSTRAP_SERVERS: broker:9092
4848
KSQL_KSQL_LOGGING_PROCESSING_STREAM_AUTO_CREATE: "true"
4949
KSQL_KSQL_LOGGING_PROCESSING_TOPIC_AUTO_CREATE: "true"
@@ -52,9 +52,9 @@ services:
5252
# KSQL_AUTHENTICATION_REALM: KsqlServer-Props
5353
# KSQL_AUTHENTICATION_ROLES: admin,developer,user
5454
# KSQL_SSL_CLIENT_AUTHENTICATION: NONE
55-
# KSQL_SSL_TRUSTSTORE_LOCATION: kafka.server.truststore.jks
55+
# KSQL_SSL_TRUSTSTORE_LOCATION: ksqldb_server_config/kafka.server.truststore.jks
5656
# KSQL_SSL_TRUSTSTORE_PASSWORD: ${SSL_PASSWORD}
57-
# KSQL_SSL_KEYSTORE_LOCATION: kafka.server.keystore.jks
57+
# KSQL_SSL_KEYSTORE_LOCATION: ksqldb_server_config/kafka.server.keystore.jks
5858
# KSQL_SSL_KEYSTORE_PASSWORD: ${SSL_PASSWORD}
5959
# KSQL_SSL_KEY_PASSWORD: ${SSL_PASSWORD}
6060
KSQL_KSQL_HEARTBEAT_ENABLE: "true"

0 commit comments

Comments
 (0)