forked from discourse/discourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV: Add S3 upload system specs using minio (discourse#22975)
This commit adds some system specs to test uploads with direct to S3 single and multipart uploads via uppy. This is done with minio as a local S3 replacement. We are doing this to catch regressions when uppy dependencies need to be upgraded or we change uppy upload code, since before this there was no way to know outside manual testing whether these changes would cause regressions. Minio's server lifecycle and the installed binaries are managed by the https://github.com/discourse/minio_runner gem, though the binaries are already installed on the discourse_test image we run GitHub CI from. These tests will only run in CI unless you specifically use the CI=1 or RUN_S3_SYSTEM_SPECS=1 env vars. For a history of experimentation here see discourse#22381 Related PRs: * discourse/minio_runner#1 * discourse/minio_runner#2 * discourse/minio_runner#3
- Loading branch information
1 parent
9b63ac4
commit cf42466
Showing
22 changed files
with
360 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
require "minio_runner" | ||
|
||
ENV["MINIO_RUNNER_LOG_LEVEL"] = "DEBUG" | ||
MinioRunner.install_binaries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
require "minio_runner" | ||
|
||
class ExecuteLocalMinioS3 | ||
def run | ||
begin | ||
start_minio | ||
save_old_config | ||
change_to_minio_settings | ||
puts "Press any key when done..." | ||
gets | ||
restore_old | ||
rescue SystemExit, Interrupt | ||
restore_old | ||
raise | ||
end | ||
end | ||
|
||
def start_minio | ||
MinioRunner.config do |minio_runner_config| | ||
minio_runner_config.minio_domain = ENV["MINIO_RUNNER_MINIO_DOMAIN"] || "minio.local" | ||
minio_runner_config.buckets = | ||
( | ||
if ENV["MINIO_RUNNER_BUCKETS"] | ||
ENV["MINIO_RUNNER_BUCKETS"].split(",") | ||
else | ||
["discoursetest"] | ||
end | ||
) | ||
minio_runner_config.public_buckets = | ||
( | ||
if ENV["MINIO_RUNNER_PUBLIC_BUCKETS"] | ||
ENV["MINIO_RUNNER_PUBLIC_BUCKETS"].split(",") | ||
else | ||
["discoursetest"] | ||
end | ||
) | ||
end | ||
puts "Starting minio..." | ||
MinioRunner.start | ||
end | ||
|
||
def save_old_config | ||
puts "Temporarily using minio config for S3. Current settings:" | ||
@current_s3_endpoint = puts_current(:s3_endpoint) | ||
@current_s3_upload_bucket = puts_current(:s3_upload_bucket) | ||
@current_s3_access_key_id = puts_current(:s3_access_key_id) | ||
@current_s3_secret_access_key = puts_current(:s3_secret_access_key) | ||
@current_allowed_internal_hosts = puts_current(:allowed_internal_hosts) | ||
end | ||
|
||
def change_to_minio_settings | ||
puts "Changing to minio settings..." | ||
SiteSetting.s3_upload_bucket = "discoursetest" | ||
SiteSetting.s3_access_key_id = MinioRunner.config.minio_root_user | ||
SiteSetting.s3_secret_access_key = MinioRunner.config.minio_root_password | ||
SiteSetting.s3_endpoint = MinioRunner.config.minio_server_url | ||
SiteSetting.allowed_internal_hosts = | ||
MinioRunner.config.minio_urls.map { |url| URI.parse(url).host }.join("|") | ||
|
||
puts_current(:s3_endpoint) | ||
puts_current(:s3_upload_bucket) | ||
puts_current(:s3_access_key_id) | ||
puts_current(:s3_secret_access_key) | ||
puts_current(:allowed_internal_hosts) | ||
end | ||
|
||
def restore_old | ||
puts "Restoring old S3 settings..." | ||
SiteSetting.s3_upload_bucket = @current_s3_upload_bucket | ||
SiteSetting.s3_access_key_id = @current_s3_access_key_id | ||
SiteSetting.s3_secret_access_key = @current_s3_secret_access_key | ||
SiteSetting.s3_endpoint = @current_s3_endpoint | ||
SiteSetting.allowed_internal_hosts = @current_allowed_internal_hosts | ||
|
||
puts_current(:s3_endpoint) | ||
puts_current(:s3_upload_bucket) | ||
puts_current(:s3_access_key_id) | ||
puts_current(:s3_secret_access_key) | ||
puts_current(:allowed_internal_hosts) | ||
puts "Done!" | ||
end | ||
|
||
def puts_current(setting) | ||
printf "%-40s %s\n", " > Current #{setting}:", SiteSetting.send(setting) | ||
SiteSetting.send(setting) | ||
end | ||
end | ||
|
||
ExecuteLocalMinioS3.new.run |
Oops, something went wrong.