Skip to content

[server] don't start DB if already running, fix post test db cleanup #18333

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2023

Conversation

svenefftinge
Copy link
Member

@svenefftinge svenefftinge commented Jul 24, 2023

Description

Don't start the DB (incl. migrations) if it is already running In server's yarn test

🤖 Generated by Copilot at 8be44b5

Refactored and renamed several test files for the AuthProviderEntry entity and the gitpod-db module. Extracted a common resetDB function to delete all entities except the builtin users before each test. Updated the package.json file of the components/server module to optimize the test database initialization. Fixed the import paths of the resetDB function in some test files of the components/server module.

Related Issue(s)

Fixes #

How to test

Documentation

Preview status

gitpod:summary

Build Options

Build
  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer
  • analytics=segment
  • with-dedicated-emulation
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated
Preview Environment
  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh
  • with-monitoring

/hold

@svenefftinge
Copy link
Member Author

/unhold

@svenefftinge
Copy link
Member Author

/hold

const manager = await typeorm.getConnection();
await manager.getRepository(DBProject).delete({});
await manager.getRepository(DBUser).delete({});
await resetDB(typeorm);
Copy link
Member Author

@svenefftinge svenefftinge Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracting all post-test DB cleanups to one method (resetDB) that ensures we don't delete needed state (e.g. admin user)

@svenefftinge svenefftinge changed the title [server] don't start DB if already running [server] don't start DB if already running, fix post test db cleanup Jul 24, 2023
@roboquat roboquat added size/XL and removed size/L labels Jul 24, 2023
Copy link
Member

@AlexTugarev AlexTugarev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@svenefftinge svenefftinge force-pushed the se/fix-build branch 5 times, most recently from a9d2861 to 9289c1d Compare July 24, 2023 18:19
@svenefftinge
Copy link
Member Author

/unhold

@roboquat roboquat merged commit 98aff7f into main Jul 24, 2023
@roboquat roboquat deleted the se/fix-build branch July 24, 2023 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants