ocean-dynamo 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +10 -3
- data/lib/ocean-dynamo/tables.rb +25 -14
- data/lib/ocean-dynamo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 577f687042b84996c0c8b6490f970a3827f90b4f
|
4
|
+
data.tar.gz: 8632b8095f13fa066e3ee63831e723b5a9398c47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec0edf51b620ed1082879309efd47d53e5bcbd97bb4689f8c294c74f930cace03389afbc28479d81f080ace84aceeb4590bda4dd57a9b6a78c9ce39ae3ee28d1
|
7
|
+
data.tar.gz: fda47b459b7c0e71977dce1490bdea63d71668dfb38cf6bc568a589c5d625411b0f7a129cfc44f4820847e0f5787db7ecbef068b5c205edb1d113e7eb7891d14
|
data/README.rdoc
CHANGED
@@ -364,7 +364,14 @@ block:
|
|
364
364
|
regexp = Regexp.new("^.+_#{CHEF_ENV}_[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}-[0-9]{1,3}_test$")
|
365
365
|
cleaner = lambda {
|
366
366
|
c = Aws::DynamoDB::Client.new
|
367
|
-
c.list_tables.table_names.each
|
367
|
+
c.list_tables.table_names.each do |t|
|
368
|
+
begin
|
369
|
+
c.delete_table({table_name: t}) if t =~ regexp
|
370
|
+
rescue Aws::DynamoDB::Errors::LimitExceededException
|
371
|
+
sleep 1
|
372
|
+
retry
|
373
|
+
end
|
374
|
+
end
|
368
375
|
}
|
369
376
|
|
370
377
|
Then, inside the +RSpec.configure+ block:
|
@@ -372,8 +379,8 @@ Then, inside the +RSpec.configure+ block:
|
|
372
379
|
config.before(:suite) { cleaner.call }
|
373
380
|
config.after(:suite) { cleaner.call }
|
374
381
|
|
375
|
-
This will remove only those tables created by the specs on this particular machine and
|
376
|
-
environment. This is safe even on AWS and
|
382
|
+
This will remove only those test tables created by the specs on this particular machine and
|
383
|
+
environment. This is safe even on AWS and in parallel with other machines.
|
377
384
|
|
378
385
|
|
379
386
|
== Rails console
|
data/lib/ocean-dynamo/tables.rb
CHANGED
@@ -64,8 +64,9 @@ module OceanDynamo
|
|
64
64
|
|
65
65
|
|
66
66
|
def table_exists?(table)
|
67
|
-
return true if table.data_loaded?
|
68
67
|
begin
|
68
|
+
fresh_table_status
|
69
|
+
return true if table.data_loaded?
|
69
70
|
table.load
|
70
71
|
rescue Aws::DynamoDB::Errors::ResourceNotFoundException
|
71
72
|
return false
|
@@ -74,9 +75,14 @@ module OceanDynamo
|
|
74
75
|
end
|
75
76
|
|
76
77
|
|
78
|
+
def fresh_table_status
|
79
|
+
dynamo_client.describe_table(table_name: table_full_name).table.table_status
|
80
|
+
end
|
81
|
+
|
82
|
+
|
77
83
|
def wait_until_table_is_active
|
78
84
|
loop do
|
79
|
-
case
|
85
|
+
case st = fresh_table_status
|
80
86
|
when "ACTIVE"
|
81
87
|
update_table_if_required
|
82
88
|
return
|
@@ -84,11 +90,11 @@ module OceanDynamo
|
|
84
90
|
sleep 1
|
85
91
|
next
|
86
92
|
when "DELETING"
|
87
|
-
sleep 1 while table_exists?(dynamo_table)
|
93
|
+
sleep 1 while table_exists?(dynamo_table) && fresh_table_status == "DELETING"
|
88
94
|
create_table
|
89
95
|
return
|
90
96
|
else
|
91
|
-
raise UnknownTableStatus.new("Unknown DynamoDB table status '#{
|
97
|
+
raise UnknownTableStatus.new("Unknown DynamoDB table status '#{st}'")
|
92
98
|
end
|
93
99
|
end
|
94
100
|
end
|
@@ -111,21 +117,26 @@ module OceanDynamo
|
|
111
117
|
gsi = global_secondary_indexes.collect { |k, v| global_secondary_index_declaration k, v }
|
112
118
|
options[:global_secondary_indexes] = gsi unless gsi.blank?
|
113
119
|
dynamo_resource.create_table(options)
|
114
|
-
|
120
|
+
loop do
|
121
|
+
ts = fresh_table_status
|
122
|
+
break if ts == "ACTIVE"
|
123
|
+
sleep 1
|
124
|
+
end
|
115
125
|
setup_dynamo
|
116
126
|
true
|
117
127
|
end
|
118
128
|
|
119
129
|
|
120
130
|
def update_table_if_required
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
131
|
+
#puts "Updating table #{table_full_name}"
|
132
|
+
# attrs = table_attribute_definitions
|
133
|
+
# active_attrs = []
|
134
|
+
# dynamo_table.attribute_definitions.each do |k|
|
135
|
+
# active_attrs << { attribute_name: k.attribute_name, attribute_type: k.attribute_type }
|
136
|
+
# end
|
137
|
+
# return false if active_attrs == attrs
|
138
|
+
# options = { attribute_definitions: attrs }
|
139
|
+
# dynamo_table.update(options)
|
129
140
|
true
|
130
141
|
end
|
131
142
|
|
@@ -204,7 +215,7 @@ module OceanDynamo
|
|
204
215
|
|
205
216
|
|
206
217
|
def delete_table
|
207
|
-
return false unless
|
218
|
+
return false unless fresh_table_status == "ACTIVE"
|
208
219
|
dynamo_table.delete
|
209
220
|
true
|
210
221
|
end
|
data/lib/ocean-dynamo/version.rb
CHANGED