Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added report files cleanup after bank load tests #137

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions signify-ts-test/test-workflow-banks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ while [[ $# -gt 0 ]]; do
fi
shift # past argument
;;
--reports-cleanup)
npx jest ./run-bank-reports-cleanup.test.ts --runInBand --forceExit
download_exit_code=$?
if [[ $download_exit_code -ne 0 ]]; then
exit 1
fi
shift # past argument
;;
--data-report)
npx jest ./run-workflow-bank-issuance.test.ts --runInBand --detectOpenHandles --forceExit
report_exit_code=$?
Expand Down
40 changes: 40 additions & 0 deletions signify-ts-test/test/run-bank-reports-cleanup.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import path from "path";
const fs = require("fs");
const yaml = require("js-yaml");

const tmpReportsPath = path.join(__dirname, "./data/tmp_reports");
const tmpReportsUnpackedPath = path.join(
__dirname,
"./data/tmp_reports_unpacked",
);
const signedReportsPath = path.join(__dirname, "./data/signed_reports");
const faileportsPath = path.join(__dirname, "./data/fail_reports");

const removeFolderRecursive = (folderPath: string) => {
if (fs.existsSync(folderPath)) {
fs.rmSync(folderPath, { recursive: true, force: true });
console.log(`Deleted folder: ${folderPath}`);
} else {
console.log(`Folder not found: ${folderPath}`);
}
};

const cleanupReports = (bankName: string) => {
const currentTmpSignedReportsUnpackedPath = `${tmpReportsUnpackedPath}/${bankName}/reports/signed_reports`;
const currentTmpFailReportsUnpackedPath = `${tmpReportsUnpackedPath}/${bankName}/reports/fail_reports`;
const signedItems = fs.readdirSync(currentTmpSignedReportsUnpackedPath);
signedItems.forEach((item: any) => {
removeFolderRecursive(`${signedReportsPath}/${item}`);
});
const failItems = fs.readdirSync(currentTmpFailReportsUnpackedPath);
failItems.forEach((item: any) => {
removeFolderRecursive(`${faileportsPath}/${item}`);
});
removeFolderRecursive(`${tmpReportsPath}`);
removeFolderRecursive(`${tmpReportsUnpackedPath}`);
};
test("bank-reports-cleanup", async function run() {
// You need to set the BANK_NAME environment variable. Ex.: export BANK_NAME=Bank_2.
const bankName = process.env.BANK_NAME || "Bank_1";
cleanupReports(bankName);
}, 3600000);
11 changes: 0 additions & 11 deletions signify-ts-test/test/run-bank-reports-download.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ const unpackZipFile = (
);
}
moveFiles(path.join(destFolder, bankName), path.join(confPath, bankName));
removeFolderRecursive(path.join(destFolder, bankName));
};

const removeFolderRecursive = (folderPath: string) => {
if (fs.existsSync(folderPath)) {
fs.rmSync(folderPath, { recursive: true, force: true });
console.log(`Deleted folder: ${folderPath}`);
} else {
console.log(`Folder not found: ${folderPath}`);
}
};

const moveReports = (
Expand Down Expand Up @@ -149,5 +139,4 @@ test("bank-reports-download", async function run() {
doAllSigned,
doFailReps,
);
removeFolderRecursive(destFilePath);
}, 3600000);
Loading