@@ -24,6 +24,7 @@ jest.mock('../chronos_npm_package/controllers/mongo.js', () => ({
24
24
health : jest . fn ( config => config ) ,
25
25
communications : jest . fn ( config => config ) ,
26
26
serverQuery : jest . fn ( config => config ) ,
27
+ storeGrafanaAPIKey : jest . fn ( config => config ) ,
27
28
} ) ) ;
28
29
29
30
jest . mock ( '../chronos_npm_package/controllers/postgres.js' , ( ) => ( {
@@ -144,7 +145,7 @@ describe('Chronos Config', () => {
144
145
} ) ;
145
146
} ) ;
146
147
describe ( 'kafka' , ( ) => {
147
- test ( 'should check if kafka is functional' , async ( ) => {
148
+ test ( 'should check if kafka with MongoDB functional' , async ( ) => {
148
149
const config = {
149
150
microservice : 'test' ,
150
151
interval : 300 ,
@@ -166,6 +167,25 @@ describe('Chronos Config', () => {
166
167
expect ( mongo . connect ) . toHaveBeenCalledWith ( config ) ;
167
168
expect ( mongo . serverQuery ) . toHaveBeenCalledWith ( config ) ;
168
169
}
170
+ } ) ;
171
+ test ( 'should check if kafka with PostgreSQL is functional' , async ( ) => {
172
+ const config = {
173
+ microservice : 'test' ,
174
+ interval : 300 ,
175
+ mode : 'micro' ,
176
+ dockerized : true ,
177
+ database : {
178
+ connection : 'REST' ,
179
+ type : 'PostgreSQL' ,
180
+ URI : process . env . CHRONOS_URI ,
181
+ } ,
182
+ notifications : [ ] ,
183
+ } ;
184
+ const { database, dockerized } = config ;
185
+ const falseDock = { dockerized : false } ;
186
+ const chronos = new Chronos ( config ) ;
187
+ chronos . kafka ( ) ;
188
+ await helpers . testMetricsQuery ( config ) ;
169
189
if ( database . type === 'PostgreSQL' ) {
170
190
expect ( postgres . connect ) . toHaveBeenCalledWith ( config ) ;
171
191
expect ( postgres . serverQuery ) . toHaveBeenCalledWith ( config ) ;
@@ -174,11 +194,11 @@ describe('Chronos Config', () => {
174
194
} ) ;
175
195
176
196
describe ( 'kubernetes' , ( ) => {
177
- test ( 'should check if kubernetes is functional' , async ( ) => {
197
+ test ( 'should check if kubernetes with mongodb is functional' , async ( ) => {
178
198
const config = {
179
199
microservice : 'test' ,
180
200
interval : 300 ,
181
- mode : 'micro ' ,
201
+ mode : 'kubernetes ' ,
182
202
dockerized : true ,
183
203
database : {
184
204
connection : 'REST' ,
@@ -193,9 +213,33 @@ describe('Chronos Config', () => {
193
213
chronos . kubernetes ( ) ;
194
214
await helpers . testMetricsQuery ( config ) ;
195
215
if ( database . type === 'MongoDB' ) {
196
- expect ( mongo . connect ) . toHaveBeenCalledWith ( config ) ;
216
+ await expect ( mongo . connect ) . toHaveBeenCalledWith ( config ) ;
217
+ await expect ( mongo . storeGrafanaAPIKey ) . toHaveBeenCalledWith ( config ) ;
197
218
expect ( mongo . serverQuery ) . toHaveBeenCalledWith ( config ) ;
198
219
}
220
+ if ( database . type === 'PostgreSQL' ) {
221
+ expect ( postgres . connect ) . toHaveBeenCalledWith ( config2 ) ;
222
+ expect ( postgres . serverQuery ) . toHaveBeenCalledWith ( config2 ) ;
223
+ }
224
+ } ) ;
225
+ test ( 'should check if kubernetes with PostGres is functional' , async ( ) => {
226
+ const config = {
227
+ microservice : 'test' ,
228
+ interval : 300 ,
229
+ mode : 'kubernetes' ,
230
+ dockerized : true ,
231
+ database : {
232
+ connection : 'REST' ,
233
+ type : 'PostgreSQL' ,
234
+ URI : process . env . CHRONOS_URI ,
235
+ } ,
236
+ notifications : [ ] ,
237
+ } ;
238
+ const { database, dockerized } = config ;
239
+ const falseDock = { dockerized : false } ;
240
+ const chronos = new Chronos ( config ) ;
241
+ chronos . kubernetes ( ) ;
242
+ await helpers . testMetricsQuery ( config ) ;
199
243
if ( database . type === 'PostgreSQL' ) {
200
244
expect ( postgres . connect ) . toHaveBeenCalledWith ( config ) ;
201
245
expect ( postgres . serverQuery ) . toHaveBeenCalledWith ( config ) ;
0 commit comments