miasma 0.2.34 → 0.2.36

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92b8d21e370e8219b46aee1a6bddae5d13c36256
4
- data.tar.gz: 8041dc78826128dd9d3ca8e0ae29815b0059b093
3
+ metadata.gz: f76d5c922de15936a098e29670707f23ca81b498
4
+ data.tar.gz: e9cff2b8a5130c0133a10d82e1cf188f3987e2dc
5
5
  SHA512:
6
- metadata.gz: 48b93716ce6f30272486cf38f9117cfcf0ce1f6e287b4beb552ecf4b9c86246260688a5f5045954a92a1a44e3879e296b3e0df464e878be55f4ee7fd9ab69fdf
7
- data.tar.gz: 00d689e12cde2cea79fd86153094b2e09c8587c2d2bda34fe6eda60a9c2ce7f281f1bb82d99aad48669d283a6bcfec4ee0c6c12b2af653f435af93dcf5527a98
6
+ metadata.gz: 579a263c2aa3f4dd5231af2852fd401e3b872dbf117f737dfdebcf8808364640209e8515d8516b183a18a1ebd86558fa160865898717d3de42241aab9823753e
7
+ data.tar.gz: 982331e848c3a20c67e6e32cd6a5fb24923fab270db778c2e639b0c577bc502931bc0464c464de913f873d864eee7d7e9b85715a7b91eb74a4a3eef09f91b3ef
@@ -1,3 +1,6 @@
1
+ # v0.2.36
2
+ * Refactor abstract model specs
3
+
1
4
  # v0.2.34
2
5
  * Remove deprecated method usage on http library
3
6
 
@@ -39,7 +39,7 @@ module Miasma
39
39
  end
40
40
 
41
41
  attribute :name, String
42
- attribute :state, Symbol, :allowed_values => [:active, :pending]
42
+ attribute :state, Symbol, :allowed_values => [:active, :pending, :terminated]
43
43
  attribute :status, String
44
44
  attribute :servers, Server, :multiple => true, :coerce => lambda{|v| Server.new(v)}
45
45
  attribute :public_addresses, Address, :multiple => true, :coerce => lambda{|v| Address.new(v)}
@@ -16,6 +16,8 @@ module Miasma
16
16
  attribute :status_reason, String
17
17
  attribute :updated, Time, :coerce => lambda{|v| Time.parse(v.to_s)}
18
18
 
19
+ on_missing :reload
20
+
19
21
  attr_reader :stack
20
22
 
21
23
  def initialize(stack, args={})
@@ -0,0 +1,12 @@
1
+ Dir.glob(File.join(File.dirname(__FILE__), 'specs', '*.rb')).each do |s_file|
2
+ s_file_name = File.basename(s_file).sub('.rb', '')
3
+ require "miasma/specs/#{s_file_name}"
4
+ end
5
+
6
+ def miasma_spec_sleep(interval=20)
7
+ if(ENV['MIASMA_TEST_LIVE_REQUESTS'])
8
+ sleep(20)
9
+ else
10
+ sleep(0.1)
11
+ end
12
+ end
@@ -0,0 +1,118 @@
1
+ MIASMA_COMPUTE_ABSTRACT = ->{
2
+
3
+ # Required `let`s:
4
+ # * compute: compute API
5
+ # * build_args: server build arguments [Smash]
6
+
7
+ describe Miasma::Models::Compute, :vcr do
8
+
9
+ it 'should provide #servers collection' do
10
+ compute.servers.must_be_kind_of Miasma::Models::Compute::Servers
11
+ end
12
+
13
+ describe Miasma::Models::Compute::Servers do
14
+
15
+ it 'should provide instance class used within collection' do
16
+ compute.servers.model.must_equal Miasma::Models::Compute::Server
17
+ end
18
+
19
+ it 'should build new instance for collection' do
20
+ instance = compute.servers.build(:name => 'test')
21
+ instance.must_be_kind_of Miasma::Models::Compute::Server
22
+ end
23
+
24
+ it 'should provide #all servers' do
25
+ compute.servers.all.must_be_kind_of Array
26
+ end
27
+
28
+ end
29
+
30
+ describe Miasma::Models::Compute::Server do
31
+
32
+ before do
33
+ unless($miasma_instance)
34
+ VCR.use_cassette('Miasma_Models_Compute_Aws/GLOBAL_compute_instance_create') do
35
+ @instance = compute.servers.build(build_args)
36
+ @instance.save
37
+ until(@instance.state == :running)
38
+ miasma_spec_sleep
39
+ @instance.reload
40
+ end
41
+ $miasma_instance = @instance
42
+ end
43
+ Kernel.at_exit do
44
+ VCR.use_cassette('Miasma_Models_Compute_Aws/GLOBAL_compute_instance_destroy') do
45
+ $miasma_instance.destroy
46
+ end
47
+ end
48
+ else
49
+ @instance = $miasma_instance
50
+ end
51
+ @instance.reload
52
+ end
53
+
54
+ let(:instance){ @instance }
55
+
56
+ describe 'instance methods' do
57
+
58
+ it 'should have a name' do
59
+ instance.name.must_equal build_args[:name]
60
+ end
61
+
62
+ it 'should have an image_id' do
63
+ instance.image_id.must_equal build_args[:image_id]
64
+ end
65
+
66
+ it 'should have a flavor_id' do
67
+ instance.flavor_id.must_equal build_args[:flavor_id]
68
+ end
69
+
70
+ it 'should have an address' do
71
+ instance.addresses.detect do |addr|
72
+ addr.version == 4
73
+ end.address.must_match /^(\d+)+\.(\d+)\.(\d+)\.(\d+)$/
74
+ end
75
+
76
+ it 'should have a status' do
77
+ instance.status.wont_be_nil
78
+ end
79
+
80
+ it 'should be in :running state' do
81
+ instance.state.must_equal :running
82
+ end
83
+
84
+ end
85
+
86
+ end
87
+
88
+ describe 'instance lifecycle' do
89
+ it 'should create new server, reload details and destroy server' do
90
+ instance = compute.servers.build(build_args)
91
+ instance.save
92
+ instance.id.wont_be_nil
93
+ instance.state.must_equal :pending
94
+ compute.servers.reload.get(instance.id).wont_be_nil
95
+ until(instance.state == :running)
96
+ miasma_spec_sleep
97
+ instance.reload
98
+ end
99
+ instance.state.must_equal :running
100
+ instance.destroy
101
+ while(instance.state == :running)
102
+ miasma_spec_sleep
103
+ instance.reload
104
+ end
105
+ [:pending, :terminated].must_include instance.state
106
+ if(instance.state == :pending)
107
+ until(instance.state == :terminated)
108
+ miasma_spec_sleep
109
+ instance.reload
110
+ end
111
+ instance.state.must_equal :terminated
112
+ end
113
+ end
114
+
115
+ end
116
+
117
+ end
118
+ }
@@ -0,0 +1,88 @@
1
+ MIASMA_LOAD_BALANCER_ABSTRACT = ->{
2
+
3
+ # Required `let`s:
4
+ # * load_balancer: load balancer API
5
+ # * build_args: load balancer build arguments [Smash]
6
+
7
+ describe Miasma::Models::LoadBalancer, :vcr do
8
+
9
+ it 'should provide #balancers collection' do
10
+ load_balancer.balancers.must_be_kind_of Miasma::Models::LoadBalancer::Balancers
11
+ end
12
+
13
+ describe Miasma::Models::LoadBalancer::Balancers do
14
+
15
+ it 'should provide instance class used within collection' do
16
+ load_balancer.balancers.model.must_equal Miasma::Models::LoadBalancer::Balancer
17
+ end
18
+
19
+ it 'should build new instance for collection' do
20
+ instance = load_balancer.balancers.build
21
+ instance.must_be_kind_of Miasma::Models::LoadBalancer::Balancer
22
+ end
23
+
24
+ it 'should provide #all balancers' do
25
+ load_balancer.balancers.all.must_be_kind_of Array
26
+ end
27
+
28
+ end
29
+
30
+ describe Miasma::Models::LoadBalancer::Balancer do
31
+
32
+ before do
33
+ unless($miasma_balancer)
34
+ VCR.use_cassette('Miasma_Models_LoadBalancer_Aws/GLOBAL_load_balancer_create') do
35
+ @balancer = load_balancer.balancers.build(build_args)
36
+ @balancer.save
37
+ until(@balancer.state == :active)
38
+ miasma_spec_sleep
39
+ @balancer.reload
40
+ end
41
+ $miasma_balancer = @balancer
42
+ end
43
+ Kernel.at_exit do
44
+ VCR.use_cassette('Miasma_Models_LoadBalancer_Aws/GLOBAL_load_balancer_destroy') do
45
+ $miasma_balancer.destroy
46
+ end
47
+ end
48
+ else
49
+ @balancer = $miasma_balancer
50
+ end
51
+ @balancer.reload
52
+ end
53
+
54
+ let(:balancer){ @balancer }
55
+
56
+ describe 'collection' do
57
+
58
+ it 'should include balancer' do
59
+ load_balancer.balancers.reload.get(balancer.id).wont_be_nil
60
+ end
61
+
62
+ end
63
+
64
+ describe 'balancer methods' do
65
+
66
+ it 'should have a name' do
67
+ balancer.name.must_equal build_args[:name]
68
+ end
69
+
70
+ it 'should be in :active state' do
71
+ balancer.state.must_equal :active
72
+ end
73
+
74
+ it 'should have a status' do
75
+ balancer.status.wont_be_nil
76
+ balancer.status.must_be_kind_of String
77
+ end
78
+
79
+ it 'should have a public address' do
80
+ balancer.public_addresses.wont_be :empty?
81
+ end
82
+
83
+ end
84
+
85
+ end
86
+
87
+ end
88
+ }
@@ -0,0 +1,121 @@
1
+ MIASMA_ORCHESTRATION_ABSTRACT = ->{
2
+
3
+ # Required `let`s:
4
+ # * orchestration: orchestration API
5
+ # * build_args: stack build arguments [Smash]
6
+
7
+ describe Miasma::Models::Orchestration, :vcr do
8
+
9
+ it 'should provide #stacks collection' do
10
+ orchestration.stacks.must_be_kind_of Miasma::Models::Orchestration::Stacks
11
+ end
12
+
13
+ describe Miasma::Models::Orchestration::Stacks do
14
+
15
+ it 'should provide instance class used within collection' do
16
+ orchestration.stacks.model.must_equal Miasma::Models::Orchestration::Stack
17
+ end
18
+
19
+ it 'should build new instance for collection' do
20
+ instance = orchestration.stacks.build
21
+ instance.must_be_kind_of Miasma::Models::Orchestration::Stack
22
+ end
23
+
24
+ it 'should provide #all stacks' do
25
+ orchestration.stacks.all.must_be_kind_of Array
26
+ end
27
+
28
+ end
29
+
30
+ describe Miasma::Models::Orchestration::Stacks do
31
+
32
+ before do
33
+ unless($miasma_stack)
34
+ VCR.use_cassette('Miasma_Models_Orchestration_Aws/GLOBAL_orchestration_stack_create') do
35
+ @stack = orchestration.stacks.build(build_args)
36
+ @stack.save
37
+ until(@stack.state == :create_complete)
38
+ miasma_spec_sleep
39
+ @stack.reload
40
+ end
41
+ @stack.template
42
+ orchestration.stacks.reload
43
+ $miasma_stack = @stack
44
+ end
45
+ Kernel.at_exit do
46
+ VCR.use_cassette('Miasma_Models_Compute_Aws/GLOBAL_orchestration_stack_destroy') do
47
+ $miasma_stack.destroy
48
+ end
49
+ end
50
+ else
51
+ @stack = $miasma_stack
52
+ end
53
+ @stack.reload
54
+ end
55
+
56
+ let(:stack){ @stack }
57
+
58
+ describe 'collection' do
59
+
60
+ it 'should include stack' do
61
+ orchestration.stacks.all.detect{|s| s.id == stack.id}.wont_be_nil
62
+ orchestration.stacks.get(stack.id).wont_be_nil
63
+ end
64
+
65
+ end
66
+
67
+ describe 'instance methods' do
68
+
69
+ it 'should have a name' do
70
+ stack.name.must_equal build_args[:name]
71
+ end
72
+
73
+ it 'should be in :create_complete state' do
74
+ stack.state.must_equal :create_complete
75
+ end
76
+
77
+ it 'should have a status' do
78
+ stack.status.must_be_kind_of String
79
+ end
80
+
81
+ it 'should have a creation time' do
82
+ stack.created.must_be_kind_of Time
83
+ end
84
+
85
+ it 'should have parameters used for creation' do
86
+ stack.parameters.to_smash.must_equal build_args[:parameters].to_smash
87
+ end
88
+
89
+ it 'should include the templated used for creation' do
90
+ stack.template.to_smash.must_equal build_args[:template].to_smash
91
+ end
92
+
93
+ end
94
+
95
+ end
96
+
97
+ describe 'instance lifecycle' do
98
+ it 'should create new stack, reload details and destroy stack' do
99
+ stack = orchestration.stacks.build(build_args.merge(:name => 'miasma-test-stack-2'))
100
+ stack.save
101
+ stack.id.wont_be_nil
102
+ stack.state.must_equal :create_in_progress
103
+ orchestration.stacks.reload.get(stack.id).wont_be_nil
104
+ until(stack.state == :create_complete)
105
+ miasma_spec_sleep
106
+ stack.reload
107
+ end
108
+ stack.state.must_equal :create_complete
109
+ stack.destroy
110
+ [:delete_in_progress, :delete_complete].must_include stack.state
111
+ until(stack.state == :delete_complete)
112
+ miasma_spec_sleep
113
+ stack.reload
114
+ end
115
+ stack.state.must_equal :delete_complete
116
+ end
117
+
118
+ end
119
+
120
+ end
121
+ }
@@ -0,0 +1,113 @@
1
+ require 'open-uri'
2
+
3
+ MIASMA_STORAGE_ABSTRACT = ->{
4
+
5
+ # Required `let`s:
6
+ # * storage: storage API
7
+
8
+ describe Miasma::Models::Storage, :vcr do
9
+
10
+ it 'should provide #buckets collection' do
11
+ storage.buckets.must_be_kind_of Miasma::Models::Storage::Buckets
12
+ end
13
+
14
+ describe Miasma::Models::Storage::Buckets do
15
+
16
+ it 'should provide instance class used within collection' do
17
+ storage.buckets.model.must_equal Miasma::Models::Storage::Bucket
18
+ end
19
+
20
+ it 'should build new instance for collection' do
21
+ storage.buckets.build.must_be_kind_of Miasma::Models::Storage::Bucket
22
+ end
23
+
24
+ it 'should provide #all buckets' do
25
+ storage.buckets.all.must_be_kind_of Array
26
+ end
27
+
28
+ end
29
+
30
+ describe Miasma::Models::Storage::Bucket do
31
+
32
+ it 'should act like a bucket' do
33
+ bucket = storage.buckets.build(:name => 'miasma-test-bucket-010')
34
+ bucket.save
35
+ bucket.reload
36
+
37
+ # should include the bucket
38
+ storage.buckets.reload.get('miasma-test-bucket-010').wont_be_nil
39
+ # should have a name
40
+ bucket.name.must_equal 'miasma-test-bucket-010'
41
+ # should have a #files collection
42
+ bucket.files.must_be_kind_of Miasma::Models::Storage::Files
43
+ #should provide #all files
44
+ bucket.files.all.must_be_kind_of Array
45
+ # should include reference to containing bucket
46
+ bucket.files.bucket.must_equal bucket
47
+ # should build new instance for collection
48
+ bucket.files.build.must_be_kind_of Miasma::Models::Storage::File
49
+
50
+ file_content = 'blahblahblah'
51
+ file = bucket.files.build
52
+ file.name = 'miasma-test-file'
53
+ file.body = file_content
54
+ file.save
55
+ file.reload
56
+
57
+ # should have a name
58
+ file.name.must_equal 'miasma-test-file'
59
+ # should have a size
60
+ file.size.must_equal file_content.size
61
+ # should have an updated timestamp
62
+ file.updated.must_be_kind_of Time
63
+ # should create a valid url
64
+ open(file.url).read.must_equal file_content
65
+ # should have a body
66
+ file.body.must_respond_to :readpartial
67
+ file.body.readpartial(Miasma::Models::Storage::READ_BODY_CHUNK_SIZE).must_equal file_content
68
+ file.destroy
69
+
70
+ big_file_content = '*' * Miasma::Models::Storage::MAX_BODY_SIZE_FOR_STRINGIFY
71
+ big_file = bucket.files.build
72
+ big_file.name = 'miasma-test-file-big'
73
+ big_file.body = big_file_content
74
+ big_file.save
75
+ big_file.reload
76
+
77
+ # should be the correct size
78
+ big_file.size.must_equal big_file.size
79
+ # should provide streaming body
80
+ big_file.body.must_respond_to :readpartial
81
+ content = big_file.body.readpartial(big_file.size)
82
+ content.must_equal big_file_content
83
+ big_file.destroy
84
+
85
+ require 'tempfile'
86
+ local_io_file = Tempfile.new('miasma-storage-test')
87
+ big_io_content = '*' * (Miasma::Models::Storage::MAX_BODY_SIZE_FOR_STRINGIFY * 1.3)
88
+ local_io_file.write big_io_content
89
+ local_io_file.flush
90
+ local_io_file.rewind
91
+ remote_file = bucket.files.build
92
+ remote_file.name = 'miasma-test-io-object-010'
93
+ remote_file.body = local_io_file
94
+ remote_file.save
95
+ remote_file.reload
96
+
97
+ # should be the correct size
98
+ remote_file.size.must_equal local_io_file.size
99
+ # should provide streaming body
100
+ remote_file.body.must_respond_to :readpartial
101
+ content = ''
102
+ while(chunk = remote_file.body.readpartial(1024))
103
+ content << chunk
104
+ end
105
+ content.must_equal big_io_content
106
+ remote_file.destroy
107
+ bucket.destroy
108
+ end
109
+
110
+ end
111
+
112
+ end
113
+ }
@@ -1,4 +1,4 @@
1
1
  module Miasma
2
2
  # current library version
3
- VERSION = Gem::Version.new('0.2.34')
3
+ VERSION = Gem::Version.new('0.2.36')
4
4
  end
@@ -19,11 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_runtime_dependency 'miasma-aws'
20
20
  s.add_runtime_dependency 'miasma-open-stack'
21
21
  s.add_runtime_dependency 'miasma-rackspace'
22
- s.executables << 'miasma-test'
23
22
  # Include development dependencies for running tests
24
23
  s.add_development_dependency 'pry'
25
- s.add_development_dependency 'minitest'
26
- s.add_development_dependency 'vcr'
27
- s.add_development_dependency 'webmock'
28
24
  s.files = Dir['{bin,lib}/**/*'] + %w(miasma.gemspec README.md CHANGELOG.md LICENSE)
29
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miasma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.34
4
+ version: 0.2.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-29 00:00:00.000000000 Z
11
+ date: 2016-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -148,59 +148,15 @@ dependencies:
148
148
  - - ">="
149
149
  - !ruby/object:Gem::Version
150
150
  version: '0'
151
- - !ruby/object:Gem::Dependency
152
- name: minitest
153
- requirement: !ruby/object:Gem::Requirement
154
- requirements:
155
- - - ">="
156
- - !ruby/object:Gem::Version
157
- version: '0'
158
- type: :development
159
- prerelease: false
160
- version_requirements: !ruby/object:Gem::Requirement
161
- requirements:
162
- - - ">="
163
- - !ruby/object:Gem::Version
164
- version: '0'
165
- - !ruby/object:Gem::Dependency
166
- name: vcr
167
- requirement: !ruby/object:Gem::Requirement
168
- requirements:
169
- - - ">="
170
- - !ruby/object:Gem::Version
171
- version: '0'
172
- type: :development
173
- prerelease: false
174
- version_requirements: !ruby/object:Gem::Requirement
175
- requirements:
176
- - - ">="
177
- - !ruby/object:Gem::Version
178
- version: '0'
179
- - !ruby/object:Gem::Dependency
180
- name: webmock
181
- requirement: !ruby/object:Gem::Requirement
182
- requirements:
183
- - - ">="
184
- - !ruby/object:Gem::Version
185
- version: '0'
186
- type: :development
187
- prerelease: false
188
- version_requirements: !ruby/object:Gem::Requirement
189
- requirements:
190
- - - ">="
191
- - !ruby/object:Gem::Version
192
- version: '0'
193
151
  description: Smoggy API
194
152
  email: code@chrisroberts.org
195
- executables:
196
- - miasma-test
153
+ executables: []
197
154
  extensions: []
198
155
  extra_rdoc_files: []
199
156
  files:
200
157
  - CHANGELOG.md
201
158
  - LICENSE
202
159
  - README.md
203
- - bin/miasma-test
204
160
  - lib/miasma.rb
205
161
  - lib/miasma/error.rb
206
162
  - lib/miasma/models.rb
@@ -229,6 +185,11 @@ files:
229
185
  - lib/miasma/models/storage/buckets.rb
230
186
  - lib/miasma/models/storage/file.rb
231
187
  - lib/miasma/models/storage/files.rb
188
+ - lib/miasma/specs.rb
189
+ - lib/miasma/specs/compute_abstract.rb
190
+ - lib/miasma/specs/load_balancer_abstract.rb
191
+ - lib/miasma/specs/orchestration_abstract.rb
192
+ - lib/miasma/specs/storage_abstract.rb
232
193
  - lib/miasma/types.rb
233
194
  - lib/miasma/types/api.rb
234
195
  - lib/miasma/types/collection.rb
@@ -1,51 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'vcr'
4
- require 'fileutils'
5
- require 'webmock/minitest'
6
- require 'minitest/autorun'
7
-
8
- require 'miasma'
9
-
10
- miasma_spec_dir = File.join(File.dirname(File.dirname(__FILE__)), 'test', 'specs')
11
-
12
- # Always load in generic model specs
13
- Dir.glob(File.join(miasma_spec_dir, 'models', '*.rb')).each do |path|
14
- require File.expand_path(path)
15
- end
16
-
17
- library_spec_dir = File.join(Dir.pwd, 'test', 'specs')
18
-
19
- unless(File.directory?(library_spec_dir))
20
- $stderr.puts "ERROR: Failed to locate expected spec directory! (#{library_spec_dir})"
21
- exit -1
22
- end
23
-
24
- if(ARGV.empty?)
25
- cassette_directory = File.join(library_spec_dir, 'cassettes')
26
-
27
- Dir.glob(File.join(library_spec_dir, '**/**/*_spec.rb')).each do |path|
28
- require File.expand_path(path)
29
- end
30
-
31
- else
32
- cassette_directory = File.join(library_spec_dir, 'cassettes')
33
-
34
- ARGV.each do |path|
35
- full_path = File.expand_path(path)
36
- if(File.exists?(full_path))
37
- require full_path
38
- else
39
- $stderr.puts "ERROR: Failed to locate specified path! (#{full_path})"
40
- exit -1
41
- end
42
- end
43
-
44
- end
45
-
46
- FileUtils.mkdir_p(cassette_directory)
47
-
48
- VCR.configure do |c|
49
- c.cassette_library_dir = cassette_directory
50
- c.hook_into :webmock
51
- end