@@ -31,7 +31,7 @@ describe('--Integration Tests--', () => {
31
31
}
32
32
expect ( streamExists ) . toEqual ( true ) ;
33
33
} )
34
-
34
+
35
35
it ( '.push properly creates a push query' , ( ) => {
36
36
let pushActive = false ;
37
37
client . push ( 'SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 1;' , async ( data ) => {
@@ -41,18 +41,19 @@ describe('--Integration Tests--', () => {
41
41
expect ( pushActive ) . toEqual ( true )
42
42
} ) ;
43
43
} )
44
-
44
+
45
45
it ( '.terminate properly terminates a push query' , ( ) => {
46
46
client . push ( 'SELECT * FROM TESTJESTSTREAM EMIT CHANGES LIMIT 3;' , async ( data ) => {
47
47
const terminateRes = await client . terminate ( JSON . parse ( data ) . queryId ) ;
48
48
expect ( terminateRes . wasTerminated ) . toEqual ( true ) ;
49
49
} )
50
50
} )
51
-
51
+
52
52
it ( '.insertStream properly inserts a row into a stream' , async ( ) => {
53
53
const response = await client . insertStream ( 'TESTJESTSTREAM' , [
54
54
{ "name" : "stab-rabbit" , "email" : "123@mail.com" , "age" : 100 }
55
55
] ) ;
56
+ console . log ( response ) ;
56
57
const data = [ ] ;
57
58
await client . push ( 'SELECT * FROM TESTJESTSTREAM EMIT CHANGES;' , async ( chunk ) => {
58
59
data . push ( JSON . parse ( chunk ) ) ;
@@ -62,10 +63,11 @@ describe('--Integration Tests--', () => {
62
63
}
63
64
} ) ;
64
65
} )
65
-
66
+
66
67
it ( '.pull receives the correct data from a pull query' , async ( ) => {
67
68
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 ] ) ;
69
71
} )
70
72
71
73
it ( '.pullFromTo receives all the data' , async ( ) => {
@@ -76,25 +78,20 @@ describe('--Integration Tests--', () => {
76
78
expect ( expectPullData ) . toEqual ( expectData ) ;
77
79
} )
78
80
} )
81
+
79
82
describe ( '--Health Tests--' , ( ) => {
80
83
beforeAll ( ( done ) => {
81
84
client = new ksqljs ( { ksqldbURL : 'http://localhost:8088' } ) ;
82
85
done ( ) ;
83
86
} ) ;
87
+
88
+ afterAll ( async ( ) => {
89
+ await client . ksql ( 'DROP STREAM IF EXISTS TESTSTREAM2;' ) ;
90
+ } )
84
91
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 }
98
95
(name VARCHAR,
99
96
email varchar,
100
97
age INTEGER)
@@ -103,93 +100,92 @@ describe('--Integration Tests--', () => {
103
100
VALUE_FORMAT = 'json',
104
101
PARTITIONS = 1
105
102
);` ) ;
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 )
152
128
} )
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 ( )
169
148
} )
170
- ) ;
171
149
} )
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 ( )
177
166
} )
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 ) ;
193
174
} )
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
+ // })
194
190
} )
195
- } )
191
+ } )
0 commit comments