8000 Fix broken tests by refershing materalized views by codihuston · Pull Request #2699 · cyberark/conjur · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix broken tests by refershing materalized views #2699

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

Draft
wants to merge 2 commits into
base: materialized_views
Choose a base branch
from

Conversation

codihuston
Copy link
Contributor
@codihuston codihuston commented Jan 9, 2023

Desired Outcome

Further resolves broken tests after the addition of materialized views. This PR contains two commits that contain two different approaches to resolving the issues.

The materialized views introduces a form of caching for some compute expensive operations for authorizing a role to a resource. As a result, this cache needs to be rehydrated / invalidated and repopulated on a per-policy load basis. This is fine, and should function out-of-box in production.

However, our testing infrastructure has an amalgamation of integration and end-to-end tests across both rspec and cucumber that leverage the models and/or repository classes directly to persist records into the database outside of a policy load. Thus, we need to

Commit 1: Attempts to refresh the materialized views from the tests, outside of the application code.
Commit 2: Attempts to refresh the materialized views from the application code using the sequel gem lifecycle hooks.

Both of these have tradeoffs. The former is a bit of a code smell that will sour the developer experience, as they have to remember to refresh these views explicitly. The latter may incur application performance implications, as loading policy that will create multiple resources may trigger multiple refreshes per policy load, which could have a profound impact on the database. We would also need to account for the update/destroy hooks as well.

Ideally, we would clean up our testing infrastructure such these resource creations are only occurring through policy load as opposed to using the model / repository classes.

Implemented Changes

Describe how the desired outcome above has been achieved with this PR. In
particular, consider:

  • What's changed? Why were these changes made?
  • How should the reviewer approach this PR, especially if manual tests are required?
  • Are there relevant screenshots you can add to the PR description?

Connected Issue/Story

Resolves #[relevant GitHub issue(s), e.g. 76]

CyberArk internal issue ID: [ONYX-30396

Definition of Done

At least 1 todo must be completed in the sections below for the PR to be
merged.

Changelog

  • The CHANGELOG has been updated, or
  • This PR does not include user-facing changes and doesn't require a
    CHANGELOG update

Test coverage

  • This PR includes new unit and integration tests to go with the code
    changes, or
  • The changes in this PR do not require tests

Documentation

  • Docs (e.g. READMEs) were updated in this PR
  • A follow-up issue to update official docs has been filed here: [insert issue ID]
  • This PR does not require updating any documentation

Behavior

  • This PR changes product behavior and has been reviewed by a PO, or
  • These changes are part of a larger initiative that will be reviewed later, or
  • No behavior was changed with this PR

Security

  • Security architect has reviewed the changes in this PR,
  • These changes are part of a larger initiative with a separate security review, or
  • There are no security aspects to these changes

@codihuston codihuston force-pushed the materialized_views_codi02 branch from 780b38c to 1527c2c Compare January 9, 2023 22:31
@codihuston codihuston force-pushed the materialized_views_codi02 branch 2 times, most recently from cac7a84 to 563d472 Compare January 10, 2023 17:02
< 9D40 div class="d-flex flex-auto">
DANGER: the after_create hooks will trigger materialized view refreshes potentially en masse, which could have a potentially profound impact on the database as opposed to refreshing materialized views from the test angle.
@codihuston codihuston force-pushed the materialized_views_codi02 branch from 563d472 to 57e78d7 Compare January 11, 2023 19:32
@szh
Copy link
Contributor
szh commented May 12, 2025

Is this still relevant @codihuston?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0