Skip to content

Commit 8d10b18

Browse files
Merge pull request #23 from oslabs-beta/ja/ssl
Ja/ssl
2 parents 4b42a7f + d10e534 commit 8d10b18

File tree

7 files changed

+225
-5683
lines changed

7 files changed

+225
-5683
lines changed

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,11 @@ dist
104104
.tern-port
105105

106106
# Local
107-
./ksqljsTest.js
107+
ksqljsTest.js
108+
package-lock.json
109+
local_ignore/
110+
.gitignore
111+
112+
# KSQLDB docker server settings
113+
ksqldb_server_config/
114+

__tests__/integrationtests.js

Lines changed: 98 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('--Integration Tests--', () => {
3131
}
3232
expect(streamExists).toEqual(true);
3333
})
34-
34+
3535
it('.push properly creates a push query', () => {
3636
let pushActive = false;
3737
client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 1;', async (data) => {
@@ -41,18 +41,19 @@ describe('--Integration Tests--', () => {
4141
expect(pushActive).toEqual(true)
4242
});
4343
})
44-
44+
4545
it('.terminate properly terminates a push query', () => {
4646
client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 3;', async (data) => {
4747
const terminateRes = await client.terminate(JSON.parse(data).queryId);
4848
expect(terminateRes.wasTerminated).toEqual(true);
4949
})
5050
})
51-
51+
5252
it('.insertStream properly inserts a row into a stream', async () => {
5353
const response = await client.insertStream('TESTJESTSTREAM', [
5454
{ "name": "stab-rabbit", "email": "123@mail.com", "age": 100 }
5555
]);
56+
console.log(response);
5657
const data = [];
5758
await client.push('SELECT * FROM TESTJESTSTREAM EMIT CHANGES;', async (chunk) => {
5859
data.push(JSON.parse(chunk));
@@ -62,10 +63,11 @@ describe('--Integration Tests--', () => {
6263
}
6364
});
6465
})
65-
66+
6667
it('.pull receives the correct data from a pull query', async () => {
6768
const pullData = await client.pull("SELECT * FROM TESTJESTSTREAM;");
68-
expect(pullData[1]).toEqual(['stab-rabbit', '123@mail.com', 100]);
69+
console.log(pullData[1]);
70+
expect(pullData[1]).toEqual(["stab-rabbit", "123@mail.com", 100]);
6971
})
7072

7173
it('.pullFromTo receives all the data', async () => {
@@ -76,25 +78,20 @@ describe('--Integration Tests--', () => {
7678
expect(expectPullData).toEqual(expectData);
7779
})
7880
})
81+
7982
describe('--Health Tests--', () => {
8083
beforeAll((done) => {
8184
client = new ksqljs({ ksqldbURL: 'http://localhost:8088' });
8285
done();
8386
});
87+
88+
afterAll(async () => {
89+
await client.ksql('DROP STREAM IF EXISTS TESTSTREAM2;');
90+
})
8491

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

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ services:
3434
image: confluentinc/ksqldb-server:0.25.1
3535
hostname: ksqldb-server
3636
container_name: ksqldb-server
37+
volumes:
38+
- type: bind
39+
source: ./
40+
target: /home/appuser
3741
depends_on:
3842
- broker
3943
ports:
@@ -43,6 +47,16 @@ services:
4347
KSQL_BOOTSTRAP_SERVERS: broker:9092
4448
KSQL_KSQL_LOGGING_PROCESSING_STREAM_AUTO_CREATE: "true"
4549
KSQL_KSQL_LOGGING_PROCESSING_TOPIC_AUTO_CREATE: "true"
50+
# KSQL_KSQL_OPTS: "-Djava.security.auth.login.config=/jaas_config.file"
51+
# KSQL_AUTHENTICATION_METHOD: BASIC
52+
# KSQL_AUTHENTICATION_REALM: KsqlServer-Props
53+
# KSQL_AUTHENTICATION_ROLES: admin,developer,user
54+
# KSQL_SSL_CLIENT_AUTHENTICATION: NONE
55+
# KSQL_SSL_TRUSTSTORE_LOCATION: ksqldb_server_config/kafka.server.truststore.jks
56+
# KSQL_SSL_TRUSTSTORE_PASSWORD: ${SSL_PASSWORD}
57+
# KSQL_SSL_KEYSTORE_LOCATION: ksqldb_server_config/kafka.server.keystore.jks
58+
# KSQL_SSL_KEYSTORE_PASSWORD: ${SSL_PASSWORD}
59+
# KSQL_SSL_KEY_PASSWORD: ${SSL_PASSWORD}
4660
KSQL_KSQL_HEARTBEAT_ENABLE: "true"
4761
KSQL_KSQL_LAG_REPORTING_ENABLE: "true"
4862

0 commit comments

Comments
 (0)