Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove production use of DatabaseConfigPersistence #19275

Merged
merged 7 commits into from
Nov 29, 2022

Conversation

cgardens
Copy link
Contributor

@cgardens cgardens commented Nov 10, 2022

Depends on PR to add new db base test calss: #19640

What

  • Removes DatabaseConfigPersistence!!!

How

  • It does this by moving relevant database queries into the ConfigRepository
  • Took this opportunity to start to split tests into their own classes by resource (e.g. workspace, actor definition). I did not break resources into their own persistences. That's too much to do in one PR, though we should do that next. I did the tests, because otherwise I couldn't wade through what was going on safely enough.
  • Removes test classes that were just testing ConfigPersistence. Moved any relevant business logic tests that were hidden in there (which there were a few, which is kinda scary because those tests were testing the old ConfigPersistence implementations and not the ones that are currently used) and moved them into appropriate classes.
  • Even with all the code that is just being moved, we are still managing to drop nearly 2K lines of code. 😄

Future Work

  • ConfigRepositoryE2EReadWriteTest.java - this class is a monster. Decided not to tackle it now, but as we split persistences and their tests by resource, we should pick at this. It basically has tests for CRUD operations for every single resource.
  • Split out test suites for workspace, actor definitions, and health checks. It should make it relatively straight forward to write separate persistences for them as a follow up.

Recommended reading order

  1. ConfigRepository.java
  2. ActorDefinitionMigratorTest.java -- this is the one where there were a lot of test that got move to it from ConfigPersistence.
  3. WorkspacePeristenceTest.java
  4. ActorDefinitionPersistenceTest.java
  5. HealthCheckPersistenceTest.java
  6. the rest...

🚨 User Impact 🚨

This PR does move around a lot of the queries from the ConfigPersistence to the ConfigRepository. There is a lot of testing but it's not that methodical or perfect coverage. There is some risk here that there is some mistake in a query that isn't caught by testing.

@cgardens cgardens temporarily deployed to more-secrets November 10, 2022 05:16 Inactive
@cgardens cgardens changed the title Remove DatabaseConfigPersistence Remove production use of DatabaseConfigPersistence Nov 10, 2022
@cgardens cgardens force-pushed the cgardens/convert-config-persistence-to-jooq branch from 7cf9a24 to 4437060 Compare November 20, 2022 21:43
@cgardens cgardens temporarily deployed to more-secrets November 20, 2022 21:46 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 20, 2022 21:46 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 20, 2022 21:48 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 20, 2022 21:48 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 20, 2022 21:57 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 20, 2022 21:57 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 20, 2022 22:08 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 20, 2022 22:08 Inactive
@@ -1,511 +0,0 @@
/*
Copy link
Contributor Author

@cgardens cgardens Nov 20, 2022

Choose a reason for hiding this comment

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

all tests in this class were moved into separate *PersistenceTest (HealthCheckPersistenceTest.java WorkspacePersistenceTest.java, and ActorDefinitionPersistenceTest.java). Also discovered we effective have no tests for the Actor resource.

import org.junit.jupiter.api.Test;

/**
* Unit test for the {@link DatabaseConfigPersistence#updateConnectorDefinitions} method.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this code path wasn't actually used anymore, so these tests were for a dead code path.

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

class ActorDefinitionPersistenceTest extends BaseConfigDatabaseTest {
Copy link
Contributor Author

@cgardens cgardens Nov 20, 2022

Choose a reason for hiding this comment

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

Changes in this file:

  • lift and shift of tests from ConfigRepository.
  • replace ConfigPersistence with ConfigRepository.
  • intentionally not changing any of the tests themselves.

import org.junit.jupiter.params.provider.ValueSource;

@SuppressWarnings({"PMD.LongVariable", "PMD.AvoidInstantiatingObjectsInLoops"})
class WorkspacePersistenceTest extends BaseConfigDatabaseTest {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes in this file:

  • lift and shift of tests from ConfigRepository.
  • replace ConfigPersistence with ConfigRepository.
  • intentionally not changing any of the tests themselves.

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

class HealthCheckPersistenceTest {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes in this file:

  • lift and shift of tests from ConfigRepository.
  • intentionally not changing any of the tests themselves.

@@ -117,6 +119,11 @@ public void clearUnsupportedProtocolVersionFlag(final UUID actorDefinitionId,
});
}

public List<StreamDescriptor> getAllStreamsForConnection(final UUID connectionId) throws ConfigNotFoundException, IOException {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved from ConfigRepository

@cgardens cgardens temporarily deployed to more-secrets November 20, 2022 23:10 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 20, 2022 23:10 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 20, 2022 23:14 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 20, 2022 23:14 Inactive
@octavia-squidington-iv octavia-squidington-iv added area/platform issues related to the platform area/server labels Nov 20, 2022
@cgardens cgardens temporarily deployed to more-secrets November 21, 2022 00:01 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 21, 2022 00:01 Inactive
Copy link
Contributor

@jdpgrailsdev jdpgrailsdev left a comment

Choose a reason for hiding this comment

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

:shipit:

Base automatically changed from cgardens/base-config-database-test to master November 28, 2022 16:31
@cgardens cgardens force-pushed the cgardens/convert-config-persistence-to-jooq branch from 71dac20 to cd96123 Compare November 29, 2022 15:26
@cgardens cgardens requested a review from a team as a code owner November 29, 2022 15:26
@cgardens cgardens temporarily deployed to more-secrets November 29, 2022 15:28 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 29, 2022 15:28 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 29, 2022 16:26 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 29, 2022 16:26 Inactive
@cgardens cgardens force-pushed the cgardens/convert-config-persistence-to-jooq branch from f72bdc4 to e99d447 Compare November 29, 2022 16:48
@cgardens cgardens temporarily deployed to more-secrets November 29, 2022 16:50 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 29, 2022 16:50 Inactive
wip

add queries

build, but lots of wips

delete DatabaseConfigPersistence

pmd fix

build local -x test

fix names

port DatabaseConfigPersistenceTest tests to ActorDefinitionMigratorTest

clean up ActorDefinitionMigratorTest

add CRUD tests for standard sync

clean up ConfigRepository
@cgardens cgardens force-pushed the cgardens/convert-config-persistence-to-jooq branch from e99d447 to 95d881e Compare November 29, 2022 17:26
@cgardens cgardens temporarily deployed to more-secrets November 29, 2022 17:28 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 29, 2022 17:28 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 29, 2022 20:52 Inactive
@cgardens cgardens temporarily deployed to more-secrets November 29, 2022 20:52 Inactive
@cgardens cgardens merged commit 2c5dabc into master Nov 29, 2022
@cgardens cgardens deleted the cgardens/convert-config-persistence-to-jooq branch November 29, 2022 23:04
terencecho added a commit that referenced this pull request Dec 1, 2022
terencecho added a commit that referenced this pull request Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/platform issues related to the platform area/server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants