323 lines
6.0 KiB
Ruby
323 lines
6.0 KiB
Ruby
JAMKAZAM_TESTING_BUCKET = 'jamkazam-testing' # cuz i'm not comfortable using aws_bucket accessor directly
|
|
|
|
def app_config
|
|
klass = Class.new do
|
|
|
|
def admin_root_url
|
|
'http://localhost:3333'
|
|
end
|
|
|
|
def email_social_alias
|
|
'social@jamkazam.com'
|
|
end
|
|
|
|
def email_alerts_alias
|
|
'alerts@jamkazam.com'
|
|
end
|
|
|
|
def email_recurly_notice
|
|
'recurly-alerts@jamkazam.com'
|
|
end
|
|
|
|
def email_generic_from
|
|
'nobody@jamkazam.com'
|
|
end
|
|
|
|
def aws_bucket
|
|
JAMKAZAM_TESTING_BUCKET
|
|
end
|
|
|
|
def aws_bucket_jamtracks
|
|
'jamkazam-jamtracks-test'
|
|
end
|
|
|
|
def aws_access_key_id
|
|
'AKIAJESQY24TOT542UHQ'
|
|
end
|
|
|
|
def aws_secret_access_key
|
|
'h0V0ffr3JOp/UtgaGrRfAk25KHNiO9gm8Pj9m6v3'
|
|
end
|
|
|
|
def aws_region
|
|
'us-east-1'
|
|
end
|
|
|
|
def aws_bucket_public
|
|
'jamkazam-testing-public'
|
|
end
|
|
|
|
def aws_cache
|
|
'315576000'
|
|
end
|
|
|
|
def audiomixer_path
|
|
# you can specify full path to audiomixer with AUDIOMIXER_PATH env variable...
|
|
# or we check for audiomixer path in the user's workspace
|
|
# and finally the debian install path
|
|
ENV['AUDIOMIXER_PATH'] || audiomixer_workspace_path || "/var/lib/audiomixer/audiomixer/audiomixerapp"
|
|
end
|
|
|
|
def ffmpeg_path
|
|
ENV['FFMPEG_PATH'] || '/usr/local/bin/ffmpeg'
|
|
end
|
|
|
|
def normalize_ogg_path
|
|
ENV['NORMALIZE_OGG_PATH'] || '/usr/local/bin/normalize-ogg'
|
|
end
|
|
|
|
def normalize_mp3_path
|
|
ENV['NORMALIZE_MP3_PATH'] || '/usr/local/bin/normalize-mp3'
|
|
end
|
|
|
|
def icecast_reload_cmd
|
|
'true' # as in, /bin/true
|
|
end
|
|
|
|
def icecast_config_file
|
|
Dir::Tmpname.make_tmpname(["#{Dir.tmpdir}/icecast", 'xml'], nil)
|
|
end
|
|
|
|
def icecast_server_id
|
|
'test'
|
|
end
|
|
|
|
def icecast_max_missing_check
|
|
2 * 60 # 2 minutes
|
|
end
|
|
|
|
def icecast_max_sourced_changed
|
|
15 # 15 seconds
|
|
end
|
|
|
|
def icecast_hardcoded_source_password
|
|
nil # generate a new password everytime
|
|
end
|
|
|
|
def icecast_wait_after_reload
|
|
0 # 0 seconds
|
|
end
|
|
|
|
def jamtracks_dir
|
|
ENV['JAMTRACKS_DIR'] || File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "..", "jamtracks"))
|
|
end
|
|
|
|
def rabbitmq_host
|
|
"localhost"
|
|
end
|
|
|
|
def rabbitmq_port
|
|
5672
|
|
end
|
|
|
|
def external_hostname
|
|
'localhost'
|
|
end
|
|
|
|
def external_protocol
|
|
'http://'
|
|
end
|
|
|
|
def external_port
|
|
3000
|
|
end
|
|
|
|
def external_root_url
|
|
"#{external_protocol}#{external_hostname}#{(external_port == 80 || external_port == 443) ? '' : ':' + external_port.to_s}"
|
|
end
|
|
|
|
def max_audio_downloads
|
|
100
|
|
end
|
|
|
|
def send_join_session_email_notifications
|
|
true
|
|
end
|
|
|
|
def max_mind_working_dir
|
|
'tmp'
|
|
end
|
|
|
|
def max_track_upload_failures
|
|
10
|
|
end
|
|
|
|
def max_track_part_upload_failures
|
|
3
|
|
end
|
|
|
|
def max_good_full_score
|
|
40
|
|
end
|
|
|
|
def max_yellow_full_score
|
|
70
|
|
end
|
|
|
|
def max_red_full_score
|
|
100
|
|
end
|
|
|
|
def scoring_timeout_minutes
|
|
30
|
|
end
|
|
|
|
def scoring_timeout_threshold
|
|
2 # don't put to 1; it'll break tests
|
|
end
|
|
|
|
def recordings_stale_time
|
|
7
|
|
end
|
|
|
|
def source_changes_missing_secs
|
|
1
|
|
end
|
|
|
|
def lock_connections
|
|
false
|
|
end
|
|
|
|
def signing_step_max_time
|
|
40 # 40 seconds
|
|
end
|
|
|
|
def signing_job_queue_max_time
|
|
600 # 20 seconds
|
|
end
|
|
|
|
def one_free_jamtrack_per_user
|
|
true
|
|
end
|
|
|
|
def secret_token
|
|
'foobar'
|
|
end
|
|
|
|
def unsubscribe_token
|
|
'blah'
|
|
end
|
|
|
|
def error_on_fraud
|
|
true
|
|
end
|
|
|
|
def expire_fingerprint_days
|
|
14
|
|
end
|
|
|
|
def found_conflict_count
|
|
1
|
|
end
|
|
|
|
def google_public_server_key
|
|
"AIzaSyCPTPq5PEcl4XWcm7NZ2IGClZlbsiE8JNo"
|
|
end
|
|
|
|
def estimated_jam_track_time
|
|
40
|
|
end
|
|
|
|
def estimated_fast_mixdown_time
|
|
30
|
|
end
|
|
|
|
def estimated_slow_mixdown_time
|
|
80
|
|
end
|
|
|
|
def num_packaging_nodes
|
|
2
|
|
end
|
|
|
|
def signing_job_signing_max_time
|
|
300
|
|
end
|
|
|
|
def mixdown_job_queue_max_time
|
|
600
|
|
end
|
|
|
|
def mixdown_step_max_time
|
|
300
|
|
end
|
|
|
|
def download_tracker_day_range
|
|
30
|
|
end
|
|
|
|
def guard_against_browser_fraud
|
|
true
|
|
end
|
|
|
|
private
|
|
|
|
def audiomixer_workspace_path
|
|
if ENV['WORKSPACE']
|
|
dev_path = ENV['WORKSPACE']
|
|
else
|
|
dev_path = ENV['HOME']
|
|
end
|
|
|
|
dev_path = "#{dev_path}/audiomixer/audiomixer/audiomixerapp"
|
|
dev_path if File.exist? dev_path
|
|
end
|
|
|
|
end
|
|
|
|
klass.new
|
|
end
|
|
|
|
def run_tests? type
|
|
type = type.to_s.capitalize
|
|
|
|
ENV["RUN_#{type}_TESTS"] == "1" || ENV[type] == "1" || ENV['ALL_TESTS'] == "1"
|
|
end
|
|
|
|
# you have go out of your way to update 'updated_at '
|
|
def set_updated_at(resource, time)
|
|
begin
|
|
ActiveRecord::Base.record_timestamps = false
|
|
resource.updated_at = time
|
|
resource.save!(validate: false)
|
|
ensure
|
|
# very important to turn it back; it'll break all tests otherwise
|
|
ActiveRecord::Base.record_timestamps = true
|
|
end
|
|
end
|
|
|
|
def wipe_s3_test_bucket
|
|
begin
|
|
# don't bother if the user isn't doing AWS tests
|
|
if run_tests? :aws
|
|
test_config = app_config
|
|
s3 = AWS::S3.new(:access_key_id => test_config.aws_access_key_id,
|
|
:secret_access_key => test_config.aws_secret_access_key)
|
|
test_bucket = s3.buckets[JAMKAZAM_TESTING_BUCKET]
|
|
if test_bucket.name == JAMKAZAM_TESTING_BUCKET
|
|
test_bucket.objects.each do |obj|
|
|
obj.delete
|
|
end
|
|
end
|
|
end
|
|
rescue
|
|
puts "Unable to cleanup AWS"
|
|
end
|
|
end
|
|
|
|
# creates a maxmind 'GEO-124' zip file using the supplied CSV
|
|
def fake_geo_124_zip(geoisp_csv)
|
|
zipfile = Tempfile.new(['fake_geo_124', '.zip'])
|
|
|
|
Zip::File.open(Pathname.new(zipfile.path).realpath.to_s, Zip::File::CREATE) do |zipfile|
|
|
zipfile.add('fake_geo_124/GeoIPISP.csv', Pathname.new(geoisp_csv.path).realpath.to_s)
|
|
end
|
|
|
|
zipfile
|
|
end
|
|
|
|
def friend(user1, user2)
|
|
FactoryGirl.create(:friendship, user: user1, friend: user2)
|
|
FactoryGirl.create(:friendship, user: user2, friend: user1)
|
|
end
|