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

ref: Convert integration tests about dropping transactions to unit tests #1720

Merged
merged 6 commits into from
Jan 18, 2023

Conversation

TBS1996
Copy link
Contributor

@TBS1996 TBS1996 commented Dec 22, 2022

previously there were two integration tests that checked if the transactions got dropped or not when they should based on the sample rate, now there is a single rust unit test that is more targeted to the relevant functions

Also created a testutils file as some helper functions from dynamic_sampling.rs were needed elsewhere in the crate

#skip-changelog

previously there were two integration tests that checked if the transactions got dropped or not when they should based on the sample rate, now there is a single rust unit test that is more targeted to the relevant functions
@TBS1996 TBS1996 changed the title ref: convert integration tests to unit tests about dropping transactions ref: Convert integration tests to unit tests about dropping transactions Dec 22, 2022
@TBS1996 TBS1996 changed the title ref: Convert integration tests to unit tests about dropping transactions ref: Convert integration about dropping transactions tests to unit tests Dec 22, 2022
@TBS1996 TBS1996 changed the title ref: Convert integration about dropping transactions tests to unit tests ref: Convert integration tests about dropping transactions to unit tests Dec 22, 2022
@TBS1996 TBS1996 marked this pull request as ready for review December 22, 2022 21:33
@TBS1996 TBS1996 requested a review from a team December 22, 2022 21:33
Copy link
Contributor

@olksdr olksdr left a comment

Choose a reason for hiding this comment

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

I still do not like that we have to start the entire ServiceState just for one unit test. Maybe it's worth looking into this more closely and actually test a little bit different (only the pieces we care about).


use crate::service::ServiceState;
use crate::testutils::{new_envelope, state_with_rule_and_condition};
use crate::utils::Semaphore as MySemaphore;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove this to TestSemaphore instead?

Suggested change
use crate::utils::Semaphore as MySemaphore;
use crate::utils::Semaphore as TestSemaphore;


// it really shouldn't be necessary to start an entire service for a unit test
// it was ported from a python integration test
ServiceState::start(arconfig).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

This starts all the actors/services we have in order for this unit test to work, which is kind of heavy and does not make much sense.

But at this point I'm not sure how to solve this yet.

The current status:

  • the function you test uses reject function on envelope_context which triggers the TestStore capture functionality

    // TODO: This could be optimized with Capture::should_capture
    TestStore::from_registry().send(Capture::rejected(self.event_id, &outcome));

  • this function also is triggered on Drop of the envelope_context

  • also the reject function triggers track_outcome which also requires Outcome actor to be available in the registry.

@TBS1996 TBS1996 requested review from a team as code owners January 13, 2023 08:59
@TBS1996 TBS1996 marked this pull request as draft January 13, 2023 09:25
@TBS1996 TBS1996 removed request for a team January 13, 2023 09:29
@TBS1996 TBS1996 requested a review from olksdr January 16, 2023 14:48
@TBS1996 TBS1996 marked this pull request as ready for review January 16, 2023 14:48
@TBS1996 TBS1996 merged commit 8bc24ba into master Jan 18, 2023
@TBS1996 TBS1996 deleted the ref/it_to_ut branch January 18, 2023 09:03
jan-auer added a commit that referenced this pull request Jan 18, 2023
* master: (35 commits)
  ref(actix): Migrate ProjectUpstream to `relay_system::Service` (#1727)
  feat(general): Add unknown SessionStatus variant (#1736)
  ref: Convert integration tests about dropping transactions to unit tests (#1720)
  release: 0.8.16
  ci: Skip redundant self-hosted E2E on library release (#1755)
  doc(changelog): Add relevant changes to python changelog (#1753)
  feat(profiling): Add profile context (#1748)
  release: 23.1.0
  profiling(fix): use an unpadded base64 encoding (#1749)
  Revert "feat(replays): Enable PII scrubbing for all organizations" (#1747)
  feat: Switch from base64 to data-encoding (#1743)
  instr(replays): Add timer metric to recording processing (#1742)
  feat(replays): Use Annotated struct definition for replay-event parsing (#1582)
  feat(sessions): Retire session duration metric (#1739)
  feat(general): Scrub all fields with IP address (#1725)
  feat(replays): Enable PII scrubbing for all organizations (#1678)
  chore(project): Add backoff mechanism for fetching projects (#1726)
  feat(profiling): Add new measurement units for profiling (#1732)
  chore(toolchain): update rust to 1.66.1 (#1735)
  ref(actix): Migrate server actor to the "service" arch (#1723)
  ...
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