mirror of
https://github.com/discourse/discourse.git
synced 2024-12-24 11:53:51 +08:00
8cf4ed5f88
This commit introduces a hidden `s3_inventory_bucket` site setting which replaces the `enable_s3_inventory` and `s3_configure_inventory_policy` site setting. The reason `enable_s3_inventory` and `s3_configure_inventory_policy` site settings are removed is because this feature has technically been broken since it was introduced. When the `enable_s3_inventory` feature is turned on, the app will because configure a daily inventory policy for the `s3_upload_bucket` bucket and store the inventories under a prefix in the bucket. The problem here is that once the inventories are created, there is nothing cleaning up all these inventories so whoever that has enabled this feature would have been paying the cost of storing a whole bunch of inventory files which are never used. Given that we have not received any complains about inventory files inflating S3 storage costs, we think that it is very likely that this feature is no longer being used and we are looking to drop support for this feature in the not too distance future. For now, we will still support a hidden `s3_inventory_bucket` site setting which site administrators can configure via the `DISCOURSE_S3_INVENTORY_BUCKET` env.
34 lines
790 B
Ruby
34 lines
790 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "s3_helper"
|
|
require "s3_inventory"
|
|
require "file_store/s3_store"
|
|
|
|
RSpec.describe "S3Inventory", type: :multisite do
|
|
let(:inventory) do
|
|
S3Inventory.new(:upload, s3_inventory_bucket: "some-inventory-bucket/some/prefix")
|
|
end
|
|
|
|
let(:csv_filename) { "#{Rails.root}/spec/fixtures/csv/s3_inventory.csv" }
|
|
|
|
it "can create per-site files" do
|
|
freeze_time
|
|
setup_s3
|
|
|
|
inventory.stubs(:files).returns([{ key: "Key", filename: "#{csv_filename}.gz" }])
|
|
inventory.stubs(:cleanup!)
|
|
|
|
files = inventory.prepare_for_all_sites
|
|
db1 = files["default"].read
|
|
db2 = files["second"].read
|
|
|
|
expect(db1.lines.count).to eq(3)
|
|
expect(db2.lines.count).to eq(1)
|
|
|
|
files.values.each do |f|
|
|
f.close
|
|
f.unlink
|
|
end
|
|
end
|
|
end
|