Commit Graph

8 Commits

Author SHA1 Message Date
Cody Cutrer 9834937c8c don't autorequire a bunch of gems that are rarely used
Change-Id: I09ed3686629b62849d392684d587f30cb2047013
Reviewed-on: https://gerrit.instructure.com/51853
Tested-by: Jenkins
Reviewed-by: Ethan Vizitei <evizitei@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2015-04-09 18:47:50 +00:00
Nick Cloward 535046bc42 max date on the audit log fix up
fixes: CNVS-16213

Sets a max date on the audit log data fixup so it does not have to run
records that were created after the bug was fixed.  Set it to the 20th
of August to give us a buffer and that was when the audit logs were
reenabled.

Test Plan:

  - Create a corrupted login event using the script below.
  - Run the fixup (Command in script below).
  - Should skip records after the 20th (see output from script ids to which 
    is which).

Setup test plan:

target_user = User.find(...)
target_pseudonym = target_user.pseudonyms.first
event_type = 'login'

# Records Before
record1 = Auditors::Authentication::Record.generate(target_pseudonym,  event_type)
record1.attributes['created_at'] = Date.new(2014, 8, 20).to_time
Auditors::Authentication::Stream.insert(record1)

record2 = Auditors::Authentication::Record.generate(target_pseudonym, event_type)
record2.attributes['id'] = record1.id
record2.attributes['created_at'] = Date.new(2014, 8, 21).to_time
Auditors::Authentication::Stream.insert(record2)

# Records After
record3= Auditors::Authentication::Record.generate(target_pseudonym,  event_type)
record3.attributes['created_at'] = Date.new(2014, 8, 21).to_time
Auditors::Authentication::Stream.insert(record3)

record4 = Auditors::Authentication::Record.generate(target_pseudonym,  event_type)
record4.attributes['id'] = record3.id
record4.attributes['created_at'] = Date.new(2014, 8, 22).to_time
Auditors::Authentication::Stream.insert(record4)

puts "Id should be fixed: #{record1.id}."
puts "Id should NOT be fixed: #{record3.id}."


# Run Fixup
DataFixup::FixAuditLogUuidIndexes::Migration::run

Change-Id: Ic57fe4da0ecedba9f45670dca08e5b279b601086
Reviewed-on: https://gerrit.instructure.com/42605
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Nick Cloward <ncloward@instructure.com>
2014-10-31 04:05:22 +00:00
Nick Cloward 3596811afd skip index without events
refs: CNVS-13987

Found some index records that cannot find a related audit event.  We
were skipping the index records that could not acquire a relevant key so
we should just skip these as well.

Test Plan:
  - Create a corrupted login event using the examples from g/37605.
  - In cqlsh, delete a record in the auditors table so the index records
    cannot reference back to the event record.
  - Run the data fixup.
  - Should complete successfully.

Change-Id: I475515ab0907901af026146af51e1590a962ee0a
Reviewed-on: https://gerrit.instructure.com/41837
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Nick Cloward <ncloward@instructure.com>
2014-10-10 20:04:49 +00:00
Nick Cloward 8315ec1371 fix audit records as they are queried
refs: CNVS-13987

Adds a parameter to event stream that allows us to add in a method to fix the
data before the event stream pulls the records.  Once the fixup is complete we
should remove these changes.

Requres g/37541.

Test Plan:

  - Corrupt some Audit log data for authentications, grade changes, and course
    changes.
  - Do not run the data fixup.
  - Use the UI or API endpoints to query the corrupted records.
  - Should fix the corrupted indexes for the corrupted records.
  - Should return corrupted event type records in results just as if the data
    fixup has ran on the records.
  - Should behave normally on records that are not corrupted or have never been
    corrupted.

Reference g/37605 for setting up corrupted event data.

Change-Id: Id0e1278c7d377ef836866e2e146e2b52887fdc68
Reviewed-on: https://gerrit.instructure.com/39089
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Nick Cloward <ncloward@instructure.com>
2014-08-16 01:53:45 +00:00
Jacob Fugal 09d9619f49 yield for each batch_size in for fixing audit logs
currently, we try and get batch_size based just on the last key seen.
but then we have to make sure we get all records for that key, iterating
on last ordered_id seen for that key. this is correct for covering the
keyspace completely, but some keys may have several batches worth of
ordered_ids. yield for each iteration of the second tier iteration as
well.

Change-Id: Idfc23ef650de63d6afd7a1787e9061a558afa892
Reviewed-on: https://gerrit.instructure.com/38661
Reviewed-by: Nick Cloward <ncloward@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Jacob Fugal <jacob@instructure.com>
QA-Review: Jacob Fugal <jacob@instructure.com>
2014-08-11 21:01:24 +00:00
Nick Cloward 8a06da0ca1 store last batch for data fixup
refs: CNVS-13987

Added a way to store the last batch that was ran.  Seperated out
the batch processor and the actual cleaner methods.  This will
allow us to add it to event stream to fix records as they are
queried if we choose.  This also moved the temporary mapping and last
batch tables to the migration.  g/38429 removes the tables.

Test Plan:
  - Same as g/37956 and g/37605
  - Migration should not fail if mapping table already exists.
  - With a grade change try deleting the submission then running the
    fixup.

Change-Id: Ibce843c22b72885f7e2510d85b482c39f513996b
Reviewed-on: https://gerrit.instructure.com/38407
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Nick Cloward <ncloward@instructure.com>
2014-07-30 21:59:41 +00:00
Nick Cloward dec7a2231e data fixup needs to support Cassandra 1.1
refs: CNVS-13987

Test Plan:

  Same as g/37605 but under Cassandra 1.1
  Lower the batch size and make sure it has the same results.

Change-Id: Id35b7a2690fd33e1769d27836deb374630f27fd3
Reviewed-on: https://gerrit.instructure.com/37956
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Nick Cloward <ncloward@instructure.com>
2014-07-24 18:01:25 +00:00
Nick Cloward 2bc1395790 audit log uuid data fixup
refs: CNVS-13987

Creates new records for audit log data that has been overritten.  Since
we cannot all of the actual event data they are created as a corrupted
record

Test Plan:
  - Clear Audit logs (Not manditory but easier to see data)
  - Generate Bad Audit data for each test case.
    * Supplied script should generate the bad data.
    * Refer to test case to ensure data is created correctly.
  - Pull Commit and run migrations.
  - Check Case 1
    * The original id record should still exist with a record in
      courses_by_course.
    * Before the fix only one course change record will exst.  After the
      after the fix a second tombstone record with a record type of
      corrupted should exist with related index records in
      courses_by_course.
    * Key column in each index should match the id/bucket format.
    * ordered_id in each should match timestamp/first eight of id.
 - Check Case 2
    * After the fix pick a tombstone record and ensure that it as an
      index record in each of the index tables: authentications_by_pseudonym,
      authentications_by_user, authentications_by_account.
    * Ensure cross bucket event indexes create a tombstone and match in
      other indexes as well.  Id should be unique in the index tables
      and stream table.

- Code to generate test cases:

target_course = Course.find(...)
target_user = User.find(...)
target_pseudonym = target_user.pseudonyms.first

event = Auditors::Course.record_created(target_course, target_user,
source: :manual)
record = Auditors::Course::Record.generate(target_course, target_user,
event.event_type, event.event_data, source: :manual)
record.attributes['id'] = event.id
record.attributes['created_at'] = Time.now + 1.day
Auditors::Course::Stream.insert(record)

event = Auditors::Authentication.record(target_pseudonym, 'login')
record = Auditors::Authentication::Record.generate(target_pseudonym,
event.event_type)
record.attributes['id'] = event.id
record.attributes['created_at'] = Time.now + 100.days
Auditors::Authentication::Stream.insert(record)

Change-Id: I888da1758282d0e3f2d19a4438c1a866a6f54125
Reviewed-on: https://gerrit.instructure.com/37605
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Nick Cloward <ncloward@instructure.com>
2014-07-18 21:44:46 +00:00