Skip to content

Commit

Permalink
more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
iker-barriocanal committed Jun 17, 2024
1 parent c236141 commit c0b2d5d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 195 deletions.
5 changes: 3 additions & 2 deletions relay-server/src/services/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1327,8 +1327,9 @@ impl EnvelopeProcessorService {
) -> Result<(), ProcessingError> {
if !state.has_event() {
// NOTE(iker): only processing relays create events from
// attachments, so these won't be normalized even if the config
// says so.
// attachments, so these events won't be normalized in
// non-processing relays even if the config is set to run full
// normalization.
return Ok(());
}

Expand Down
6 changes: 3 additions & 3 deletions relay-server/src/services/processor/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ pub fn extract<G: EventProcessing>(
return Err(ProcessingError::DuplicateItem(duplicate.ty().clone()));
}

let fully_normalized = event_item
.as_ref()
.map_or(false, |item| item.fully_normalized());
let fully_normalized = event_item.as_ref().map_or(false, |item| {
item.creates_event() && item.fully_normalized()
});
let normalization_skipped = config.processing_enabled()
&& global_config.options.processing_disable_normalization
&& envelope.meta().is_from_internal_relay()
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/extended-event-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,5 @@
"username": "username"
},
"version": "7",
"location": "whydoyouask"
"location": "not-empty-so-that-it-isnt-dropped"
}
33 changes: 13 additions & 20 deletions tests/integration/test_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,12 @@ def test_processing_with_full_normalization(
@pytest.mark.parametrize(
"relay_static_config_normalization, relay_force_normalization, processing_skip_normalization",
[
(False, False, False),
(False, True, False),
(False, True, True),
(True, True, True),
(False, False, False), # 0. nothing enabled
(False, True, False), # 1. enable flag in relay
(False, True, True), # 2. enable flag in processing
(True, True, True), # 3. enable config in relay
(True, False, True), # x. disable config in relay still works
(True, False, False), # x. disable config in processing still works
],
)
def test_relay_chain_normalizes_events(
Expand All @@ -151,17 +153,6 @@ def test_relay_chain_normalizes_events(
relay_force_normalization,
processing_skip_normalization,
):
"""
1. everything disabled
2. relay ff enable
3. proc ff enable
4. relay with config enabled, all ffs enabled
x. relay with config enabled, ffs disabled
-> after enabling the static config, remove feature flags from the code.
this is same situation as step 4
"""
input, expected = get_test_data("extended-event")

events_consumer = events_consumer()
Expand Down Expand Up @@ -198,9 +189,11 @@ def test_relay_chain_normalizes_events(

ingested, _ = events_consumer.get_event(timeout=10)

if relay_force_normalization and not processing_skip_normalization:
# Running full normalization twice on the same envelope adds the extra
# key error twice, one per run.
# Running full normalization twice on the same envelope adds the errors
# twice, one per run. The rest is the same.
if (
relay_static_config_normalization or relay_force_normalization
) and not processing_skip_normalization:
assert ingested["errors"] == [
{"name": "location", "type": "invalid_attribute"},
{"name": "location", "type": "invalid_attribute"},
Expand All @@ -221,8 +214,8 @@ def test_relay_doesnt_normalize_unextracted_unreal_event(
feat_flag_force_normalization,
):
"""
pop relays forward minidumps, apple crash reports and unreal events without marking them
as normalized. this happens independently of the configuration, including it full normalization is forced
Independently of the configuration, relays forward minidumps, apple crash
reports and unreal events without marking them as normalized.
"""
project_id = 42
mini_sentry.add_basic_project_config(project_id)
Expand Down
169 changes: 0 additions & 169 deletions tests/integration/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -1334,175 +1334,6 @@ def test_kafka_ssl(relay_with_processing):
)


@pytest.mark.parametrize(
"force_full_normalization",
[False, True],
)
@pytest.mark.parametrize(
"normalization_level",
["disabled", "default", "full"],
)
def test_relay_normalization(
mini_sentry, relay, normalization_level, force_full_normalization
):
if force_full_normalization:
mini_sentry.global_config["options"] = {
"relay.force_full_normalization": True,
}

project_id = 42
mini_sentry.add_basic_project_config(project_id)
relay = relay(
upstream=mini_sentry,
options={"normalization": {"level": normalization_level}},
)

event = {"dist": " foo ", "other": {"should i be deleted": True}}
relay.send_event(project_id, event)

ingested = mini_sentry.captured_events.get(timeout=1).get_event()

if not force_full_normalization and normalization_level == "disabled":
assert not force_full_normalization
assert ingested["dist"] == " foo "
assert ingested["other"] == {"should i be deleted": True}
elif not force_full_normalization and normalization_level == "default":
assert ingested["dist"] == "foo"
assert ingested["other"] == {"should i be deleted": True}
else:
assert force_full_normalization or normalization_level == "full"
assert ingested["dist"] == "foo"
assert ingested["other"] is None


@pytest.mark.parametrize(
"disable_normalization, normalization_level, from_internal, expect_full_normalization",
[
(False, "disabled", False, True),
(True, "disabled", False, True),
(False, "disabled", True, False),
(True, "disabled", True, False),
(False, "default", False, True),
(True, "default", False, True),
(False, "default", True, True),
(True, "default", True, False),
(False, "full", False, True),
(True, "full", False, True),
(False, "full", True, True),
(True, "full", True, False),
],
)
def test_processing_relay_normalization(
mini_sentry,
events_consumer,
relay_with_processing,
relay_credentials,
normalization_level,
from_internal,
expect_full_normalization,
disable_normalization,
):
if disable_normalization:
mini_sentry.global_config["options"] = {
"relay.disable_normalization.processing": True,
}

project_id = 42
mini_sentry.add_basic_project_config(project_id)
events_consumer = events_consumer()
credentials = relay_credentials()
relay_config = {
"normalization": {"level": normalization_level},
}
if from_internal:
relay_config["auth"] = {
"static_relays": {
credentials["id"]: {
"public_key": credentials["public_key"],
"internal": True,
}
}
}
processing = relay_with_processing(options=relay_config)

event = {"dist": " foo ", "other": {"should i be deleted": True}}
processing.send_event(
project_id,
event,
headers={"x-sentry-relay-id": credentials["id"]},
)

ingested, _ = events_consumer.get_event(timeout=1)

# Processing relays run full normalization if they need to, or don't run
# normalization at all.
if expect_full_normalization:
assert ingested["dist"] == "foo"
assert ingested["other"] is None
else:
assert ingested["dist"] == " foo "
assert ingested["other"] == {"should i be deleted": True}


@pytest.mark.parametrize(
"force_relay_normalization, disable_processing_normalization",
[
(False, False),
(False, True),
(True, False),
(True, True),
],
)
def test_relay_chain_normalization(
mini_sentry,
events_consumer,
relay_with_processing,
relay,
relay_credentials,
force_relay_normalization,
disable_processing_normalization,
):
if force_relay_normalization:
mini_sentry.global_config["options"] = {
"relay.force_full_normalization": True,
}
if disable_processing_normalization:
mini_sentry.global_config["options"] = {
"relay.disable_normalization.processing": True,
}

project_id = 42
mini_sentry.add_basic_project_config(project_id)
events_consumer = events_consumer()

credentials = relay_credentials()
processing = relay_with_processing(
static_relays={
credentials["id"]: {
"public_key": credentials["public_key"],
"internal": True,
},
},
options={"normalization": {"level": "disabled"}},
)
relay = relay(
processing,
credentials=credentials,
options={
"normalization": {
"level": "full",
}
},
)

event = {"dist": " foo ", "other": {"should i be deleted": True}}
relay.send_event(project_id, event)

ingested, _ = events_consumer.get_event(timeout=1)
assert ingested["dist"] == "foo"
assert ingested["other"] is None


def test_error_with_type_transaction_fixed_by_inference(
mini_sentry, events_consumer, relay_with_processing, relay, relay_credentials
):
Expand Down

0 comments on commit c0b2d5d

Please sign in to comment.