test/yao/resources/test_server.rb in yao-0.18.0 vs test/yao/resources/test_server.rb in yao-0.19.0
- old
+ new
@@ -1,6 +1,7 @@
class TestServer < TestYaoResource
+ include RestfullyAccessibleStub
def test_server
# https://docs.openstack.org/api-ref/compute/?expanded=list-servers-detail,list-servers-detailed-detail#list-servers
params = {
@@ -269,8 +270,102 @@
server = Yao::Server.new('project_id' => '0123456789abcdef0123456789abcdef')
ports = server.ports
assert_instance_of(Array, ports)
assert_equal(0, ports.size)
+ assert_requested(stub)
+ end
+
+ def test_start
+ server_id = '2ce4c5b3-2866-4972-93ce-77a2ea46a7f9'
+ stub = stub_post_request(
+ "https://example.com:12345/servers/#{server_id}/action",
+ [{"os-start": nil}]
+ )
+
+ Yao::Server.new('id' => server_id).start
+ assert_requested(stub)
+ end
+
+ def test_shutoff
+ server_id = '2ce4c5b3-2866-4972-93ce-77a2ea46a7f9'
+ stub = stub_post_request(
+ "https://example.com:12345/servers/#{server_id}/action",
+ [{"os-stop": nil}]
+ )
+
+ Yao::Server.new('id' => server_id).stop
+ assert_requested(stub)
+ assert_equal(Yao::Server.method(:stop), Yao::Server.method(:shutoff))
+ end
+
+ def test_reboot
+ server_id = '2ce4c5b3-2866-4972-93ce-77a2ea46a7f9'
+ stub = stub_post_request(
+ "https://example.com:12345/servers/#{server_id}/action",
+ [{"reboot": { "type" => "HARD" }}]
+ )
+
+ Yao::Server.new('id' => server_id).reboot
+ assert_requested(stub)
+ end
+
+ def test_resize
+ server_id = '2ce4c5b3-2866-4972-93ce-77a2ea46a7f9'
+ stub = stub_post_request(
+ "https://example.com:12345/servers/#{server_id}/action",
+ [{"resize": { "flavorRef": "test-flavor" }}]
+ )
+
+ Yao::Server.new('id' => server_id).resize("test-flavor")
+ assert_requested(stub)
+ end
+
+ def test_live_migrate
+ server_id = '2ce4c5b3-2866-4972-93ce-77a2ea46a7f9'
+ stub = stub_post_request(
+ "https://example.com:12345/servers/#{server_id}/action",
+ [{"os-migrateLive": {
+ "host": "test-node-1",
+ "block_migration": false,
+ "disk_over_commit": false
+ }}]
+ )
+
+ Yao::Server.new('id' => server_id).live_migrate("test-node-1", false, false)
+ assert_requested(stub)
+ end
+
+ def test_add_security_group
+ server_id = '2ce4c5b3-2866-4972-93ce-77a2ea46a7f9'
+ stub = stub_post_request(
+ "https://example.com:12345/servers/#{server_id}/action",
+ [{"addSecurityGroup": { "name": "test-sg" }}]
+ )
+
+ Yao::Server.new('id' => server_id).add_security_group("test-sg")
+ assert_requested(stub)
+ end
+
+ def test_remove_security_group
+ server_id = '2ce4c5b3-2866-4972-93ce-77a2ea46a7f9'
+ stub = stub_post_request(
+ "https://example.com:12345/servers/#{server_id}/action",
+ [{"removeSecurityGroup": { "name": "test-sg" }}]
+ )
+
+ Yao::Server.new('id' => server_id).remove_security_group("test-sg")
+ assert_requested(stub)
+ end
+
+ def test_get_vnc_concolse
+ server_id = '2ce4c5b3-2866-4972-93ce-77a2ea46a7f9'
+ stub = stub_post_request(
+ "https://example.com:12345/servers/#{server_id}/action",
+ [{"os-getVNCConsole": { "type": "novnc" }}],
+ {"console": { "url": "https://example.com/vnc" }}
+ )
+
+ Yao::Server.new('id' => server_id).get_vnc_console
assert_requested(stub)
end
end