Commit Graph

72 Commits

Author SHA1 Message Date
Klaas van Schelven
6b9e4d8011 Project.delete_deferred(): first version (WIP)
Implemented using a batch-wise dependency-scanner in delayed
(snappea) style.

* no real point-of-entry in the (regular, non-admin) UI yet.
* no hiding of Projects which are delete-in-progress from the UI

* lack of DRY
* some unnessary work (needed in the Issue-context, but not here)
  is still being done.

See #50
2025-07-03 21:01:28 +02:00
Klaas van Schelven
99f71b8a47 Fix the tests (query-counting across DBs) 2025-07-03 14:48:51 +02:00
Klaas van Schelven
2baa4446fd Issue deletion: event pre-deletes (storage, project-counts) 2025-07-03 13:18:28 +02:00
Klaas van Schelven
3b3ce782c5 Fix the tests for prev. commit
tests were broken b/c not respecting constraints / not properly using the factories.
2025-07-03 11:33:58 +02:00
Klaas van Schelven
e45c61d6f0 Various models: .issue and .grouping; SET_NULL => DO_NOTHING
I originally thought `SET_NULL` would be a good way to "do stuff later", but
that's only so the degree that [1] updates are cheaper than deletes and [2]
2nd-order effects (further deletes in the dep-tree) are avoided.

Now that we have explicit Issue-deletion (deps-first, delayed, properly batched)
the SET_NULL behavior is always a no-op (but with cost in queries).

As a result, in the test for issue deletion (which has deletes for many
of the altered models), the following 8 queries are no longer done:

```
SELECT "issues_grouping"."id", [..many fields..] FROM "issues_grouping" WHERE "issues_grouping"."id" IN (1)
UPDATE "events_event" SET "grouping_id" = NULL WHERE "events_event"."grouping_id" IN (1)

[.. a few moments later..]

SELECT "issues_issue"."id", [..many fields..] FROM "issues_issue" WHERE "issues_issue"."id" = 'uuid'
UPDATE "issues_grouping" SET "issue_id" = NULL WHERE "issues_grouping"."issue_id" IN ('uuid')
UPDATE "issues_turningpoint" SET "issue_id" = NULL WHERE "issues_turningpoint"."issue_id" IN ('uuid')
UPDATE "events_event" SET "issue_id" = NULL WHERE "events_event"."issue_id" IN ('uuid')
UPDATE "tags_eventtag" SET "issue_id" = NULL WHERE "tags_eventtag"."issue_id" IN ('uuid')
UPDATE "tags_issuetag" SET "issue_id" = NULL WHERE "tags_issuetag"."issue_id" IN ('uuid')
```

(breaks the tests b/c of constraints and not always using factories; will fix next)
2025-07-03 11:33:58 +02:00
Klaas van Schelven
e58be0018f Tag models: no CASCADE
CASCADE was defined for keys & values, but in practice those are never directly
deleted except in the very case in which it has been established that they are
'orphaned', i.e. no longer being referrred to. That's exactly the case in which
CASCADE is superfluous.

As a result, in the test for issue deletion (which contains a prune of
tagvalue), the following 3 queries are no longer done:

```
SELECT "tags_tagvalue"."id", "tags_tagvalue"."project_id", "tags_tagvalue"."key_id", "tags_tagvalue"."value" FROM "tags_tagvalue" WHERE "tags_tagvalue"."id" IN (1)
DELETE FROM "tags_eventtag" WHERE "tags_eventtag"."value_id" IN (1)
DELETE FROM "tags_issuetag" WHERE "tags_issuetag"."value_id" IN (1)
```
2025-07-03 11:33:58 +02:00
Klaas van Schelven
428011ff9b Prune orphans (TagValue, via IssueTag) inline
See #135
2025-07-03 11:33:53 +02:00
Klaas van Schelven
29238ece43 Test for model-topo overrides 2025-07-02 23:48:10 +02:00
Klaas van Schelven
f1878da154 Fix the test
tests were green but IssueTag was missing from the assertions (and some others doubled)
2025-07-02 23:35:23 +02:00
Klaas van Schelven
ee9add5e5f Vacuum Tags command
See #135
2025-07-02 21:43:51 +02:00
Klaas van Schelven
aed19e70d3 Issue deletion test: actually test the Issue itself 2025-07-02 16:41:42 +02:00
Klaas van Schelven
6e9defedb4 Simple IntegrationTest for issue deletion 2025-06-27 12:57:51 +02:00
Klaas van Schelven
0c11bf0787 Add trivial viewtest 2025-04-11 11:19:03 +02:00
Klaas van Schelven
5930740e0b Tags: as a separate tab 2025-03-03 12:56:20 +01:00
Klaas van Schelven
934764dd8c Tests: Better error message for failing integration tests 2025-02-20 09:26:04 +01:00
Klaas van Schelven
9ee623de6b Add Event.grouping field and fill it
An event always has a single (automatically calculated) Grouping associated with it.
We add this info to the Event model (we'll soon display it in the UI, and as per the
now-removed comment it's simply the consistent thing to do)
2025-01-31 16:16:07 +01:00
Klaas van Schelven
43a6049180 Fix warning in tests (unclosed file) 2025-01-31 13:17:20 +01:00
Klaas van Schelven
ba7472321a Fix broken import
broken in ae9cb209a5
2025-01-23 12:30:00 +01:00
Klaas van Schelven
4a28c51b6a Tests: Add known-broken handling for events that are invalid on purpose 2024-11-15 11:20:12 +01:00
Klaas van Schelven
3222c0d85e Fix the tests (missing initial data in transactiontestcase) 2024-11-15 10:14:01 +01:00
Klaas van Schelven
9db0b121ec Further HTML correctness checks; by not going through Firefox a few more issues were unhidden 2024-09-26 16:14:51 +02:00
Klaas van Schelven
096d1f7d9a Add 'samples' tests as such explicitly 2024-09-19 13:10:13 +02:00
Klaas van Schelven
f2a78fed9d Use the envelope's event_id when using the envelope endpoint
* As per the spec 'takes precendence'
* Also fixes the reported bug on Laravel, which apparently doesn't send event_id
  as part of the event payload.
* Fixes the envelope tests (they were doing nothing when I moved the
  data samples around recently)
* Adds a 'no event_id in data, but yes in envelope' test to that test.
* Adds handling to send_json such that we can send envelopes when the event_id
  is missing from the event data.
2024-09-18 11:36:47 +02:00
Klaas van Schelven
c5465f2f8a Don't assume samples miss the 'timestamp' property
(we have fixed the samples accordingly)
2024-09-17 09:38:08 +02:00
Klaas van Schelven
519c09b662 Syntax error fix 2024-09-16 14:19:34 +02:00
Klaas van Schelven
f1b75aab81 api.json.schema: put back in code, make test fail on invalidness and related fixes
This reverts course on 4201fbd778, and restores event.schema.json from that
commit.  In that commit we said: 'this is not used'. Not true: it's used in a
test, though this test used the validity check to silently skip.

In this commit:

1. Do _not_ just silently skip invalid samples. Since we have a way of properly
   validating, let's use that so that we know how useful the samples that we have
   actually are.

2. Deal with "_meta", a field that we sometimes see in the "private samples" (data
   that ultimately comes from running a somewhat recent python-sdk against my
   actual codebase). The need for this was exposed by [1]

3. Add a test for the up-to-date-ness of event.json.schema

4. remove special-cased attribute-checks in `is_valid`; `send_json` was, at the
   time, an opportunistic way to just get my hands on some sample data. the
   approach at validation reflected that: I just did some tests on the existence
   of certain attributes to determine which json files were even events. But in
   the end I did a full validation using an API schema, which kinda made the
   whole business useless. This commit cleans up the individual checks.
2024-09-16 11:28:05 +02:00
Klaas van Schelven
55aa917436 Integration test using the extracted event-samples 2024-09-13 11:46:25 +02:00
Klaas van Schelven
9e4b326ab6 whitespace 2024-09-12 12:41:22 +02:00
Klaas van Schelven
10c91ccbdc fix tests
recently introduced (e59fd3a225) caching made it so that repeated calls to
create_release_if_needed no longer work if releases have been created in the
meantime.

In actual usage create_release_if_needed is always called on a single project
so I _think_ just calling `fresh` in the tests is good way to get to green
tests again.
2024-09-12 12:17:47 +02:00
Klaas van Schelven
1bfac5d8c6 assertEquals -> assertEual (Python 3.12)
<<insert remarks about fashion police>>
2024-08-21 08:49:49 +02:00
Klaas van Schelven
b76e474ef1 Navigation: fix for missing events
Now that we have eviction, events may disappear. Deal with it:

* event-specific 404 that still allows for navigation
* first/last buttons
* navigation to prev/next when prev/next is not just 1 step away
* don't use HttpRedirect for "lookup based" views
    in principle, the thing you were looking for might go missing in-between
    drawback: these URLs are not "stable"
2024-07-19 11:03:08 +02:00
Klaas van Schelven
d56a8663a7 Remove the periodCounter and the PC registry
direct consequence of switching to SQL-based counting
2024-07-16 15:08:05 +02:00
Klaas van Schelven
d68aff05ca Quota 2024-07-15 09:37:36 +02:00
Klaas van Schelven
edff0e219c PeriodCounter: remove event-based approach
Replacing it with passing the thresholds on each call to `inc`.

The event-based approach was broken in a multi-process setup (such as having a separate
gunicorn and snappea), because the unmute events would be registered GUI-side
(gunicorn), and the single process where the counting happened had a different PC
instance.

The solution is to get rid of the event-listener approach, and just make an inventory of
the threshold-checks that need to be done right before each call to `inc`. Because the
calls to `inc` happen in a single process (we [will] enforce this elsewhere) this fixes
the problem.

During refactoring it became clear that this is probably a good idea anyway: many
comments about corner-cases could be removed.

Other things I found:

* The now-removed `_digest_event_python_postprocessing` did more than Python alone (it
  also touched the DB for unmutes) so that was probably a separate bug (now fixed).

* In the event-listener-based code, I foresaw the need for `on_become_false` (but did
  not use it yet). The idea was probably that this could be useful in the quota setting
  (a quota can become unmet after a while) but in fact it isn't useful, because when a
  quota becomes unmet you'd still need to check all quota and OR them.

Tests have not been truly refactored (the new architecture probably points to a new
desired set of tests) but rather have been made to run in the simplest way possible.
2024-07-09 09:31:36 +02:00
Klaas van Schelven
c4358aaece Fix tests for users.User idiom 2024-06-12 17:45:06 +02:00
Klaas van Schelven
8d23239526 Be more strict about usage of TransactionTestCase in tests 2024-04-27 20:35:35 +02:00
Klaas van Schelven
c50780ab4e Use atomic transactions in views 2024-04-18 13:15:46 +02:00
Klaas van Schelven
d89e3d4dd5 Add 'next-materialized historic annotation 2024-04-16 09:31:12 +02:00
Klaas van Schelven
2c4e8b9f20 Regular v.s. Django Testcase: be explicit
I recently ran into a funny issue where the TestCases were influencing my
development DB's contents
2024-04-15 09:17:53 +02:00
Klaas van Schelven
280bd2172b History page: 'mostly done' (a first setup) 2024-04-12 16:07:25 +02:00
Klaas van Schelven
729a4c7ea1 Make <no transaction> explicit;
and more moving-around-of-code in preparation for our next step
2024-04-08 15:03:02 +02:00
Klaas van Schelven
cb75d318af Remove the event_type_name from the grouper
it adds very little, especially now that we've put this information in the type
('Log Message') and removing this allows us to refactor more freely
2024-04-08 14:52:09 +02:00
Klaas van Schelven
8d17e7b128 For log messages, demote the msg into the value
and make the type 'Log Message'.
This may just be a matter of personal taste, but I've always found these
messages-as-type super-confusing. I'd rather have some made up (but clear,
and thanks to the whitespace unlikely-to-otherwise-exist) type "Log Message".

This is also inline in what I've already done in the UI.
2024-04-08 14:48:39 +02:00
Klaas van Schelven
9dfae5a829 Use the diamond-separator when generating fingerprint-based groupers too 2024-04-05 15:41:12 +02:00
Klaas van Schelven
eaa5ee6838 Tests for existing grouping functionality 2024-04-05 12:10:51 +02:00
Klaas van Schelven
09a716a8d7 Stacktrace ordering: stack-of-plates as an option
implemented in-python; doing this using flex quickly became a mess
2024-04-04 10:40:32 +02:00
Klaas van Schelven
f40ee395ee Make issues/templatetags more robust
(the need for which was exposed by the recently added tests)
2024-04-03 10:15:13 +02:00
Klaas van Schelven
17b5c0d089 Add integration test for issue-ingestion & rendering 2024-04-03 09:52:50 +02:00
Klaas van Schelven
3ffa0f9671 issue-views: test for project membership 2024-03-25 23:38:17 +01:00
Klaas van Schelven
6100767548 Add view tests for issues 2024-03-25 23:06:41 +01:00