web47core 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -6
- data/README.md +32 -0
- data/bin/cron_server +0 -0
- data/lib/app/jobs/cron/server.rb +12 -12
- data/lib/app/models/concerns/core_system_configuration.rb +3 -13
- data/lib/app/models/concerns/email_able.rb +7 -1
- data/lib/app/models/concerns/time_zone_able.rb +4 -0
- data/test/jobs/cron/server_test.rb +160 -0
- data/test/models/concerns/system_configuration_test.rb +4 -15
- data/test/test_helper.rb +1 -1
- data/web47core.gemspec +2 -2
- metadata +8 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b81b89188cf055248f7ddfdad9f4690db1b5933006de7af6050143ecd0cc5ce2
|
4
|
+
data.tar.gz: b02ca0f7865c5c8a6f0b39979dd7afd7ff5f750552c69bd7798c71e9bfcb6342
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c5f6bf9c0d5e689e07fc9cb399abc878cd7ee997d90a02d62e7ca8f27aed12468e416a1e7d24f41b7a499e131a04bfd3654f753700d8e61edfb6c5de704995b
|
7
|
+
data.tar.gz: 33d4911d88b3b3dd2e37934d8ad9fcb367c02b2f866f0f0a0ab121a8a2fa99472bc4e7b882137de7345d008a4b1377f5ccc56aeea64e016b76ba350c5539629a
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
web47core (0.1.
|
4
|
+
web47core (0.1.1)
|
5
5
|
activesupport (~> 5.0)
|
6
|
-
aws-sdk-
|
6
|
+
aws-sdk-autoscaling
|
7
7
|
daemons
|
8
8
|
delayed_job_mongoid (~> 2.3)
|
9
9
|
email_format
|
@@ -67,15 +67,15 @@ GEM
|
|
67
67
|
ansi (1.5.0)
|
68
68
|
arel (9.0.0)
|
69
69
|
aws-eventstream (1.0.3)
|
70
|
-
aws-partitions (1.
|
70
|
+
aws-partitions (1.290.0)
|
71
|
+
aws-sdk-autoscaling (1.33.0)
|
72
|
+
aws-sdk-core (~> 3, >= 3.71.0)
|
73
|
+
aws-sigv4 (~> 1.1)
|
71
74
|
aws-sdk-core (3.92.0)
|
72
75
|
aws-eventstream (~> 1.0, >= 1.0.2)
|
73
76
|
aws-partitions (~> 1, >= 1.239.0)
|
74
77
|
aws-sigv4 (~> 1.1)
|
75
78
|
jmespath (~> 1.0)
|
76
|
-
aws-sdk-ec2 (1.151.0)
|
77
|
-
aws-sdk-core (~> 3, >= 3.71.0)
|
78
|
-
aws-sigv4 (~> 1.1)
|
79
79
|
aws-sigv4 (1.1.1)
|
80
80
|
aws-eventstream (~> 1.0, >= 1.0.2)
|
81
81
|
bson (4.8.2)
|
data/README.md
CHANGED
@@ -78,6 +78,14 @@ _Please do not ship to production code using the git repo, as the production ser
|
|
78
78
|
9. `SlackNotification`
|
79
79
|
10. `SmsNotification`
|
80
80
|
11. `Template`
|
81
|
+
12. `App47Logger` and `App47LoggerTest`
|
82
|
+
13. `Emailable` or `EmailAble` and `EamailbleTest`, be sure to change `Emailable` to `EmailAble`
|
83
|
+
14. `RedisConfiguration` and `RedisConfgurationTest`
|
84
|
+
15. `Searchable` and `SearchableTest`, be sure to change `Searchable` to `SearchAble`
|
85
|
+
15. `TimezoneAble` and `TimezoneAbleTest`
|
86
|
+
15. `CronJobServer` and `CronJobServerTest`
|
87
|
+
15. `JobCronTab` and `JobCronTabTest`
|
88
|
+
15. `CronTab`
|
81
89
|
|
82
90
|
#### Models
|
83
91
|
##### Concerns
|
@@ -108,3 +116,27 @@ class Account
|
|
108
116
|
has_many :users
|
109
117
|
end
|
110
118
|
```
|
119
|
+
##### Cron
|
120
|
+
Cron infrastructure for running jobs every minute, hour, day, week, month or some combination
|
121
|
+
1. Remove `config/initializers/job_cron_tabs.rb` that was previous used to ensure cron tabs, they will be loaded automatically now
|
122
|
+
2. Remove the `Delayed::Backend::Mongoid::Job` class definition, not the settings from `config/initializers/delayed_job.rb`, these are included in this gem now.
|
123
|
+
3. Cron jobs should extend from `Cron::Job` now and specify `cron_tab_entry` within the class.
|
124
|
+
```ruby
|
125
|
+
module Cron
|
126
|
+
class MyJob < Job
|
127
|
+
cron_tab_entry :daily
|
128
|
+
def perform
|
129
|
+
# do your work
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
```
|
134
|
+
Allowed values of cron_tab_entry are
|
135
|
+
* :always - run every minute
|
136
|
+
* :hourly - run every hour
|
137
|
+
* :daily - run every day
|
138
|
+
* :weekly - run every week on Sunday
|
139
|
+
* :monthly - run every month on the first day of the month
|
140
|
+
* '*/5 1,3 * 2 *' - Run according to unix crontab entry format. This would run every tuesday on the 1st and 3rd hour, for any minute divisable by 5, so 0, 5, 10, 15, etc..
|
141
|
+
|
142
|
+
4.
|
data/bin/cron_server
CHANGED
File without changes
|
data/lib/app/jobs/cron/server.rb
CHANGED
@@ -42,7 +42,7 @@ module Cron
|
|
42
42
|
end
|
43
43
|
time_to_next_run
|
44
44
|
rescue StandardError => error
|
45
|
-
App47Logger.log_error 'Unable to run cron
|
45
|
+
App47Logger.log_error 'Unable to run cron server', error
|
46
46
|
time_to_next_run
|
47
47
|
ensure
|
48
48
|
check_in
|
@@ -58,7 +58,7 @@ module Cron
|
|
58
58
|
#
|
59
59
|
def run_jobs
|
60
60
|
now = Time.now.utc
|
61
|
-
|
61
|
+
Cron::Tab.all.each { |tab| tab.run if tab.time_to_run?(now) }
|
62
62
|
end
|
63
63
|
|
64
64
|
#
|
@@ -86,7 +86,7 @@ module Cron
|
|
86
86
|
# Warm up a server on the next evaluation
|
87
87
|
#
|
88
88
|
def self.warm_up_server
|
89
|
-
return unless SystemConfiguration.
|
89
|
+
return unless SystemConfiguration.aws_auto_scaling_configured?
|
90
90
|
|
91
91
|
primary_server.auto_scale([primary_server.desired_server_count + 1, 10].min)
|
92
92
|
end
|
@@ -103,7 +103,7 @@ module Cron
|
|
103
103
|
return if primary.present? && primary.alive?
|
104
104
|
|
105
105
|
# no one else is in, so become primary
|
106
|
-
|
106
|
+
update! state: STATE_PRIMARY, last_check_in_at: Time.now.utc
|
107
107
|
end
|
108
108
|
|
109
109
|
#
|
@@ -111,9 +111,10 @@ module Cron
|
|
111
111
|
#
|
112
112
|
def become_secondary(user = nil)
|
113
113
|
if user.present?
|
114
|
-
update_attributes_and_log! user, state: STATE_SECONDARY
|
114
|
+
# update_attributes_and_log! user, state: STATE_SECONDARY
|
115
|
+
update! state: STATE_SECONDARY
|
115
116
|
else
|
116
|
-
|
117
|
+
update! state: STATE_SECONDARY
|
117
118
|
end
|
118
119
|
end
|
119
120
|
|
@@ -156,7 +157,7 @@ module Cron
|
|
156
157
|
# Auto scale environment
|
157
158
|
#
|
158
159
|
def check_auto_scale
|
159
|
-
return unless SystemConfiguration.
|
160
|
+
return unless SystemConfiguration.aws_auto_scaling_configured?
|
160
161
|
|
161
162
|
if delayed_jobs_count.eql?(0)
|
162
163
|
handle_zero_job_count
|
@@ -169,10 +170,9 @@ module Cron
|
|
169
170
|
# Returns the AWS AutoScaling Client
|
170
171
|
#
|
171
172
|
def client
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
@client ||= Aws::AutoScaling::Client.new(credentials)
|
173
|
+
@client ||= Aws::AutoScaling::Client.new(access_key_id: sys_config.aws_access_key_id,
|
174
|
+
secret_access_key: sys_config.aws_secret_access_key,
|
175
|
+
region: sys_config.aws_region)
|
176
176
|
end
|
177
177
|
|
178
178
|
def sys_config
|
@@ -253,7 +253,7 @@ module Cron
|
|
253
253
|
# Make sure we don't remove any workers with assigned jobs by accident
|
254
254
|
return if desired_count.positive? && desired_count <= current_desired_capacity
|
255
255
|
|
256
|
-
client.update_auto_scaling_group(auto_scaling_group_name: sys_config.
|
256
|
+
client.update_auto_scaling_group(auto_scaling_group_name: sys_config.aws_auto_scaling_group_name,
|
257
257
|
min_size: desired_count,
|
258
258
|
desired_capacity: desired_count)
|
259
259
|
end
|
@@ -47,8 +47,8 @@ module CoreSystemConfiguration
|
|
47
47
|
field :default_time_zone, type: String, default: 'US/Eastern'
|
48
48
|
# AWS
|
49
49
|
field :aws_region, type: String
|
50
|
-
field :
|
51
|
-
field :
|
50
|
+
field :aws_access_key_id, type: String
|
51
|
+
field :aws_secret_access_key, type: String
|
52
52
|
field :aws_auto_scaling_group_name, type: String
|
53
53
|
# Zendesk
|
54
54
|
field :zendesk_token, type: String
|
@@ -154,7 +154,7 @@ module CoreSystemConfiguration
|
|
154
154
|
# Determine if AWS is configured
|
155
155
|
#
|
156
156
|
def aws_configured?
|
157
|
-
[aws_region.present?,
|
157
|
+
[aws_region.present?, aws_access_key_id.present?, aws_secret_access_key.present?].all?
|
158
158
|
end
|
159
159
|
|
160
160
|
#
|
@@ -164,16 +164,6 @@ module CoreSystemConfiguration
|
|
164
164
|
aws_configured? && aws_auto_scaling_group_name.present?
|
165
165
|
end
|
166
166
|
|
167
|
-
#
|
168
|
-
# AWS client.
|
169
|
-
#
|
170
|
-
def aws_ec2_client
|
171
|
-
return nil unless aws_configured?
|
172
|
-
|
173
|
-
Aws::EC2::Client.new region: aws_region,
|
174
|
-
credentials: Aws::Credentials.new(aws_access_key, aws_access_secret)
|
175
|
-
end
|
176
|
-
|
177
167
|
#
|
178
168
|
# Return the zendesk documentation URL
|
179
169
|
#
|
@@ -1,3 +1,9 @@
|
|
1
|
+
begin
|
2
|
+
require 'email_format'
|
3
|
+
rescue LoadError
|
4
|
+
raise "You need to add gem 'email_format' to your Gemfile if you wish to use it."
|
5
|
+
end
|
6
|
+
|
1
7
|
#
|
2
8
|
# Objects that emails can be sent too...
|
3
9
|
#
|
@@ -15,7 +21,7 @@ module EmailAble
|
|
15
21
|
#
|
16
22
|
# Validations
|
17
23
|
#
|
18
|
-
validates :email,
|
24
|
+
validates :email, email_format: { strict: true }
|
19
25
|
#
|
20
26
|
# Callbacks
|
21
27
|
#
|
@@ -0,0 +1,160 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Cron
|
4
|
+
class ServerTest < ActiveSupport::TestCase
|
5
|
+
context 'Delayed job counting' do
|
6
|
+
setup do
|
7
|
+
@server = Cron::Server.find_or_create_server
|
8
|
+
Delayed::Worker.delay_jobs = true
|
9
|
+
end
|
10
|
+
teardown do
|
11
|
+
Delayed::Worker.delay_jobs = false
|
12
|
+
end
|
13
|
+
should 'return zero' do
|
14
|
+
assert_equal 0, @server.delayed_jobs_count
|
15
|
+
end
|
16
|
+
should 'return three' do
|
17
|
+
3.times do
|
18
|
+
MockDelayedJob.new.background
|
19
|
+
end
|
20
|
+
assert_equal 3, @server.delayed_jobs_count
|
21
|
+
end
|
22
|
+
should 'return zero with failed job' do
|
23
|
+
MockDelayedJob.new.background
|
24
|
+
job = Delayed::Backend::Mongoid::Job.first
|
25
|
+
job.set failed_at: Time.now.utc
|
26
|
+
assert_equal 0, @server.delayed_jobs_count
|
27
|
+
end
|
28
|
+
end
|
29
|
+
context 'AutoScalingJob' do
|
30
|
+
setup do
|
31
|
+
@auto_scaling_group_name = 'redmonocle-testing-group'
|
32
|
+
@config = SystemConfiguration.first
|
33
|
+
@config.set(aws_access_key_id: 'access_key_id',
|
34
|
+
aws_secret_access_key: 'secret_access_key',
|
35
|
+
aws_region: 'region',
|
36
|
+
aws_auto_scaling_group_name: @auto_scaling_group_name)
|
37
|
+
end
|
38
|
+
should 'not create any more instances if there are 1 - 249 jobs' do
|
39
|
+
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(49).at_least_once
|
40
|
+
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).never
|
41
|
+
Cron::Server.new.check_auto_scale
|
42
|
+
end
|
43
|
+
should 'create additional instances if there are 1,000 - 1,999 jobs and the number of instances currently running is less than the desired number of instances' do
|
44
|
+
Cron::Server.any_instance.expects(:current_desired_capacity).returns(0).at_least_once
|
45
|
+
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(51).at_least_once
|
46
|
+
params = { auto_scaling_group_name: @auto_scaling_group_name, min_size: 1, desired_capacity: 1 }
|
47
|
+
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).with(params).once
|
48
|
+
Cron::Server.new.check_auto_scale
|
49
|
+
end
|
50
|
+
should 'not create any additional instances if there are 1,000 - 1,999 jobs and the number of desired instances is less than or equal to the number of instances currently running' do
|
51
|
+
Cron::Server.any_instance.expects(:current_desired_capacity).returns(1).at_least_once
|
52
|
+
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(200).at_least_once
|
53
|
+
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).never
|
54
|
+
Cron::Server.new.check_auto_scale
|
55
|
+
end
|
56
|
+
should 'create additional instances if there are 2,000 - 2,999 jobs and the number of instances currently running is less than the desired number of instances' do
|
57
|
+
Cron::Server.any_instance.expects(:current_desired_capacity).returns(1).at_least_once
|
58
|
+
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(300).at_least_once
|
59
|
+
params = { auto_scaling_group_name: @auto_scaling_group_name, min_size: 2, desired_capacity: 2 }
|
60
|
+
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).with(params).once
|
61
|
+
Cron::Server.new.check_auto_scale
|
62
|
+
end
|
63
|
+
should 'not create any additional instances if there are 2,000 - 2,999 jobs and the number of desired instances is less than or equal to the number of instances currently running' do
|
64
|
+
Cron::Server.any_instance.expects(:current_desired_capacity).returns(3).at_least_once
|
65
|
+
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(750).at_least_once
|
66
|
+
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).never
|
67
|
+
Cron::Server.new.check_auto_scale
|
68
|
+
end
|
69
|
+
should 'create additional instances if there are 3,000 - 3,999 jobs and the number of instances currently running is less than the desired number of instances' do
|
70
|
+
Cron::Server.any_instance.expects(:current_desired_capacity).returns(1).at_least_once
|
71
|
+
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(300).at_least_once
|
72
|
+
params = { auto_scaling_group_name: @auto_scaling_group_name, min_size: 2, desired_capacity: 2 }
|
73
|
+
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).with(params).once
|
74
|
+
Cron::Server.new.check_auto_scale
|
75
|
+
end
|
76
|
+
should 'not create any additional instances if there are 3,000 - 3,999 jobs and the number of desired instances is less than or equal to the number of instances currently running' do
|
77
|
+
Cron::Server.any_instance.expects(:current_desired_capacity).returns(5).at_least_once
|
78
|
+
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(3_000).at_least_once
|
79
|
+
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).never
|
80
|
+
Cron::Server.new.check_auto_scale
|
81
|
+
end
|
82
|
+
should 'create additional instances if there are 4,000 jobs or more and the number of instances currently running is less than the desired number of instances' do
|
83
|
+
Cron::Server.any_instance.expects(:current_desired_capacity).returns(1).at_least_once
|
84
|
+
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(700).at_least_once
|
85
|
+
params = { auto_scaling_group_name: @auto_scaling_group_name, min_size: 3, desired_capacity: 3 }
|
86
|
+
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).with(params).once
|
87
|
+
Cron::Server.new.check_auto_scale
|
88
|
+
end
|
89
|
+
should 'not create any additional instances if there are 4,000 jobs or more and the number of desired instances is less than or equal to the number of instances currently running' do
|
90
|
+
Cron::Server.any_instance.expects(:current_desired_capacity).returns(7).at_least_once
|
91
|
+
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(4_000).at_least_once
|
92
|
+
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).never
|
93
|
+
Cron::Server.new.check_auto_scale
|
94
|
+
end
|
95
|
+
should 'remove all instances if there are no jobs left to run' do
|
96
|
+
Cron::Server.any_instance.expects(:current_desired_capacity).returns(7).at_least_once
|
97
|
+
Cron::Server.any_instance.expects(:delayed_jobs_count).returns(0).at_least_once
|
98
|
+
params = { auto_scaling_group_name: @auto_scaling_group_name, min_size: 0, desired_capacity: 0 }
|
99
|
+
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).with(params).once
|
100
|
+
Cron::Server.new.check_auto_scale
|
101
|
+
end
|
102
|
+
should 'create additional instances by warming up a server' do
|
103
|
+
Cron::Server.any_instance.expects(:current_desired_capacity).returns(0).at_least_once
|
104
|
+
# Cron::Server.any_instance.expects(:delayed_jobs_count).returns(0).at_least_once
|
105
|
+
params = { auto_scaling_group_name: @auto_scaling_group_name, min_size: 1, desired_capacity: 1 }
|
106
|
+
Aws::AutoScaling::Client.any_instance.expects(:update_auto_scaling_group).with(params).once
|
107
|
+
Cron::Server.find_or_create_server.become_primary
|
108
|
+
Cron::Server.warm_up_server
|
109
|
+
end
|
110
|
+
end
|
111
|
+
context 'Run jobs' do
|
112
|
+
setup do
|
113
|
+
Cron::JobTab.ensure_cron_tabs
|
114
|
+
Cron::Tab.any_instance.expects(:time_to_run?).returns(true).at_least_once
|
115
|
+
Cron::TrimCronServers.expects(:perform_later).once
|
116
|
+
Cron::TrimNotifications.expects(:perform_later).once
|
117
|
+
end
|
118
|
+
should 'run jobs' do
|
119
|
+
assert_nothing_raised do
|
120
|
+
Cron::Server.find_or_create_server.execute
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
context 'Highlander' do
|
125
|
+
setup do
|
126
|
+
@s1 = Cron::Server.create! host_name: 's1', pid: '1123'
|
127
|
+
@s2 = Cron::Server.create! host_name: 's2', pid: '1124'
|
128
|
+
@s3 = Cron::Server.create! host_name: 's3', pid: '1125'
|
129
|
+
@s4 = Cron::Server.create! host_name: 's4', pid: '1126'
|
130
|
+
end
|
131
|
+
should 'allow one to become primary' do
|
132
|
+
assert_nothing_raised { @s1.become_primary }
|
133
|
+
assert_equal 1, Cron::Server.where(state: 'primary').count
|
134
|
+
end
|
135
|
+
should 'prevent second primary' do
|
136
|
+
assert_nothing_raised { @s1.become_primary }
|
137
|
+
refute @s2.update_attributes state: 'primary'
|
138
|
+
assert_equal 1, Cron::Server.where(state: 'primary').count
|
139
|
+
end
|
140
|
+
should 'determine to be alive ' do
|
141
|
+
server = Cron::Server.new host_name: 's1', pid: '1123', last_check_in_at: Time.now.utc
|
142
|
+
assert server.alive?
|
143
|
+
refute server.dead?
|
144
|
+
end
|
145
|
+
should 'determine to be dead' do
|
146
|
+
server = Cron::Server.new host_name: 's1', pid: '1123', last_check_in_at: 2.minutes.ago
|
147
|
+
refute server.alive?
|
148
|
+
assert server.dead?
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
class MockDelayedJob
|
155
|
+
def background
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
handle_asynchronously :background
|
160
|
+
end
|
@@ -33,8 +33,8 @@ class SystemConfigurationTest < ActiveSupport::TestCase
|
|
33
33
|
should_have_field :zendesk_updates_path, type: String, klass: SystemConfiguration, default: 'hc'
|
34
34
|
# AWS
|
35
35
|
should_have_field :aws_region, type: String, klass: SystemConfiguration
|
36
|
-
should_have_field :
|
37
|
-
should_have_field :
|
36
|
+
should_have_field :aws_secret_access_key, type: String, klass: SystemConfiguration
|
37
|
+
should_have_field :aws_secret_access_key, type: String, klass: SystemConfiguration
|
38
38
|
should_have_field :aws_auto_scaling_group_name, type: String, klass: SystemConfiguration
|
39
39
|
# Switchboard
|
40
40
|
should_have_field :switchboard_base_url, type: String, klass: SystemConfiguration, default: 'https://switchboard.app47.com'
|
@@ -128,27 +128,16 @@ class SystemConfigurationTest < ActiveSupport::TestCase
|
|
128
128
|
assert SystemConfiguration.configuration.update aws_region: 'us'
|
129
129
|
refute SystemConfiguration.aws_configured?
|
130
130
|
refute SystemConfiguration.aws_auto_scaling_configured?
|
131
|
-
assert SystemConfiguration.configuration.update
|
131
|
+
assert SystemConfiguration.configuration.update aws_access_key_id: 'key'
|
132
132
|
refute SystemConfiguration.aws_configured?
|
133
133
|
refute SystemConfiguration.aws_auto_scaling_configured?
|
134
|
-
assert SystemConfiguration.configuration.update
|
134
|
+
assert SystemConfiguration.configuration.update aws_secret_access_key: 'abc123'
|
135
135
|
assert SystemConfiguration.aws_configured?
|
136
136
|
refute SystemConfiguration.aws_auto_scaling_configured?
|
137
137
|
assert SystemConfiguration.configuration.update aws_auto_scaling_group_name: 'g1'
|
138
138
|
assert SystemConfiguration.aws_configured?
|
139
139
|
assert SystemConfiguration.aws_auto_scaling_configured?
|
140
140
|
end
|
141
|
-
should 'not retrieve client' do
|
142
|
-
assert_nil SystemConfiguration.aws_ec2_client
|
143
|
-
end
|
144
|
-
should 'retrieve client' do
|
145
|
-
assert SystemConfiguration.configuration.update aws_region: 'us',
|
146
|
-
aws_access_key: 'key',
|
147
|
-
aws_access_secret: 'key'
|
148
|
-
client = SystemConfiguration.aws_ec2_client
|
149
|
-
assert_not_nil client
|
150
|
-
assert client.is_a?(Aws::EC2::Client)
|
151
|
-
end
|
152
141
|
end
|
153
142
|
|
154
143
|
context 'twilio configuration' do
|
data/test/test_helper.rb
CHANGED
data/web47core.gemspec
CHANGED
@@ -8,7 +8,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
8
8
|
Gem::Specification.new do |spec|
|
9
9
|
spec.required_ruby_version = '~> 2.4.1'
|
10
10
|
spec.name = 'web47core'
|
11
|
-
spec.version = '0.1.
|
11
|
+
spec.version = '0.1.1'
|
12
12
|
spec.authors = ['Chris Schroeder']
|
13
13
|
spec.email = ['chris@app47.com']
|
14
14
|
spec.summary = 'App47 Web Core Library.'
|
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
|
26
26
|
# spec.add_dependency 'json'
|
27
27
|
spec.add_runtime_dependency 'activesupport', '~> 5.0'
|
28
|
-
spec.add_runtime_dependency 'aws-sdk-
|
28
|
+
spec.add_runtime_dependency 'aws-sdk-autoscaling'
|
29
29
|
spec.add_runtime_dependency 'delayed_job_mongoid', '~> 2.3'
|
30
30
|
spec.add_runtime_dependency 'daemons'
|
31
31
|
spec.add_runtime_dependency 'email_format'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web47core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Schroeder
|
@@ -25,25 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: aws-sdk-
|
28
|
+
name: aws-sdk-autoscaling
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.140'
|
34
|
-
- - "<="
|
31
|
+
- - ">="
|
35
32
|
- !ruby/object:Gem::Version
|
36
|
-
version: '
|
33
|
+
version: '0'
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
|
-
- - "
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '1.140'
|
44
|
-
- - "<="
|
38
|
+
- - ">="
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
40
|
+
version: '0'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: delayed_job_mongoid
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -556,6 +550,7 @@ files:
|
|
556
550
|
- test/fixtures/redis/options.yml
|
557
551
|
- test/fixtures/redis/sentinel.yml
|
558
552
|
- test/fixtures/redis/url.yml
|
553
|
+
- test/jobs/cron/server_test.rb
|
559
554
|
- test/jobs/cron/switchboard_sync_configuration_test.rb
|
560
555
|
- test/jobs/cron/trim_cron_servers_test.rb
|
561
556
|
- test/jobs/cron/trim_failed_delayed_jobs_test.rb
|
@@ -611,6 +606,7 @@ test_files:
|
|
611
606
|
- test/fixtures/redis/options.yml
|
612
607
|
- test/fixtures/redis/sentinel.yml
|
613
608
|
- test/fixtures/redis/url.yml
|
609
|
+
- test/jobs/cron/server_test.rb
|
614
610
|
- test/jobs/cron/switchboard_sync_configuration_test.rb
|
615
611
|
- test/jobs/cron/trim_cron_servers_test.rb
|
616
612
|
- test/jobs/cron/trim_failed_delayed_jobs_test.rb
|