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

perf(test): Speed up orca-sql tests #3827

Merged
merged 5 commits into from
Jul 23, 2020
Merged

perf(test): Speed up orca-sql tests #3827

merged 5 commits into from
Jul 23, 2020

Conversation

ezimanyi
Copy link
Contributor

Reduces the time to run :orca-sql:test from ~2m30s to ~1m40s.

  • perf(test): Speed up PgSQL tests

    When overriding setupSpec, Spock runs both the parent (super.setupSpec) and the subclass setupSpec (in that order). This means that for the PgSQL tests, we're creating a MySQL database then immediately discarding it to replace it with a PgSQL database.

    As creating the database spins up a container and is resonably slow, lightly refactor this so that we don't do this extra work.

  • refactor(test): Push some logic down from execution repository tests

    There's a lot of coupling between PipelineExecutionRepositoryTck and its subclasses that causes initialization order dependencies. In order to make it easier to make changes (such as changing what fields are updated in setup vs setupSpec), refactor this so that each subclass is fully responsible for initialization and we can control the order.

    The main issue here is that the super class was storing and initializing the ExecutionRepository, but we can't actually create the ExecutionRepository until we've created the persistence store, which is owned by the implementations. So we were subtly depending on each subclass having already initialized its persistence store before we create the ExecutionRepository.

    Now it's up to each subclass ot handle this order-dependence and expose a method to get the ExecutionRepository.

  • perf(test): Share execution repository among tests

    Given that we share the actual persistence between tests, there's not much benefit to creating a new ExecutionRepository for each test. Speed the tests up by re-using it between tests.

  • perf(test): Remove previous repository from base test

    The previous repository is only used in the Jedis tests; remove it from the base class so we can avoid creating it and cleaning it up after every test.

ezimanyi added 4 commits July 22, 2020 13:11
When overriding setupSpec, Spock runs both the parent (super.setupSpec)
and the subclass setupSpec (in that order). This means that for the
PgSQL tests, we're creating a MySQL database then immediately discarding
it to replace it with a PgSQL database.

As creating the database spins up a container and is resonably slow,
lightly refactor this so that we don't do this extra work.
There's a lot of coupling between PipelineExecutionRepositoryTck and
its subclasses that causes initialization order dependencies. In order
to make it easier to make changes (such as changing what fields are
updated in setup vs setupSpec), refactor this so that each subclass
is fully responsible for initialization and we can control the order.

The main issue here is that the super class was storing and
initializing the ExecutionRepository, but we can't actually create
the ExecutionRepository until we've created the persistence store,
which is owned by the implementations. So we were subtly depending
on each subclass having already initialized its persistence store
before we create the ExecutionRepository.

Now it's up to each subclass ot handle this order-dependence and
expose a method to get the ExecutionRepository.
Given that we share the actual persistence between tests, there's
not much benefit to creating a new ExecutionRepository for each
test. Speed the tests up by re-using it between tests.
The previous repository is only used in the Jedis tests; remove it
from the base class so we can avoid creating it and cleaning it up
after every test.
Copy link
Contributor

@maggieneterval maggieneterval left a comment

Choose a reason for hiding this comment

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

⏩ 🐳 🎥 🎥 🧪 💯

Copy link
Contributor

@marchello2000 marchello2000 left a comment

Choose a reason for hiding this comment

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

❤️

Copy link
Member

@plumpy plumpy left a comment

Choose a reason for hiding this comment

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

wow

@ezimanyi ezimanyi added the ready to merge Approved and ready for merge label Jul 23, 2020
@mergify mergify bot added the auto merged Merged automatically by a bot label Jul 23, 2020
@mergify mergify bot merged commit 669f0e6 into spinnaker:master Jul 23, 2020
@ezimanyi ezimanyi deleted the faster-sql-tests branch July 23, 2020 14:36
KathrynLewis pushed a commit to KathrynLewis/orca that referenced this pull request Jan 31, 2021
* perf(test): Speed up PgSQL tests

When overriding setupSpec, Spock runs both the parent (super.setupSpec)
and the subclass setupSpec (in that order). This means that for the
PgSQL tests, we're creating a MySQL database then immediately discarding
it to replace it with a PgSQL database.

As creating the database spins up a container and is resonably slow,
lightly refactor this so that we don't do this extra work.

* refactor(test): Push some logic down from execution repository tests

There's a lot of coupling between PipelineExecutionRepositoryTck and
its subclasses that causes initialization order dependencies. In order
to make it easier to make changes (such as changing what fields are
updated in setup vs setupSpec), refactor this so that each subclass
is fully responsible for initialization and we can control the order.

The main issue here is that the super class was storing and
initializing the ExecutionRepository, but we can't actually create
the ExecutionRepository until we've created the persistence store,
which is owned by the implementations. So we were subtly depending
on each subclass having already initialized its persistence store
before we create the ExecutionRepository.

Now it's up to each subclass ot handle this order-dependence and
expose a method to get the ExecutionRepository.

* perf(test): Share execution repository among tests

Given that we share the actual persistence between tests, there's
not much benefit to creating a new ExecutionRepository for each
test. Speed the tests up by re-using it between tests.

* perf(test): Remove previous repository from base test

The previous repository is only used in the Jedis tests; remove it
from the base class so we can avoid creating it and cleaning it up
after every test.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto merged Merged automatically by a bot ready to merge Approved and ready for merge target-release/1.22
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants