Skip to content

Commit 2d784a3

Browse files
authored
Merge pull request #12 from HEET-Group/devDocker-addingGrafana
Dev docker adding grafana
2 parents ffa4d79 + 3762557 commit 2d784a3

File tree

7 files changed

+60
-55
lines changed

7 files changed

+60
-55
lines changed

__backend-tests__/alert.test.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

__backend-tests__/chronosMethods.test.js

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jest.mock('../chronos_npm_package/controllers/mongo.js', () => ({
2424
health: jest.fn(config => config),
2525
communications: jest.fn(config => config),
2626
serverQuery: jest.fn(config => config),
27+
storeGrafanaAPIKey: jest.fn(config => config),
2728
}));
2829

2930
jest.mock('../chronos_npm_package/controllers/postgres.js', () => ({
@@ -144,7 +145,7 @@ describe('Chronos Config', () => {
144145
});
145146
});
146147
describe('kafka', () => {
147-
test('should check if kafka is functional', async () => {
148+
test('should check if kafka with MongoDB functional', async () => {
148149
const config = {
149150
microservice: 'test',
150151
interval: 300,
@@ -166,6 +167,25 @@ describe('Chronos Config', () => {
166167
expect(mongo.connect).toHaveBeenCalledWith(config);
167168
expect(mongo.serverQuery).toHaveBeenCalledWith(config);
168169
}
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);
169189
if (database.type === 'PostgreSQL') {
170190
expect(postgres.connect).toHaveBeenCalledWith(config);
171191
expect(postgres.serverQuery).toHaveBeenCalledWith(config);
@@ -174,11 +194,11 @@ describe('Chronos Config', () => {
174194
});
175195

176196
describe('kubernetes', () => {
177-
test('should check if kubernetes is functional', async () => {
197+
test('should check if kubernetes with mongodb is functional', async () => {
178198
const config = {
179199
microservice: 'test',
180200
interval: 300,
181-
mode: 'micro',
201+
mode: 'kubernetes',
182202
dockerized: true,
183203
database: {
184204
connection: 'REST',
@@ -193,9 +213,33 @@ describe('Chronos Config', () => {
193213
chronos.kubernetes();
194214
await helpers.testMetricsQuery(config);
195215
if (database.type === 'MongoDB') {
196-
expect(mongo.connect).toHaveBeenCalledWith(config);
216+
await expect(mongo.connect).toHaveBeenCalledWith(config);
217+
await expect(mongo.storeGrafanaAPIKey).toHaveBeenCalledWith(config);
197218
expect(mongo.serverQuery).toHaveBeenCalledWith(config);
198219
}
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);
199243
if (database.type === 'PostgreSQL') {
200244
expect(postgres.connect).toHaveBeenCalledWith(config);
201245
expect(postgres.serverQuery).toHaveBeenCalledWith(config);

__backend-tests__/dockerHelper.test.js

Whitespace-only changes.

__backend-tests__/healthHelpers.test.js

Whitespace-only changes.

__backend-tests__/jest.config.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
module.exports = {
2-
// testEnvironment: 'node', // Use the Node.js environment for testing
3-
// roots: ['<rootDir>/controllers'], // Set the root directory for test files
4-
5-
// testRegex: '(/tests/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
6-
7-
// // Code coverage settings
8-
// collectCoverage: true,
9-
// coverageDirectory: 'coverage',
2+
// testEnvironment: 'node', // Use the Node.js environment for testing
3+
// roots: ['<rootDir>/controllers'], // Set the root directory for test files
104

11-
// // Specify the test path patterns to ignore frontend tests
12-
// testPathIgnorePatterns: ['/node_modules/', '/__tests__/'],
13-
// };
5+
// testRegex: '(/tests/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
146

15-
// =======
7+
// // Code coverage settings
8+
// collectCoverage: true,
9+
// coverageDirectory: 'coverage',
10+
11+
// // Specify the test path patterns to ignore frontend tests
12+
// testPathIgnorePatterns: ['/node_modules/', '/__tests__/'],
13+
// };
14+
15+
// =======
1616
roots: ['<rootDir>'], // Set the root directory for test files (adjust this path to your test folder)
1717

1818
testRegex: '(/tests/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
1919

2020
// Code coverage settings
2121
collectCoverage: true,
2222
coverageDirectory: 'coverage',
23-
2423
// Specify the test path patterns to ignore (frontend tests)
2524
testPathIgnorePatterns: ['/node_modules/', '/__tests__/'],
2625
};
27-

__backend-tests__/postgres.test.js

Whitespace-only changes.

__backend-tests__/utilities.test.js

Whitespace-only changes.

0 commit comments

Comments
 (0)