@centreon/js-config 24.4.1-MON-23368-containers.14 → 24.4.1-release-24-04-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cypress/e2e/commands.ts +166 -181
- package/cypress/e2e/configuration.ts +0 -2
- package/cypress/e2e/tasks.ts +1 -119
- package/package.json +4 -7
package/cypress/e2e/commands.ts
CHANGED
|
@@ -100,24 +100,6 @@ Cypress.Commands.add(
|
|
|
100
100
|
}
|
|
101
101
|
);
|
|
102
102
|
|
|
103
|
-
Cypress.Commands.add('getContainerId', (containerName: string) => {
|
|
104
|
-
cy.log(`Getting container id of ${containerName}`);
|
|
105
|
-
|
|
106
|
-
return cy.task('getContainerId', containerName);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
Cypress.Commands.add('getContainerIpAddress', (containerName: string) => {
|
|
110
|
-
cy.log(`Getting container ip address of ${containerName}`);
|
|
111
|
-
|
|
112
|
-
return cy.task('getContainerIpAddress', containerName);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
Cypress.Commands.add('getContainersLogs', () => {
|
|
116
|
-
cy.log('Getting containers logs');
|
|
117
|
-
|
|
118
|
-
return cy.task('getContainersLogs');
|
|
119
|
-
});
|
|
120
|
-
|
|
121
103
|
interface CopyFromContainerProps {
|
|
122
104
|
destination: string;
|
|
123
105
|
name?: string;
|
|
@@ -126,18 +108,15 @@ interface CopyFromContainerProps {
|
|
|
126
108
|
|
|
127
109
|
Cypress.Commands.add(
|
|
128
110
|
'copyFromContainer',
|
|
129
|
-
(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
serviceName: name,
|
|
139
|
-
source
|
|
140
|
-
});
|
|
111
|
+
(
|
|
112
|
+
{
|
|
113
|
+
name = Cypress.env('dockerName'),
|
|
114
|
+
source,
|
|
115
|
+
destination
|
|
116
|
+
}: CopyFromContainerProps,
|
|
117
|
+
options?: Partial<Cypress.ExecOptions>
|
|
118
|
+
) => {
|
|
119
|
+
return cy.exec(`docker cp ${name}:${source} "${destination}"`, options);
|
|
141
120
|
}
|
|
142
121
|
);
|
|
143
122
|
|
|
@@ -157,8 +136,6 @@ Cypress.Commands.add(
|
|
|
157
136
|
}: CopyToContainerProps,
|
|
158
137
|
options?: Partial<Cypress.ExecOptions>
|
|
159
138
|
) => {
|
|
160
|
-
cy.log(`Copy content from ${source} to ${name}:${destination}`);
|
|
161
|
-
|
|
162
139
|
return cy.exec(`docker cp ${source} ${name}:${destination}`, options);
|
|
163
140
|
}
|
|
164
141
|
);
|
|
@@ -229,23 +206,19 @@ interface ExecInContainerProps {
|
|
|
229
206
|
name: string;
|
|
230
207
|
}
|
|
231
208
|
|
|
232
|
-
interface ExecInContainerResult {
|
|
233
|
-
exitCode: number;
|
|
234
|
-
output: string;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
209
|
Cypress.Commands.add(
|
|
238
210
|
'execInContainer',
|
|
239
211
|
({ command, name }: ExecInContainerProps): Cypress.Chainable => {
|
|
240
212
|
return cy
|
|
241
|
-
.
|
|
213
|
+
.exec(`docker exec -i ${name} ${command}`, { failOnNonZeroExit: false })
|
|
242
214
|
.then((result) => {
|
|
243
|
-
if (result.
|
|
215
|
+
if (result.code) {
|
|
244
216
|
// output will not be truncated
|
|
245
217
|
throw new Error(`
|
|
246
218
|
Execution of "${command}" failed
|
|
247
|
-
Exit code: ${result.
|
|
248
|
-
|
|
219
|
+
Exit code: ${result.code}
|
|
220
|
+
Stdout:\n${result.stdout}
|
|
221
|
+
Stderr:\n${result.stderr}`);
|
|
249
222
|
}
|
|
250
223
|
|
|
251
224
|
return cy.wrap(result);
|
|
@@ -253,166 +226,181 @@ Cypress.Commands.add(
|
|
|
253
226
|
}
|
|
254
227
|
);
|
|
255
228
|
|
|
256
|
-
interface
|
|
257
|
-
|
|
258
|
-
|
|
229
|
+
interface PortBinding {
|
|
230
|
+
destination: number;
|
|
231
|
+
source: number;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
interface StartContainerProps {
|
|
235
|
+
image: string;
|
|
236
|
+
name: string;
|
|
237
|
+
portBindings: Array<PortBinding>;
|
|
259
238
|
}
|
|
260
239
|
|
|
261
240
|
Cypress.Commands.add(
|
|
262
|
-
'
|
|
263
|
-
({
|
|
264
|
-
|
|
241
|
+
'startContainer',
|
|
242
|
+
({ name, image, portBindings }: StartContainerProps): Cypress.Chainable => {
|
|
243
|
+
cy.log(`Starting container ${name} from image ${image}`);
|
|
244
|
+
|
|
245
|
+
return cy.task(
|
|
246
|
+
'startContainer',
|
|
247
|
+
{ image, name, portBindings },
|
|
248
|
+
{ timeout: 600000 } // 10 minutes because docker pull can be very slow
|
|
249
|
+
);
|
|
265
250
|
}
|
|
266
251
|
);
|
|
267
252
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
253
|
+
Cypress.Commands.add(
|
|
254
|
+
'createDirectory',
|
|
255
|
+
(directoryPath: string): Cypress.Chainable => {
|
|
256
|
+
return cy.task('createDirectory', directoryPath);
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
interface StartWebContainerProps {
|
|
261
|
+
name?: string;
|
|
262
|
+
os?: string;
|
|
273
263
|
useSlim?: boolean;
|
|
274
|
-
|
|
275
|
-
webVersion?: string;
|
|
264
|
+
version?: string;
|
|
276
265
|
}
|
|
277
266
|
|
|
278
267
|
Cypress.Commands.add(
|
|
279
|
-
'
|
|
268
|
+
'startWebContainer',
|
|
280
269
|
({
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
'OPENID_IMAGE_VERSION'
|
|
284
|
-
)}`,
|
|
285
|
-
profiles = [],
|
|
286
|
-
samlImage = `docker.centreon.com/centreon/keycloak:${Cypress.env(
|
|
287
|
-
'SAML_IMAGE_VERSION'
|
|
288
|
-
)}`,
|
|
270
|
+
name = Cypress.env('dockerName'),
|
|
271
|
+
os = Cypress.env('WEB_IMAGE_OS'),
|
|
289
272
|
useSlim = true,
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}: StartContainersProps = {}): Cypress.Chainable => {
|
|
293
|
-
cy.log('Starting containers ...');
|
|
294
|
-
|
|
273
|
+
version = Cypress.env('WEB_IMAGE_VERSION')
|
|
274
|
+
}: StartWebContainerProps = {}): Cypress.Chainable => {
|
|
295
275
|
const slimSuffix = useSlim ? '-slim' : '';
|
|
296
276
|
|
|
297
|
-
const
|
|
277
|
+
const image = `docker.centreon.com/centreon/centreon-web${slimSuffix}-${os}:${version}`;
|
|
298
278
|
|
|
299
279
|
return cy
|
|
300
|
-
.
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
{
|
|
304
|
-
)
|
|
280
|
+
.startContainer({
|
|
281
|
+
image,
|
|
282
|
+
name,
|
|
283
|
+
portBindings: [{ destination: 4000, source: 80 }]
|
|
284
|
+
})
|
|
305
285
|
.then(() => {
|
|
306
286
|
const baseUrl = 'http://127.0.0.1:4000';
|
|
307
287
|
|
|
308
288
|
Cypress.config('baseUrl', baseUrl);
|
|
309
289
|
|
|
310
|
-
return cy.
|
|
290
|
+
return cy.task(
|
|
291
|
+
'waitOn',
|
|
292
|
+
`${baseUrl}/centreon/api/latest/platform/installation/status`
|
|
293
|
+
);
|
|
311
294
|
})
|
|
312
295
|
.visit('/') // this is necessary to refresh browser cause baseUrl has changed (flash appears in video)
|
|
313
296
|
.setUserTokenApiV1();
|
|
314
297
|
}
|
|
315
298
|
);
|
|
316
299
|
|
|
317
|
-
|
|
318
|
-
|
|
300
|
+
interface StopWebContainerProps {
|
|
301
|
+
name?: string;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
Cypress.Commands.add(
|
|
305
|
+
'stopWebContainer',
|
|
306
|
+
({
|
|
307
|
+
name = Cypress.env('dockerName')
|
|
308
|
+
}: StopWebContainerProps = {}): Cypress.Chainable => {
|
|
309
|
+
const logDirectory = `results/logs/${Cypress.spec.name.replace(
|
|
310
|
+
artifactIllegalCharactersMatcher,
|
|
311
|
+
'_'
|
|
312
|
+
)}/${Cypress.currentTest.title.replace(
|
|
313
|
+
artifactIllegalCharactersMatcher,
|
|
314
|
+
'_'
|
|
315
|
+
)}`;
|
|
319
316
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
317
|
+
return cy
|
|
318
|
+
.visitEmptyPage()
|
|
319
|
+
.createDirectory(logDirectory)
|
|
320
|
+
.copyFromContainer({
|
|
321
|
+
destination: `${logDirectory}/broker`,
|
|
322
|
+
name,
|
|
323
|
+
source: '/var/log/centreon-broker'
|
|
324
|
+
})
|
|
325
|
+
.copyFromContainer({
|
|
326
|
+
destination: `${logDirectory}/engine`,
|
|
327
|
+
name,
|
|
328
|
+
source: '/var/log/centreon-engine'
|
|
329
|
+
})
|
|
330
|
+
.copyFromContainer({
|
|
331
|
+
destination: `${logDirectory}/centreon`,
|
|
332
|
+
name,
|
|
333
|
+
source: '/var/log/centreon'
|
|
334
|
+
})
|
|
335
|
+
.copyFromContainer({
|
|
336
|
+
destination: `${logDirectory}/centreon-gorgone`,
|
|
337
|
+
name,
|
|
338
|
+
source: '/var/log/centreon-gorgone'
|
|
339
|
+
})
|
|
340
|
+
.then(() => {
|
|
341
|
+
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
342
|
+
return cy.copyFromContainer({
|
|
343
|
+
destination: `${logDirectory}/php`,
|
|
344
|
+
name,
|
|
345
|
+
source: '/var/log/php-fpm'
|
|
346
|
+
});
|
|
347
|
+
}
|
|
327
348
|
|
|
328
|
-
|
|
349
|
+
return cy.copyFromContainer(
|
|
350
|
+
{
|
|
351
|
+
destination: `${logDirectory}/php8.1-fpm-centreon-error.log`,
|
|
352
|
+
name,
|
|
353
|
+
source: '/var/log/php8.1-fpm-centreon-error.log'
|
|
354
|
+
},
|
|
355
|
+
{ failOnNonZeroExit: false }
|
|
356
|
+
);
|
|
357
|
+
})
|
|
358
|
+
.then(() => {
|
|
359
|
+
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
360
|
+
return cy.copyFromContainer({
|
|
361
|
+
destination: `${logDirectory}/httpd`,
|
|
362
|
+
name,
|
|
363
|
+
source: '/var/log/httpd'
|
|
364
|
+
});
|
|
365
|
+
}
|
|
329
366
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
`results/logs/${Cypress.spec.name.replace(
|
|
338
|
-
artifactIllegalCharactersMatcher,
|
|
339
|
-
'_'
|
|
340
|
-
)}/${Cypress.currentTest.title.replace(
|
|
341
|
-
artifactIllegalCharactersMatcher,
|
|
342
|
-
'_'
|
|
343
|
-
)}/container-${containerName}.log`,
|
|
344
|
-
logs
|
|
367
|
+
return cy.copyFromContainer(
|
|
368
|
+
{
|
|
369
|
+
destination: `${logDirectory}/apache2`,
|
|
370
|
+
name,
|
|
371
|
+
source: '/var/log/apache2'
|
|
372
|
+
},
|
|
373
|
+
{ failOnNonZeroExit: false }
|
|
345
374
|
);
|
|
346
|
-
})
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
source: '/var/log/centreon-broker'
|
|
352
|
-
})
|
|
353
|
-
.copyFromContainer({
|
|
354
|
-
destination: `${logDirectory}/engine`,
|
|
355
|
-
name,
|
|
356
|
-
source: '/var/log/centreon-engine'
|
|
357
|
-
})
|
|
358
|
-
.copyFromContainer({
|
|
359
|
-
destination: `${logDirectory}/centreon`,
|
|
360
|
-
name,
|
|
361
|
-
source: '/var/log/centreon'
|
|
362
|
-
})
|
|
363
|
-
.copyFromContainer({
|
|
364
|
-
destination: `${logDirectory}/centreon-gorgone`,
|
|
365
|
-
name,
|
|
366
|
-
source: '/var/log/centreon-gorgone'
|
|
367
|
-
})
|
|
368
|
-
.then(() => {
|
|
369
|
-
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
370
|
-
return cy.copyFromContainer({
|
|
371
|
-
destination: `${logDirectory}/php`,
|
|
372
|
-
name,
|
|
373
|
-
source: '/var/log/php-fpm'
|
|
374
|
-
});
|
|
375
|
-
}
|
|
375
|
+
})
|
|
376
|
+
.exec(`chmod -R 755 "${logDirectory}"`)
|
|
377
|
+
.stopContainer({ name });
|
|
378
|
+
}
|
|
379
|
+
);
|
|
376
380
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
name,
|
|
381
|
-
source: '/var/log/php8.1-fpm-centreon-error.log'
|
|
382
|
-
},
|
|
383
|
-
{ failOnNonZeroExit: false }
|
|
384
|
-
);
|
|
385
|
-
})
|
|
386
|
-
.then(() => {
|
|
387
|
-
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
388
|
-
return cy.copyFromContainer({
|
|
389
|
-
destination: `${logDirectory}/httpd`,
|
|
390
|
-
name,
|
|
391
|
-
source: '/var/log/httpd'
|
|
392
|
-
});
|
|
393
|
-
}
|
|
381
|
+
interface StopContainerProps {
|
|
382
|
+
name: string;
|
|
383
|
+
}
|
|
394
384
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
385
|
+
Cypress.Commands.add(
|
|
386
|
+
'stopContainer',
|
|
387
|
+
({ name }: StopContainerProps): Cypress.Chainable => {
|
|
388
|
+
cy.log(`Stopping container ${name}`);
|
|
389
|
+
|
|
390
|
+
cy.exec(`docker logs ${name}`).then(({ stdout }) => {
|
|
391
|
+
cy.writeFile(
|
|
392
|
+
`results/logs/${Cypress.spec.name.replace(
|
|
393
|
+
artifactIllegalCharactersMatcher,
|
|
394
|
+
'_'
|
|
395
|
+
)}/${Cypress.currentTest.title.replace(
|
|
396
|
+
artifactIllegalCharactersMatcher,
|
|
397
|
+
'_'
|
|
398
|
+
)}/container-${name}.log`,
|
|
399
|
+
stdout
|
|
402
400
|
);
|
|
403
|
-
})
|
|
404
|
-
.exec(`chmod -R 755 "${logDirectory}"`)
|
|
405
|
-
.task(
|
|
406
|
-
'stopContainers',
|
|
407
|
-
{},
|
|
408
|
-
{ timeout: 600000 } // 10 minutes because docker pull can be very slow
|
|
409
|
-
);
|
|
410
|
-
});
|
|
401
|
+
});
|
|
411
402
|
|
|
412
|
-
|
|
413
|
-
'createDirectory',
|
|
414
|
-
(directoryPath: string): Cypress.Chainable => {
|
|
415
|
-
return cy.task('createDirectory', directoryPath);
|
|
403
|
+
return cy.task('stopContainer', { name });
|
|
416
404
|
}
|
|
417
405
|
);
|
|
418
406
|
|
|
@@ -588,9 +576,6 @@ declare global {
|
|
|
588
576
|
command,
|
|
589
577
|
name
|
|
590
578
|
}: ExecInContainerProps) => Cypress.Chainable;
|
|
591
|
-
getContainerId: (containerName: string) => Cypress.Chainable;
|
|
592
|
-
getContainerIpAddress: (containerName: string) => Cypress.Chainable;
|
|
593
|
-
getContainersLogs: () => Cypress.Chainable;
|
|
594
579
|
getIframeBody: () => Cypress.Chainable;
|
|
595
580
|
getTimeFromHeader: () => Cypress.Chainable;
|
|
596
581
|
getWebVersion: () => Cypress.Chainable;
|
|
@@ -601,6 +586,7 @@ declare global {
|
|
|
601
586
|
dashboard: Dashboard,
|
|
602
587
|
patch: PatchDashboardBody
|
|
603
588
|
) => Cypress.Chainable;
|
|
589
|
+
|
|
604
590
|
loginByTypeOfUser: ({
|
|
605
591
|
jsonName,
|
|
606
592
|
loginViaApi
|
|
@@ -611,24 +597,23 @@ declare global {
|
|
|
611
597
|
rootItemNumber,
|
|
612
598
|
subMenu
|
|
613
599
|
}: NavigateToProps) => Cypress.Chainable;
|
|
614
|
-
requestOnDatabase: ({
|
|
615
|
-
database,
|
|
616
|
-
query
|
|
617
|
-
}: RequestOnDatabaseProps) => Cypress.Chainable;
|
|
618
600
|
shareDashboardToUser: ({
|
|
619
601
|
dashboardName,
|
|
620
602
|
userName,
|
|
621
603
|
role
|
|
622
604
|
}: ShareDashboardToUserProps) => Cypress.Chainable;
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
605
|
+
startContainer: ({
|
|
606
|
+
name,
|
|
607
|
+
image
|
|
608
|
+
}: StartContainerProps) => Cypress.Chainable;
|
|
609
|
+
startWebContainer: ({
|
|
610
|
+
name,
|
|
611
|
+
os,
|
|
627
612
|
useSlim,
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
}
|
|
631
|
-
|
|
613
|
+
version
|
|
614
|
+
}?: StartWebContainerProps) => Cypress.Chainable;
|
|
615
|
+
stopContainer: ({ name }: StopContainerProps) => Cypress.Chainable;
|
|
616
|
+
stopWebContainer: ({ name }?: StopWebContainerProps) => Cypress.Chainable;
|
|
632
617
|
visitEmptyPage: () => Cypress.Chainable;
|
|
633
618
|
waitForContainerAndSetToken: () => Cypress.Chainable;
|
|
634
619
|
}
|
|
@@ -60,9 +60,7 @@ export default ({
|
|
|
60
60
|
},
|
|
61
61
|
env: {
|
|
62
62
|
...env,
|
|
63
|
-
DATABASE_IMAGE: 'bitnami/mariadb:10.5',
|
|
64
63
|
OPENID_IMAGE_VERSION: process.env.MAJOR || '24.04',
|
|
65
|
-
SAML_IMAGE_VERSION: process.env.MAJOR || '24.04',
|
|
66
64
|
WEB_IMAGE_OS: 'alma9',
|
|
67
65
|
WEB_IMAGE_VERSION: webImageVersion,
|
|
68
66
|
dockerName: dockerName || 'centreon-dev'
|
package/cypress/e2e/tasks.ts
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
1
|
import { execSync } from 'child_process';
|
|
3
|
-
import {
|
|
2
|
+
import { existsSync, mkdirSync } from 'fs';
|
|
4
3
|
|
|
5
4
|
import Docker from 'dockerode';
|
|
6
|
-
import tar from 'tar-fs';
|
|
7
|
-
import {
|
|
8
|
-
DockerComposeEnvironment,
|
|
9
|
-
StartedTestContainer,
|
|
10
|
-
Wait,
|
|
11
|
-
getContainerRuntimeClient
|
|
12
|
-
} from 'testcontainers';
|
|
13
|
-
import { createConnection } from 'mysql2/promise';
|
|
14
5
|
|
|
15
6
|
export default (on: Cypress.PluginEvents): void => {
|
|
16
7
|
const docker = new Docker();
|
|
17
|
-
let dockerEnvironment;
|
|
18
8
|
|
|
19
9
|
interface PortBinding {
|
|
20
10
|
destination: number;
|
|
@@ -32,19 +22,6 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
32
22
|
}
|
|
33
23
|
|
|
34
24
|
on('task', {
|
|
35
|
-
copyFromContainer: async ({ destination, serviceName, source }) => {
|
|
36
|
-
const container = dockerEnvironment.getContainer(`${serviceName}-1`);
|
|
37
|
-
|
|
38
|
-
await container.copyArchiveFromContainer(source).then((archiveStream) => {
|
|
39
|
-
return new Promise<void>((resolve) => {
|
|
40
|
-
const dest = tar.extract(destination);
|
|
41
|
-
archiveStream.pipe(dest);
|
|
42
|
-
dest.on('finish', resolve);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
return null;
|
|
47
|
-
},
|
|
48
25
|
createDirectory: async (directoryPath: string) => {
|
|
49
26
|
if (!existsSync(directoryPath)) {
|
|
50
27
|
mkdirSync(directoryPath, { recursive: true });
|
|
@@ -52,70 +29,6 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
52
29
|
|
|
53
30
|
return null;
|
|
54
31
|
},
|
|
55
|
-
execInContainer: async ({ command, name }) => {
|
|
56
|
-
const container = dockerEnvironment.getContainer(`${name}-1`);
|
|
57
|
-
|
|
58
|
-
const { exitCode, output } = await container.exec([
|
|
59
|
-
'bash',
|
|
60
|
-
'-c',
|
|
61
|
-
command
|
|
62
|
-
]);
|
|
63
|
-
|
|
64
|
-
return { exitCode, output };
|
|
65
|
-
},
|
|
66
|
-
getContainerId: (containerName: string) => {
|
|
67
|
-
const container: StartedTestContainer = dockerEnvironment.getContainer(
|
|
68
|
-
`${containerName}-1`
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
return container.getId();
|
|
72
|
-
},
|
|
73
|
-
getContainerIpAddress: (containerName: string) => {
|
|
74
|
-
const container: StartedTestContainer = dockerEnvironment.getContainer(
|
|
75
|
-
`${containerName}-1`
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const networkNames = container.getNetworkNames();
|
|
79
|
-
|
|
80
|
-
return container.getIpAddress(networkNames[0]);
|
|
81
|
-
},
|
|
82
|
-
getContainersLogs: async () => {
|
|
83
|
-
try {
|
|
84
|
-
const { dockerode } = (await getContainerRuntimeClient()).container;
|
|
85
|
-
const containers = await dockerode.listContainers();
|
|
86
|
-
|
|
87
|
-
return containers.reduce((acc, container) => {
|
|
88
|
-
const containerName = container.Names[0].replace('/', '');
|
|
89
|
-
acc[containerName] = execSync(`docker logs -t ${container.Id}`, {
|
|
90
|
-
stdio: 'pipe'
|
|
91
|
-
}).toString('utf8');
|
|
92
|
-
|
|
93
|
-
return acc;
|
|
94
|
-
}, {});
|
|
95
|
-
} catch (error) {
|
|
96
|
-
console.warn('Cannot get containers logs');
|
|
97
|
-
console.warn(error);
|
|
98
|
-
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
requestOnDatabase: async ({ database, query }) => {
|
|
103
|
-
const container = dockerEnvironment.getContainer('db-1');
|
|
104
|
-
|
|
105
|
-
const client = await createConnection({
|
|
106
|
-
database,
|
|
107
|
-
host: container.getHost(),
|
|
108
|
-
password: 'centreon',
|
|
109
|
-
port: container.getMappedPort(3306),
|
|
110
|
-
user: 'centreon'
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const [rows, fields] = await client.execute(query);
|
|
114
|
-
|
|
115
|
-
await client.end();
|
|
116
|
-
|
|
117
|
-
return [rows, fields];
|
|
118
|
-
},
|
|
119
32
|
startContainer: async ({
|
|
120
33
|
image,
|
|
121
34
|
name,
|
|
@@ -176,32 +89,6 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
176
89
|
|
|
177
90
|
return container;
|
|
178
91
|
},
|
|
179
|
-
startContainers: async ({
|
|
180
|
-
composeFilePath = `${__dirname}/../../../../../.github/docker/`,
|
|
181
|
-
databaseImage,
|
|
182
|
-
openidImage,
|
|
183
|
-
profiles,
|
|
184
|
-
samlImage,
|
|
185
|
-
webImage
|
|
186
|
-
}) => {
|
|
187
|
-
const composeFile = 'docker-compose.yml';
|
|
188
|
-
|
|
189
|
-
dockerEnvironment = await new DockerComposeEnvironment(
|
|
190
|
-
composeFilePath,
|
|
191
|
-
composeFile
|
|
192
|
-
)
|
|
193
|
-
.withEnvironment({
|
|
194
|
-
MYSQL_IMAGE: databaseImage,
|
|
195
|
-
OPENID_IMAGE: openidImage,
|
|
196
|
-
SAML_IMAGE: samlImage,
|
|
197
|
-
WEB_IMAGE: webImage
|
|
198
|
-
})
|
|
199
|
-
.withProfiles(...profiles)
|
|
200
|
-
.withWaitStrategy('web', Wait.forHealthCheck())
|
|
201
|
-
.up();
|
|
202
|
-
|
|
203
|
-
return null;
|
|
204
|
-
},
|
|
205
92
|
stopContainer: async ({ name }: StopContainerProps) => {
|
|
206
93
|
const container = await docker.getContainer(name);
|
|
207
94
|
await container.kill();
|
|
@@ -209,11 +96,6 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
209
96
|
|
|
210
97
|
return null;
|
|
211
98
|
},
|
|
212
|
-
stopContainers: async () => {
|
|
213
|
-
await dockerEnvironment.down();
|
|
214
|
-
|
|
215
|
-
return null;
|
|
216
|
-
},
|
|
217
99
|
waitOn: async (url: string) => {
|
|
218
100
|
execSync(`npx wait-on ${url}`);
|
|
219
101
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/js-config",
|
|
3
3
|
"description": "Centreon Frontend shared build configuration",
|
|
4
|
-
"version": "24.4.1-
|
|
4
|
+
"version": "24.4.1-release-24-04-next.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/centreon/centreon-frontend.git"
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"cypress"
|
|
25
25
|
],
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
27
|
+
"prettier": "^3.0.0",
|
|
28
|
+
"eslint": "^8.53.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@badeball/cypress-cucumber-preprocessor": "^19.1.0",
|
|
@@ -58,9 +58,6 @@
|
|
|
58
58
|
"eslint-plugin-react-hooks": "^4.5.0",
|
|
59
59
|
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
60
60
|
"eslint-plugin-typescript-sort-keys": "^2.1.0",
|
|
61
|
-
"mochawesome": "^7.1.3"
|
|
62
|
-
"mysql2": "^3.6.5",
|
|
63
|
-
"tar-fs": "^3.0.4",
|
|
64
|
-
"testcontainers": "^10.4.0"
|
|
61
|
+
"mochawesome": "^7.1.3"
|
|
65
62
|
}
|
|
66
63
|
}
|