From 255f1433dbf9d5149273fcca30c3b656d86ca674 Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 13:43:09 -0300 Subject: [PATCH 01/25] Save Tue Apr 23 01:43:09 PM -03 2024 --- .github/workflows/build.yml | 9 +++++ .github/workflows/docker-release.yml | 13 +++++++ .github/workflows/pr.yml | 11 ++++++ Dockerfile | 52 ++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/docker-release.yml create mode 100644 .github/workflows/pr.yml create mode 100644 Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..f7e988907 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,9 @@ +name: build + +on: + push: + pull_request: + +jobs: + build: + uses: decentraland/platform-actions/.github/workflows/apps-with-db-build.yml@main diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml new file mode 100644 index 000000000..b74ff6754 --- /dev/null +++ b/.github/workflows/docker-release.yml @@ -0,0 +1,13 @@ +name: Publish 'latest' image + +on: + release: + types: + - "created" + +jobs: + cd: + uses: decentraland/platform-actions/.github/workflows/apps-docker-release.yml@main + with: + service-name: catalyst + secrets: inherit diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 000000000..7ecea6f85 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,11 @@ +name: CI/CD on PR + +on: + pull_request: + +jobs: + pr: + uses: decentraland/platform-actions/.github/workflows/apps-pr.yml@main + with: + service-name: catalyst + secrets: inherit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..6ce87d978 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,52 @@ +FROM node:16-alpine as base +WORKDIR /app +RUN apk add --no-cache bash git + +COPY package.json . +COPY yarn.lock . +COPY blocks-cache-*.csv . +COPY content/package.json content/ + +# get production dependencies +FROM base as dependencies +RUN yarn install --prod --frozen-lockfile + +# build sources +FROM base as catalyst-builder +RUN yarn install --frozen-lockfile + +COPY . . +FROM catalyst-builder as content-builder +RUN yarn workspace @catalyst/content-server build + +# build final image with transpiled code and runtime dependencies +FROM base + +COPY --from=dependencies /app/node_modules ./node_modules/ +COPY --from=dependencies /app/content/node_modules ./node_modules/ + +COPY --from=content-builder /app/content/dist/src content/ +COPY --from=content-builder /app/content/blocks-cache-*.csv . + +# https://docs.docker.com/engine/reference/builder/#arg +ARG CURRENT_VERSION=4.0.0-ci +ENV CURRENT_VERSION=${CURRENT_VERSION:-4.0.0} + +# https://docs.docker.com/engine/reference/builder/#arg +ARG COMMIT_HASH=local +ENV COMMIT_HASH=${COMMIT_HASH:-local} + +EXPOSE 6969 + +# Please _DO NOT_ use a custom ENTRYPOINT because it may prevent signals +# (i.e. SIGTERM) to reach the service +# Read more here: https://aws.amazon.com/blogs/containers/graceful-shutdowns-with-ecs/ +# and: https://www.ctl.io/developers/blog/post/gracefully-stopping-docker-containers/ + +# We use Tini to handle signals and PID1 (https://github.com/krallin/tini, read why here https://github.com/krallin/tini/issues/8) +RUN apk add --no-cache tini + +ENTRYPOINT ["/sbin/tini", "--"] + +# Run the program under Tini +CMD [ "/usr/local/bin/node", "--max-old-space-size=8192", "content/entrypoints/run-server.js" ] From b3187f887262926e6a52d2258aecc6878170138f Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 14:30:50 -0300 Subject: [PATCH 02/25] Save Tue Apr 23 02:30:50 PM -03 2024 --- .circleci/config.yml | 309 ------------------------------------------- Dockerfile | 14 +- package.json | 2 +- 3 files changed, 12 insertions(+), 313 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 9a3703922..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,309 +0,0 @@ -version: 2.1 - -references: - .workspace_root: &workspace_root /tmp/repo - - .attach_root: &attach_root - attach_workspace: - at: *workspace_root - - .image_client: &image_client - image: cimg/node:16.14-browsers - - .working_directory_root: &working_directory_root - working_directory: *workspace_root - - .base_env: &base_env - docker: - - <<: *image_client - working_directory: *workspace_root - - .testing_branches: &testing_branches - filters: - branches: - ignore: main - tags: - ignore: /(.*)/ - - .all_branches_and_tags: &all_branches_and_tags - filters: - branches: - only: /(.*)/ - tags: - only: /^\d+\.\d+\.\d(.*)/ # semver - - .main_and_tags: &main_and_tags - filters: - branches: - only: main - tags: - only: /^\d+\.\d+\.\d(.*)/ # semver - -commands: - login_dockerhub: - steps: - - run: - name: Log into DockerHub - command: docker login -u "${QUAY_USER}" -p "${QUAY_PASS}" quay.io - build_docker_image: - parameters: - dockerfile: - type: string - steps: - - setup_remote_docker: { docker_layer_caching: true, version: 20.10.2 } - - run: - name: Build Docker image - command: | - if echo "${CIRCLE_TAG}" | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; then - DOCKER_BUILDKIT=1 docker build -t ${DOCKER_IMAGE_NAME}:${CIRCLE_SHA1} --build-arg COMMIT_HASH=${CIRCLE_SHA1} --build-arg CURRENT_VERSION=${CIRCLE_TAG} -f <> . - else - DOCKER_BUILDKIT=1 docker build -t ${DOCKER_IMAGE_NAME}:${CIRCLE_SHA1} --build-arg COMMIT_HASH=${CIRCLE_SHA1} --build-arg CURRENT_VERSION=${CIRCLE_BRANCH} -f <> . - fi - push_docker_image: - steps: - - run: - name: Push image - command: | - docker push "${DOCKER_IMAGE_NAME}:${CIRCLE_SHA1}" - if echo "${CIRCLE_TAG}" | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; then - docker tag "${DOCKER_IMAGE_NAME}:${CIRCLE_SHA1}" "${DOCKER_IMAGE_NAME}:${CIRCLE_TAG}" - docker push "${DOCKER_IMAGE_NAME}:${CIRCLE_TAG}" - docker tag "${DOCKER_IMAGE_NAME}:${CIRCLE_SHA1}" "${DOCKER_IMAGE_NAME}:latest" - docker push "${DOCKER_IMAGE_NAME}:latest" - # TODO: publish SNS message for stable channel - fi - - if [ "${CIRCLE_BRANCH}" = "main" ]; then - docker tag "${DOCKER_IMAGE_NAME}:${CIRCLE_SHA1}" "${DOCKER_IMAGE_NAME}:next" - docker push "${DOCKER_IMAGE_NAME}:next" - - # TODO: publish SNS message for latest channel - fi - -jobs: - checkout: - <<: *base_env - - steps: - - checkout - - # Download and cache dependencies - - restore_cache: - name: Restore Yarn Package Cache - keys: - - yarn-packages-{{ checksum "yarn.lock" }} - - - run: - name: Install Dependencies - command: yarn --frozen-lockfile --cache-folder ~/.cache/yarn - - - save_cache: - name: Save Yarn Package Cache - key: yarn-packages-{{ checksum "yarn.lock" }} - paths: - - ~/.cache/yarn - - # persist to workspace to use in downstream jobs - - persist_to_workspace: - root: *workspace_root - paths: - - . - - linter: - <<: *base_env - steps: - - <<: *attach_root - - run: yarn lint:check - - build-content: - docker: - - <<: *image_client - - image: cimg/postgres:12.9 - command: postgres -c max_connections=300 - environment: - POSTGRES_DB: postgres_test - POSTGRES_PASSWORD: '12345678' - POSTGRES_USER: postgres - parallelism: 5 - working_directory: *workspace_root - steps: - - <<: *attach_root - - run: - name: Run tests - command: | - cd content - TESTFILES=$(circleci tests glob "test/**/*.spec.ts" | circleci tests split --split-by=timings) - yarn test:ci $TESTFILES --coverageDirectory=reports --reporters=jest-junit --reporters=default - mv reports/coverage-final.json reports/coverage-${CIRCLE_NODE_INDEX:-0}.json - mv api-coverage/api-coverage.csv api-coverage/api-coverage-${CIRCLE_NODE_INDEX:-0}.csv || true - environment: - CI: 'true' - API_COVERAGE: 'true' - JEST_JUNIT_OUTPUT_DIR: './test-result' - JEST_JUNIT_ADD_FILE_ATTRIBUTE: 'true' - - store_test_results: - path: content/test-result - - store_artifacts: - path: content/test-result - - persist_to_workspace: - root: *workspace_root - paths: - - content/reports - - content/api-coverage - - report-content-coverage: - <<: *base_env - steps: - - <<: *attach_root - - run: - name: Report coverage - command: | - cd content - yarn nyc merge reports - mkdir .nyc_output/ - mv coverage.json .nyc_output/coverage.json - yarn nyc report --reporter=lcov --reporter=text - - store_test_results: - path: content/coverage - - store_artifacts: - path: content/coverage - report-content-api-coverage: - <<: *base_env - steps: - - <<: *attach_root - - run: - name: Report API coverage - command: | - cd content - yarn report-api-coverage - build-lambdas: - <<: *base_env - steps: - - <<: *attach_root - - run: - name: Build content - command: yarn workspace @catalyst/lambdas-server build - - run: - name: Run tests - command: yarn workspace @catalyst/lambdas-server test - - publish-content-docker: - <<: *base_env - docker: - - image: cimg/node:16.14-browsers - environment: &ENVIRONMENT - DOCKER_IMAGE_NAME: quay.io/decentraland/catalyst-content - steps: - - <<: *attach_root - - build_docker_image: - dockerfile: "Dockerfile.content" - - login_dockerhub - - push_docker_image - - publish-lambdas-docker: - <<: *base_env - docker: - - image: cimg/node:16.14-browsers - environment: &ENVIRONMENT - DOCKER_IMAGE_NAME: quay.io/decentraland/catalyst-lambdas - steps: - - <<: *attach_root - - build_docker_image: - dockerfile: "Dockerfile.lambdas" - - login_dockerhub - - push_docker_image - - publish-content-docker-without-tag: - <<: *base_env - docker: - - image: cimg/node:16.14-browsers - environment: &ENVIRONMENT - DOCKER_IMAGE_NAME: quay.io/decentraland/catalyst-content - steps: - - <<: *attach_root - - build_docker_image: - dockerfile: "Dockerfile.content" - - login_dockerhub - - run: - name: Push image (without tag) - command: | - docker push "${DOCKER_IMAGE_NAME}:${CIRCLE_SHA1}" - - publish-lambdas-docker-without-tag: - <<: *base_env - docker: - - image: cimg/node:16.14-browsers - environment: &ENVIRONMENT - DOCKER_IMAGE_NAME: quay.io/decentraland/catalyst-lambdas - steps: - - <<: *attach_root - - build_docker_image: - dockerfile: "Dockerfile.lambdas" - - login_dockerhub - - run: - name: Push image (without tag) - command: | - docker push "${DOCKER_IMAGE_NAME}:${CIRCLE_SHA1}" - -workflows: - version: 2 - - build-deploy: - jobs: - # checkout code - - checkout: - <<: *all_branches_and_tags - - - linter: - <<: *all_branches_and_tags - requires: - - checkout - - # build packages - - build-content: - <<: *all_branches_and_tags - requires: - - checkout - - report-content-coverage: - <<: *all_branches_and_tags - requires: - - build-content - - report-content-api-coverage: - <<: *all_branches_and_tags - requires: - - build-content - - build-lambdas: - <<: *all_branches_and_tags - requires: - - checkout - - # publish docker images in "main" and semver tags - # main publishes to @next - # semver tags publish to @latest - - publish-content-docker: - <<: *main_and_tags - requires: - - build-content - - report-content-coverage - - report-content-api-coverage - - - publish-lambdas-docker: - <<: *main_and_tags - requires: - - build-lambdas - - # NOT (main | semver) enables manual approval to release untagged docker images - - accept-publish-docker-for-testing: - <<: *testing_branches - type: approval - requires: - - build-content - - build-lambdas - - publish-content-docker-without-tag: - <<: *testing_branches - requires: - - accept-publish-docker-for-testing - - publish-lambdas-docker-without-tag: - <<: *testing_branches - requires: - - accept-publish-docker-for-testing diff --git a/Dockerfile b/Dockerfile index 6ce87d978..4badd342e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,8 +4,9 @@ RUN apk add --no-cache bash git COPY package.json . COPY yarn.lock . -COPY blocks-cache-*.csv . +COPY content/blocks-cache-*.csv content/ COPY content/package.json content/ +COPY lambdas/package.json lambdas/ # get production dependencies FROM base as dependencies @@ -25,8 +26,9 @@ FROM base COPY --from=dependencies /app/node_modules ./node_modules/ COPY --from=dependencies /app/content/node_modules ./node_modules/ -COPY --from=content-builder /app/content/dist/src content/ -COPY --from=content-builder /app/content/blocks-cache-*.csv . +COPY --from=catalyst-builder /app/content/dist/src content/ +COPY --from=catalyst-builder /app/content/blocks-cache-*.csv /app/ +COPY --from=catalyst-builder /app/lambdas/dist/src lambdas/ # https://docs.docker.com/engine/reference/builder/#arg ARG CURRENT_VERSION=4.0.0-ci @@ -50,3 +52,9 @@ ENTRYPOINT ["/sbin/tini", "--"] # Run the program under Tini CMD [ "/usr/local/bin/node", "--max-old-space-size=8192", "content/entrypoints/run-server.js" ] + + + + +# EXPOSE 7070 +# CMD [ "/usr/local/bin/node", "--max-old-space-size=8192", "lambdas/entrypoints/run-server.js" ] diff --git a/package.json b/package.json index 1ad5160fe..08e98ef54 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "start": "yarn workspaces run start:server", "start:content": "yarn workspace @catalyst/content-server start:db && yarn workspace @catalyst/content-server start:server", "start:lambdas": "yarn workspace @catalyst/lambdas-server start:server", - "test": "run-s 'test:*'", + "test": "yarn test:content && yarn test:lambdas", "test:content": "yarn workspace @catalyst/content-server test", "test:lambdas": "yarn workspace @catalyst/lambdas-server test", "unused": "npx depcheck; yarn unused:content; yarn unused:lambdas", From 6a2b07bde07819b6ce611643ec8192a9a8391d86 Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 14:42:01 -0300 Subject: [PATCH 03/25] Save Tue Apr 23 02:42:01 PM -03 2024 --- .github/workflows/build.yml | 6 +++++- Dockerfile | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f7e988907..b9c167a69 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,4 +6,8 @@ on: jobs: build: - uses: decentraland/platform-actions/.github/workflows/apps-with-db-build.yml@main + uses: decentraland/platform-actions/.github/workflows/apps-with-db-build.yml@db + with: + postgres-user: postgres + postgres-password: 12345678 + postgres-db: postgres_test diff --git a/Dockerfile b/Dockerfile index 4badd342e..c86bd2b36 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,10 +15,8 @@ RUN yarn install --prod --frozen-lockfile # build sources FROM base as catalyst-builder RUN yarn install --frozen-lockfile - COPY . . -FROM catalyst-builder as content-builder -RUN yarn workspace @catalyst/content-server build +RUN yarn build # build final image with transpiled code and runtime dependencies FROM base From c65330ddb72ee3d41a630c77576fb64a1c0f54e7 Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 14:55:43 -0300 Subject: [PATCH 04/25] remove leak detector --- content/package.json | 1 - .../test/integration/E2ETestEnvironment.ts | 9 +++-- .../controller/active-entities.spec.ts | 3 -- .../active-entity-by-content-hash.spec.ts | 3 -- .../controller/active-pointers.spec.ts | 3 -- .../test/integration/controller/audit.spec.ts | 3 -- .../controller/available-content.spec.ts | 3 -- .../integration/controller/content.spec.ts | 3 -- .../controller/deployment-fields.spec.ts | 3 -- .../controller/deployment-pagination.spec.ts | 3 -- .../integration/controller/entities.spec.ts | 3 -- .../controller/entity-metadata.spec.ts | 3 -- .../integration/controller/status.spec.ts | 3 -- .../deployer/concurrent-deployments.spec.ts | 3 -- .../deployment-entity-overlap.spec.ts | 3 -- .../ports/deployer/deployment-filters.spec.ts | 3 -- .../metadata-schema-validations.spec.ts | 3 -- .../ports/deployer/old-entity-synced.spec.ts | 3 -- .../ports/deployer/order-check.spec.ts | 3 -- .../deployer/same-timestamp-check.spec.ts | 3 -- .../ports/failedDeployments.spec.ts | 3 -- .../ports/processedSnapshotStorage.spec.ts | 3 -- .../integration/ports/snapshotStorage.spec.ts | 3 -- .../ports/system-properties.spec.ts | 3 -- .../syncronization/error-handling.spec.ts | 5 --- .../integration/upload-and-download.spec.ts | 3 -- yarn.lock | 39 ------------------- 27 files changed, 5 insertions(+), 118 deletions(-) diff --git a/content/package.json b/content/package.json index 09ea62e49..14f0f3705 100644 --- a/content/package.json +++ b/content/package.json @@ -77,7 +77,6 @@ "jest": "27.4.7", "jest-extra-utils": "^0.1.0", "jest-junit": "^13.0.0", - "jest-leak-detector": "^29.3.1", "lint-staged": "13.0.3", "nyc": "^15.1.0", "prettier": "2.7.1", diff --git a/content/test/integration/E2ETestEnvironment.ts b/content/test/integration/E2ETestEnvironment.ts index a6305a80b..b61098e47 100644 --- a/content/test/integration/E2ETestEnvironment.ts +++ b/content/test/integration/E2ETestEnvironment.ts @@ -3,7 +3,6 @@ import { ILoggerComponent } from '@well-known-components/interfaces' import { createLogComponent } from '@well-known-components/logger' import { createTestMetricsComponent } from '@well-known-components/metrics' import { random } from 'faker' -import LeakDetector from 'jest-leak-detector' import ms from 'ms' import { DEFAULT_DATABASE_CONFIG, Environment, EnvironmentBuilder, EnvironmentConfig } from '../../src/Environment' import { stopAllComponents } from '../../src/logic/components-lifecycle' @@ -149,7 +148,11 @@ export class ServerBuilder { private readonly builder: EnvironmentBuilder private readonly storageBaseFolder: string - constructor(private readonly testEnvCalls: TestEnvCalls, env: Environment, public dao: DAOComponent) { + constructor( + private readonly testEnvCalls: TestEnvCalls, + env: Environment, + public dao: DAOComponent + ) { this.builder = new EnvironmentBuilder(env) this.storageBaseFolder = env.getConfig(EnvironmentConfig.STORAGE_ROOT_FOLDER) ?? 'storage' } @@ -218,10 +221,8 @@ export function setupTestEnvironment(overrideConfigs?: Record) { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(testEnv) await testEnv.stop() testEnv = null as any - expect(await detector.isLeaking()).toBe(false) }) return () => testEnv diff --git a/content/test/integration/controller/active-entities.spec.ts b/content/test/integration/controller/active-entities.spec.ts index dee3e9167..6976060f0 100644 --- a/content/test/integration/controller/active-entities.spec.ts +++ b/content/test/integration/controller/active-entities.spec.ts @@ -5,7 +5,6 @@ import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidat import { buildDeployData } from '../E2ETestUtils' import { getIntegrationResourcePathFor } from '../resources/get-resource-path' import { TestProgram } from '../TestProgram' -import LeakDetector from 'jest-leak-detector' import { createDefaultServer, resetServer } from '../simpleTestEnvironment' describe('Integration - Get Active Entities', () => { @@ -20,10 +19,8 @@ describe('Integration - Get Active Entities', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it('when asking without params, it returns client error', async () => { diff --git a/content/test/integration/controller/active-entity-by-content-hash.spec.ts b/content/test/integration/controller/active-entity-by-content-hash.spec.ts index 1628d6013..b4a8cb4c7 100644 --- a/content/test/integration/controller/active-entity-by-content-hash.spec.ts +++ b/content/test/integration/controller/active-entity-by-content-hash.spec.ts @@ -3,7 +3,6 @@ import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidat import { buildDeployData } from '../E2ETestUtils' import { createDefaultServer, resetServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' -import LeakDetector from 'jest-leak-detector' describe('Integration - Get Active Entities By Content Hash', () => { let server: TestProgram @@ -17,10 +16,8 @@ describe('Integration - Get Active Entities By Content Hash', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it("When the deployment doesn't exist returns 404", async () => { diff --git a/content/test/integration/controller/active-pointers.spec.ts b/content/test/integration/controller/active-pointers.spec.ts index d52d153cd..8af0574a5 100644 --- a/content/test/integration/controller/active-pointers.spec.ts +++ b/content/test/integration/controller/active-pointers.spec.ts @@ -6,7 +6,6 @@ import { getIntegrationResourcePathFor } from '../resources/get-resource-path' import { TestProgram } from '../TestProgram' import FormData = require('form-data') import { resetServer, createDefaultServer } from '../simpleTestEnvironment' -import LeakDetector from 'jest-leak-detector' interface ActivePointersRow { entity_id: string @@ -37,10 +36,8 @@ describe('Integration - Create entities', () => { afterAll(async () => { jest.restoreAllMocks() stopAllComponents({ fs }) - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it('when creating a profile, pointer should be stored in active-pointers table', async () => { diff --git a/content/test/integration/controller/audit.spec.ts b/content/test/integration/controller/audit.spec.ts index 3ebd20267..79889990e 100644 --- a/content/test/integration/controller/audit.spec.ts +++ b/content/test/integration/controller/audit.spec.ts @@ -4,7 +4,6 @@ import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidat import { buildDeployData, deployEntitiesCombo } from '../E2ETestUtils' import { createDefaultServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' -import LeakDetector from 'jest-leak-detector' describe('Integration - Audit', () => { let server: TestProgram @@ -16,10 +15,8 @@ describe('Integration - Audit', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it('returns 400 when no cid is provided', async () => { diff --git a/content/test/integration/controller/available-content.spec.ts b/content/test/integration/controller/available-content.spec.ts index adbd2dad6..c580c7d47 100644 --- a/content/test/integration/controller/available-content.spec.ts +++ b/content/test/integration/controller/available-content.spec.ts @@ -2,7 +2,6 @@ import fetch from 'node-fetch' import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidator' import { createDefaultServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' -import LeakDetector from 'jest-leak-detector' describe('Integration - Available Content', () => { let server: TestProgram @@ -14,10 +13,8 @@ describe('Integration - Available Content', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it('returns 400 when no cid is provided', async () => { diff --git a/content/test/integration/controller/content.spec.ts b/content/test/integration/controller/content.spec.ts index 94d5800d9..cd804730f 100644 --- a/content/test/integration/controller/content.spec.ts +++ b/content/test/integration/controller/content.spec.ts @@ -2,7 +2,6 @@ import fetch from 'node-fetch' import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidator' import { createDefaultServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' -import LeakDetector from 'jest-leak-detector' describe('Integration - Get Content', () => { let server: TestProgram @@ -14,10 +13,8 @@ describe('Integration - Get Content', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it('returns 404 when the content file does not exist', async () => { diff --git a/content/test/integration/controller/deployment-fields.spec.ts b/content/test/integration/controller/deployment-fields.spec.ts index 2dcded4f9..1b8d8af84 100644 --- a/content/test/integration/controller/deployment-fields.spec.ts +++ b/content/test/integration/controller/deployment-fields.spec.ts @@ -5,7 +5,6 @@ import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidat import { buildDeployData } from '../E2ETestUtils' import { createDefaultServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' -import LeakDetector from 'jest-leak-detector' describe('Integration - Deployment Fields', () => { const fetcher = createFetchComponent() @@ -25,10 +24,8 @@ describe('Integration - Deployment Fields', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it('When deployments fields filter is used, then the result is the expected', async () => { diff --git a/content/test/integration/controller/deployment-pagination.spec.ts b/content/test/integration/controller/deployment-pagination.spec.ts index 2b9ade8d1..3fde17f68 100644 --- a/content/test/integration/controller/deployment-pagination.spec.ts +++ b/content/test/integration/controller/deployment-pagination.spec.ts @@ -8,7 +8,6 @@ import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidat import { buildDeployData, EntityCombo } from '../E2ETestUtils' import { resetServer, createDefaultServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' -import LeakDetector from 'jest-leak-detector' describe('Integration - Deployment Pagination', () => { const fetcher = createFetchComponent() @@ -43,10 +42,8 @@ describe('Integration - Deployment Pagination', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it('given local timestamp and asc when getting two elements the next link page is correct', async () => { diff --git a/content/test/integration/controller/entities.spec.ts b/content/test/integration/controller/entities.spec.ts index 9bec937ca..1e87471ee 100644 --- a/content/test/integration/controller/entities.spec.ts +++ b/content/test/integration/controller/entities.spec.ts @@ -2,7 +2,6 @@ import fetch from 'node-fetch' import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidator' import { createDefaultServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' -import LeakDetector from 'jest-leak-detector' describe('Integration - Entities', () => { let server: TestProgram @@ -14,10 +13,8 @@ describe('Integration - Entities', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it('returns 500 when there is an exception while deploying the entity', async () => { diff --git a/content/test/integration/controller/entity-metadata.spec.ts b/content/test/integration/controller/entity-metadata.spec.ts index 415ed822e..1ffb065b2 100644 --- a/content/test/integration/controller/entity-metadata.spec.ts +++ b/content/test/integration/controller/entity-metadata.spec.ts @@ -3,7 +3,6 @@ import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidat import { buildDeployData } from '../E2ETestUtils' import { createDefaultServer, resetServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' -import LeakDetector from 'jest-leak-detector' describe('Integration - Get wearable image and thumbnail', () => { let server: TestProgram @@ -17,10 +16,8 @@ describe('Integration - Get wearable image and thumbnail', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it('when entity does not exist, it should return 404', async () => { diff --git a/content/test/integration/controller/status.spec.ts b/content/test/integration/controller/status.spec.ts index c07e9306b..cfa79ceb4 100644 --- a/content/test/integration/controller/status.spec.ts +++ b/content/test/integration/controller/status.spec.ts @@ -2,7 +2,6 @@ import fetch from 'node-fetch' import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidator' import { createDefaultServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' -import LeakDetector from 'jest-leak-detector' describe('Integration - Status', () => { let server: TestProgram @@ -14,10 +13,8 @@ describe('Integration - Status', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it('returns 200 when the status is ok', async () => { diff --git a/content/test/integration/ports/deployer/concurrent-deployments.spec.ts b/content/test/integration/ports/deployer/concurrent-deployments.spec.ts index 251bf9a35..c7f1f6f9f 100644 --- a/content/test/integration/ports/deployer/concurrent-deployments.spec.ts +++ b/content/test/integration/ports/deployer/concurrent-deployments.spec.ts @@ -5,7 +5,6 @@ import { AppComponents } from '../../../../src/types' import { makeNoopServerValidator, makeNoopValidator } from '../../../helpers/service/validations/NoOpValidator' import { buildDeployData, deployEntitiesCombo, EntityCombo } from '../../E2ETestUtils' import { TestProgram } from '../../TestProgram' -import LeakDetector from 'jest-leak-detector' import { createDefaultServer } from '../../simpleTestEnvironment' const P1 = 'x1,y1' @@ -26,10 +25,8 @@ describe('Integration - Concurrent deployments', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it('When deployments are executed concurrently, then only one remains active', async () => { diff --git a/content/test/integration/ports/deployer/deployment-entity-overlap.spec.ts b/content/test/integration/ports/deployer/deployment-entity-overlap.spec.ts index cd4bbd22e..df6b5d314 100644 --- a/content/test/integration/ports/deployer/deployment-entity-overlap.spec.ts +++ b/content/test/integration/ports/deployer/deployment-entity-overlap.spec.ts @@ -11,7 +11,6 @@ import { AppComponents } from '../../../../src/types' import { makeNoopServerValidator, makeNoopValidator } from '../../../helpers/service/validations/NoOpValidator' import { buildDeployData, buildDeployDataAfterEntity, createIdentity, EntityCombo, Identity } from '../../E2ETestUtils' import { TestProgram } from '../../TestProgram' -import LeakDetector from 'jest-leak-detector' import { createDefaultServer } from '../../simpleTestEnvironment' const P1 = '0,0' @@ -31,10 +30,8 @@ describe('Integration - Deployment with Entity Overlaps', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) let identity: Identity diff --git a/content/test/integration/ports/deployer/deployment-filters.spec.ts b/content/test/integration/ports/deployer/deployment-filters.spec.ts index 166a1ca32..fbc242633 100644 --- a/content/test/integration/ports/deployer/deployment-filters.spec.ts +++ b/content/test/integration/ports/deployer/deployment-filters.spec.ts @@ -12,7 +12,6 @@ import { AppComponents } from '../../../../src/types' import { makeNoopServerValidator, makeNoopValidator } from '../../../helpers/service/validations/NoOpValidator' import { buildDeployData, buildDeployDataAfterEntity, EntityCombo } from '../../E2ETestUtils' import { TestProgram } from '../../TestProgram' -import LeakDetector from 'jest-leak-detector' import { createDefaultServer, resetServer } from '../../simpleTestEnvironment' const P1 = 'x1,y1' @@ -36,10 +35,8 @@ describe('Integration - Deployment Filters', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) let E1: EntityCombo, E2: EntityCombo, E3: EntityCombo diff --git a/content/test/integration/ports/deployer/metadata-schema-validations.spec.ts b/content/test/integration/ports/deployer/metadata-schema-validations.spec.ts index 9364e24b9..70c73aeb7 100644 --- a/content/test/integration/ports/deployer/metadata-schema-validations.spec.ts +++ b/content/test/integration/ports/deployer/metadata-schema-validations.spec.ts @@ -4,7 +4,6 @@ import { AppComponents, EntityVersion } from '../../../../src/types' import { makeNoopServerValidator } from '../../../helpers/service/validations/NoOpValidator' import { EntityCombo, buildDeployData, createIdentity } from '../../E2ETestUtils' import { TestProgram } from '../../TestProgram' -import LeakDetector from 'jest-leak-detector' import { createDefaultServer, resetServer } from '../../simpleTestEnvironment' const P1 = '0,0' @@ -25,10 +24,8 @@ describe('Integration - Deployment with metadata validation', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it('When scene metadata is missing, deployment result should include the proper error', async () => { diff --git a/content/test/integration/ports/deployer/old-entity-synced.spec.ts b/content/test/integration/ports/deployer/old-entity-synced.spec.ts index c0e3940d9..f90a27a77 100644 --- a/content/test/integration/ports/deployer/old-entity-synced.spec.ts +++ b/content/test/integration/ports/deployer/old-entity-synced.spec.ts @@ -5,7 +5,6 @@ import { makeNoopServerValidator } from '../../../helpers/service/validations/No import { EntityCombo } from '../../E2ETestUtils' import { getIntegrationResourcePathFor } from '../../resources/get-resource-path' import { TestProgram } from '../../TestProgram' -import LeakDetector from 'jest-leak-detector' import { createDefaultServer } from '../../simpleTestEnvironment' describe('Integration - Deployment synced old entity', () => { @@ -18,10 +17,8 @@ describe('Integration - Deployment synced old entity', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it('When deploying an entity with cid v0 hashes of entities before ADR 45, it should succeed', async () => { diff --git a/content/test/integration/ports/deployer/order-check.spec.ts b/content/test/integration/ports/deployer/order-check.spec.ts index dc34c21c1..42de12aa0 100644 --- a/content/test/integration/ports/deployer/order-check.spec.ts +++ b/content/test/integration/ports/deployer/order-check.spec.ts @@ -4,7 +4,6 @@ import { makeNoopServerValidator, makeNoopValidator } from '../../../helpers/ser import { buildDeployData, buildDeployDataAfterEntity, deployEntitiesCombo, EntityCombo } from '../../E2ETestUtils' import { createDefaultServer } from '../../simpleTestEnvironment' import { TestProgram } from '../../TestProgram' -import LeakDetector from 'jest-leak-detector' /** * This test verifies that the active entity and overwrites are calculated correctly, regardless of the order in which the entities where deployed. @@ -28,10 +27,8 @@ describe('Integration - Order Check', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) beforeAll(async () => { diff --git a/content/test/integration/ports/deployer/same-timestamp-check.spec.ts b/content/test/integration/ports/deployer/same-timestamp-check.spec.ts index 9679c4d37..88f1d2d36 100644 --- a/content/test/integration/ports/deployer/same-timestamp-check.spec.ts +++ b/content/test/integration/ports/deployer/same-timestamp-check.spec.ts @@ -4,7 +4,6 @@ import { AppComponents } from '../../../../src/types' import { makeNoopServerValidator, makeNoopValidator } from '../../../helpers/service/validations/NoOpValidator' import { buildDeployData, deployEntitiesCombo, EntityCombo } from '../../E2ETestUtils' import { TestProgram } from '../../TestProgram' -import LeakDetector from 'jest-leak-detector' import { createDefaultServer } from '../../simpleTestEnvironment' const P1 = 'X1,Y1' @@ -35,10 +34,8 @@ describe('Integration - Same Timestamp Check', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it(`When oldest is deployed first, the active is the newest`, async () => { diff --git a/content/test/integration/ports/failedDeployments.spec.ts b/content/test/integration/ports/failedDeployments.spec.ts index 457fa9384..25c5df536 100644 --- a/content/test/integration/ports/failedDeployments.spec.ts +++ b/content/test/integration/ports/failedDeployments.spec.ts @@ -8,7 +8,6 @@ import { SnapshotFailedDeployment } from '../../../src/ports/failedDeployments' import { TestProgram } from '../TestProgram' -import LeakDetector from 'jest-leak-detector' import { createDefaultServer, resetServer } from '../simpleTestEnvironment' describe('failed deployments - ', () => { @@ -22,10 +21,8 @@ describe('failed deployments - ', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) const aFailedDeployment = { diff --git a/content/test/integration/ports/processedSnapshotStorage.spec.ts b/content/test/integration/ports/processedSnapshotStorage.spec.ts index 94b4ea5f2..3da65fe3b 100644 --- a/content/test/integration/ports/processedSnapshotStorage.spec.ts +++ b/content/test/integration/ports/processedSnapshotStorage.spec.ts @@ -2,7 +2,6 @@ import * as snapshotQueries from '../../../src/logic/database-queries/snapshots- import { saveProcessedSnapshot } from '../../../src/logic/database-queries/snapshots-queries' import { TestProgram } from '../TestProgram' -import LeakDetector from 'jest-leak-detector' import { createDefaultServer, resetServer } from '../simpleTestEnvironment' describe('precessed snapshot storage', () => { @@ -21,10 +20,8 @@ describe('precessed snapshot storage', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) describe('processedFrom', () => { diff --git a/content/test/integration/ports/snapshotStorage.spec.ts b/content/test/integration/ports/snapshotStorage.spec.ts index c89e77060..db207ee15 100644 --- a/content/test/integration/ports/snapshotStorage.spec.ts +++ b/content/test/integration/ports/snapshotStorage.spec.ts @@ -1,6 +1,5 @@ import * as snapshotQueries from '../../../src/logic/database-queries/snapshots-queries' import { TestProgram } from '../TestProgram' -import LeakDetector from 'jest-leak-detector' import { createDefaultServer } from '../simpleTestEnvironment' describe('snapshot storage', () => { @@ -12,10 +11,8 @@ describe('snapshot storage', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it('should return true if the snapshot is stored', async () => { diff --git a/content/test/integration/ports/system-properties.spec.ts b/content/test/integration/ports/system-properties.spec.ts index 2ba2f55f9..c5122979b 100644 --- a/content/test/integration/ports/system-properties.spec.ts +++ b/content/test/integration/ports/system-properties.spec.ts @@ -1,6 +1,5 @@ import { createSystemProperties, SYSTEM_PROPERTIES } from '../../../src/ports/system-properties' import { TestProgram } from '../TestProgram' -import LeakDetector from 'jest-leak-detector' import { createDefaultServer } from '../simpleTestEnvironment' describe('system properties - ', () => { @@ -12,10 +11,8 @@ describe('system properties - ', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it('test values', async () => { diff --git a/content/test/integration/syncronization/error-handling.spec.ts b/content/test/integration/syncronization/error-handling.spec.ts index 2d3e03956..a25906b49 100644 --- a/content/test/integration/syncronization/error-handling.spec.ts +++ b/content/test/integration/syncronization/error-handling.spec.ts @@ -18,7 +18,6 @@ import { } from '../E2EAssertions' import { awaitUntil, buildDeployData, buildDeployDataAfterEntity, createIdentity } from '../E2ETestUtils' import { TestProgram } from '../TestProgram' -import LeakDetector from 'jest-leak-detector' import { createAdditionalServer, createDefaultServer } from '../simpleTestEnvironment' describe('End 2 end - Error handling', () => { @@ -44,18 +43,14 @@ describe('End 2 end - Error handling', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server1) await server1.stopProgram() server1 = null as any - expect(await detector.isLeaking()).toBe(false) }) afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server2) await server2.stopProgram() server2 = null as any - expect(await detector.isLeaking()).toBe(false) }) //TODO: [new-sync] Check that this is being tested somewhere else diff --git a/content/test/integration/upload-and-download.spec.ts b/content/test/integration/upload-and-download.spec.ts index 7ef7b4432..b29eec0ec 100644 --- a/content/test/integration/upload-and-download.spec.ts +++ b/content/test/integration/upload-and-download.spec.ts @@ -7,7 +7,6 @@ import { assertDeploymentsAreReported, buildDeployment } from './E2EAssertions' import { buildDeployData } from './E2ETestUtils' import { getIntegrationResourcePathFor } from './resources/get-resource-path' import { TestProgram } from './TestProgram' -import LeakDetector from 'jest-leak-detector' import { createDefaultServer, resetServer } from './simpleTestEnvironment' const POINTER0 = 'X0,Y0' @@ -24,10 +23,8 @@ describe('End 2 end deploy test', () => { afterAll(async () => { jest.restoreAllMocks() - const detector = new LeakDetector(server) await server.stopProgram() server = null as any - expect(await detector.isLeaking()).toBe(false) }) it('When a user tries to deploy the same entity twice, then an exception is thrown', async () => { diff --git a/yarn.lock b/yarn.lock index 9c6b858d9..871c1e809 100644 --- a/yarn.lock +++ b/yarn.lock @@ -937,13 +937,6 @@ terminal-link "^2.0.0" v8-to-istanbul "^8.1.0" -"@jest/schemas@^29.0.0": - version "29.0.0" - resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.0.0.tgz#5f47f5994dd4ef067fb7b4188ceac45f77fe952a" - integrity sha512-3Ab5HgYIIAnS0HjqJHQYZS+zXc4tUmTmBH3z83ajI6afXp8X3ZtdLX+nXx+I7LNkJD7uN9LAVhgnjDgZa2z0kA== - dependencies: - "@sinclair/typebox" "^0.24.1" - "@jest/source-map@^27.5.1": version "27.5.1" resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-27.5.1.tgz#6608391e465add4205eae073b55e7f279e04e8cf" @@ -1125,11 +1118,6 @@ resolved "https://registry.yarnpkg.com/@sideway/pinpoint/-/pinpoint-2.0.0.tgz#cff8ffadc372ad29fd3f78277aeb29e632cc70df" integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ== -"@sinclair/typebox@^0.24.1": - version "0.24.51" - resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.24.51.tgz#645f33fe4e02defe26f2f5c0410e1c094eac7f5f" - integrity sha512-1P1OROm/rdubP5aFDSZQILU0vrLCJ4fvHt6EoqHEM+2D/G5MK3bIaymUKLit8Js9gbns5UyJnkP/TZROLw4tUA== - "@sinonjs/commons@^1.6.0", "@sinonjs/commons@^1.7.0", "@sinonjs/commons@^1.8.3": version "1.8.3" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d" @@ -4142,11 +4130,6 @@ jest-get-type@^27.5.1: resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-27.5.1.tgz#3cd613c507b0f7ace013df407a1c1cd578bcb4f1" integrity sha512-2KY95ksYSaK7DMBWQn6dQz3kqAf3BB64y2udeG+hv4KfSOb9qwcYQstTJc1KCbsix+wLZWZYN8t7nwX3GOBLRw== -jest-get-type@^29.2.0: - version "29.2.0" - resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-29.2.0.tgz#726646f927ef61d583a3b3adb1ab13f3a5036408" - integrity sha512-uXNJlg8hKFEnDgFsrCjznB+sTxdkuqiCL6zMgA75qEbAJjJYTs9XPrvDctrEig2GDow22T/LvHgO57iJhXB/UA== - jest-haste-map@^27.5.1: version "27.5.1" resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-27.5.1.tgz#9fd8bd7e7b4fa502d9c6164c5640512b4e811e7f" @@ -4208,14 +4191,6 @@ jest-leak-detector@^27.5.1: jest-get-type "^27.5.1" pretty-format "^27.5.1" -jest-leak-detector@^29.3.1: - version "29.3.1" - resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-29.3.1.tgz#95336d020170671db0ee166b75cd8ef647265518" - integrity sha512-3DA/VVXj4zFOPagGkuqHnSQf1GZBmmlagpguxEERO6Pla2g84Q1MaVIB3YMxgUaFIaYag8ZnTyQgiZ35YEqAQA== - dependencies: - jest-get-type "^29.2.0" - pretty-format "^29.3.1" - jest-matcher-utils@^27.0.0, jest-matcher-utils@^27.5.1: version "27.5.1" resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-27.5.1.tgz#9c0cdbda8245bc22d2331729d1091308b40cf8ab" @@ -5518,15 +5493,6 @@ pretty-format@^27.0.0, pretty-format@^27.5.1: ansi-styles "^5.0.0" react-is "^17.0.1" -pretty-format@^29.3.1: - version "29.3.1" - resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.3.1.tgz#1841cac822b02b4da8971dacb03e8a871b4722da" - integrity sha512-FyLnmb1cYJV8biEIiRyzRFvs2lry7PPIvOqKVe1GCUEYg4YGmlx1qG9EJNMxArYm7piII4qb8UV1Pncq5dxmcg== - dependencies: - "@jest/schemas" "^29.0.0" - ansi-styles "^5.0.0" - react-is "^18.0.0" - process-nextick-args@~2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" @@ -5664,11 +5630,6 @@ react-is@^17.0.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== -react-is@^18.0.0: - version "18.2.0" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b" - integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w== - read-yaml-file@2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/read-yaml-file/-/read-yaml-file-2.1.0.tgz#c5866712db9ef5343b4d02c2413bada53c41c4a9" From 541fdcc82ecf48602547578de9215e4467f3073c Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 14:57:11 -0300 Subject: [PATCH 05/25] Save Tue Apr 23 02:57:11 PM -03 2024 --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9c167a69..06d209f69 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,6 +2,8 @@ name: build on: push: + branches: + - 'main' pull_request: jobs: From fd6c02b30c49409ecd24e8748d07a5d6aaf46e55 Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 15:21:43 -0300 Subject: [PATCH 06/25] Revert "remove leak detector" This reverts commit c65330ddb72ee3d41a630c77576fb64a1c0f54e7. --- content/package.json | 1 + .../test/integration/E2ETestEnvironment.ts | 9 ++--- .../controller/active-entities.spec.ts | 3 ++ .../active-entity-by-content-hash.spec.ts | 3 ++ .../controller/active-pointers.spec.ts | 3 ++ .../test/integration/controller/audit.spec.ts | 3 ++ .../controller/available-content.spec.ts | 3 ++ .../integration/controller/content.spec.ts | 3 ++ .../controller/deployment-fields.spec.ts | 3 ++ .../controller/deployment-pagination.spec.ts | 3 ++ .../integration/controller/entities.spec.ts | 3 ++ .../controller/entity-metadata.spec.ts | 3 ++ .../integration/controller/status.spec.ts | 3 ++ .../deployer/concurrent-deployments.spec.ts | 3 ++ .../deployment-entity-overlap.spec.ts | 3 ++ .../ports/deployer/deployment-filters.spec.ts | 3 ++ .../metadata-schema-validations.spec.ts | 3 ++ .../ports/deployer/old-entity-synced.spec.ts | 3 ++ .../ports/deployer/order-check.spec.ts | 3 ++ .../deployer/same-timestamp-check.spec.ts | 3 ++ .../ports/failedDeployments.spec.ts | 3 ++ .../ports/processedSnapshotStorage.spec.ts | 3 ++ .../integration/ports/snapshotStorage.spec.ts | 3 ++ .../ports/system-properties.spec.ts | 3 ++ .../syncronization/error-handling.spec.ts | 5 +++ .../integration/upload-and-download.spec.ts | 3 ++ yarn.lock | 39 +++++++++++++++++++ 27 files changed, 118 insertions(+), 5 deletions(-) diff --git a/content/package.json b/content/package.json index 14f0f3705..09ea62e49 100644 --- a/content/package.json +++ b/content/package.json @@ -77,6 +77,7 @@ "jest": "27.4.7", "jest-extra-utils": "^0.1.0", "jest-junit": "^13.0.0", + "jest-leak-detector": "^29.3.1", "lint-staged": "13.0.3", "nyc": "^15.1.0", "prettier": "2.7.1", diff --git a/content/test/integration/E2ETestEnvironment.ts b/content/test/integration/E2ETestEnvironment.ts index b61098e47..a6305a80b 100644 --- a/content/test/integration/E2ETestEnvironment.ts +++ b/content/test/integration/E2ETestEnvironment.ts @@ -3,6 +3,7 @@ import { ILoggerComponent } from '@well-known-components/interfaces' import { createLogComponent } from '@well-known-components/logger' import { createTestMetricsComponent } from '@well-known-components/metrics' import { random } from 'faker' +import LeakDetector from 'jest-leak-detector' import ms from 'ms' import { DEFAULT_DATABASE_CONFIG, Environment, EnvironmentBuilder, EnvironmentConfig } from '../../src/Environment' import { stopAllComponents } from '../../src/logic/components-lifecycle' @@ -148,11 +149,7 @@ export class ServerBuilder { private readonly builder: EnvironmentBuilder private readonly storageBaseFolder: string - constructor( - private readonly testEnvCalls: TestEnvCalls, - env: Environment, - public dao: DAOComponent - ) { + constructor(private readonly testEnvCalls: TestEnvCalls, env: Environment, public dao: DAOComponent) { this.builder = new EnvironmentBuilder(env) this.storageBaseFolder = env.getConfig(EnvironmentConfig.STORAGE_ROOT_FOLDER) ?? 'storage' } @@ -221,8 +218,10 @@ export function setupTestEnvironment(overrideConfigs?: Record) { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(testEnv) await testEnv.stop() testEnv = null as any + expect(await detector.isLeaking()).toBe(false) }) return () => testEnv diff --git a/content/test/integration/controller/active-entities.spec.ts b/content/test/integration/controller/active-entities.spec.ts index 6976060f0..dee3e9167 100644 --- a/content/test/integration/controller/active-entities.spec.ts +++ b/content/test/integration/controller/active-entities.spec.ts @@ -5,6 +5,7 @@ import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidat import { buildDeployData } from '../E2ETestUtils' import { getIntegrationResourcePathFor } from '../resources/get-resource-path' import { TestProgram } from '../TestProgram' +import LeakDetector from 'jest-leak-detector' import { createDefaultServer, resetServer } from '../simpleTestEnvironment' describe('Integration - Get Active Entities', () => { @@ -19,8 +20,10 @@ describe('Integration - Get Active Entities', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it('when asking without params, it returns client error', async () => { diff --git a/content/test/integration/controller/active-entity-by-content-hash.spec.ts b/content/test/integration/controller/active-entity-by-content-hash.spec.ts index b4a8cb4c7..1628d6013 100644 --- a/content/test/integration/controller/active-entity-by-content-hash.spec.ts +++ b/content/test/integration/controller/active-entity-by-content-hash.spec.ts @@ -3,6 +3,7 @@ import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidat import { buildDeployData } from '../E2ETestUtils' import { createDefaultServer, resetServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' +import LeakDetector from 'jest-leak-detector' describe('Integration - Get Active Entities By Content Hash', () => { let server: TestProgram @@ -16,8 +17,10 @@ describe('Integration - Get Active Entities By Content Hash', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it("When the deployment doesn't exist returns 404", async () => { diff --git a/content/test/integration/controller/active-pointers.spec.ts b/content/test/integration/controller/active-pointers.spec.ts index 8af0574a5..d52d153cd 100644 --- a/content/test/integration/controller/active-pointers.spec.ts +++ b/content/test/integration/controller/active-pointers.spec.ts @@ -6,6 +6,7 @@ import { getIntegrationResourcePathFor } from '../resources/get-resource-path' import { TestProgram } from '../TestProgram' import FormData = require('form-data') import { resetServer, createDefaultServer } from '../simpleTestEnvironment' +import LeakDetector from 'jest-leak-detector' interface ActivePointersRow { entity_id: string @@ -36,8 +37,10 @@ describe('Integration - Create entities', () => { afterAll(async () => { jest.restoreAllMocks() stopAllComponents({ fs }) + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it('when creating a profile, pointer should be stored in active-pointers table', async () => { diff --git a/content/test/integration/controller/audit.spec.ts b/content/test/integration/controller/audit.spec.ts index 79889990e..3ebd20267 100644 --- a/content/test/integration/controller/audit.spec.ts +++ b/content/test/integration/controller/audit.spec.ts @@ -4,6 +4,7 @@ import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidat import { buildDeployData, deployEntitiesCombo } from '../E2ETestUtils' import { createDefaultServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' +import LeakDetector from 'jest-leak-detector' describe('Integration - Audit', () => { let server: TestProgram @@ -15,8 +16,10 @@ describe('Integration - Audit', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it('returns 400 when no cid is provided', async () => { diff --git a/content/test/integration/controller/available-content.spec.ts b/content/test/integration/controller/available-content.spec.ts index c580c7d47..adbd2dad6 100644 --- a/content/test/integration/controller/available-content.spec.ts +++ b/content/test/integration/controller/available-content.spec.ts @@ -2,6 +2,7 @@ import fetch from 'node-fetch' import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidator' import { createDefaultServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' +import LeakDetector from 'jest-leak-detector' describe('Integration - Available Content', () => { let server: TestProgram @@ -13,8 +14,10 @@ describe('Integration - Available Content', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it('returns 400 when no cid is provided', async () => { diff --git a/content/test/integration/controller/content.spec.ts b/content/test/integration/controller/content.spec.ts index cd804730f..94d5800d9 100644 --- a/content/test/integration/controller/content.spec.ts +++ b/content/test/integration/controller/content.spec.ts @@ -2,6 +2,7 @@ import fetch from 'node-fetch' import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidator' import { createDefaultServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' +import LeakDetector from 'jest-leak-detector' describe('Integration - Get Content', () => { let server: TestProgram @@ -13,8 +14,10 @@ describe('Integration - Get Content', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it('returns 404 when the content file does not exist', async () => { diff --git a/content/test/integration/controller/deployment-fields.spec.ts b/content/test/integration/controller/deployment-fields.spec.ts index 1b8d8af84..2dcded4f9 100644 --- a/content/test/integration/controller/deployment-fields.spec.ts +++ b/content/test/integration/controller/deployment-fields.spec.ts @@ -5,6 +5,7 @@ import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidat import { buildDeployData } from '../E2ETestUtils' import { createDefaultServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' +import LeakDetector from 'jest-leak-detector' describe('Integration - Deployment Fields', () => { const fetcher = createFetchComponent() @@ -24,8 +25,10 @@ describe('Integration - Deployment Fields', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it('When deployments fields filter is used, then the result is the expected', async () => { diff --git a/content/test/integration/controller/deployment-pagination.spec.ts b/content/test/integration/controller/deployment-pagination.spec.ts index 3fde17f68..2b9ade8d1 100644 --- a/content/test/integration/controller/deployment-pagination.spec.ts +++ b/content/test/integration/controller/deployment-pagination.spec.ts @@ -8,6 +8,7 @@ import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidat import { buildDeployData, EntityCombo } from '../E2ETestUtils' import { resetServer, createDefaultServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' +import LeakDetector from 'jest-leak-detector' describe('Integration - Deployment Pagination', () => { const fetcher = createFetchComponent() @@ -42,8 +43,10 @@ describe('Integration - Deployment Pagination', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it('given local timestamp and asc when getting two elements the next link page is correct', async () => { diff --git a/content/test/integration/controller/entities.spec.ts b/content/test/integration/controller/entities.spec.ts index 1e87471ee..9bec937ca 100644 --- a/content/test/integration/controller/entities.spec.ts +++ b/content/test/integration/controller/entities.spec.ts @@ -2,6 +2,7 @@ import fetch from 'node-fetch' import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidator' import { createDefaultServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' +import LeakDetector from 'jest-leak-detector' describe('Integration - Entities', () => { let server: TestProgram @@ -13,8 +14,10 @@ describe('Integration - Entities', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it('returns 500 when there is an exception while deploying the entity', async () => { diff --git a/content/test/integration/controller/entity-metadata.spec.ts b/content/test/integration/controller/entity-metadata.spec.ts index 1ffb065b2..415ed822e 100644 --- a/content/test/integration/controller/entity-metadata.spec.ts +++ b/content/test/integration/controller/entity-metadata.spec.ts @@ -3,6 +3,7 @@ import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidat import { buildDeployData } from '../E2ETestUtils' import { createDefaultServer, resetServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' +import LeakDetector from 'jest-leak-detector' describe('Integration - Get wearable image and thumbnail', () => { let server: TestProgram @@ -16,8 +17,10 @@ describe('Integration - Get wearable image and thumbnail', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it('when entity does not exist, it should return 404', async () => { diff --git a/content/test/integration/controller/status.spec.ts b/content/test/integration/controller/status.spec.ts index cfa79ceb4..c07e9306b 100644 --- a/content/test/integration/controller/status.spec.ts +++ b/content/test/integration/controller/status.spec.ts @@ -2,6 +2,7 @@ import fetch from 'node-fetch' import { makeNoopValidator } from '../../helpers/service/validations/NoOpValidator' import { createDefaultServer } from '../simpleTestEnvironment' import { TestProgram } from '../TestProgram' +import LeakDetector from 'jest-leak-detector' describe('Integration - Status', () => { let server: TestProgram @@ -13,8 +14,10 @@ describe('Integration - Status', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it('returns 200 when the status is ok', async () => { diff --git a/content/test/integration/ports/deployer/concurrent-deployments.spec.ts b/content/test/integration/ports/deployer/concurrent-deployments.spec.ts index c7f1f6f9f..251bf9a35 100644 --- a/content/test/integration/ports/deployer/concurrent-deployments.spec.ts +++ b/content/test/integration/ports/deployer/concurrent-deployments.spec.ts @@ -5,6 +5,7 @@ import { AppComponents } from '../../../../src/types' import { makeNoopServerValidator, makeNoopValidator } from '../../../helpers/service/validations/NoOpValidator' import { buildDeployData, deployEntitiesCombo, EntityCombo } from '../../E2ETestUtils' import { TestProgram } from '../../TestProgram' +import LeakDetector from 'jest-leak-detector' import { createDefaultServer } from '../../simpleTestEnvironment' const P1 = 'x1,y1' @@ -25,8 +26,10 @@ describe('Integration - Concurrent deployments', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it('When deployments are executed concurrently, then only one remains active', async () => { diff --git a/content/test/integration/ports/deployer/deployment-entity-overlap.spec.ts b/content/test/integration/ports/deployer/deployment-entity-overlap.spec.ts index df6b5d314..cd4bbd22e 100644 --- a/content/test/integration/ports/deployer/deployment-entity-overlap.spec.ts +++ b/content/test/integration/ports/deployer/deployment-entity-overlap.spec.ts @@ -11,6 +11,7 @@ import { AppComponents } from '../../../../src/types' import { makeNoopServerValidator, makeNoopValidator } from '../../../helpers/service/validations/NoOpValidator' import { buildDeployData, buildDeployDataAfterEntity, createIdentity, EntityCombo, Identity } from '../../E2ETestUtils' import { TestProgram } from '../../TestProgram' +import LeakDetector from 'jest-leak-detector' import { createDefaultServer } from '../../simpleTestEnvironment' const P1 = '0,0' @@ -30,8 +31,10 @@ describe('Integration - Deployment with Entity Overlaps', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) let identity: Identity diff --git a/content/test/integration/ports/deployer/deployment-filters.spec.ts b/content/test/integration/ports/deployer/deployment-filters.spec.ts index fbc242633..166a1ca32 100644 --- a/content/test/integration/ports/deployer/deployment-filters.spec.ts +++ b/content/test/integration/ports/deployer/deployment-filters.spec.ts @@ -12,6 +12,7 @@ import { AppComponents } from '../../../../src/types' import { makeNoopServerValidator, makeNoopValidator } from '../../../helpers/service/validations/NoOpValidator' import { buildDeployData, buildDeployDataAfterEntity, EntityCombo } from '../../E2ETestUtils' import { TestProgram } from '../../TestProgram' +import LeakDetector from 'jest-leak-detector' import { createDefaultServer, resetServer } from '../../simpleTestEnvironment' const P1 = 'x1,y1' @@ -35,8 +36,10 @@ describe('Integration - Deployment Filters', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) let E1: EntityCombo, E2: EntityCombo, E3: EntityCombo diff --git a/content/test/integration/ports/deployer/metadata-schema-validations.spec.ts b/content/test/integration/ports/deployer/metadata-schema-validations.spec.ts index 70c73aeb7..9364e24b9 100644 --- a/content/test/integration/ports/deployer/metadata-schema-validations.spec.ts +++ b/content/test/integration/ports/deployer/metadata-schema-validations.spec.ts @@ -4,6 +4,7 @@ import { AppComponents, EntityVersion } from '../../../../src/types' import { makeNoopServerValidator } from '../../../helpers/service/validations/NoOpValidator' import { EntityCombo, buildDeployData, createIdentity } from '../../E2ETestUtils' import { TestProgram } from '../../TestProgram' +import LeakDetector from 'jest-leak-detector' import { createDefaultServer, resetServer } from '../../simpleTestEnvironment' const P1 = '0,0' @@ -24,8 +25,10 @@ describe('Integration - Deployment with metadata validation', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it('When scene metadata is missing, deployment result should include the proper error', async () => { diff --git a/content/test/integration/ports/deployer/old-entity-synced.spec.ts b/content/test/integration/ports/deployer/old-entity-synced.spec.ts index f90a27a77..c0e3940d9 100644 --- a/content/test/integration/ports/deployer/old-entity-synced.spec.ts +++ b/content/test/integration/ports/deployer/old-entity-synced.spec.ts @@ -5,6 +5,7 @@ import { makeNoopServerValidator } from '../../../helpers/service/validations/No import { EntityCombo } from '../../E2ETestUtils' import { getIntegrationResourcePathFor } from '../../resources/get-resource-path' import { TestProgram } from '../../TestProgram' +import LeakDetector from 'jest-leak-detector' import { createDefaultServer } from '../../simpleTestEnvironment' describe('Integration - Deployment synced old entity', () => { @@ -17,8 +18,10 @@ describe('Integration - Deployment synced old entity', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it('When deploying an entity with cid v0 hashes of entities before ADR 45, it should succeed', async () => { diff --git a/content/test/integration/ports/deployer/order-check.spec.ts b/content/test/integration/ports/deployer/order-check.spec.ts index 42de12aa0..dc34c21c1 100644 --- a/content/test/integration/ports/deployer/order-check.spec.ts +++ b/content/test/integration/ports/deployer/order-check.spec.ts @@ -4,6 +4,7 @@ import { makeNoopServerValidator, makeNoopValidator } from '../../../helpers/ser import { buildDeployData, buildDeployDataAfterEntity, deployEntitiesCombo, EntityCombo } from '../../E2ETestUtils' import { createDefaultServer } from '../../simpleTestEnvironment' import { TestProgram } from '../../TestProgram' +import LeakDetector from 'jest-leak-detector' /** * This test verifies that the active entity and overwrites are calculated correctly, regardless of the order in which the entities where deployed. @@ -27,8 +28,10 @@ describe('Integration - Order Check', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) beforeAll(async () => { diff --git a/content/test/integration/ports/deployer/same-timestamp-check.spec.ts b/content/test/integration/ports/deployer/same-timestamp-check.spec.ts index 88f1d2d36..9679c4d37 100644 --- a/content/test/integration/ports/deployer/same-timestamp-check.spec.ts +++ b/content/test/integration/ports/deployer/same-timestamp-check.spec.ts @@ -4,6 +4,7 @@ import { AppComponents } from '../../../../src/types' import { makeNoopServerValidator, makeNoopValidator } from '../../../helpers/service/validations/NoOpValidator' import { buildDeployData, deployEntitiesCombo, EntityCombo } from '../../E2ETestUtils' import { TestProgram } from '../../TestProgram' +import LeakDetector from 'jest-leak-detector' import { createDefaultServer } from '../../simpleTestEnvironment' const P1 = 'X1,Y1' @@ -34,8 +35,10 @@ describe('Integration - Same Timestamp Check', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it(`When oldest is deployed first, the active is the newest`, async () => { diff --git a/content/test/integration/ports/failedDeployments.spec.ts b/content/test/integration/ports/failedDeployments.spec.ts index 25c5df536..457fa9384 100644 --- a/content/test/integration/ports/failedDeployments.spec.ts +++ b/content/test/integration/ports/failedDeployments.spec.ts @@ -8,6 +8,7 @@ import { SnapshotFailedDeployment } from '../../../src/ports/failedDeployments' import { TestProgram } from '../TestProgram' +import LeakDetector from 'jest-leak-detector' import { createDefaultServer, resetServer } from '../simpleTestEnvironment' describe('failed deployments - ', () => { @@ -21,8 +22,10 @@ describe('failed deployments - ', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) const aFailedDeployment = { diff --git a/content/test/integration/ports/processedSnapshotStorage.spec.ts b/content/test/integration/ports/processedSnapshotStorage.spec.ts index 3da65fe3b..94b4ea5f2 100644 --- a/content/test/integration/ports/processedSnapshotStorage.spec.ts +++ b/content/test/integration/ports/processedSnapshotStorage.spec.ts @@ -2,6 +2,7 @@ import * as snapshotQueries from '../../../src/logic/database-queries/snapshots- import { saveProcessedSnapshot } from '../../../src/logic/database-queries/snapshots-queries' import { TestProgram } from '../TestProgram' +import LeakDetector from 'jest-leak-detector' import { createDefaultServer, resetServer } from '../simpleTestEnvironment' describe('precessed snapshot storage', () => { @@ -20,8 +21,10 @@ describe('precessed snapshot storage', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) describe('processedFrom', () => { diff --git a/content/test/integration/ports/snapshotStorage.spec.ts b/content/test/integration/ports/snapshotStorage.spec.ts index db207ee15..c89e77060 100644 --- a/content/test/integration/ports/snapshotStorage.spec.ts +++ b/content/test/integration/ports/snapshotStorage.spec.ts @@ -1,5 +1,6 @@ import * as snapshotQueries from '../../../src/logic/database-queries/snapshots-queries' import { TestProgram } from '../TestProgram' +import LeakDetector from 'jest-leak-detector' import { createDefaultServer } from '../simpleTestEnvironment' describe('snapshot storage', () => { @@ -11,8 +12,10 @@ describe('snapshot storage', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it('should return true if the snapshot is stored', async () => { diff --git a/content/test/integration/ports/system-properties.spec.ts b/content/test/integration/ports/system-properties.spec.ts index c5122979b..2ba2f55f9 100644 --- a/content/test/integration/ports/system-properties.spec.ts +++ b/content/test/integration/ports/system-properties.spec.ts @@ -1,5 +1,6 @@ import { createSystemProperties, SYSTEM_PROPERTIES } from '../../../src/ports/system-properties' import { TestProgram } from '../TestProgram' +import LeakDetector from 'jest-leak-detector' import { createDefaultServer } from '../simpleTestEnvironment' describe('system properties - ', () => { @@ -11,8 +12,10 @@ describe('system properties - ', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it('test values', async () => { diff --git a/content/test/integration/syncronization/error-handling.spec.ts b/content/test/integration/syncronization/error-handling.spec.ts index a25906b49..2d3e03956 100644 --- a/content/test/integration/syncronization/error-handling.spec.ts +++ b/content/test/integration/syncronization/error-handling.spec.ts @@ -18,6 +18,7 @@ import { } from '../E2EAssertions' import { awaitUntil, buildDeployData, buildDeployDataAfterEntity, createIdentity } from '../E2ETestUtils' import { TestProgram } from '../TestProgram' +import LeakDetector from 'jest-leak-detector' import { createAdditionalServer, createDefaultServer } from '../simpleTestEnvironment' describe('End 2 end - Error handling', () => { @@ -43,14 +44,18 @@ describe('End 2 end - Error handling', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server1) await server1.stopProgram() server1 = null as any + expect(await detector.isLeaking()).toBe(false) }) afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server2) await server2.stopProgram() server2 = null as any + expect(await detector.isLeaking()).toBe(false) }) //TODO: [new-sync] Check that this is being tested somewhere else diff --git a/content/test/integration/upload-and-download.spec.ts b/content/test/integration/upload-and-download.spec.ts index b29eec0ec..7ef7b4432 100644 --- a/content/test/integration/upload-and-download.spec.ts +++ b/content/test/integration/upload-and-download.spec.ts @@ -7,6 +7,7 @@ import { assertDeploymentsAreReported, buildDeployment } from './E2EAssertions' import { buildDeployData } from './E2ETestUtils' import { getIntegrationResourcePathFor } from './resources/get-resource-path' import { TestProgram } from './TestProgram' +import LeakDetector from 'jest-leak-detector' import { createDefaultServer, resetServer } from './simpleTestEnvironment' const POINTER0 = 'X0,Y0' @@ -23,8 +24,10 @@ describe('End 2 end deploy test', () => { afterAll(async () => { jest.restoreAllMocks() + const detector = new LeakDetector(server) await server.stopProgram() server = null as any + expect(await detector.isLeaking()).toBe(false) }) it('When a user tries to deploy the same entity twice, then an exception is thrown', async () => { diff --git a/yarn.lock b/yarn.lock index 871c1e809..9c6b858d9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -937,6 +937,13 @@ terminal-link "^2.0.0" v8-to-istanbul "^8.1.0" +"@jest/schemas@^29.0.0": + version "29.0.0" + resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.0.0.tgz#5f47f5994dd4ef067fb7b4188ceac45f77fe952a" + integrity sha512-3Ab5HgYIIAnS0HjqJHQYZS+zXc4tUmTmBH3z83ajI6afXp8X3ZtdLX+nXx+I7LNkJD7uN9LAVhgnjDgZa2z0kA== + dependencies: + "@sinclair/typebox" "^0.24.1" + "@jest/source-map@^27.5.1": version "27.5.1" resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-27.5.1.tgz#6608391e465add4205eae073b55e7f279e04e8cf" @@ -1118,6 +1125,11 @@ resolved "https://registry.yarnpkg.com/@sideway/pinpoint/-/pinpoint-2.0.0.tgz#cff8ffadc372ad29fd3f78277aeb29e632cc70df" integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ== +"@sinclair/typebox@^0.24.1": + version "0.24.51" + resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.24.51.tgz#645f33fe4e02defe26f2f5c0410e1c094eac7f5f" + integrity sha512-1P1OROm/rdubP5aFDSZQILU0vrLCJ4fvHt6EoqHEM+2D/G5MK3bIaymUKLit8Js9gbns5UyJnkP/TZROLw4tUA== + "@sinonjs/commons@^1.6.0", "@sinonjs/commons@^1.7.0", "@sinonjs/commons@^1.8.3": version "1.8.3" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d" @@ -4130,6 +4142,11 @@ jest-get-type@^27.5.1: resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-27.5.1.tgz#3cd613c507b0f7ace013df407a1c1cd578bcb4f1" integrity sha512-2KY95ksYSaK7DMBWQn6dQz3kqAf3BB64y2udeG+hv4KfSOb9qwcYQstTJc1KCbsix+wLZWZYN8t7nwX3GOBLRw== +jest-get-type@^29.2.0: + version "29.2.0" + resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-29.2.0.tgz#726646f927ef61d583a3b3adb1ab13f3a5036408" + integrity sha512-uXNJlg8hKFEnDgFsrCjznB+sTxdkuqiCL6zMgA75qEbAJjJYTs9XPrvDctrEig2GDow22T/LvHgO57iJhXB/UA== + jest-haste-map@^27.5.1: version "27.5.1" resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-27.5.1.tgz#9fd8bd7e7b4fa502d9c6164c5640512b4e811e7f" @@ -4191,6 +4208,14 @@ jest-leak-detector@^27.5.1: jest-get-type "^27.5.1" pretty-format "^27.5.1" +jest-leak-detector@^29.3.1: + version "29.3.1" + resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-29.3.1.tgz#95336d020170671db0ee166b75cd8ef647265518" + integrity sha512-3DA/VVXj4zFOPagGkuqHnSQf1GZBmmlagpguxEERO6Pla2g84Q1MaVIB3YMxgUaFIaYag8ZnTyQgiZ35YEqAQA== + dependencies: + jest-get-type "^29.2.0" + pretty-format "^29.3.1" + jest-matcher-utils@^27.0.0, jest-matcher-utils@^27.5.1: version "27.5.1" resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-27.5.1.tgz#9c0cdbda8245bc22d2331729d1091308b40cf8ab" @@ -5493,6 +5518,15 @@ pretty-format@^27.0.0, pretty-format@^27.5.1: ansi-styles "^5.0.0" react-is "^17.0.1" +pretty-format@^29.3.1: + version "29.3.1" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.3.1.tgz#1841cac822b02b4da8971dacb03e8a871b4722da" + integrity sha512-FyLnmb1cYJV8biEIiRyzRFvs2lry7PPIvOqKVe1GCUEYg4YGmlx1qG9EJNMxArYm7piII4qb8UV1Pncq5dxmcg== + dependencies: + "@jest/schemas" "^29.0.0" + ansi-styles "^5.0.0" + react-is "^18.0.0" + process-nextick-args@~2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" @@ -5630,6 +5664,11 @@ react-is@^17.0.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== +react-is@^18.0.0: + version "18.2.0" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b" + integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w== + read-yaml-file@2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/read-yaml-file/-/read-yaml-file-2.1.0.tgz#c5866712db9ef5343b4d02c2413bada53c41c4a9" From 2e45be276ffacb9f20aebdd23ea42a381b13ad14 Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 17:08:10 -0300 Subject: [PATCH 07/25] Save Tue Apr 23 05:08:10 PM -03 2024 --- .../service/synchronization/retryFailedDeployments.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/content/src/service/synchronization/retryFailedDeployments.ts b/content/src/service/synchronization/retryFailedDeployments.ts index d7c9b19b3..0d2d1a587 100644 --- a/content/src/service/synchronization/retryFailedDeployments.ts +++ b/content/src/service/synchronization/retryFailedDeployments.ts @@ -27,7 +27,8 @@ export const createRetryFailedDeployments = ( ): IRetryFailedDeploymentsComponent => { const retryDelay = components.env.getConfig(EnvironmentConfig.RETRY_FAILED_DEPLOYMENTS_DELAY_TIME) const logger = components.logs.getLogger('RetryFailedDeployments') - const ac = new AbortController() + let ac: AbortController | undefined = new AbortController() + const signal = ac.signal let running = false return { @@ -37,12 +38,15 @@ export const createRetryFailedDeployments = ( }, stop: async () => { running = false - ac.abort() + if (ac) { + ac.abort() + } + ac = undefined logger.debug('Stopping retry failed deployments') }, schedule: async () => { while (running) { - await setTimeout(retryDelay, null, { signal: ac.signal }) + await setTimeout(retryDelay, null, { signal }) if (!running) { return } From b1e898e76590ead3906b84028c5eb7532565fcc1 Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 17:37:14 -0300 Subject: [PATCH 08/25] Save Tue Apr 23 05:37:14 PM -03 2024 --- content/src/components.ts | 6 +- content/src/service.ts | 18 +-- .../syncronization/error-handling.spec.ts | 108 +++++++++--------- 3 files changed, 66 insertions(+), 66 deletions(-) diff --git a/content/src/components.ts b/content/src/components.ts index 3e08ed947..4d8e713d9 100644 --- a/content/src/components.ts +++ b/content/src/components.ts @@ -310,7 +310,7 @@ export async function initComponentsWithEnv(env: Environment): Promise { ) }) - //TODO: [new-sync] Fix this when deny-listed items are excluded from the snapshots and pointer changes - xit(`When a user tries to fix an entity, it doesn't matter if there is already a newer entity deployed`, async () => { - // Prepare entity to deploy - const { deployData: deployData1, entity: entityBeingDeployed1 } = await buildDeployData(['0,0', '0,1'], { - metadata: { a: 'metadata' }, - contentPaths: ['test/integration/resources/some-binary-file.png'] - }) - - // Deploy entity 1 - await server1.deployEntity(deployData1) - - // Cause sync failure - // TODO!: Add sync failure - - // Assert deployment is marked as failed on server 2 - await awaitUntil(() => assertThereIsAFailedDeployment(server2)) - - // Prepare entity to deploy - const { deployData: deployData2, entity: entityBeingDeployed2 } = await buildDeployDataAfterEntity( - entityBeingDeployed1, - ['0,1'], - { metadata: { a: 'metadata2' } } - ) - - // Deploy entity 2 on server 2 - await server2.deployEntity(deployData2) - - // Fix entity 1 on server 2 - await server2.deployEntity(deployData1, true) - - // Assert there are no more failed deployments - const newFailedDeployments: FailedDeployment[] = await server2.getFailedDeployments() - expect(newFailedDeployments.length).toBe(0) - - // Wait for servers to sync and assert entity 2 is the active entity on both servers - await awaitUntil(() => assertEntitiesAreActiveOnServer(server1, entityBeingDeployed2)) - await assertEntitiesAreActiveOnServer(server2, entityBeingDeployed2) - await assertEntitiesAreDeployedButNotActive(server1, entityBeingDeployed1) - await assertEntitiesAreDeployedButNotActive(server2, entityBeingDeployed1) - }) - - it(`When a user tries to fix an entity that didn't exist, the entity gets deployed`, async () => { - // Prepare entity to deploy - const { deployData, entity } = await buildDeployData(['0,0', '0,1'], { metadata: { a: 'metadata' } }) - - // Try to deploy the entity, and fail - await server1.deployEntity(deployData, true) - - // asser that the entity got deployed - await assertEntitiesAreActiveOnServer(server1, entity) - }) + // //TODO: [new-sync] Fix this when deny-listed items are excluded from the snapshots and pointer changes + // xit(`When a user tries to fix an entity, it doesn't matter if there is already a newer entity deployed`, async () => { + // // Prepare entity to deploy + // const { deployData: deployData1, entity: entityBeingDeployed1 } = await buildDeployData(['0,0', '0,1'], { + // metadata: { a: 'metadata' }, + // contentPaths: ['test/integration/resources/some-binary-file.png'] + // }) + + // // Deploy entity 1 + // await server1.deployEntity(deployData1) + + // // Cause sync failure + // // TODO!: Add sync failure + + // // Assert deployment is marked as failed on server 2 + // await awaitUntil(() => assertThereIsAFailedDeployment(server2)) + + // // Prepare entity to deploy + // const { deployData: deployData2, entity: entityBeingDeployed2 } = await buildDeployDataAfterEntity( + // entityBeingDeployed1, + // ['0,1'], + // { metadata: { a: 'metadata2' } } + // ) + + // // Deploy entity 2 on server 2 + // await server2.deployEntity(deployData2) + + // // Fix entity 1 on server 2 + // await server2.deployEntity(deployData1, true) + + // // Assert there are no more failed deployments + // const newFailedDeployments: FailedDeployment[] = await server2.getFailedDeployments() + // expect(newFailedDeployments.length).toBe(0) + + // // Wait for servers to sync and assert entity 2 is the active entity on both servers + // await awaitUntil(() => assertEntitiesAreActiveOnServer(server1, entityBeingDeployed2)) + // await assertEntitiesAreActiveOnServer(server2, entityBeingDeployed2) + // await assertEntitiesAreDeployedButNotActive(server1, entityBeingDeployed1) + // await assertEntitiesAreDeployedButNotActive(server2, entityBeingDeployed1) + // }) + + // it(`When a user tries to fix an entity that didn't exist, the entity gets deployed`, async () => { + // // Prepare entity to deploy + // const { deployData, entity } = await buildDeployData(['0,0', '0,1'], { metadata: { a: 'metadata' } }) + + // // Try to deploy the entity, and fail + // await server1.deployEntity(deployData, true) + + // // asser that the entity got deployed + // await assertEntitiesAreActiveOnServer(server1, entity) + // }) it(`When a user tries to fix an entity that hadn't fail, then it is an idempotent operation`, async () => { // Prepare entity to deploy From c2acce49cea7717ec6ff5a6583da97b5f6cf65ea Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 17:40:15 -0300 Subject: [PATCH 09/25] Save Tue Apr 23 05:40:15 PM -03 2024 --- .github/workflows/build.yml | 71 +++++++++++++++++++++++++++++++++---- content/src/service.ts | 18 +++++----- 2 files changed, 74 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 06d209f69..29865b06a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,9 +7,68 @@ on: pull_request: jobs: - build: - uses: decentraland/platform-actions/.github/workflows/apps-with-db-build.yml@db - with: - postgres-user: postgres - postgres-password: 12345678 - postgres-db: postgres_test + validations: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Use Node.js 18.x + uses: actions/setup-node@v3 + with: + node-version: 18.x + cache: yarn + - name: install + run: yarn install --frozen-lockfile + - name: lint + run: yarn lint:check + + test-content: + runs-on: ubuntu-latest + strategy: + matrix: + shard: [1, 2, 3, 4] + services: + postgres: + image: postgres + env: + POSTGRES_USER: postgres + POSTGRES_DB: 12345678 + POSTGRES_PASSWORD: postgres_test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + steps: + - uses: actions/checkout@v3 + - name: Use Node.js 16.16.0 + uses: actions/setup-node@v3 + with: + node-version: 16.16.0 + cache: yarn + - name: install + run: yarn install --frozen-lockfile + - name: create .env + run: echo "" >> .env + - name: build + run: yarn build + - run: cd content; yarn test --shard=${{ matrix.shard }}/${{ strategy.job-total }} --coverage + + test-lambdas: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Use Node.js 16.16.0 + uses: actions/setup-node@v3 + with: + node-version: 16.16.0 + cache: yarn + - name: install + run: yarn install --frozen-lockfile + - name: create .env + run: echo "" >> .env + - name: build + run: yarn build + - name: test + run: yarn test:lambdas diff --git a/content/src/service.ts b/content/src/service.ts index 80b6dca45..a36e4f328 100644 --- a/content/src/service.ts +++ b/content/src/service.ts @@ -31,10 +31,10 @@ export async function main(program: Lifecycle.EntryPointParameters Date: Tue, 23 Apr 2024 17:42:22 -0300 Subject: [PATCH 10/25] Save Tue Apr 23 05:42:22 PM -03 2024 --- content/src/components.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/src/components.ts b/content/src/components.ts index 4d8e713d9..3e08ed947 100644 --- a/content/src/components.ts +++ b/content/src/components.ts @@ -310,7 +310,7 @@ export async function initComponentsWithEnv(env: Environment): Promise Date: Tue, 23 Apr 2024 17:46:48 -0300 Subject: [PATCH 11/25] Save Tue Apr 23 05:46:48 PM -03 2024 --- .github/workflows/build.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 29865b06a..cddb79cce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,14 +18,13 @@ jobs: cache: yarn - name: install run: yarn install --frozen-lockfile + - name: build + run: yarn build - name: lint run: yarn lint:check test-content: runs-on: ubuntu-latest - strategy: - matrix: - shard: [1, 2, 3, 4] services: postgres: image: postgres @@ -51,9 +50,8 @@ jobs: run: yarn install --frozen-lockfile - name: create .env run: echo "" >> .env - - name: build - run: yarn build - - run: cd content; yarn test --shard=${{ matrix.shard }}/${{ strategy.job-total }} --coverage + - name: test + run: yarn test:lambdas test-lambdas: runs-on: ubuntu-latest @@ -68,7 +66,5 @@ jobs: run: yarn install --frozen-lockfile - name: create .env run: echo "" >> .env - - name: build - run: yarn build - name: test run: yarn test:lambdas From 8c502f478165a54548c305b65858f197a03c3a2f Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 17:48:46 -0300 Subject: [PATCH 12/25] Save Tue Apr 23 05:48:46 PM -03 2024 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cddb79cce..a13571b0f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,7 +51,7 @@ jobs: - name: create .env run: echo "" >> .env - name: test - run: yarn test:lambdas + run: yarn test:content test-lambdas: runs-on: ubuntu-latest From 98e97871097995bea485889a66b0f862b2b8e8ff Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 17:53:01 -0300 Subject: [PATCH 13/25] Save Tue Apr 23 05:53:01 PM -03 2024 --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a13571b0f..5e220a500 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,6 +52,8 @@ jobs: run: echo "" >> .env - name: test run: yarn test:content + env: + PG_COMPONENT_PSQL_CONNECTION_STRING: postgres://postgres:pass1234@localhost/db test-lambdas: runs-on: ubuntu-latest From e01ca42e088b74a2fefcee4443de2d04ca34ec7e Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 17:56:55 -0300 Subject: [PATCH 14/25] Save Tue Apr 23 05:56:55 PM -03 2024 --- .github/workflows/build.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e220a500..76c6acb1a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,9 +29,9 @@ jobs: postgres: image: postgres env: + POSTGRES_DB: postgres_test POSTGRES_USER: postgres - POSTGRES_DB: 12345678 - POSTGRES_PASSWORD: postgres_test + POSTGRES_PASSWORD: 12345678 options: >- --health-cmd pg_isready --health-interval 10s @@ -52,8 +52,6 @@ jobs: run: echo "" >> .env - name: test run: yarn test:content - env: - PG_COMPONENT_PSQL_CONNECTION_STRING: postgres://postgres:pass1234@localhost/db test-lambdas: runs-on: ubuntu-latest From 418a51829c0e42539da6d0394ba733466837f07c Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 18:03:07 -0300 Subject: [PATCH 15/25] Save Tue Apr 23 06:03:07 PM -03 2024 --- .github/workflows/build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 76c6acb1a..fc5e377b8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,6 +25,9 @@ jobs: test-content: runs-on: ubuntu-latest + strategy: + matrix: + shard: [1, 2, 3, 4] services: postgres: image: postgres @@ -51,7 +54,8 @@ jobs: - name: create .env run: echo "" >> .env - name: test - run: yarn test:content + run: cd content; yarn test --shard=${{ matrix.shard }}/${{ strategy.job-total }} --coverage + test-lambdas: runs-on: ubuntu-latest From 5f8c70ef73f3726cbcf36e1f76851b30b96eda2f Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 18:12:27 -0300 Subject: [PATCH 16/25] Save Tue Apr 23 06:12:27 PM -03 2024 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fc5e377b8..cf3514a52 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,7 +27,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - shard: [1, 2, 3, 4] + shard: [1, 2, 3, 4, 5, 6] services: postgres: image: postgres From e5dc7d857b332f26299b8e664bae8a2c35405172 Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 18:20:14 -0300 Subject: [PATCH 17/25] Save Tue Apr 23 06:20:14 PM -03 2024 --- .github/workflows/build.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cf3514a52..3cfd2fd87 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,9 +25,6 @@ jobs: test-content: runs-on: ubuntu-latest - strategy: - matrix: - shard: [1, 2, 3, 4, 5, 6] services: postgres: image: postgres @@ -54,7 +51,7 @@ jobs: - name: create .env run: echo "" >> .env - name: test - run: cd content; yarn test --shard=${{ matrix.shard }}/${{ strategy.job-total }} --coverage + run: yarn test:content test-lambdas: From 7e238c61f3ceb3409ca755b55a94d4d37db56ea5 Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 18:34:53 -0300 Subject: [PATCH 18/25] Save Tue Apr 23 06:34:53 PM -03 2024 --- Dockerfile.content | 52 ---------------------------------------------- Dockerfile.lambdas | 49 ------------------------------------------- 2 files changed, 101 deletions(-) delete mode 100644 Dockerfile.content delete mode 100644 Dockerfile.lambdas diff --git a/Dockerfile.content b/Dockerfile.content deleted file mode 100644 index 6ce87d978..000000000 --- a/Dockerfile.content +++ /dev/null @@ -1,52 +0,0 @@ -FROM node:16-alpine as base -WORKDIR /app -RUN apk add --no-cache bash git - -COPY package.json . -COPY yarn.lock . -COPY blocks-cache-*.csv . -COPY content/package.json content/ - -# get production dependencies -FROM base as dependencies -RUN yarn install --prod --frozen-lockfile - -# build sources -FROM base as catalyst-builder -RUN yarn install --frozen-lockfile - -COPY . . -FROM catalyst-builder as content-builder -RUN yarn workspace @catalyst/content-server build - -# build final image with transpiled code and runtime dependencies -FROM base - -COPY --from=dependencies /app/node_modules ./node_modules/ -COPY --from=dependencies /app/content/node_modules ./node_modules/ - -COPY --from=content-builder /app/content/dist/src content/ -COPY --from=content-builder /app/content/blocks-cache-*.csv . - -# https://docs.docker.com/engine/reference/builder/#arg -ARG CURRENT_VERSION=4.0.0-ci -ENV CURRENT_VERSION=${CURRENT_VERSION:-4.0.0} - -# https://docs.docker.com/engine/reference/builder/#arg -ARG COMMIT_HASH=local -ENV COMMIT_HASH=${COMMIT_HASH:-local} - -EXPOSE 6969 - -# Please _DO NOT_ use a custom ENTRYPOINT because it may prevent signals -# (i.e. SIGTERM) to reach the service -# Read more here: https://aws.amazon.com/blogs/containers/graceful-shutdowns-with-ecs/ -# and: https://www.ctl.io/developers/blog/post/gracefully-stopping-docker-containers/ - -# We use Tini to handle signals and PID1 (https://github.com/krallin/tini, read why here https://github.com/krallin/tini/issues/8) -RUN apk add --no-cache tini - -ENTRYPOINT ["/sbin/tini", "--"] - -# Run the program under Tini -CMD [ "/usr/local/bin/node", "--max-old-space-size=8192", "content/entrypoints/run-server.js" ] diff --git a/Dockerfile.lambdas b/Dockerfile.lambdas deleted file mode 100644 index 47b9f3c0e..000000000 --- a/Dockerfile.lambdas +++ /dev/null @@ -1,49 +0,0 @@ -FROM node:16-alpine as base - -WORKDIR /app -RUN apk add --no-cache bash git - -COPY package.json . -COPY yarn.lock . -COPY lambdas/package.json lambdas/ - -# get production dependencies -FROM base as dependencies -RUN yarn install --prod --frozen-lockfile - -# build sources -FROM base as catalyst-builder -RUN yarn install --frozen-lockfile - -COPY . . -FROM catalyst-builder as lambdas-builder -RUN yarn workspace @catalyst/lambdas-server build - -# build final image with transpiled code and runtime dependencies -FROM base - -COPY --from=dependencies /app/node_modules ./node_modules/ -COPY --from=lambdas-builder /app/lambdas/dist/src lambdas/ - -# https://docs.docker.com/engine/reference/builder/#arg -ARG CURRENT_VERSION=4.0.0-ci -ENV CURRENT_VERSION=${CURRENT_VERSION:-4.0.0} - -# https://docs.docker.com/engine/reference/builder/#arg -ARG COMMIT_HASH=local -ENV COMMIT_HASH=${COMMIT_HASH:-local} - -EXPOSE 7070 - -# Please _DO NOT_ use a custom ENTRYPOINT because it may prevent signals -# (i.e. SIGTERM) to reach the service -# Read more here: https://aws.amazon.com/blogs/containers/graceful-shutdowns-with-ecs/ -# and: https://www.ctl.io/developers/blog/post/gracefully-stopping-docker-containers/ - -# We use Tini to handle signals and PID1 (https://github.com/krallin/tini, read why here https://github.com/krallin/tini/issues/8) -RUN apk add --no-cache tini - -ENTRYPOINT ["/sbin/tini", "--"] - -# Run the program under Tini -CMD [ "/usr/local/bin/node", "--max-old-space-size=8192", "lambdas/entrypoints/run-server.js" ] From 79dccd756633108c1a645574901b7a4a875461a9 Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Tue, 23 Apr 2024 18:36:22 -0300 Subject: [PATCH 19/25] Save Tue Apr 23 06:36:22 PM -03 2024 --- .../syncronization/error-handling.spec.ts | 108 +++++++++--------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/content/test/integration/syncronization/error-handling.spec.ts b/content/test/integration/syncronization/error-handling.spec.ts index 6a76b0938..2d3e03956 100644 --- a/content/test/integration/syncronization/error-handling.spec.ts +++ b/content/test/integration/syncronization/error-handling.spec.ts @@ -11,12 +11,12 @@ import { assertDeploymentFailed, assertDeploymentsAreReported, assertEntitiesAreActiveOnServer, - // assertEntitiesAreDeployedButNotActive, + assertEntitiesAreDeployedButNotActive, assertEntityWasNotDeployed, - // assertThereIsAFailedDeployment, + assertThereIsAFailedDeployment, buildDeployment } from '../E2EAssertions' -import { awaitUntil, buildDeployData, createIdentity } from '../E2ETestUtils' +import { awaitUntil, buildDeployData, buildDeployDataAfterEntity, createIdentity } from '../E2ETestUtils' import { TestProgram } from '../TestProgram' import LeakDetector from 'jest-leak-detector' import { createAdditionalServer, createDefaultServer } from '../simpleTestEnvironment' @@ -73,57 +73,57 @@ describe('End 2 end - Error handling', () => { ) }) - // //TODO: [new-sync] Fix this when deny-listed items are excluded from the snapshots and pointer changes - // xit(`When a user tries to fix an entity, it doesn't matter if there is already a newer entity deployed`, async () => { - // // Prepare entity to deploy - // const { deployData: deployData1, entity: entityBeingDeployed1 } = await buildDeployData(['0,0', '0,1'], { - // metadata: { a: 'metadata' }, - // contentPaths: ['test/integration/resources/some-binary-file.png'] - // }) - - // // Deploy entity 1 - // await server1.deployEntity(deployData1) - - // // Cause sync failure - // // TODO!: Add sync failure - - // // Assert deployment is marked as failed on server 2 - // await awaitUntil(() => assertThereIsAFailedDeployment(server2)) - - // // Prepare entity to deploy - // const { deployData: deployData2, entity: entityBeingDeployed2 } = await buildDeployDataAfterEntity( - // entityBeingDeployed1, - // ['0,1'], - // { metadata: { a: 'metadata2' } } - // ) - - // // Deploy entity 2 on server 2 - // await server2.deployEntity(deployData2) - - // // Fix entity 1 on server 2 - // await server2.deployEntity(deployData1, true) - - // // Assert there are no more failed deployments - // const newFailedDeployments: FailedDeployment[] = await server2.getFailedDeployments() - // expect(newFailedDeployments.length).toBe(0) - - // // Wait for servers to sync and assert entity 2 is the active entity on both servers - // await awaitUntil(() => assertEntitiesAreActiveOnServer(server1, entityBeingDeployed2)) - // await assertEntitiesAreActiveOnServer(server2, entityBeingDeployed2) - // await assertEntitiesAreDeployedButNotActive(server1, entityBeingDeployed1) - // await assertEntitiesAreDeployedButNotActive(server2, entityBeingDeployed1) - // }) - - // it(`When a user tries to fix an entity that didn't exist, the entity gets deployed`, async () => { - // // Prepare entity to deploy - // const { deployData, entity } = await buildDeployData(['0,0', '0,1'], { metadata: { a: 'metadata' } }) - - // // Try to deploy the entity, and fail - // await server1.deployEntity(deployData, true) - - // // asser that the entity got deployed - // await assertEntitiesAreActiveOnServer(server1, entity) - // }) + //TODO: [new-sync] Fix this when deny-listed items are excluded from the snapshots and pointer changes + xit(`When a user tries to fix an entity, it doesn't matter if there is already a newer entity deployed`, async () => { + // Prepare entity to deploy + const { deployData: deployData1, entity: entityBeingDeployed1 } = await buildDeployData(['0,0', '0,1'], { + metadata: { a: 'metadata' }, + contentPaths: ['test/integration/resources/some-binary-file.png'] + }) + + // Deploy entity 1 + await server1.deployEntity(deployData1) + + // Cause sync failure + // TODO!: Add sync failure + + // Assert deployment is marked as failed on server 2 + await awaitUntil(() => assertThereIsAFailedDeployment(server2)) + + // Prepare entity to deploy + const { deployData: deployData2, entity: entityBeingDeployed2 } = await buildDeployDataAfterEntity( + entityBeingDeployed1, + ['0,1'], + { metadata: { a: 'metadata2' } } + ) + + // Deploy entity 2 on server 2 + await server2.deployEntity(deployData2) + + // Fix entity 1 on server 2 + await server2.deployEntity(deployData1, true) + + // Assert there are no more failed deployments + const newFailedDeployments: FailedDeployment[] = await server2.getFailedDeployments() + expect(newFailedDeployments.length).toBe(0) + + // Wait for servers to sync and assert entity 2 is the active entity on both servers + await awaitUntil(() => assertEntitiesAreActiveOnServer(server1, entityBeingDeployed2)) + await assertEntitiesAreActiveOnServer(server2, entityBeingDeployed2) + await assertEntitiesAreDeployedButNotActive(server1, entityBeingDeployed1) + await assertEntitiesAreDeployedButNotActive(server2, entityBeingDeployed1) + }) + + it(`When a user tries to fix an entity that didn't exist, the entity gets deployed`, async () => { + // Prepare entity to deploy + const { deployData, entity } = await buildDeployData(['0,0', '0,1'], { metadata: { a: 'metadata' } }) + + // Try to deploy the entity, and fail + await server1.deployEntity(deployData, true) + + // asser that the entity got deployed + await assertEntitiesAreActiveOnServer(server1, entity) + }) it(`When a user tries to fix an entity that hadn't fail, then it is an idempotent operation`, async () => { // Prepare entity to deploy From 3254b1f3cebf11373ea5981986e3c32cff2ab770 Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Wed, 24 Apr 2024 14:44:49 -0300 Subject: [PATCH 20/25] remove comments --- Dockerfile | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index c86bd2b36..6f0ec1aa9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,9 +50,3 @@ ENTRYPOINT ["/sbin/tini", "--"] # Run the program under Tini CMD [ "/usr/local/bin/node", "--max-old-space-size=8192", "content/entrypoints/run-server.js" ] - - - - -# EXPOSE 7070 -# CMD [ "/usr/local/bin/node", "--max-old-space-size=8192", "lambdas/entrypoints/run-server.js" ] From 8b050bd4ba933ec02f982f6a556686d96fa200c9 Mon Sep 17 00:00:00 2001 From: Hugo Arregui Date: Thu, 25 Apr 2024 09:46:41 -0300 Subject: [PATCH 21/25] Save Thu Apr 25 09:46:41 AM -03 2024 --- .github/workflows/docker-next.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/docker-next.yml diff --git a/.github/workflows/docker-next.yml b/.github/workflows/docker-next.yml new file mode 100644 index 000000000..f05f5fe12 --- /dev/null +++ b/.github/workflows/docker-next.yml @@ -0,0 +1,13 @@ +name: CI/CD on main branch + +on: + push: + branches: + - "main" + +jobs: + cd: + uses: decentraland/platform-actions/.github/workflows/apps-docker-next.yml@main + with: + service-name: catalyst + secrets: inherit From ec43dc47e61e8f7e3adee5331ef2e6e7ac6eb755 Mon Sep 17 00:00:00 2001 From: Hugo Arregui <969314+hugoArregui@users.noreply.github.com> Date: Thu, 25 Apr 2024 13:42:04 -0300 Subject: [PATCH 22/25] Update .github/workflows/build.yml Co-authored-by: Mariano Goldman Signed-off-by: Hugo Arregui <969314+hugoArregui@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3cfd2fd87..7019891c6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: validations: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js 18.x uses: actions/setup-node@v3 with: From 201bac8aec7a6522ed0f4475bdf712432ab8df7c Mon Sep 17 00:00:00 2001 From: Hugo Arregui <969314+hugoArregui@users.noreply.github.com> Date: Thu, 25 Apr 2024 13:42:11 -0300 Subject: [PATCH 23/25] Update .github/workflows/build.yml Co-authored-by: Mariano Goldman Signed-off-by: Hugo Arregui <969314+hugoArregui@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7019891c6..a668caf59 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Use Node.js 18.x - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 18.x cache: yarn From 001c28b3727c5866b026929a3da47521c934c80b Mon Sep 17 00:00:00 2001 From: Hugo Arregui <969314+hugoArregui@users.noreply.github.com> Date: Thu, 25 Apr 2024 13:42:16 -0300 Subject: [PATCH 24/25] Update .github/workflows/build.yml Co-authored-by: Mariano Goldman Signed-off-by: Hugo Arregui <969314+hugoArregui@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a668caf59..27cae3b87 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,7 +42,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Use Node.js 16.16.0 - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 16.16.0 cache: yarn From b84e08c13dc9eba6806cf57ced2f9f8a46dc5266 Mon Sep 17 00:00:00 2001 From: Hugo Arregui <969314+hugoArregui@users.noreply.github.com> Date: Thu, 25 Apr 2024 13:42:33 -0300 Subject: [PATCH 25/25] Update .github/workflows/build.yml Co-authored-by: Mariano Goldman Signed-off-by: Hugo Arregui <969314+hugoArregui@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 27cae3b87..c2d389de1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,7 +40,7 @@ jobs: ports: - 5432:5432 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js 16.16.0 uses: actions/setup-node@v4 with: