add back try-catch around api calls (#1815)

* add back try-catch around api calls to avoid UnhandledPromiseRejectionWarning

* minor fixes for pagination to account for parallel runs

* missed one

* a few more fixes

* search only files to get correct and consistent number of results

* try something

* add try catch in upload output

* fix cleanup on Create file / folder from template to account for parallel running

* fix incorrect test case id
fix for undefined properties
unexclude some tests to see if still failing

* revert change in order to fix test

* unused import

* exclude test due to missing EXIF aspect

* trigger one more run
This commit is contained in:
Adina Parpalita
2020-11-25 07:45:50 +02:00
committed by GitHub
parent fe2fe0c669
commit 885a1b1b33
18 changed files with 362 additions and 194 deletions

View File

@@ -19,7 +19,11 @@ async function uploadScreenshot(retryCount) {
hostEcm: process.env.SCREENSHOT_URL
});
await alfrescoJsApi.login(process.env.SCREENSHOT_USERNAME, process.env.SCREENSHOT_PASSWORD);
try {
await alfrescoJsApi.login(process.env.SCREENSHOT_USERNAME, process.env.SCREENSHOT_PASSWORD);
} catch (error) {
console.log(` ---- Upload output - login failed : ${error}`);
}
let folderNode;
@@ -34,23 +38,30 @@ async function uploadScreenshot(retryCount) {
'overwrite': true
});
} catch (error) {
folderNode = await alfrescoJsApi.nodes.getNode('-my-', {
'relativePath': `${screenshotSavePath}/retry-${retryCount}`,
'nodeType': 'cm:folder'
}, {}, {
'overwrite': true
});
console.log(`--- Upload output - add node failed. Maybe already exists. ${error}`);
try {
console.log('--- trying to get the Builds folder ');
folderNode = await alfrescoJsApi.nodes.getNode('-my-', {
'relativePath': `${screenshotSavePath}/retry-${retryCount}`,
'nodeType': 'cm:folder'
}, {}, {
'overwrite': true
});
} catch (error) {
console.log(`--- Upload out - get node failed. ${error}`);
}
}
const screenShotsPath = path.resolve(__dirname, '../../../e2e-output/screenshots/');
let files = fs.readdirSync(screenShotsPath);
for (const fileName of files) {
let pathFile = path.join(screenShotsPath, fileName);
let file = fs.createReadStream(pathFile);
let safeFileName = fileName.replace(new RegExp('"', 'g'), '');
try {
for (const fileName of files) {
let pathFile = path.join(screenShotsPath, fileName);
let file = fs.createReadStream(pathFile);
let safeFileName = fileName.replace(new RegExp('"', 'g'), '');
try {
await alfrescoJsApi.upload.uploadFile(
file,
'',
@@ -62,9 +73,9 @@ async function uploadScreenshot(retryCount) {
autoRename: true,
}
);
} catch (error) {
console.log(error);
}
} catch (error) {
console.log(`Upload failed: ${error}`);
}
fs.renameSync(path.resolve(__dirname, '../../../e2e-output/'), path.resolve(__dirname, `../../e2e-output-${retryCount}/`))
@@ -76,17 +87,23 @@ async function uploadScreenshot(retryCount) {
let pathFile = path.join(__dirname, `../../e2e-result-${process.env.TRAVIS_JOB_NUMBER}-${retryCount}.tar`);
let file = fs.createReadStream(pathFile);
await alfrescoJsApi.upload.uploadFile(
file,
'',
folderNode.entry.id,
null,
{
'name': `e2e-result-${process.env.TRAVIS_JOB_NUMBER}-${retryCount}.tar`,
'nodeType': 'cm:content',
'autoRename': true
}
);
try {
await alfrescoJsApi.upload.uploadFile(
file,
'',
folderNode.entry.id,
null,
{
'name': `e2e-result-${process.env.TRAVIS_JOB_NUMBER}-${retryCount}.tar`,
'nodeType': 'cm:content',
'autoRename': true
}
);
} catch (error) {
console.log(`--- Upload output failed. ${error}`);
}
fs.rmdirSync(path.resolve(__dirname, `../../e2e-output-${retryCount}/`), { recursive: true });
}