torpedo 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ * Wed Dec 7 2011 Dan Prince <dan.prince@rackspace.com> - 1.0.10
2
+ -Add admin password and change password tests.
3
+ -Add revert resize test.
4
+ -Add hard and soft reboot tests.
5
+
1
6
  * Wed Nov 16 2011 Dan Prince <dan.prince@rackspace.com> - 1.0.9
2
7
  -Add options to disable ssh and ping tests.
3
8
 
data/README.md CHANGED
@@ -28,6 +28,10 @@ Installation
28
28
  test_create_image: false
29
29
  test_rebuild_server: false
30
30
  test_resize_server: false
31
+ test_revert_resize_server: false
32
+ test_admin_password: false
33
+ test_soft_reboot_server: false
34
+ test_hard_reboot_server: false
31
35
 
32
36
  # IMAGES (Set one of the following)
33
37
  image_name: Ubuntu Natty (11.04)
@@ -45,7 +49,7 @@ Installation
45
49
  #ssh_private_key: <your home dir>/.ssh/id_rsa
46
50
  #ssh_public_key: <your home dir>/.ssh/id_rsa.pub
47
51
 
48
- # KEYPAIRS (used to verify AMI style images)
52
+ # KEYPAIRS (used to verify images that support keypairs)
49
53
  #keypair: test.pem
50
54
  #keyname: test
51
55
  EOF_CAT
@@ -83,7 +87,7 @@ Payload
83
87
  * list images
84
88
  * get image
85
89
  * list limits
86
- * create server (ping and ssh test)
90
+ * create server (ping and ssh test w/ admin password and personality)
87
91
  * delete server metadata items
88
92
  * update one server metadata item
89
93
  * update multiple server metadata items
@@ -93,6 +97,9 @@ Payload
93
97
  * rebuild server (ping and ssh test)
94
98
  * resize server (ping and ssh test)
95
99
  * resize confirm (ping and ssh test)
100
+ * resize revert (ping and ssh test)
101
+ * soft reboot (ping and ssh test)
102
+ * hard reboot (ping and ssh test)
96
103
  * delete image metadata
97
104
  * update one image metadata item
98
105
  * update multiple image metadata items
data/Rakefile CHANGED
@@ -18,13 +18,14 @@ Jeweler::Tasks.new do |gem|
18
18
  gem.executables = "torpedo"
19
19
  gem.homepage = "http://github.com/dprince/torpedo"
20
20
  gem.license = "MIT"
21
- gem.summary = %Q{Sink bad code! Ruby Smoke Tests for OpenStack.}
22
- gem.description = %Q{CLI to run functional smoke tests for OpenStack.}
21
+ gem.summary = %Q{Fire when ready. Fast Ruby integration tests for OpenStack.}
22
+ gem.description = %Q{Fast integration tests OpenStack Compute.}
23
23
  gem.email = "dan.prince@rackspace.com"
24
24
  gem.authors = ["Dan Prince"]
25
25
  # dependencies defined in Gemfile
26
- gem.add_dependency 'thor'
27
- gem.add_dependency 'openstack-compute', '>= 1.1.4'
26
+ gem.add_dependency 'thor', '~>0.14.6'
27
+ gem.add_dependency 'openstack-compute', '~>1.1.5'
28
+ gem.add_dependency('net-ssh', '~>2.2.1')
28
29
  end
29
30
  Jeweler::RubygemsDotOrgTasks.new
30
31
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.9
1
+ 1.0.10
@@ -1,5 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
2
  require 'tempfile'
3
+ require 'net/ssh'
3
4
 
4
5
  module Torpedo
5
6
  module Compute
@@ -11,6 +12,7 @@ class Servers < Test::Unit::TestCase
11
12
  @@flavor_ref = Helper::get_flavor_ref(Helper::get_connection)
12
13
  @@flavor_ref_resize = Helper::get_flavor_ref_resize(@conn)
13
14
  @@server = nil #ref to last created server
15
+ @@hostname = "torpedo"
14
16
 
15
17
  def setup
16
18
  @conn=Helper::get_connection
@@ -19,6 +21,8 @@ class Servers < Test::Unit::TestCase
19
21
  def create_server(server_opts)
20
22
  @@server = @conn.create_server(server_opts)
21
23
  @@servers << @@server
24
+ @@admin_pass = @@server.adminPass #original admin_pass
25
+ @@host_id = @@server.hostId #original host ID
22
26
  @@server
23
27
  end
24
28
 
@@ -29,20 +33,43 @@ class Servers < Test::Unit::TestCase
29
33
  image
30
34
  end
31
35
 
32
- def ssh_test(ip_addr)
36
+ def get_personalities
37
+ if TEST_ADMIN_PASSWORD then
38
+ tmp_file=Tempfile.new "server_tests"
39
+ tmp_file.write("yo")
40
+ tmp_file.flush
41
+ {tmp_file.path => "/tmp/foo/bar"}
42
+ else
43
+ # NOTE: if admin_pass is disabled we inject the public key so we still
44
+ # can still login. This would only matter if KEYPAIR was disabled as well.
45
+ {SSH_PUBLIC_KEY => "/root/.ssh/authorized_keys"}
46
+ end
47
+ end
48
+
49
+ def ssh_test(ip_addr, test_cmd="hostname", test_output=@@hostname, admin_pass=@@admin_pass)
50
+
51
+ ssh_opts = {}
52
+ if TEST_ADMIN_PASSWORD then
53
+ ssh_opts.store(:password, admin_pass)
54
+ else
55
+ ssh_identity=SSH_PRIVATE_KEY
56
+ if KEYPAIR and not KEYPAIR.empty? then
57
+ ssh_identity=KEYPAIR
58
+ end
59
+ ssh_opts.store(:keys, ssh_identity)
60
+ end
61
+
33
62
  begin
34
63
  Timeout::timeout(SSH_TIMEOUT) do
35
-
36
64
  while(1) do
37
- ssh_identity=SSH_PRIVATE_KEY
38
- if KEYPAIR and not KEYPAIR.empty? then
39
- ssh_identity=KEYPAIR
40
- end
41
- if system("ssh -o StrictHostKeyChecking=no -i #{ssh_identity} root@#{ip_addr} /bin/true > /dev/null 2>&1") then
42
- return true
65
+ begin
66
+ Net::SSH.start(ip_addr, 'root', ssh_opts) do |ssh|
67
+ return ssh.exec!(test_cmd) == test_output
68
+ end
69
+ rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Net::SSH::Exception
70
+ next
43
71
  end
44
72
  end
45
-
46
73
  end
47
74
  rescue Timeout::Error => te
48
75
  fail("Timeout trying to ssh to server: #{ip_addr}")
@@ -76,7 +103,7 @@ class Servers < Test::Unit::TestCase
76
103
  assert_not_nil(server.hostId)
77
104
  assert_equal(flavor_ref, server.flavor['id'])
78
105
  assert_equal(image_ref.to_s, server.image['id'])
79
- assert_equal('test1', server.name)
106
+ assert_equal(@@hostname, server.name)
80
107
  server = @conn.server(server.id)
81
108
 
82
109
  begin
@@ -96,7 +123,13 @@ class Servers < Test::Unit::TestCase
96
123
  # lookup the first IPv4 address and use that for verification
97
124
  v4_addresses = server.addresses[:public].reject {|addr| addr.version != 4}
98
125
  ping_test(v4_addresses[0].address) if TEST_PING
99
- ssh_test(v4_addresses[0].address) if TEST_SSH
126
+ if TEST_SSH
127
+ if TEST_ADMIN_PASSWORD
128
+ ssh_test(v4_addresses[0].address, "cat /tmp/foo/bar", "yo")
129
+ else
130
+ ssh_test(v4_addresses[0].address)
131
+ end
132
+ end
100
133
 
101
134
  server
102
135
 
@@ -104,18 +137,13 @@ class Servers < Test::Unit::TestCase
104
137
 
105
138
  def test_001_create_server
106
139
 
107
- # NOTE: When using AMI style images we rely on keypairs for SSH access.
108
-
109
- # NOTE: injecting two or more files doesn't work for now due to XenStore
110
- # limitations
111
- personalities={SSH_PUBLIC_KEY => "/root/.ssh/authorized_keys"}
112
140
  metadata={ "key1" => "value1", "key2" => "value2" }
113
- options = {:name => "test1", :imageRef => @@image_ref, :flavorRef => @@flavor_ref, :personality => personalities, :metadata => metadata}
141
+ options = {:name => @@hostname, :imageRef => @@image_ref, :flavorRef => @@flavor_ref, :personality => get_personalities, :metadata => metadata}
114
142
  if KEYNAME and not KEYNAME.empty? then
115
143
  options[:key_name] = KEYNAME
116
144
  end
117
145
  server = create_server(options)
118
- assert_not_nil(@@server.adminPass)
146
+ assert_not_nil(server.adminPass)
119
147
 
120
148
  #boot a server and check it
121
149
  check_server(server, @@image_ref, @@flavor_ref)
@@ -230,18 +258,89 @@ class Servers < Test::Unit::TestCase
230
258
 
231
259
  end if TEST_CREATE_IMAGE
232
260
 
233
-
234
261
  def test_030_rebuild
235
- # make sure our snapshot boots
236
- personalities={SSH_PUBLIC_KEY => "/root/.ssh/authorized_keys"}
237
- @@server.rebuild!(:imageRef => @@image_ref, :personality => personalities)
262
+ # NOTE: this will use the snapshot if TEST_CREATE_IMAGE is enabled
263
+ @@server.rebuild!(:adminPass => @@admin_pass, :imageRef => @@image_ref, :personality => get_personalities)
238
264
  server = @conn.server(@@server.id)
239
265
  sleep 15 # sleep a couple seconds until rebuild starts
240
266
  check_server(server, @@image_ref, @@flavor_ref)
241
267
 
242
268
  end if TEST_REBUILD_SERVER
243
269
 
244
- def test_040_resize
270
+ def test_035_soft_reboot
271
+ # make sure our snapshot boots
272
+ @@server.reboot(type='SOFT')
273
+ server = @conn.server(@@server.id)
274
+ assert_equal('REBOOT', server.status)
275
+ check_server(server, @@image_ref, @@flavor_ref)
276
+ end if TEST_SOFT_REBOOT_SERVER
277
+
278
+ def test_036_hard_reboot
279
+ # make sure our snapshot boots
280
+ @@server.reboot(type='HARD')
281
+ server = @conn.server(@@server.id)
282
+ assert_equal('HARD_REBOOT', server.status)
283
+ check_server(server, @@image_ref, @@flavor_ref)
284
+ end if TEST_HARD_REBOOT_SERVER
285
+
286
+ def test_037_change_password
287
+ @@admin_pass = "AnGrYbIrD$"
288
+ @@server.change_password!(@@admin_pass)
289
+ server = @conn.server(@@server.id)
290
+ begin
291
+ timeout(60) do
292
+ until server.status == 'ACTIVE' do
293
+ server = @conn.server(server.id)
294
+ sleep 1
295
+ end
296
+ end
297
+ rescue Timeout::Error => te
298
+ fail('Timeout changing server password.')
299
+ end
300
+ check_server(server, @@image_ref, @@flavor_ref)
301
+ end if TEST_ADMIN_PASSWORD
302
+
303
+ def test_040_resize_revert
304
+
305
+ @@server.resize!(@@flavor_ref_resize)
306
+ server = @conn.server(@@server.id)
307
+ assert_equal('RESIZE', server.status)
308
+
309
+ begin
310
+ timeout(SERVER_BUILD_TIMEOUT) do
311
+ until server.status == 'VERIFY_RESIZE' do
312
+ if server.status == "ERROR" then
313
+ fail('Server ERROR state detected when resizing server!')
314
+ end
315
+ server = @conn.server(server.id)
316
+ sleep 1
317
+ end
318
+ end
319
+ rescue Timeout::Error => te
320
+ fail('Timeout resizing server.')
321
+ end
322
+
323
+ check_server(server, @@image_ref, @@flavor_ref_resize, 'VERIFY_RESIZE')
324
+
325
+ @@server.revert_resize!
326
+ server = @conn.server(@@server.id)
327
+ begin
328
+ timeout(60) do
329
+ until server.status == 'ACTIVE' do
330
+ server = @conn.server(server.id)
331
+ sleep 1
332
+ end
333
+ end
334
+ rescue Timeout::Error => te
335
+ fail('Timeout waiting for revert resize.')
336
+ end
337
+
338
+ check_server(server, @@image_ref, @@flavor_ref)
339
+ assert_equal(server.hostId, @@host_id)
340
+
341
+ end if TEST_REVERT_RESIZE_SERVER
342
+
343
+ def test_041_resize
245
344
 
246
345
  @@server.resize!(@@flavor_ref_resize)
247
346
  server = @conn.server(@@server.id)
@@ -262,10 +361,11 @@ class Servers < Test::Unit::TestCase
262
361
  end
263
362
 
264
363
  check_server(server, @@image_ref, @@flavor_ref_resize, 'VERIFY_RESIZE')
364
+ assert_not_equal(server.hostId, @@host_id) if TEST_HOSTID_ON_RESIZE
265
365
 
266
366
  end if TEST_RESIZE_SERVER
267
367
 
268
- def test_041_resize_confirm
368
+ def test_042_resize_confirm
269
369
 
270
370
  @@server.confirm_resize!
271
371
  server = @conn.server(@@server.id)
data/lib/torpedo.rb CHANGED
@@ -12,7 +12,12 @@ SSH_PRIVATE_KEY=configs['ssh_private_key'] || ENV['HOME'] + "/.ssh/id_rsa"
12
12
  SSH_PUBLIC_KEY=configs['ssh_public_key'] || ENV['HOME'] + "/.ssh/id_rsa.pub"
13
13
  TEST_CREATE_IMAGE=configs['test_create_image'] || false
14
14
  TEST_REBUILD_SERVER=configs['test_rebuild_server'] || false
15
+ TEST_SOFT_REBOOT_SERVER=configs['test_soft_reboot_server'] || false
16
+ TEST_HARD_REBOOT_SERVER=configs['test_hard_reboot_server'] || false
15
17
  TEST_RESIZE_SERVER=configs['test_resize_server'] || false
18
+ TEST_REVERT_RESIZE_SERVER=configs['test_revert_resize_server'] || false
19
+ TEST_ADMIN_PASSWORD=configs['test_admin_password'] || false
20
+ TEST_HOSTID_ON_RESIZE=configs['test_hostid_on_resize'] || false
16
21
  KEYPAIR=configs['keypair']
17
22
  KEYNAME=configs['keyname']
18
23
 
data/torpedo.gemspec CHANGED
@@ -5,13 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{torpedo}
8
- s.version = "1.0.7"
8
+ s.version = "1.0.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dan Prince"]
12
- s.date = %q{2011-11-02}
12
+ s.date = %q{2011-12-07}
13
13
  s.default_executable = %q{torpedo}
14
- s.description = %q{CLI to run functional smoke tests for OpenStack.}
14
+ s.description = %q{Fast integration tests OpenStack Compute.}
15
15
  s.email = %q{dan.prince@rackspace.com}
16
16
  s.executables = ["torpedo"]
17
17
  s.extra_rdoc_files = [
@@ -36,14 +36,13 @@ Gem::Specification.new do |s|
36
36
  "lib/torpedo/compute/servers.rb",
37
37
  "lib/torpedo/config.rb",
38
38
  "test/helper.rb",
39
- "test/test_torpedo.rb",
40
39
  "torpedo.gemspec"
41
40
  ]
42
41
  s.homepage = %q{http://github.com/dprince/torpedo}
43
42
  s.licenses = ["MIT"]
44
43
  s.require_paths = ["lib"]
45
44
  s.rubygems_version = %q{1.3.7}
46
- s.summary = %q{Sink bad code! Ruby Smoke Tests for OpenStack.}
45
+ s.summary = %q{Fire when ready. Fast Ruby integration tests for OpenStack.}
47
46
 
48
47
  if s.respond_to? :specification_version then
49
48
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
@@ -52,19 +51,22 @@ Gem::Specification.new do |s|
52
51
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
52
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
54
53
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
55
- s.add_runtime_dependency(%q<thor>, [">= 0"])
56
- s.add_runtime_dependency(%q<openstack-compute>, [">= 1.1.4"])
54
+ s.add_runtime_dependency(%q<thor>, ["~> 0.14.6"])
55
+ s.add_runtime_dependency(%q<openstack-compute>, ["~> 1.1.5"])
56
+ s.add_runtime_dependency(%q<net-ssh>, ["~> 2.2.1"])
57
57
  else
58
58
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
59
59
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
60
- s.add_dependency(%q<thor>, [">= 0"])
61
- s.add_dependency(%q<openstack-compute>, [">= 1.1.4"])
60
+ s.add_dependency(%q<thor>, ["~> 0.14.6"])
61
+ s.add_dependency(%q<openstack-compute>, ["~> 1.1.5"])
62
+ s.add_dependency(%q<net-ssh>, ["~> 2.2.1"])
62
63
  end
63
64
  else
64
65
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
65
66
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
66
- s.add_dependency(%q<thor>, [">= 0"])
67
- s.add_dependency(%q<openstack-compute>, [">= 1.1.4"])
67
+ s.add_dependency(%q<thor>, ["~> 0.14.6"])
68
+ s.add_dependency(%q<openstack-compute>, ["~> 1.1.5"])
69
+ s.add_dependency(%q<net-ssh>, ["~> 2.2.1"])
68
70
  end
69
71
  end
70
72
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torpedo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 9
10
- version: 1.0.9
9
+ - 10
10
+ version: 1.0.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dan Prince
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-16 00:00:00 -05:00
18
+ date: 2011-12-07 00:00:00 -05:00
19
19
  default_executable: torpedo
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -56,12 +56,14 @@ dependencies:
56
56
  version_requirements: &id003 !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ">="
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- hash: 3
61
+ hash: 43
62
62
  segments:
63
63
  - 0
64
- version: "0"
64
+ - 14
65
+ - 6
66
+ version: 0.14.6
65
67
  requirement: *id003
66
68
  type: :runtime
67
69
  - !ruby/object:Gem::Dependency
@@ -70,17 +72,33 @@ dependencies:
70
72
  version_requirements: &id004 !ruby/object:Gem::Requirement
71
73
  none: false
72
74
  requirements:
73
- - - ">="
75
+ - - ~>
74
76
  - !ruby/object:Gem::Version
75
- hash: 27
77
+ hash: 25
76
78
  segments:
77
79
  - 1
78
80
  - 1
79
- - 4
80
- version: 1.1.4
81
+ - 5
82
+ version: 1.1.5
81
83
  requirement: *id004
82
84
  type: :runtime
83
- description: CLI to run functional smoke tests for OpenStack.
85
+ - !ruby/object:Gem::Dependency
86
+ prerelease: false
87
+ name: net-ssh
88
+ version_requirements: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ hash: 5
94
+ segments:
95
+ - 2
96
+ - 2
97
+ - 1
98
+ version: 2.2.1
99
+ requirement: *id005
100
+ type: :runtime
101
+ description: Fast integration tests OpenStack Compute.
84
102
  email: dan.prince@rackspace.com
85
103
  executables:
86
104
  - torpedo
@@ -107,7 +125,6 @@ files:
107
125
  - lib/torpedo/compute/servers.rb
108
126
  - lib/torpedo/config.rb
109
127
  - test/helper.rb
110
- - test/test_torpedo.rb
111
128
  - torpedo.gemspec
112
129
  has_rdoc: true
113
130
  homepage: http://github.com/dprince/torpedo
@@ -142,6 +159,6 @@ rubyforge_project:
142
159
  rubygems_version: 1.3.7
143
160
  signing_key:
144
161
  specification_version: 3
145
- summary: Sink bad code! Ruby Smoke Tests for OpenStack.
162
+ summary: Fire when ready. Fast Ruby integration tests for OpenStack.
146
163
  test_files: []
147
164
 
data/test/test_torpedo.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestTorpedo < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end