@centreon/js-config 25.2.0 → 25.2.2
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 +98 -88
- package/cypress/e2e/configuration.ts +9 -2
- package/cypress/e2e/tasks.ts +10 -12
- package/package.json +1 -1
- package/rspack/base/globalConfig.js +6 -2
package/cypress/e2e/commands.ts
CHANGED
|
@@ -511,103 +511,111 @@ Cypress.Commands.add(
|
|
|
511
511
|
}
|
|
512
512
|
);
|
|
513
513
|
|
|
514
|
-
Cypress.Commands.add(
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
514
|
+
Cypress.Commands.add(
|
|
515
|
+
'getLogDirectory',
|
|
516
|
+
(): Cypress.Chainable => {
|
|
517
|
+
const logDirectory = `results/logs/${Cypress.spec.name.replace(
|
|
518
|
+
artifactIllegalCharactersMatcher,
|
|
519
|
+
'_'
|
|
520
|
+
)}/${Cypress.currentTest.title.replace(
|
|
521
|
+
artifactIllegalCharactersMatcher,
|
|
522
|
+
'_'
|
|
523
|
+
)}`;
|
|
524
524
|
|
|
525
|
-
|
|
525
|
+
return cy
|
|
526
|
+
.createDirectory(logDirectory)
|
|
527
|
+
.exec(`chmod -R 755 "${logDirectory}"`)
|
|
528
|
+
.wrap(logDirectory);
|
|
529
|
+
}
|
|
530
|
+
);
|
|
526
531
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
.getContainersLogs()
|
|
531
|
-
.then((containersLogs: Array<Array<string>>) => {
|
|
532
|
-
if (!containersLogs) {
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
532
|
+
interface CopyWebContainerLogsProps {
|
|
533
|
+
name: string;
|
|
534
|
+
}
|
|
535
535
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
);
|
|
547
|
-
});
|
|
548
|
-
})
|
|
549
|
-
.copyFromContainer({
|
|
550
|
-
destination: `${logDirectory}/broker`,
|
|
551
|
-
name,
|
|
552
|
-
source: '/var/log/centreon-broker'
|
|
553
|
-
})
|
|
554
|
-
.copyFromContainer({
|
|
555
|
-
destination: `${logDirectory}/engine`,
|
|
556
|
-
name,
|
|
557
|
-
source: '/var/log/centreon-engine'
|
|
558
|
-
})
|
|
559
|
-
.copyFromContainer({
|
|
560
|
-
destination: `${logDirectory}/centreon`,
|
|
561
|
-
name,
|
|
562
|
-
source: '/var/log/centreon'
|
|
563
|
-
})
|
|
564
|
-
.copyFromContainer({
|
|
565
|
-
destination: `${logDirectory}/centreon-gorgone`,
|
|
566
|
-
name,
|
|
567
|
-
source: '/var/log/centreon-gorgone'
|
|
568
|
-
})
|
|
569
|
-
.then(() => {
|
|
536
|
+
Cypress.Commands.add(
|
|
537
|
+
'copyWebContainerLogs',
|
|
538
|
+
({ name }: CopyWebContainerLogsProps): Cypress.Chainable => {
|
|
539
|
+
cy.log(`Getting logs from container ${name} ...`);
|
|
540
|
+
|
|
541
|
+
return cy.getLogDirectory().then((logDirectory) => {
|
|
542
|
+
let sourcePhpLogs = '/var/log/php8.1-fpm-centreon-error.log';
|
|
543
|
+
let targetPhpLogs = `${logDirectory}/php8.1-fpm-centreon-error.log`;
|
|
544
|
+
let sourceApacheLogs = '/var/log/apache2';
|
|
545
|
+
let targetApacheLogs = `${logDirectory}/apache2`;
|
|
570
546
|
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
});
|
|
547
|
+
sourcePhpLogs = '/var/log/php-fpm';
|
|
548
|
+
targetPhpLogs = `${logDirectory}/php`;
|
|
549
|
+
sourceApacheLogs = '/var/log/httpd';
|
|
550
|
+
targetApacheLogs = `${logDirectory}/httpd`;
|
|
576
551
|
}
|
|
577
552
|
|
|
578
|
-
return cy
|
|
579
|
-
{
|
|
580
|
-
destination: `${logDirectory}/
|
|
553
|
+
return cy
|
|
554
|
+
.copyFromContainer({
|
|
555
|
+
destination: `${logDirectory}/broker`,
|
|
581
556
|
name,
|
|
582
|
-
source: '/var/log/
|
|
583
|
-
}
|
|
584
|
-
{
|
|
585
|
-
|
|
586
|
-
})
|
|
587
|
-
.then(() => {
|
|
588
|
-
if (Cypress.env('WEB_IMAGE_OS').includes('alma')) {
|
|
589
|
-
return cy.copyFromContainer({
|
|
590
|
-
destination: `${logDirectory}/httpd`,
|
|
557
|
+
source: '/var/log/centreon-broker'
|
|
558
|
+
})
|
|
559
|
+
.copyFromContainer({
|
|
560
|
+
destination: `${logDirectory}/engine`,
|
|
591
561
|
name,
|
|
592
|
-
source: '/var/log/
|
|
593
|
-
})
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
return cy.copyFromContainer(
|
|
597
|
-
{
|
|
598
|
-
destination: `${logDirectory}/apache2`,
|
|
562
|
+
source: '/var/log/centreon-engine'
|
|
563
|
+
})
|
|
564
|
+
.copyFromContainer({
|
|
565
|
+
destination: `${logDirectory}/centreon`,
|
|
599
566
|
name,
|
|
600
|
-
source: '/var/log/
|
|
601
|
-
}
|
|
602
|
-
{
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
567
|
+
source: '/var/log/centreon'
|
|
568
|
+
})
|
|
569
|
+
.copyFromContainer({
|
|
570
|
+
destination: `${logDirectory}/centreon-gorgone`,
|
|
571
|
+
name,
|
|
572
|
+
source: '/var/log/centreon-gorgone'
|
|
573
|
+
})
|
|
574
|
+
.copyFromContainer({
|
|
575
|
+
destination: targetPhpLogs,
|
|
576
|
+
name,
|
|
577
|
+
source: sourcePhpLogs,
|
|
578
|
+
})
|
|
579
|
+
.copyFromContainer({
|
|
580
|
+
destination: targetApacheLogs,
|
|
581
|
+
name,
|
|
582
|
+
source: sourceApacheLogs,
|
|
583
|
+
})
|
|
584
|
+
.exec(`chmod -R 755 "${logDirectory}"`);
|
|
585
|
+
});
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
Cypress.Commands.add('stopContainers', (): Cypress.Chainable => {
|
|
589
|
+
cy.log('Stopping containers ...');
|
|
590
|
+
|
|
591
|
+
const name = 'web';
|
|
592
|
+
|
|
593
|
+
return cy
|
|
594
|
+
.visitEmptyPage()
|
|
595
|
+
.getLogDirectory()
|
|
596
|
+
.then((logDirectory) => {
|
|
597
|
+
return cy
|
|
598
|
+
.getContainersLogs()
|
|
599
|
+
.then((containersLogs: Array<Array<string>>) => {
|
|
600
|
+
if (!containersLogs) {
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
Object.entries(containersLogs).forEach(([containerName, logs]) => {
|
|
605
|
+
cy.writeFile(
|
|
606
|
+
`${logDirectory}/container-${containerName}.log`,
|
|
607
|
+
logs
|
|
608
|
+
);
|
|
609
|
+
});
|
|
610
|
+
})
|
|
611
|
+
.copyWebContainerLogs({ name })
|
|
612
|
+
.exec(`chmod -R 755 "${logDirectory}"`)
|
|
613
|
+
.task(
|
|
614
|
+
'stopContainers',
|
|
615
|
+
{},
|
|
616
|
+
{ timeout: 600000 } // 10 minutes because docker pull can be very slow
|
|
617
|
+
);
|
|
618
|
+
});
|
|
611
619
|
});
|
|
612
620
|
|
|
613
621
|
Cypress.Commands.add(
|
|
@@ -880,6 +888,7 @@ declare global {
|
|
|
880
888
|
props: CopyToContainerProps,
|
|
881
889
|
options?: Partial<Cypress.ExecOptions>
|
|
882
890
|
) => Cypress.Chainable;
|
|
891
|
+
copyWebContainerLogs: (props: CopyWebContainerLogsProps) => Cypress.Chainable;
|
|
883
892
|
createDirectory: (directoryPath: string) => Cypress.Chainable;
|
|
884
893
|
execInContainer: (
|
|
885
894
|
props: ExecInContainerProps,
|
|
@@ -899,6 +908,7 @@ declare global {
|
|
|
899
908
|
getContainerIpAddress: (containerName: string) => Cypress.Chainable;
|
|
900
909
|
getContainersLogs: () => Cypress.Chainable;
|
|
901
910
|
getIframeBody: () => Cypress.Chainable;
|
|
911
|
+
getLogDirectory: () => Cypress.Chainable;
|
|
902
912
|
getTimeFromHeader: () => Cypress.Chainable;
|
|
903
913
|
getWebVersion: () => Cypress.Chainable;
|
|
904
914
|
hoverRootMenuItem: (rootItemNumber: number) => Cypress.Chainable;
|
|
@@ -50,14 +50,21 @@ export default ({
|
|
|
50
50
|
},
|
|
51
51
|
setupNodeEvents: async (cypressOn, config) => {
|
|
52
52
|
const on = require('cypress-on-fix')(cypressOn)
|
|
53
|
-
installLogsPrinter(
|
|
53
|
+
installLogsPrinter(
|
|
54
|
+
on,
|
|
55
|
+
{
|
|
56
|
+
commandTrimLength: 5000,
|
|
57
|
+
defaultTrimLength: 5000,
|
|
58
|
+
}
|
|
59
|
+
);
|
|
54
60
|
await esbuildPreprocessor(on, config);
|
|
55
61
|
tasks(on);
|
|
56
62
|
|
|
57
63
|
return plugins(on, config);
|
|
58
64
|
},
|
|
59
65
|
specPattern,
|
|
60
|
-
supportFile: 'support/e2e.{js,jsx,ts,tsx}'
|
|
66
|
+
supportFile: 'support/e2e.{js,jsx,ts,tsx}',
|
|
67
|
+
testIsolation: true,
|
|
61
68
|
},
|
|
62
69
|
env: {
|
|
63
70
|
...env,
|
package/cypress/e2e/tasks.ts
CHANGED
|
@@ -55,19 +55,17 @@ export default (on: Cypress.PluginEvents): void => {
|
|
|
55
55
|
on('task', {
|
|
56
56
|
copyFromContainer: async ({ destination, serviceName, source }) => {
|
|
57
57
|
try {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
dest.on('finish', resolve);
|
|
68
|
-
});
|
|
58
|
+
const container = getContainer(serviceName);
|
|
59
|
+
|
|
60
|
+
await container
|
|
61
|
+
.copyArchiveFromContainer(source)
|
|
62
|
+
.then((archiveStream) => {
|
|
63
|
+
return new Promise<void>((resolve) => {
|
|
64
|
+
const dest = tar.extract(destination);
|
|
65
|
+
archiveStream.pipe(dest);
|
|
66
|
+
dest.on('finish', resolve);
|
|
69
67
|
});
|
|
70
|
-
|
|
68
|
+
});
|
|
71
69
|
} catch (error) {
|
|
72
70
|
console.error(error);
|
|
73
71
|
}
|
package/package.json
CHANGED
|
@@ -63,8 +63,12 @@ module.exports = {
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
output: {
|
|
66
|
-
chunkFilename:
|
|
67
|
-
|
|
66
|
+
chunkFilename: isDev
|
|
67
|
+
? '[name].[chunkhash:8].chunk.js'
|
|
68
|
+
: '[name].[contenthash].[chunkhash].[hash].js',
|
|
69
|
+
filename: isDev
|
|
70
|
+
? '[name].[chunkhash:8].js'
|
|
71
|
+
: '[name].[contenthash].[hash].js',
|
|
68
72
|
libraryTarget: 'umd',
|
|
69
73
|
umdNamedDefine: true
|
|
70
74
|
}
|