mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Detect when s3 inventory failure is caused by etag difference (#10427)
This commit is contained in:
@@ -64,7 +64,10 @@ describe "S3Inventory" do
|
||||
|
||||
CSV.foreach(csv_filename, headers: false) do |row|
|
||||
next unless row[S3Inventory::CSV_KEY_INDEX].include?("default")
|
||||
Fabricate(:upload, etag: row[S3Inventory::CSV_ETAG_INDEX], updated_at: 2.days.ago)
|
||||
Fabricate(:upload,
|
||||
etag: row[S3Inventory::CSV_ETAG_INDEX],
|
||||
url: File.join(Discourse.store.absolute_base_url, row[S3Inventory::CSV_KEY_INDEX]),
|
||||
updated_at: 2.days.ago)
|
||||
end
|
||||
|
||||
@upload1 = Fabricate(:upload, etag: "ETag", updated_at: 1.days.ago)
|
||||
@@ -84,6 +87,25 @@ describe "S3Inventory" do
|
||||
expect(Discourse.stats.get("missing_s3_uploads")).to eq(2)
|
||||
end
|
||||
|
||||
it "should detect when a url match exists with a different etag" do
|
||||
differing_etag = Upload.find_by(etag: "defcaac0b4aca535c284e95f30d608d0")
|
||||
differing_etag.update_columns(etag: "somethingelse")
|
||||
|
||||
output = capture_stdout do
|
||||
inventory.backfill_etags_and_list_missing
|
||||
end
|
||||
|
||||
expect(output).to eq(<<~TEXT)
|
||||
#{differing_etag.url} has different etag
|
||||
#{@upload1.url}
|
||||
#{@no_etag.url}
|
||||
3 of 5 uploads are missing
|
||||
1 of these are caused by differing etags
|
||||
Null the etag column and re-run for automatic backfill
|
||||
TEXT
|
||||
expect(Discourse.stats.get("missing_s3_uploads")).to eq(3)
|
||||
end
|
||||
|
||||
it "marks missing uploads as not verified and found uploads as verified. uploads not checked will be verified nil" do
|
||||
expect(Upload.where(verified: nil).count).to eq(12)
|
||||
output = capture_stdout do
|
||||
|
||||
Reference in New Issue
Block a user