azure 0.7.1 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +31 -0
- data/azure.gemspec +2 -1
- data/lib/azure.rb +1 -0
- data/lib/azure/base_management/management_http_request.rb +3 -12
- data/lib/azure/blob/auth/shared_access_signature.rb +4 -0
- data/lib/azure/blob/blob_service.rb +2 -2
- data/lib/azure/client_services.rb +13 -13
- data/lib/azure/core/http/http_request.rb +3 -14
- data/lib/azure/core/service.rb +2 -1
- data/lib/azure/http_client.rb +1 -17
- data/lib/azure/http_response_helper.rb +38 -0
- data/lib/azure/sql_database_management/serialization.rb +4 -0
- data/lib/azure/sql_database_management/sql_database_management_service.rb +10 -9
- data/lib/azure/version.rb +1 -1
- data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +2 -2
- data/lib/azure/virtual_machine_management/serialization.rb +21 -12
- data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +8 -3
- metadata +17 -199
- data/test/fixtures/32px-fulls-black.jpg +0 -0
- data/test/fixtures/affinity_group.xml +0 -33
- data/test/fixtures/all_containers.xml +0 -20
- data/test/fixtures/all_tables.xml +0 -22
- data/test/fixtures/container_acl.xml +0 -11
- data/test/fixtures/create_sql_database_server.xml +0 -2
- data/test/fixtures/create_storage_desc_error.xml +0 -5
- data/test/fixtures/create_storage_extendedprop_error.xml +0 -8
- data/test/fixtures/create_storage_extendedpropname_error.xml +0 -6
- data/test/fixtures/create_storage_full_error.xml +0 -6
- data/test/fixtures/create_storage_label_error.xml +0 -5
- data/test/fixtures/create_storage_location_error.xml +0 -5
- data/test/fixtures/create_storage_name_error.xml +0 -6
- data/test/fixtures/create_table_response_entry.xml +0 -15
- data/test/fixtures/delete_storage_container_error.xml +0 -5
- data/test/fixtures/delete_storage_error.xml +0 -5
- data/test/fixtures/deployment_error.xml +0 -5
- data/test/fixtures/empty_xml_file +0 -0
- data/test/fixtures/get_storage_account_error.xml +0 -5
- data/test/fixtures/get_storage_account_properties.xml +0 -34
- data/test/fixtures/get_storage_account_properties_new.xml +0 -32
- data/test/fixtures/http_error.xml +0 -5
- data/test/fixtures/insert_entity_response_entry.xml +0 -25
- data/test/fixtures/list_affinity_groups.xml +0 -22
- data/test/fixtures/list_blobs.xml +0 -121
- data/test/fixtures/list_block_all_with_none_committed.xml +0 -22
- data/test/fixtures/list_blocks_all.xml +0 -23
- data/test/fixtures/list_blocks_committed.xml +0 -13
- data/test/fixtures/list_cloud_services.xml +0 -39
- data/test/fixtures/list_containers.xml +0 -38
- data/test/fixtures/list_firewall_management_endpoint.xml +0 -27
- data/test/fixtures/list_locations.xml +0 -212
- data/test/fixtures/list_os_images.xml +0 -110
- data/test/fixtures/list_page_ranges.xml +0 -11
- data/test/fixtures/list_sql_database.xml +0 -24
- data/test/fixtures/list_sql_server_firewall.xml +0 -23
- data/test/fixtures/list_storage_account_single.xml +0 -25
- data/test/fixtures/list_storage_accounts.xml +0 -48
- data/test/fixtures/list_virtual_networks.xml +0 -91
- data/test/fixtures/list_vm_images.xml +0 -21
- data/test/fixtures/logging.xml +0 -11
- data/test/fixtures/management_certificate.pem +0 -55
- data/test/fixtures/management_certificate.pfx +0 -0
- data/test/fixtures/management_certificate.publishsettings +0 -12
- data/test/fixtures/messages.xml +0 -12
- data/test/fixtures/metrics.xml +0 -10
- data/test/fixtures/privatekey.key +0 -28
- data/test/fixtures/query_entities_empty_response.xml +0 -7
- data/test/fixtures/query_entities_response.xml +0 -45
- data/test/fixtures/queue_service_properties.xml +0 -22
- data/test/fixtures/queue_service_properties_original.xml +0 -19
- data/test/fixtures/queues.xml +0 -16
- data/test/fixtures/retention_policy.xml +0 -5
- data/test/fixtures/sb_default_create_queue_response.xml +0 -23
- data/test/fixtures/sb_default_create_relay_response.xml +0 -15
- data/test/fixtures/sb_default_create_topic_response.xml +0 -18
- data/test/fixtures/sb_get_access_token_response.txt +0 -1
- data/test/fixtures/sb_queues_runtime_peek_message_response_headers.txt +0 -9
- data/test/fixtures/storage_service_keys.xml +0 -8
- data/test/fixtures/storage_service_properties.xml +0 -55
- data/test/fixtures/update_storage_account.xml +0 -16
- data/test/fixtures/update_storage_error.xml +0 -5
- data/test/fixtures/updated_storage_accounts.xml +0 -55
- data/test/fixtures/virtual_machine.xml +0 -116
- data/test/fixtures/windows_virtual_machine.xml +0 -106
- data/test/integration/affinity_group/Affinity_test.rb +0 -55
- data/test/integration/affinity_group/Create_Affinity_test.rb +0 -64
- data/test/integration/affinity_group/Delete_Affinity_test.rb +0 -56
- data/test/integration/affinity_group/List_Affinity_test.rb +0 -41
- data/test/integration/affinity_group/Update_Affinity_test.rb +0 -87
- data/test/integration/blob/blob_gb18030_test.rb +0 -199
- data/test/integration/blob/blob_metadata_test.rb +0 -75
- data/test/integration/blob/blob_pages_test.rb +0 -119
- data/test/integration/blob/blob_properties_test.rb +0 -77
- data/test/integration/blob/block_blob_test.rb +0 -303
- data/test/integration/blob/container/container_acl_test.rb +0 -69
- data/test/integration/blob/container/container_metadata_test.rb +0 -50
- data/test/integration/blob/container/create_container_test.rb +0 -60
- data/test/integration/blob/container/delete_container_test.rb +0 -39
- data/test/integration/blob/container/get_container_properties_test.rb +0 -48
- data/test/integration/blob/container/list_containers_test.rb +0 -79
- data/test/integration/blob/container/root_container_test.rb +0 -55
- data/test/integration/blob/copy_blob_test.rb +0 -113
- data/test/integration/blob/create_blob_snapshot_test.rb +0 -80
- data/test/integration/blob/create_page_blob_test.rb +0 -83
- data/test/integration/blob/delete_blob_test.rb +0 -159
- data/test/integration/blob/get_blob_test.rb +0 -65
- data/test/integration/blob/informative_errors_test.rb +0 -39
- data/test/integration/blob/lease/acquire_lease_test.rb +0 -36
- data/test/integration/blob/lease/break_lease_test.rb +0 -40
- data/test/integration/blob/lease/release_lease_test.rb +0 -40
- data/test/integration/blob/lease/renew_lease_test.rb +0 -42
- data/test/integration/blob/list_blobs_test.rb +0 -113
- data/test/integration/cloud_service/Cloud_Create_test.rb +0 -45
- data/test/integration/cloud_service/Cloud_Delete_test.rb +0 -45
- data/test/integration/database/create_sql_server_firewall_test.rb +0 -81
- data/test/integration/database/create_sql_server_test.rb +0 -53
- data/test/integration/database/delete_sql_server_firewall_test.rb +0 -63
- data/test/integration/database/delete_sql_server_test.rb +0 -44
- data/test/integration/database/list_sql_server_firewall_test.rb +0 -44
- data/test/integration/database/list_sql_servers_test.rb +0 -44
- data/test/integration/database/reset_password_sql_server_test.rb +0 -53
- data/test/integration/location/Location_List_test.rb +0 -38
- data/test/integration/location/RoleSize_List_test.rb +0 -34
- data/test/integration/queue/clear_messages_test.rb +0 -42
- data/test/integration/queue/create_message_test.rb +0 -75
- data/test/integration/queue/create_queue_test.rb +0 -50
- data/test/integration/queue/delete_message_test.rb +0 -67
- data/test/integration/queue/delete_queue_test.rb +0 -45
- data/test/integration/queue/informative_errors_test.rb +0 -42
- data/test/integration/queue/list_messages_encoded_test.rb +0 -79
- data/test/integration/queue/list_messages_test.rb +0 -79
- data/test/integration/queue/list_queues_test.rb +0 -43
- data/test/integration/queue/peek_messages_test.rb +0 -59
- data/test/integration/queue/queue_gb18030_test.rb +0 -131
- data/test/integration/queue/queue_metadata_test.rb +0 -40
- data/test/integration/queue/update_message_test.rb +0 -74
- data/test/integration/service_bus/informative_errors_test.rb +0 -37
- data/test/integration/service_bus/queues_scenario_test.rb +0 -200
- data/test/integration/service_bus/queues_test.rb +0 -266
- data/test/integration/service_bus/relay_test.rb +0 -132
- data/test/integration/service_bus/rules_test.rb +0 -145
- data/test/integration/service_bus/sb_queue_gb18030_test.rb +0 -182
- data/test/integration/service_bus/scenario_test.rb +0 -101
- data/test/integration/service_bus/subscriptions_test.rb +0 -211
- data/test/integration/service_bus/topics_scenario_test.rb +0 -406
- data/test/integration/service_bus/topics_test.rb +0 -129
- data/test/integration/storage_management/storage_management_test.rb +0 -185
- data/test/integration/table/create_table_test.rb +0 -36
- data/test/integration/table/delete_entity_batch_test.rb +0 -107
- data/test/integration/table/delete_entity_test.rb +0 -94
- data/test/integration/table/delete_table_test.rb +0 -40
- data/test/integration/table/get_table_test.rb +0 -37
- data/test/integration/table/informative_errors_test.rb +0 -39
- data/test/integration/table/insert_entity_batch_test.rb +0 -100
- data/test/integration/table/insert_entity_test.rb +0 -88
- data/test/integration/table/insert_or_merge_entity_batch_test.rb +0 -159
- data/test/integration/table/insert_or_merge_entity_test.rb +0 -143
- data/test/integration/table/insert_or_replace_entity_batch_test.rb +0 -152
- data/test/integration/table/insert_or_replace_entity_test.rb +0 -137
- data/test/integration/table/merge_entity_batch_test.rb +0 -128
- data/test/integration/table/merge_entity_test.rb +0 -113
- data/test/integration/table/query_entities_test.rb +0 -196
- data/test/integration/table/query_tables_test.rb +0 -43
- data/test/integration/table/query_test.rb +0 -251
- data/test/integration/table/table_acl_test.rb +0 -52
- data/test/integration/table/table_gb18030_test.rb +0 -355
- data/test/integration/table/update_entity_batch_test.rb +0 -149
- data/test/integration/table/update_entity_test.rb +0 -131
- data/test/integration/test_helper.rb +0 -40
- data/test/integration/vm/VM_Create_test.rb +0 -262
- data/test/integration/vm/VM_Delete_test.rb +0 -53
- data/test/integration/vm/VM_Operations_test.rb +0 -172
- data/test/integration/vm_image/virtual_machine_disk_test.rb +0 -37
- data/test/integration/vm_image/virtual_machine_image_test.rb +0 -37
- data/test/integration/vnet/Virtual_Network_Create_test.rb +0 -116
- data/test/integration/vnet/Virtual_Network_list_test.rb +0 -48
- data/test/support/env.rb +0 -19
- data/test/support/fixtures.rb +0 -36
- data/test/support/name_generator.rb +0 -168
- data/test/support/stubs.rb +0 -42
- data/test/support/virtual_machine_name_generator.rb +0 -102
- data/test/support/virtual_network_helper.rb +0 -73
- data/test/test_helper.rb +0 -47
- data/test/unit/affinity_group/affinity_group_test.rb +0 -189
- data/test/unit/affinity_group/serialization_test.rb +0 -87
- data/test/unit/base_management/base_management_service_test.rb +0 -19
- data/test/unit/base_management/location_test.rb +0 -56
- data/test/unit/base_management/role_size_test.rb +0 -50
- data/test/unit/blob/auth/shared_access_signature_test.rb +0 -71
- data/test/unit/blob/blob_service_test.rb +0 -1970
- data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +0 -94
- data/test/unit/cloud_service_management/serialization_test.rb +0 -169
- data/test/unit/config/azure_test.rb +0 -131
- data/test/unit/config/client_test.rb +0 -37
- data/test/unit/core/auth/shared_key_lite_test.rb +0 -51
- data/test/unit/core/auth/shared_key_test.rb +0 -58
- data/test/unit/core/auth/signer_test.rb +0 -30
- data/test/unit/core/http/http_error_test.rb +0 -61
- data/test/unit/core/http/http_request_test.rb +0 -138
- data/test/unit/core/http/http_response_test.rb +0 -20
- data/test/unit/core/http/retry_policy_test.rb +0 -23
- data/test/unit/core/utility_test.rb +0 -122
- data/test/unit/database/serialization_test.rb +0 -94
- data/test/unit/database/sql_database_server_service_test.rb +0 -341
- data/test/unit/http_client_test.rb +0 -74
- data/test/unit/service/serialization_test.rb +0 -533
- data/test/unit/service/storage_service_test.rb +0 -297
- data/test/unit/storage_management/serialization_test.rb +0 -244
- data/test/unit/storage_management/storage_management_service_test.rb +0 -247
- data/test/unit/table/edmtype_test.rb +0 -108
- data/test/unit/virtual_machine_image_management/serialization_test.rb +0 -50
- data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +0 -114
- data/test/unit/virtual_machine_management/serialization_test.rb +0 -316
- data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +0 -480
- data/test/unit/vnet/serialization_test.rb +0 -187
- data/test/unit/vnet/virtual_network_management_service_test.rb +0 -131
@@ -1,131 +0,0 @@
|
|
1
|
-
#-------------------------------------------------------------------------
|
2
|
-
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
#--------------------------------------------------------------------------
|
15
|
-
require "integration/test_helper"
|
16
|
-
require "azure/table/table_service"
|
17
|
-
require "azure/core/http/http_error"
|
18
|
-
|
19
|
-
describe Azure::Table::TableService do
|
20
|
-
describe "#update_entity" do
|
21
|
-
subject { Azure::Table::TableService.new }
|
22
|
-
let(:table_name){ TableNameHelper.name }
|
23
|
-
|
24
|
-
let(:entity_properties){
|
25
|
-
{
|
26
|
-
"PartitionKey" => "testingpartition",
|
27
|
-
"RowKey" => "abcd1234_existing",
|
28
|
-
"CustomStringProperty" => "CustomPropertyValue",
|
29
|
-
"CustomIntegerProperty" => 37,
|
30
|
-
"CustomBooleanProperty" => true,
|
31
|
-
"CustomDateProperty" => Time.now
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
before {
|
36
|
-
subject.create_table table_name
|
37
|
-
subject.insert_entity table_name, entity_properties
|
38
|
-
@existing_etag = ""
|
39
|
-
|
40
|
-
exists = false
|
41
|
-
begin
|
42
|
-
existing = subject.get_entity table_name, entity_properties["PartitionKey"], entity_properties["RowKey"]
|
43
|
-
@existing_etag = existing.etag
|
44
|
-
exists = true
|
45
|
-
rescue
|
46
|
-
end
|
47
|
-
|
48
|
-
assert exists, "cannot verify existing record"
|
49
|
-
}
|
50
|
-
|
51
|
-
after { TableNameHelper.clean }
|
52
|
-
|
53
|
-
it "updates an existing entity, removing any properties not included in the update operation" do
|
54
|
-
etag = subject.update_entity table_name, {
|
55
|
-
"PartitionKey" => entity_properties["PartitionKey"],
|
56
|
-
"RowKey" => entity_properties["RowKey"],
|
57
|
-
"NewCustomProperty" => "NewCustomValue"
|
58
|
-
}
|
59
|
-
|
60
|
-
etag.must_be_kind_of String
|
61
|
-
etag.wont_equal @existing_etag
|
62
|
-
|
63
|
-
result = subject.get_entity table_name, entity_properties["PartitionKey"], entity_properties["RowKey"]
|
64
|
-
|
65
|
-
result.must_be_kind_of Azure::Table::Entity
|
66
|
-
result.table.must_equal table_name
|
67
|
-
|
68
|
-
# removed all existing props
|
69
|
-
entity_properties.each { |k,v|
|
70
|
-
result.properties.wont_include k unless k == "PartitionKey" || k == "RowKey"
|
71
|
-
}
|
72
|
-
|
73
|
-
# and has the new one
|
74
|
-
result.properties["NewCustomProperty"].must_equal "NewCustomValue"
|
75
|
-
end
|
76
|
-
|
77
|
-
it "updates an existing entity, removing any properties not included in the update operation and adding nil one" do
|
78
|
-
etag = subject.update_entity table_name, {
|
79
|
-
"PartitionKey" => entity_properties["PartitionKey"],
|
80
|
-
"RowKey" => entity_properties["RowKey"],
|
81
|
-
"NewCustomProperty" => nil
|
82
|
-
}
|
83
|
-
|
84
|
-
etag.must_be_kind_of String
|
85
|
-
etag.wont_equal @existing_etag
|
86
|
-
|
87
|
-
result = subject.get_entity table_name, entity_properties["PartitionKey"], entity_properties["RowKey"]
|
88
|
-
|
89
|
-
result.must_be_kind_of Azure::Table::Entity
|
90
|
-
result.table.must_equal table_name
|
91
|
-
|
92
|
-
# removed all existing props
|
93
|
-
entity_properties.each { |k,v|
|
94
|
-
result.properties.wont_include k unless k == "PartitionKey" || k == "RowKey"
|
95
|
-
}
|
96
|
-
|
97
|
-
# and has the new one
|
98
|
-
result.properties["NewCustomProperty"].must_equal nil
|
99
|
-
end
|
100
|
-
|
101
|
-
it "errors on a non-existing row key" do
|
102
|
-
assert_raises(Azure::Core::Http::HTTPError) do
|
103
|
-
entity = entity_properties.dup
|
104
|
-
entity["RowKey"] = "this-row-key-does-not-exist"
|
105
|
-
subject.update_entity table_name, entity
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
it "errors on an invalid table name" do
|
110
|
-
assert_raises(Azure::Core::Http::HTTPError) do
|
111
|
-
subject.update_entity "this_table.cannot-exist!", entity_properties
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
it "errors on an invalid partition key" do
|
116
|
-
assert_raises(Azure::Core::Http::HTTPError) do
|
117
|
-
entity = entity_properties.dup
|
118
|
-
entity["PartitionKey"] = "this/partition_key#is?invalid"
|
119
|
-
subject.update_entity table_name, entity
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
it "errors on an invalid row key" do
|
124
|
-
assert_raises(Azure::Core::Http::HTTPError) do
|
125
|
-
entity = entity_properties.dup
|
126
|
-
entity["RowKey"] = "this/row_key#is?invalid"
|
127
|
-
subject.update_entity table_name, entity
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
#-------------------------------------------------------------------------
|
2
|
-
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
#--------------------------------------------------------------------------
|
15
|
-
require 'test_helper'
|
16
|
-
require 'azure'
|
17
|
-
|
18
|
-
Azure.configure do |config|
|
19
|
-
config.storage_access_key = ENV.fetch('AZURE_STORAGE_ACCESS_KEY')
|
20
|
-
config.storage_account_name = ENV.fetch('AZURE_STORAGE_ACCOUNT')
|
21
|
-
config.sb_namespace = ENV.fetch('AZURE_SERVICEBUS_NAMESPACE')
|
22
|
-
config.sb_access_key = ENV.fetch('AZURE_SERVICEBUS_ACCESS_KEY')
|
23
|
-
config.management_certificate = ENV.fetch('AZURE_MANAGEMENT_CERTIFICATE')
|
24
|
-
config.subscription_id = ENV.fetch('AZURE_SUBSCRIPTION_ID')
|
25
|
-
end
|
26
|
-
|
27
|
-
util = Class.new.extend(Azure::Core::Utility)
|
28
|
-
|
29
|
-
StorageAccountName = util.random_string('storagetest',10)
|
30
|
-
Images = Azure::VirtualMachineImageManagementService.new.list_virtual_machine_images
|
31
|
-
LinuxImage = Images.select{|image| image.os_type == 'Linux'}.first
|
32
|
-
WindowsImage = Images.select{|image| image.os_type == 'Windows'}.first
|
33
|
-
locations = WindowsImage.locations.split(';')
|
34
|
-
WindowsImageLocation = locations.include?('West US') ? 'West US' : locations.first
|
35
|
-
locations = LinuxImage.locations.split(';')
|
36
|
-
LinuxImageLocation = locations.include?('West US') ? 'West US' : locations.first
|
37
|
-
|
38
|
-
MiniTest.after_run {
|
39
|
-
VirtualMachineNameGenerator.cleanup
|
40
|
-
}
|
@@ -1,262 +0,0 @@
|
|
1
|
-
#-------------------------------------------------------------------------
|
2
|
-
# Copyright 2013 Microsoft Open Technologies, Inc.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
#--------------------------------------------------------------------------
|
15
|
-
require 'integration/test_helper'
|
16
|
-
|
17
|
-
describe Azure::VirtualMachineManagementService do
|
18
|
-
include Azure::Core::Utility
|
19
|
-
|
20
|
-
subject { Azure::VirtualMachineManagementService.new }
|
21
|
-
let(:cloud_service) { Azure::CloudServiceManagementService.new }
|
22
|
-
let(:names) { VirtualMachineNameHelper.name }
|
23
|
-
let(:virtual_machine_name) { names.first }
|
24
|
-
let(:cloud_service_name) { names.last }
|
25
|
-
let(:storage_account_name) { StorageAccountName }
|
26
|
-
let(:username) { 'adminuser' }
|
27
|
-
let(:password) { 'Admin123' }
|
28
|
-
let(:private_key) { Fixtures['privatekey.key'] }
|
29
|
-
|
30
|
-
let(:params)do
|
31
|
-
{
|
32
|
-
vm_name: virtual_machine_name,
|
33
|
-
vm_user: username,
|
34
|
-
image: LinuxImage.name,
|
35
|
-
password: password,
|
36
|
-
location: LinuxImageLocation
|
37
|
-
}
|
38
|
-
end
|
39
|
-
|
40
|
-
let(:windows_params)do
|
41
|
-
{
|
42
|
-
vm_name: virtual_machine_name,
|
43
|
-
vm_user: username,
|
44
|
-
image: WindowsImage.name,
|
45
|
-
password: password,
|
46
|
-
location: WindowsImageLocation
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
let(:options)do
|
51
|
-
{
|
52
|
-
storage_account_name: storage_account_name,
|
53
|
-
cloud_service_name: cloud_service_name,
|
54
|
-
vm_size: 'Basic_A0'
|
55
|
-
}
|
56
|
-
end
|
57
|
-
|
58
|
-
let(:default_options) do
|
59
|
-
{
|
60
|
-
storage_account_name: storage_account_name,
|
61
|
-
cloud_service_name: cloud_service_name
|
62
|
-
}
|
63
|
-
end
|
64
|
-
|
65
|
-
before do
|
66
|
-
Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
|
67
|
-
end
|
68
|
-
|
69
|
-
describe '#deployment' do
|
70
|
-
|
71
|
-
describe '#add_role' do
|
72
|
-
before do
|
73
|
-
@vm_obj = subject.create_virtual_machine(params, options)
|
74
|
-
params[:cloud_service_name] = options[:cloud_service_name]
|
75
|
-
options.delete(:cloud_service_name)
|
76
|
-
params.delete(:location)
|
77
|
-
params[:vm_name] = "add-#{virtual_machine_name}"
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'should add role to existing storage account and cloud service' do
|
81
|
-
vm = subject.add_role(params, options)
|
82
|
-
vm.cloud_service_name.must_equal params[:cloud_service_name]
|
83
|
-
vm.vm_name.must_equal params[:vm_name]
|
84
|
-
vm.deployment_name.must_equal @vm_obj.deployment_name
|
85
|
-
vm.os_type.must_equal 'Linux'
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'should add role and create new storage account' do
|
89
|
-
params[:vm_name] = "Add-storage-#{virtual_machine_name}"
|
90
|
-
vm = subject.add_role(params)
|
91
|
-
vm.cloud_service_name.must_equal params[:cloud_service_name]
|
92
|
-
vm.vm_name.must_equal params[:vm_name]
|
93
|
-
vm.deployment_name.must_equal @vm_obj.deployment_name
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe '#virtual_network' do
|
98
|
-
let(:subnet_name) { 'Subnet-1' }
|
99
|
-
let(:geo_location) { LinuxImageLocation }
|
100
|
-
let(:static_virtual_network_ipaddress){'172.16.0.10'}
|
101
|
-
before do
|
102
|
-
options[:virtual_network_name] = 'v-net'
|
103
|
-
inputoptions = {
|
104
|
-
subnet: [{ name: subnet_name, ip_address: '172.16.0.0', cidr: 12 }],
|
105
|
-
dns: [{ name: 'DNS', ip_address: '1.2.3.4' }]
|
106
|
-
}
|
107
|
-
vnet_service = Azure::VirtualNetworkManagementService
|
108
|
-
vnet_service.new.set_network_configuration(
|
109
|
-
options[:virtual_network_name],
|
110
|
-
geo_location,
|
111
|
-
['172.16.0.0/12'],
|
112
|
-
inputoptions
|
113
|
-
) rescue nil
|
114
|
-
options[:subnet_name] = subnet_name
|
115
|
-
options[:static_virtual_network_ipaddress] = '172.16.0.10'
|
116
|
-
subject.create_virtual_machine(params, options)
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'should provision virtual machine in a existing virtual network' do
|
120
|
-
virtual_machine = subject.get_virtual_machine(virtual_machine_name, cloud_service_name)
|
121
|
-
virtual_machine.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
|
122
|
-
virtual_machine.vm_name.must_equal virtual_machine_name
|
123
|
-
virtual_machine.virtual_network_name.must_equal options[:virtual_network_name]
|
124
|
-
virtual_machine.subnet.must_equal subnet_name
|
125
|
-
virtual_machine.static_virtual_network_ipaddress.must_equal static_virtual_network_ipaddress
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'should set options hash with valid cloud_service_name, deployment_name, storage_account_name and virtual network' do
|
130
|
-
csn = options[:cloud_service_name]
|
131
|
-
options[:availability_set_name] = 'aval-set-test'
|
132
|
-
vm = subject.create_virtual_machine(params, options)
|
133
|
-
vm.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
|
134
|
-
vm.cloud_service_name.wont_be_nil
|
135
|
-
vm.vm_name.must_equal virtual_machine_name
|
136
|
-
vm.deployment_name.wont_be_nil
|
137
|
-
vm.deployment_name.must_equal vm.cloud_service_name
|
138
|
-
vm.os_type.must_equal 'Linux'
|
139
|
-
vm.role_size.must_equal 'Basic_A0'
|
140
|
-
vm.availability_set_name.must_equal 'aval-set-test'
|
141
|
-
options[:storage_account_name].wont_be_nil
|
142
|
-
assert_match(/^#{params[:vm_name] + '-service'}*/, csn)
|
143
|
-
end
|
144
|
-
|
145
|
-
it 'should creates http and https enabled winrm virtual machine without certificate.' do
|
146
|
-
default_options.merge!(winrm_transport: %w(https http))
|
147
|
-
result = subject.create_virtual_machine(windows_params, default_options)
|
148
|
-
result.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
|
149
|
-
assert_equal(result.os_type, 'Windows')
|
150
|
-
tcp_endpoints_names = []
|
151
|
-
result.tcp_endpoints.each do |tcp_endpoint|
|
152
|
-
tcp_endpoints_names << tcp_endpoint[:name]
|
153
|
-
end
|
154
|
-
tcp_endpoints_names.must_include 'PowerShell'
|
155
|
-
tcp_endpoints_names.must_include 'WinRm-Http'
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'should creates https enabled winrm virtual machine using certificate.' do
|
159
|
-
default_options.merge!(
|
160
|
-
winrm_transport: ['https'],
|
161
|
-
private_key_file: private_key
|
162
|
-
)
|
163
|
-
result = subject.create_virtual_machine(windows_params, default_options)
|
164
|
-
result.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
|
165
|
-
assert_equal(result.os_type, 'Windows')
|
166
|
-
tcp_endpoints_names = []
|
167
|
-
result.tcp_endpoints.each do |tcp_endpoint|
|
168
|
-
tcp_endpoints_names << tcp_endpoint[:name]
|
169
|
-
end
|
170
|
-
tcp_endpoints_names.must_include 'PowerShell'
|
171
|
-
end
|
172
|
-
|
173
|
-
it 'should creates windows virtual machine without winrm.' do
|
174
|
-
default_options.merge!(winrm_transport: ['none'])
|
175
|
-
result = subject.create_virtual_machine(windows_params, default_options)
|
176
|
-
result.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
|
177
|
-
assert_equal(result.os_type, 'Windows')
|
178
|
-
tcp_endpoints_names = []
|
179
|
-
result.tcp_endpoints.each do |tcp_endpoint|
|
180
|
-
tcp_endpoints_names << tcp_endpoint['Name']
|
181
|
-
end
|
182
|
-
assert !tcp_endpoints_names.include?('PowerShell')
|
183
|
-
assert !tcp_endpoints_names.include?('WinRm-Http')
|
184
|
-
end
|
185
|
-
|
186
|
-
it 'created linux virtual machine should be accessible using password and certificate' do
|
187
|
-
default_options.merge!(
|
188
|
-
private_key_file: private_key
|
189
|
-
)
|
190
|
-
result = subject.create_virtual_machine(params, default_options)
|
191
|
-
result.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
|
192
|
-
assert_equal(result.os_type, 'Linux')
|
193
|
-
end
|
194
|
-
|
195
|
-
it 'throws error as port value is beyond or less than actual range' do
|
196
|
-
default_options.merge!(tcp_endpoints: '80,166535:166535')
|
197
|
-
ex = assert_raises(RuntimeError){subject.create_virtual_machine(params, default_options)}
|
198
|
-
error_msg = "invalid. Allowed values are 'a number between 1 to 65535'."
|
199
|
-
assert_match(/#{error_msg}/i, ex.message)
|
200
|
-
|
201
|
-
default_options.merge!(tcp_endpoints: '80,0:0')
|
202
|
-
ex = assert_raises(RuntimeError){subject.create_virtual_machine(params, default_options)}
|
203
|
-
assert_match(/#{error_msg}/i,ex.message)
|
204
|
-
cloud_service.delete_cloud_service(cloud_service_name)
|
205
|
-
end
|
206
|
-
|
207
|
-
it 'throws error when multiple VMs created under same DNS' do
|
208
|
-
subject.create_virtual_machine(params, default_options)
|
209
|
-
ex = assert_raises(RuntimeError){subject.create_virtual_machine(windows_params, default_options)}
|
210
|
-
error_msg = 'The specified deployment slot Production is occupied.'
|
211
|
-
assert_match(/#{error_msg}/i, ex.message)
|
212
|
-
end
|
213
|
-
|
214
|
-
it 'throws SystemExit error when vm_user not provided' do
|
215
|
-
params.delete(:vm_user)
|
216
|
-
ex = assert_raises(RuntimeError){subject.create_virtual_machine(params)}
|
217
|
-
assert_match(/You did not provide a valid 'vm_user' value./i, ex.message)
|
218
|
-
end
|
219
|
-
|
220
|
-
it 'throws Runtime error when image not provide' do
|
221
|
-
params.delete(:image)
|
222
|
-
ex = assert_raises(RuntimeError){ subject.create_virtual_machine(params)}
|
223
|
-
assert_match(/The virtual machine image source is not valid/i, ex.message)
|
224
|
-
end
|
225
|
-
|
226
|
-
it 'error thrown when invalid storage account name is given' do
|
227
|
-
default_options.merge!(storage_account_name: 'storageuse_91')
|
228
|
-
ex = assert_raises(RuntimeError){subject.create_virtual_machine(params, default_options)}
|
229
|
-
assert_match(/The name is not a valid storage account name./i, ex.message)
|
230
|
-
cloud_service.delete_cloud_service(cloud_service_name)
|
231
|
-
end
|
232
|
-
|
233
|
-
it 'error thrown when invalid cloud name is given' do
|
234
|
-
default_options.merge!(cloud_service_name: 'cloud-server-test_91')
|
235
|
-
ex = assert_raises(RuntimeError){ subject.create_virtual_machine(params, default_options)}
|
236
|
-
assert_match(/The hosted service name is invalid/i, ex.message)
|
237
|
-
end
|
238
|
-
|
239
|
-
it 'error thrown when invalid deployment name provided' do
|
240
|
-
default_options.merge!(deployment_name: 'instance_B')
|
241
|
-
ex = assert_raises(RuntimeError){subject.create_virtual_machine(params, default_options)}
|
242
|
-
assert_match(/The deployment name is invalid/i,ex.message)
|
243
|
-
cloud_service.delete_cloud_service(cloud_service_name)
|
244
|
-
end
|
245
|
-
|
246
|
-
it 'error thrown when invalid VM name given for Windows OS' do
|
247
|
-
windows_params.merge!(vm_name: 'MSServerInstnce01')
|
248
|
-
ex = assert_raises(RuntimeError) {subject.create_virtual_machine(windows_params, default_options)}
|
249
|
-
error_msg = 'The computer name cannot be more than 15 characters long'
|
250
|
-
assert_match(/#{error_msg}/i, ex.message)
|
251
|
-
cloud_service.delete_cloud_service(cloud_service_name)
|
252
|
-
end
|
253
|
-
|
254
|
-
it 'error thrown when blank password for Windows OS provided' do
|
255
|
-
windows_params.delete(:password)
|
256
|
-
ex = assert_raises(RuntimeError){ subject.create_virtual_machine(windows_params, default_options)}
|
257
|
-
assert_match(/You did not provide a valid 'password' value./i, ex.message)
|
258
|
-
end
|
259
|
-
|
260
|
-
end # deployment
|
261
|
-
|
262
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
#-------------------------------------------------------------------------
|
2
|
-
# Copyright 2013 Microsoft Open Technologies, Inc.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
#--------------------------------------------------------------------------
|
15
|
-
require 'integration/test_helper'
|
16
|
-
|
17
|
-
describe Azure::VirtualMachineManagementService do
|
18
|
-
|
19
|
-
subject { Azure::VirtualMachineManagementService.new }
|
20
|
-
let(:names) { VirtualMachineNameHelper.name }
|
21
|
-
let(:virtual_machine_name) { names.first }
|
22
|
-
let(:csn) { names.last }
|
23
|
-
let(:username) { 'admin' }
|
24
|
-
before do
|
25
|
-
Azure::Loggerx.expects(:puts).at_least_once.returns(nil)
|
26
|
-
params = {
|
27
|
-
vm_name: virtual_machine_name,
|
28
|
-
vm_user: 'user',
|
29
|
-
image: LinuxImage.name,
|
30
|
-
password: 'User123',
|
31
|
-
location: LinuxImageLocation
|
32
|
-
}
|
33
|
-
options = {
|
34
|
-
storage_account_name: StorageAccountName,
|
35
|
-
cloud_service_name: csn,
|
36
|
-
}
|
37
|
-
subject.create_virtual_machine(params, options)
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#delete_virtual_machine' do
|
41
|
-
|
42
|
-
it 'delete existing virtual machine and cloud service' do
|
43
|
-
subject.delete_virtual_machine(virtual_machine_name, csn)
|
44
|
-
vm = subject.get_virtual_machine(virtual_machine_name, csn)
|
45
|
-
vm.must_be_nil
|
46
|
-
cloud_service = Azure::CloudServiceManagementService.new
|
47
|
-
cloud_presence = cloud_service.get_cloud_service(csn)
|
48
|
-
cloud_presence.must_equal nil
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|