From b5f79c1020807de288c9e890660cfe4e18ddeb9c Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Mon, 23 Oct 2023 13:21:33 -0400 Subject: [PATCH] fix: dont mutate homeorg info if no homeorg --- package-lock.json | 141 ++++++++---------- package.json | 25 ++-- src/middleware.js | 30 ++-- .../organizations/organizations.model.js | 16 +- src/tasks/sync-audit-table.js | 69 +++++---- src/tasks/sync-default-organizations.js | 2 +- src/tasks/sync-governance-body.js | 2 +- src/tasks/sync-organization-meta.js | 2 +- src/tasks/sync-picklists.js | 2 +- tests/integration/project.spec.js | 1 + tests/integration/unit.spec.js | 3 + tests/test-fixtures/project-fixtures.js | 2 + tests/test-fixtures/staging-fixtures.js | 1 + tests/test-fixtures/unit-fixtures.js | 2 + 14 files changed, 142 insertions(+), 156 deletions(-) diff --git a/package-lock.json b/package-lock.json index 246cc91c..d1876c1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,33 +8,32 @@ "name": "cadt", "version": "1.6.15", "dependencies": { - "@babel/eslint-parser": "^7.22.9", - "@chia-carbon/core-registry-config": "^1.0.2", - "@chia-carbon/core-registry-logger": "^1.0.12", + "@babel/eslint-parser": "^7.22.15", + "async-mutex": "^0.4.0", "body-parser": "^1.20.2", "cli-spinner": "^0.2.10", "cors": "^2.8.5", "csvtojson": "^2.0.10", - "dotenv": "^16.0.3", + "dotenv": "^16.3.1", "express": "^4.18.2", "express-joi-validation": "^5.0.1", - "joi": "^17.5.0", + "joi": "^17.11.0", "js-yaml": "^4.1.0", "lodash": "^4.17.21", "log-update": "^4.0.0", - "multer": "*", + "multer": "^1.4.5-lts.1", "mysql2": "^2.3.3", "node-xlsx": "^0.23.0", - "regenerator-runtime": "^0.13.9", + "regenerator-runtime": "^0.13.11", "rxjs": "^7.8.1", - "sequelize": "^6.32.0", - "socket.io": "^4.6.1", + "sequelize": "^6.33.0", + "socket.io": "^4.7.2", "sqlite3": "^5.1.6", - "superagent": "^8.0.9", - "toad-scheduler": "^1.6.0", - "uuidv4": "^6", - "winston": "^3.7.2", - "winston-daily-rotate-file": "^4.6.1" + "superagent": "^8.1.2", + "toad-scheduler": "^3.0.0", + "uuidv4": "^6.2.13", + "winston": "^3.11.0", + "winston-daily-rotate-file": "^4.7.1" }, "bin": { "cadt": "build/server.js" @@ -1824,26 +1823,6 @@ "node": ">=6.9.0" } }, - "node_modules/@chia-carbon/core-registry-config": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@chia-carbon/core-registry-config/-/core-registry-config-1.0.3.tgz", - "integrity": "sha512-7bB+fihP0C/eRzTmDiOmbpLpfKYPjI0dN2074hbwmuIGgVHGMu12J2qt5Mae8pEWtkEIKk4517MJQTtWx8GmPw==", - "dependencies": { - "chia-root-resolver": "^1.0.0", - "js-yaml": "^4.1.0", - "lodash": "^4.17.21" - } - }, - "node_modules/@chia-carbon/core-registry-logger": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/@chia-carbon/core-registry-logger/-/core-registry-logger-1.0.12.tgz", - "integrity": "sha512-emeAXaKdqohjXXFwpDGkJbmeU4nIOSxtoqbVBARveSy1G8z3fgeK7lekm+4qmMtKPxv0Rmvy24UGT86WwaRj+w==", - "dependencies": { - "chia-root-resolver": "^1.0.0", - "winston": "^3.10.0", - "winston-daily-rotate-file": "^4.7.1" - } - }, "node_modules/@colors/colors": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz", @@ -3109,6 +3088,14 @@ "resolved": "https://registry.npmjs.org/async/-/async-3.2.4.tgz", "integrity": "sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==" }, + "node_modules/async-mutex": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.4.0.tgz", + "integrity": "sha512-eJFZ1YhRR8UN8eBLoNzcDPcy/jqjsg6I1AP+KvWQX80BqOSW1oJPJXDylPUEeMr2ZQvHgnQ//Lp6f3RQ1zI7HA==", + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -3194,13 +3181,13 @@ } }, "node_modules/babel-plugin-polyfill-corejs3": { - "version": "0.8.5", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.8.5.tgz", - "integrity": "sha512-Q6CdATeAvbScWPNLB8lzSO7fgUVBkQt6zLgNlfyeCr/EQaEQR+bWiBYYPYAFyE528BMjRhL+1QBMOI4jc/c5TA==", + "version": "0.8.6", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.8.6.tgz", + "integrity": "sha512-leDIc4l4tUgU7str5BWLS2h8q2N4Nf6lGZP6UrNDxdtfF2g69eJ5L0H7S8A5Ln/arfFAfHor5InAdZuIOwZdgQ==", "dev": true, "dependencies": { "@babel/helper-define-polyfill-provider": "^0.4.3", - "core-js-compat": "^3.32.2" + "core-js-compat": "^3.33.1" }, "peerDependencies": { "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" @@ -3482,9 +3469,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001551", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001551.tgz", - "integrity": "sha512-vtBAez47BoGMMzlbYhfXrMV1kvRF2WP/lqiMuDu1Sb4EE4LKEgjopFDSRtZfdVnslNRpOqV/woE+Xgrwj6VQlg==", + "version": "1.0.30001553", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001553.tgz", + "integrity": "sha512-N0ttd6TrFfuqKNi+pMgWJTb9qrdJu4JSpgPFLe/lrD19ugC6fZgF0pUewRowDwzdDnb9V41mFcdlYgl/PyKf4A==", "funding": [ { "type": "opencollective", @@ -3586,11 +3573,6 @@ "node": "*" } }, - "node_modules/chia-root-resolver": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/chia-root-resolver/-/chia-root-resolver-1.0.0.tgz", - "integrity": "sha512-oZOYbZxzK0688hU9S2EYWZ8ks5NI9zOlABFDsqBtvZwvYZbXEUYaLob+AqMhxLG3p0Dr0Ry+Rm6VPKOl9fQvAA==" - }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -5228,9 +5210,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.562", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.562.tgz", - "integrity": "sha512-kMGVZLP65O2/oH7zzaoIA5hcr4/xPYO6Sa83FrIpWcd7YPPtSlxqwxTd8lJIwKxaiXM6FGsYK4ukyJ40XkW7jg==" + "version": "1.4.565", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.565.tgz", + "integrity": "sha512-XbMoT6yIvg2xzcbs5hCADi0dXBh4//En3oFXmtPX+jiyyiCTiM9DGFT2SLottjpEs9Z8Mh8SqahbR96MaHfuSg==" }, "node_modules/emoji-regex": { "version": "8.0.0", @@ -6233,14 +6215,14 @@ } }, "node_modules/get-intrinsic": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz", - "integrity": "sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz", + "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", "dependencies": { - "function-bind": "^1.1.1", - "has": "^1.0.3", + "function-bind": "^1.1.2", "has-proto": "^1.0.1", - "has-symbols": "^1.0.3" + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -6898,14 +6880,6 @@ "node": ">=6" } }, - "node_modules/has": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.4.tgz", - "integrity": "sha512-qdSAmqLF6209RFj4VVItywPMbm3vWylknmB3nvNiUIs72xAimcM8nVYxYr7ncvZq5qzk9MKIZR8ijqD/1QuYjQ==", - "engines": { - "node": ">= 0.4.0" - } - }, "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -6915,11 +6889,11 @@ } }, "node_modules/has-property-descriptors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", - "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", + "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", "dependencies": { - "get-intrinsic": "^1.1.1" + "get-intrinsic": "^1.2.2" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -6952,6 +6926,17 @@ "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", "integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==" }, + "node_modules/hasown": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", + "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/he": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", @@ -7214,12 +7199,12 @@ } }, "node_modules/is-core-module": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.0.tgz", - "integrity": "sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==", + "version": "2.13.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", + "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", "dev": true, "dependencies": { - "has": "^1.0.3" + "hasown": "^2.0.0" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -7809,14 +7794,6 @@ "node": ">= 12.0.0" } }, - "node_modules/logform/node_modules/@colors/colors": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", - "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", - "engines": { - "node": ">=0.1.90" - } - }, "node_modules/long": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", @@ -10727,9 +10704,9 @@ } }, "node_modules/toad-scheduler": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/toad-scheduler/-/toad-scheduler-1.6.1.tgz", - "integrity": "sha512-UjNerGmJIp72lt1d6wtGZUdgzgYFM9xVJBeDJzCLOVIHbrf8c6e3iq6rswRV/8/KA8WJLUuH71LYu96yoXgNRQ==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/toad-scheduler/-/toad-scheduler-3.0.0.tgz", + "integrity": "sha512-BYmrORvaGmjziir/ra8qD3qAKczJveqK5ZOO/wn7oS5qLI4iibOza3DBGgu+EwNp9zdlBTKSeZPmxZxzGy1dxw==" }, "node_modules/toidentifier": { "version": "1.0.1", diff --git a/package.json b/package.json index 61b5be27..cb868d7b 100644 --- a/package.json +++ b/package.json @@ -31,31 +31,32 @@ "assets": "package.json" }, "dependencies": { - "@babel/eslint-parser": "^7.22.9", + "@babel/eslint-parser": "^7.22.15", + "async-mutex": "^0.4.0", "body-parser": "^1.20.2", "cli-spinner": "^0.2.10", "cors": "^2.8.5", "csvtojson": "^2.0.10", - "dotenv": "^16.0.3", + "dotenv": "^16.3.1", "express": "^4.18.2", "express-joi-validation": "^5.0.1", - "joi": "^17.5.0", + "joi": "^17.11.0", "js-yaml": "^4.1.0", "lodash": "^4.17.21", "log-update": "^4.0.0", - "multer": "*", + "multer": "^1.4.5-lts.1", "mysql2": "^2.3.3", "node-xlsx": "^0.23.0", - "regenerator-runtime": "^0.13.9", + "regenerator-runtime": "^0.13.11", "rxjs": "^7.8.1", - "sequelize": "^6.32.0", - "socket.io": "^4.6.1", + "sequelize": "^6.33.0", + "socket.io": "^4.7.2", "sqlite3": "^5.1.6", - "superagent": "^8.0.9", - "toad-scheduler": "^1.6.0", - "uuidv4": "^6", - "winston": "^3.7.2", - "winston-daily-rotate-file": "^4.6.1" + "superagent": "^8.1.2", + "toad-scheduler": "^3.0.0", + "uuidv4": "^6.2.13", + "winston": "^3.11.0", + "winston-daily-rotate-file": "^4.7.1" }, "devDependencies": { "@babel/cli": "^7.23.0", diff --git a/src/middleware.js b/src/middleware.js index 4dbdd3ec..9124e08f 100644 --- a/src/middleware.js +++ b/src/middleware.js @@ -101,19 +101,23 @@ app.use(function (req, res, next) { }); app.use(async function (req, res, next) { - // If the home organization is syncing, then we treat all requests as read-only - const homeOrg = await Organization.getHomeOrg(); - - if (req.method !== 'GET' && !homeOrg.synced) { - res.status(400).json({ - message: - 'Your organization data is still resyncing, please try again after it completes', - success: false, - }); - } else if (homeOrg.synced) { - res.setHeader(headerKeys.HOME_ORGANIZATION_SYNCED, true); - } else { - res.setHeader(headerKeys.HOME_ORGANIZATION_SYNCED, false); + if (process.env.NODE_ENV !== 'test') { + // If the home organization is syncing, then we treat all requests as read-only + const homeOrg = await Organization.getHomeOrg(); + + if (homeOrg) { + if (req.method !== 'GET' && !homeOrg.synced) { + res.status(400).json({ + message: + 'Your organization data is still resyncing, please try again after it completes', + success: false, + }); + } else if (homeOrg?.synced) { + res.setHeader(headerKeys.HOME_ORGANIZATION_SYNCED, true); + } else { + res.setHeader(headerKeys.HOME_ORGANIZATION_SYNCED, false); + } + } } next(); diff --git a/src/models/organizations/organizations.model.js b/src/models/organizations/organizations.model.js index 17560dbd..d8cf9971 100644 --- a/src/models/organizations/organizations.model.js +++ b/src/models/organizations/organizations.model.js @@ -23,16 +23,6 @@ import ModelTypes from './organizations.modeltypes.cjs'; class Organization extends Model { static async getHomeOrg(includeAddress = true) { const myOrganization = await Organization.findOne({ - attributes: [ - 'orgUid', - 'name', - 'icon', - 'subscribed', - 'registryId', - 'fileStoreId', - 'metadata', - 'synced', - ], where: { isHome: true }, raw: true, }); @@ -51,14 +41,16 @@ class Organization extends Model { delete myOrganization.metadata; } - myOrganization.synced = myOrganization?.synced === 1; - if (myOrganization && includeAddress) { myOrganization.xchAddress = await datalayer.getPublicAddress(); myOrganization.fileStoreSubscribed = true; return myOrganization; } + if (myOrganization) { + myOrganization.synced = myOrganization.synced === 1; + } + return myOrganization; } diff --git a/src/tasks/sync-audit-table.js b/src/tasks/sync-audit-table.js index 76b4cb77..b725968f 100644 --- a/src/tasks/sync-audit-table.js +++ b/src/tasks/sync-audit-table.js @@ -2,9 +2,10 @@ import _ from 'lodash'; import { Sequelize } from 'sequelize'; import { SimpleIntervalJob, Task } from 'toad-scheduler'; +import { Mutex } from 'async-mutex'; import { Organization, Audit, ModelKeys, Staging, Meta } from '../models'; import datalayer from '../datalayer'; -import { decodeHex } from '../utils/datalayer-utils'; +import { decodeHex, encodeHex } from '../utils/datalayer-utils'; import dotenv from 'dotenv'; import { logger } from '../config/logger.cjs'; import { sequelize, sequelizeMirror } from '../database'; @@ -16,16 +17,13 @@ import { import { mirrorDBEnabled } from '../database'; dotenv.config(); - +const mutex = new Mutex(); const CONFIG = getConfig().APP; -let taskIsRunning = false; - const task = new Task('sync-audit', async () => { - try { - if (!taskIsRunning) { - taskIsRunning = true; - + if (!mutex.isLocked()) { + const releaseMutex = await mutex.acquire(); + try { const hasMigratedToNewSyncMethod = await Meta.findOne({ where: { metaKey: 'migratedToNewSync' }, }); @@ -80,28 +78,28 @@ const task = new Task('sync-audit', async () => { logger.info(`Migration Complete`); } - } - } catch (error) { - logger.error(`Error during datasync: ${error.message}`); + } catch (error) { + logger.error(`Error during datasync: ${error.message}`); - // Log additional information if present in the error object - if (error.response && error.response.body) { - logger.error( - `Additional error details: ${JSON.stringify(error.response.body)}`, - ); + // Log additional information if present in the error object + if (error.response && error.response.body) { + logger.error( + `Additional error details: ${JSON.stringify(error.response.body)}`, + ); + } + } finally { + releaseMutex(); } - } finally { - taskIsRunning = false; } }); const job = new SimpleIntervalJob( { - seconds: 30, + seconds: 10, runImmediately: true, }, task, - 'sync-audit', + { id: 'sync-audit', preventOverrun: true }, ); const processJob = async () => { @@ -221,27 +219,32 @@ const syncOrganizationAudit = async (organization) => { rootHash = lastRootSaved.rootHash; } - const isSynced = rootHistory[rootHistory.length - 1].root_hash === rootHash; + let isSynced = rootHistory[rootHistory.length - 1].root_hash === rootHash; const historyIndex = rootHistory.findIndex( (root) => root.root_hash === rootHash, ); + const syncRemaining = rootHistory.length - historyIndex - 1; + await Organization.update( { synced: isSynced, - sync_remaining: rootHistory.length - historyIndex - 1, + sync_remaining: syncRemaining, }, { where: { orgUid: organization.orgUid } }, ); - if (isSynced) { + if (process.env.NODE_ENV !== 'test' && isSynced) { return; } // Organization not synced, sync it logger.info(' '); logger.info(`Syncing Registry: ${_.get(organization, 'name')}`); + logger.info( + `${organization.name} is ${syncRemaining} DataLayer generations away from being fully synced.`, + ); if (!CONFIG.USE_SIMULATOR) { await new Promise((resolve) => setTimeout(resolve, 30000)); @@ -264,29 +267,29 @@ const syncOrganizationAudit = async (organization) => { ); if (_.isEmpty(kvDiff)) { - const errorMsg = [ - `No data found for ${organization.name} in the current generation.`, + const warningMsg = [ + `No data found for ${organization.name} in the current datalayer generation.`, `Missing data for root hash: ${root2.root_hash}.`, - "Check your internet connection, otherwise the organization's file propagation server may be offline.", - 'Syncing for this organization will be halted until resolved.', - 'If the issue persists, contact the organization.', + `This issue is often temporary and could be due to a lag in data propagation.`, + 'Syncing for this organization will be paused until this is resolved.', + 'For ongoing issues, please contact the organization.', ].join(' '); - logger.error(errorMsg); + logger.warn(warningMsg); return; } - // 0x636f6d6d656e74 is hex for 'comment' const comment = kvDiff.filter( (diff) => - (diff.key === '636f6d6d656e74' || diff.key === '0x636f6d6d656e74') && + (diff.key === encodeHex('comment') || + diff.key === `0x${encodeHex('comment')}`) && diff.type === 'INSERT', ); - // 0x617574686F72 is hex for 'author'T const author = kvDiff.filter( (diff) => - (diff.key === '617574686f72' || diff.key === '0x617574686F72') && + (diff.key === encodeHex('author') || + diff.key === `0x${encodeHex('author')}`) && diff.type === 'INSERT', ); diff --git a/src/tasks/sync-default-organizations.js b/src/tasks/sync-default-organizations.js index 9ba85823..f4bc4ddd 100644 --- a/src/tasks/sync-default-organizations.js +++ b/src/tasks/sync-default-organizations.js @@ -34,7 +34,7 @@ const job = new SimpleIntervalJob( runImmediately: true, }, task, - 'sync-default-organizations', + { id: 'sync-default-organizations', preventOverrun: true }, ); export default job; diff --git a/src/tasks/sync-governance-body.js b/src/tasks/sync-governance-body.js index de9b245e..6efef003 100644 --- a/src/tasks/sync-governance-body.js +++ b/src/tasks/sync-governance-body.js @@ -51,7 +51,7 @@ const job = new SimpleIntervalJob( runImmediately: true, }, task, - 'sync-governance-meta', + { id: 'sync-governance-meta', preventOverrun: true }, ); export default job; diff --git a/src/tasks/sync-organization-meta.js b/src/tasks/sync-organization-meta.js index 652ccb23..c333dba9 100644 --- a/src/tasks/sync-organization-meta.js +++ b/src/tasks/sync-organization-meta.js @@ -36,7 +36,7 @@ const job = new SimpleIntervalJob( runImmediately: true, }, task, - 'sync-organization-meta', + { id: 'sync-organization-meta', preventOverrun: true }, ); export default job; diff --git a/src/tasks/sync-picklists.js b/src/tasks/sync-picklists.js index 0f762370..7d82da67 100644 --- a/src/tasks/sync-picklists.js +++ b/src/tasks/sync-picklists.js @@ -28,7 +28,7 @@ const job = new SimpleIntervalJob( runImmediately: true, }, task, - 'sync-picklist', + { id: 'sync-picklist', preventOverrun: true }, ); export default job; diff --git a/tests/integration/project.spec.js b/tests/integration/project.spec.js index 02bd5d50..ad12769d 100644 --- a/tests/integration/project.spec.js +++ b/tests/integration/project.spec.js @@ -58,6 +58,7 @@ describe('Project Resource Integration Tests', function () { await testFixtures.commitStagingRecords(); await testFixtures.waitForDataLayerSync(); await testFixtures.waitForDataLayerSync(); + await testFixtures.waitForDataLayerSync(); // The staging table should be empty after committing expect(await testFixtures.getLastCreatedStagingRecord()).to.equal( diff --git a/tests/integration/unit.spec.js b/tests/integration/unit.spec.js index 92085191..99081e76 100644 --- a/tests/integration/unit.spec.js +++ b/tests/integration/unit.spec.js @@ -155,6 +155,7 @@ describe('Unit Resource Integration Tests', function () { expect(createdCommitResult.statusCode).to.equal(200); expect(createdCommitResult.body).to.deep.equal({ message: 'Staging Table committed to full node', + success: true, }); // The node simulator runs on an async process, we are importing @@ -191,6 +192,7 @@ describe('Unit Resource Integration Tests', function () { expect(unitRes.body).to.deep.equal({ message: 'Unit split successful', + success: true, }); expect(unitRes.statusCode).to.equal(200); @@ -247,6 +249,7 @@ describe('Unit Resource Integration Tests', function () { expect(stagingRes.statusCode).to.equal(200); expect(commitRes.body).to.deep.equal({ message: 'Staging Table committed to full node', + success: true, }); // After commiting the true flag should be set to this staging record diff --git a/tests/test-fixtures/project-fixtures.js b/tests/test-fixtures/project-fixtures.js index 2a27e467..19ab4446 100644 --- a/tests/test-fixtures/project-fixtures.js +++ b/tests/test-fixtures/project-fixtures.js @@ -37,6 +37,7 @@ export const updateProject = async (warehouseProjectId, originalRecord) => { expect(result.body).to.deep.equal({ message: 'Project update added to staging', + success: true, }); expect(result.statusCode).to.equal(200); @@ -49,6 +50,7 @@ export const deleteProject = async (warehouseProjectId) => { .send({ warehouseProjectId }); expect(result.body).to.deep.equal({ message: 'Project deleted successfully', + success: true, }); expect(result.statusCode).to.equal(200); return result; diff --git a/tests/test-fixtures/staging-fixtures.js b/tests/test-fixtures/staging-fixtures.js index 0d9f2ebd..a7979932 100644 --- a/tests/test-fixtures/staging-fixtures.js +++ b/tests/test-fixtures/staging-fixtures.js @@ -24,6 +24,7 @@ export const commitStagingRecords = async () => { expect(results.statusCode).to.equal(200); expect(results.body).to.deep.equal({ message: 'Staging Table committed to full node', + success: true, }); return results; diff --git a/tests/test-fixtures/unit-fixtures.js b/tests/test-fixtures/unit-fixtures.js index 822b15dc..b5415581 100644 --- a/tests/test-fixtures/unit-fixtures.js +++ b/tests/test-fixtures/unit-fixtures.js @@ -24,6 +24,7 @@ export const deleteUnit = async (warehouseUnitId) => { .send({ warehouseUnitId }); expect(result.body).to.deep.equal({ message: 'Unit deleted successfully', + success: true, }); expect(result.statusCode).to.equal(200); return result; @@ -50,6 +51,7 @@ export const updateUnit = async (warehouseUnitId, originalRecord) => { expect(result.body).to.deep.equal({ message: 'Unit update added to staging', + success: true, }); expect(result.statusCode).to.equal(200);