ocean-dynamo 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3c55ae49ff1ad852246e6af0b6727f284a10acc
4
- data.tar.gz: 17c013a3f22302b9a48a117a83e800e35297fb35
3
+ metadata.gz: 577f687042b84996c0c8b6490f970a3827f90b4f
4
+ data.tar.gz: 8632b8095f13fa066e3ee63831e723b5a9398c47
5
5
  SHA512:
6
- metadata.gz: 16351feeb2ff2d90ea76d87c9c352c752fc0d29eab5c77d8dc522d39779c69835ce90b88599823ffed8a638c01d26c1556807f91533c0a71337d0600bbc1a93a
7
- data.tar.gz: b9cdc4ea2f37f4dabd048264e61bc96f79b504b4d9fc6f89e94519e6f9c5f66a6bd097f614f35a2698296ba72ff55b756395752dac95b3bed0c0823f2fe1edd7
6
+ metadata.gz: ec0edf51b620ed1082879309efd47d53e5bcbd97bb4689f8c294c74f930cace03389afbc28479d81f080ace84aceeb4590bda4dd57a9b6a78c9ce39ae3ee28d1
7
+ data.tar.gz: fda47b459b7c0e71977dce1490bdea63d71668dfb38cf6bc568a589c5d625411b0f7a129cfc44f4820847e0f5787db7ecbef068b5c205edb1d113e7eb7891d14
@@ -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 { |t| c.delete_table({table_name: t}) if t =~ regexp }
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 for parallel testing.
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
@@ -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 dynamo_table.table_status
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 '#{dynamo_table.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
- sleep 1 until dynamo_table.table_status == "ACTIVE"
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
- attrs = table_attribute_definitions
122
- active_attrs = []
123
- dynamo_table.attribute_definitions.each do |k|
124
- active_attrs << { attribute_name: k.attribute_name, attribute_type: k.attribute_type }
125
- end
126
- return false if active_attrs == attrs
127
- options = { attribute_definitions: attrs }
128
- dynamo_table.update(options)
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 dynamo_table.data_loaded? && dynamo_table.table_status == "ACTIVE"
218
+ return false unless fresh_table_status == "ACTIVE"
208
219
  dynamo_table.delete
209
220
  true
210
221
  end
@@ -1,3 +1,3 @@
1
1
  module OceanDynamo
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean-dynamo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Bengtson