azure 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/Gemfile.lock +36 -0
- data/README.md +3 -0
- data/Rakefile +81 -0
- data/azure.gemspec +20 -9
- data/lib/azure.rb +4 -0
- data/lib/azure/atom.rb +170 -0
- data/lib/azure/auth.rb +29 -0
- data/lib/azure/blobs.rb +620 -0
- data/lib/azure/blobs/blob.rb +360 -0
- data/lib/azure/blobs/container.rb +209 -0
- data/lib/azure/blobs/service.rb +396 -0
- data/lib/azure/blobs/shared_access_signature.rb +84 -0
- data/lib/azure/blobs/uri.rb +60 -0
- data/lib/azure/configuration.rb +121 -0
- data/lib/azure/core/auth/shared_key.rb +95 -0
- data/lib/azure/core/auth/shared_key_lite.rb +34 -0
- data/lib/azure/core/collection.rb +118 -0
- data/lib/azure/core/service.rb +43 -0
- data/lib/azure/core/signer.rb +32 -0
- data/lib/azure/core/utils/interval.rb +97 -0
- data/lib/azure/core/utils/queryable.rb +74 -0
- data/lib/azure/core/utils/storage_service_properties.rb +83 -0
- data/lib/azure/core/utils/string.rb +59 -0
- data/lib/azure/error.rb +72 -0
- data/lib/azure/queues.rb +272 -0
- data/lib/azure/queues/message.rb +174 -0
- data/lib/azure/queues/queue.rb +187 -0
- data/lib/azure/queues/service.rb +263 -0
- data/lib/azure/queues/service_properties.rb +152 -0
- data/lib/azure/queues/uri.rb +78 -0
- data/lib/azure/request.rb +102 -0
- data/lib/azure/response.rb +93 -0
- data/lib/azure/service_bus.rb +4 -0
- data/lib/azure/service_bus/auth/authorizer.rb +22 -0
- data/lib/azure/service_bus/auth/uri.rb +52 -0
- data/lib/azure/service_bus/auth/wrap.rb +37 -0
- data/lib/azure/service_bus/auth/wrap_service.rb +76 -0
- data/lib/azure/service_bus/auth/wrap_token.rb +45 -0
- data/lib/azure/service_bus/auth/wrap_token_manager.rb +46 -0
- data/lib/azure/service_bus/brokered_message.rb +139 -0
- data/lib/azure/service_bus/brokered_message_serializer.rb +113 -0
- data/lib/azure/service_bus/queues.rb +194 -0
- data/lib/azure/service_bus/queues/queue.rb +100 -0
- data/lib/azure/service_bus/queues/queue_serializer.rb +51 -0
- data/lib/azure/service_bus/queues/service.rb +154 -0
- data/lib/azure/service_bus/queues/uri.rb +80 -0
- data/lib/azure/service_bus/rules.rb +110 -0
- data/lib/azure/service_bus/rules/rule.rb +97 -0
- data/lib/azure/service_bus/rules/service.rb +122 -0
- data/lib/azure/service_bus/rules/uri.rb +39 -0
- data/lib/azure/service_bus/service_bus_service.rb +22 -0
- data/lib/azure/service_bus/subscriptions.rb +170 -0
- data/lib/azure/service_bus/subscriptions/service.rb +133 -0
- data/lib/azure/service_bus/subscriptions/subscription.rb +164 -0
- data/lib/azure/service_bus/subscriptions/subscription_serializer.rb +74 -0
- data/lib/azure/service_bus/subscriptions/uri.rb +71 -0
- data/lib/azure/service_bus/topics.rb +120 -0
- data/lib/azure/service_bus/topics/service.rb +98 -0
- data/lib/azure/service_bus/topics/topic.rb +122 -0
- data/lib/azure/service_bus/topics/topic_serializer.rb +44 -0
- data/lib/azure/service_bus/topics/uri.rb +58 -0
- data/lib/azure/service_runtime/client/goal_state_pipe_monitor.rb +21 -0
- data/lib/azure/service_runtime/client/goal_state_protocol.rb +18 -0
- data/lib/azure/service_runtime/client/runtime_client.rb +135 -0
- data/lib/azure/service_runtime/deployment.rb +24 -0
- data/lib/azure/service_runtime/local_resource.rb +15 -0
- data/lib/azure/service_runtime/role.rb +17 -0
- data/lib/azure/service_runtime/role_environment.rb +206 -0
- data/lib/azure/service_runtime/role_environment_change.rb +32 -0
- data/lib/azure/service_runtime/role_instance.rb +35 -0
- data/lib/azure/service_runtime/role_instance_endpoint.rb +14 -0
- data/lib/azure/tables.rb +215 -0
- data/lib/azure/tables/auth/shared_key.rb +71 -0
- data/lib/azure/tables/auth/shared_key_lite.rb +30 -0
- data/lib/azure/tables/entities_collection.rb +66 -0
- data/lib/azure/tables/entity.rb +127 -0
- data/lib/azure/tables/service.rb +211 -0
- data/lib/azure/tables/table.rb +129 -0
- data/lib/azure/tables/tables_collection.rb +62 -0
- data/lib/azure/tables/types.rb +65 -0
- data/lib/azure/tables/uri.rb +62 -0
- data/test/fixtures/32px-fulls-black.jpg +0 -0
- data/test/fixtures/all_containers.xml +20 -0
- data/test/fixtures/all_tables.xml +22 -0
- data/test/fixtures/create_table_response_entry.xml +15 -0
- data/test/fixtures/error.xml +5 -0
- data/test/fixtures/insert_entity_response_entry.xml +25 -0
- data/test/fixtures/messages.xml +12 -0
- data/test/fixtures/query_entities_empty_response.xml +7 -0
- data/test/fixtures/query_entities_response.xml +45 -0
- data/test/fixtures/queue_service_properties.xml +22 -0
- data/test/fixtures/queue_service_properties_original.xml +19 -0
- data/test/fixtures/queues.xml +16 -0
- data/test/fixtures/sb_default_create_queue_response.xml +23 -0
- data/test/fixtures/sb_default_create_topic_response.xml +18 -0
- data/test/fixtures/sb_get_access_token_response.txt +1 -0
- data/test/fixtures/sb_queues_runtime_peek_message_response_headers.txt +9 -0
- data/test/integration/blobs/auth_test.rb +19 -0
- data/test/integration/blobs/blob_test.rb +61 -0
- data/test/integration/blobs/clear_page_range_test.rb +19 -0
- data/test/integration/blobs/copy_test.rb +33 -0
- data/test/integration/blobs/create_blobs_test.rb +51 -0
- data/test/integration/blobs/create_container_test.rb +13 -0
- data/test/integration/blobs/create_snapshot_test.rb +17 -0
- data/test/integration/blobs/delete_blob_snapshots_test.rb +19 -0
- data/test/integration/blobs/delete_blobs_test.rb +25 -0
- data/test/integration/blobs/delete_container_test.rb +24 -0
- data/test/integration/blobs/delete_snapshot_test.rb +17 -0
- data/test/integration/blobs/get_blob_snapshot_test.rb +18 -0
- data/test/integration/blobs/get_blobs_test.rb +31 -0
- data/test/integration/blobs/get_page_range_test.rb +19 -0
- data/test/integration/blobs/list_blobs_test.rb +39 -0
- data/test/integration/blobs/list_containers_test.rb +28 -0
- data/test/integration/blobs/manage_blob_leases_test.rb +45 -0
- data/test/integration/blobs/manage_blob_metadata_test.rb +51 -0
- data/test/integration/blobs/manage_blob_properties_test.rb +25 -0
- data/test/integration/blobs/manage_blob_service_properties_test.rb +38 -0
- data/test/integration/blobs/manage_container_metadata_test.rb +46 -0
- data/test/integration/blobs/manage_container_permissions_test.rb +17 -0
- data/test/integration/blobs/update_page_range_test.rb +20 -0
- data/test/integration/queues/clear_messages_test.rb +22 -0
- data/test/integration/queues/create_queue_test.rb +13 -0
- data/test/integration/queues/delete_message_test.rb +42 -0
- data/test/integration/queues/delete_queue_test.rb +24 -0
- data/test/integration/queues/get_messages_test.rb +39 -0
- data/test/integration/queues/list_queues_test.rb +43 -0
- data/test/integration/queues/manage_queue_metadata_test.rb +45 -0
- data/test/integration/queues/manage_queue_service_properties_test.rb +27 -0
- data/test/integration/queues/peek_messages_test.rb +55 -0
- data/test/integration/queues/put_message_test.rb +31 -0
- data/test/integration/queues/update_message_test.rb +46 -0
- data/test/integration/service_bus/auth_test.rb +18 -0
- data/test/integration/service_bus/queues/create_queue_test.rb +25 -0
- data/test/integration/service_bus/queues/delete_message_from_queue_test.rb +29 -0
- data/test/integration/service_bus/queues/delete_queue_test.rb +25 -0
- data/test/integration/service_bus/queues/get_queue_test.rb +23 -0
- data/test/integration/service_bus/queues/list_queues_test.rb +39 -0
- data/test/integration/service_bus/queues/peek_message_from_queue_test.rb +34 -0
- data/test/integration/service_bus/queues/read_and_delete_message_from_queue_test.rb +31 -0
- data/test/integration/service_bus/queues/send_message_to_queue_test.rb +22 -0
- data/test/integration/service_bus/queues/unlock_message_from_queue_test.rb +36 -0
- data/test/integration/service_bus/rules/create_rule_test.rb +19 -0
- data/test/integration/service_bus/rules/delete_rule_test.rb +17 -0
- data/test/integration/service_bus/rules/get_rule_test.rb +21 -0
- data/test/integration/service_bus/rules/list_rules_test.rb +24 -0
- data/test/integration/service_bus/rules/rule_test.rb +16 -0
- data/test/integration/service_bus/subscriptions/create_subscription_test.rb +25 -0
- data/test/integration/service_bus/subscriptions/delete_message_from_subscription_test.rb +31 -0
- data/test/integration/service_bus/subscriptions/delete_subscription_test.rb +30 -0
- data/test/integration/service_bus/subscriptions/fetch_subscription_test.rb +28 -0
- data/test/integration/service_bus/subscriptions/list_subscriptions_test.rb +23 -0
- data/test/integration/service_bus/subscriptions/peek_lock_message_from_subscription_test.rb +42 -0
- data/test/integration/service_bus/subscriptions/read_delete_message_from_subscription_test.rb +36 -0
- data/test/integration/service_bus/subscriptions/subscription_test.rb +31 -0
- data/test/integration/service_bus/subscriptions/unlock_message_from_subscription_test.rb +43 -0
- data/test/integration/service_bus/topics/create_topic_test.rb +25 -0
- data/test/integration/service_bus/topics/delete_topic_test.rb +25 -0
- data/test/integration/service_bus/topics/get_topic_test.rb +23 -0
- data/test/integration/service_bus/topics/list_topics_test.rb +39 -0
- data/test/integration/service_bus/topics/send_message_to_topic_test.rb +23 -0
- data/test/integration/tables/auth_test.rb +29 -0
- data/test/integration/tables/creating_tables_test.rb +16 -0
- data/test/integration/tables/delete_entity_test.rb +39 -0
- data/test/integration/tables/deleting_table_test.rb +22 -0
- data/test/integration/tables/insert_entity_test.rb +23 -0
- data/test/integration/tables/merge_entity_test.rb +28 -0
- data/test/integration/tables/query_entities_test.rb +131 -0
- data/test/integration/tables/query_tables_test.rb +63 -0
- data/test/integration/tables/update_entity_test.rb +54 -0
- data/test/integration/test_helper.rb +14 -0
- data/test/support/blobs.rb +12 -0
- data/test/support/env.rb +5 -0
- data/test/support/fixtures.rb +22 -0
- data/test/support/stubs.rb +28 -0
- data/test/support/table_names.rb +44 -0
- data/test/test_helper.rb +10 -0
- data/test/unit/atom_test.rb +58 -0
- data/test/unit/auth_test.rb +24 -0
- data/test/unit/blobs/blob_test.rb +5 -0
- data/test/unit/blobs/container_test.rb +67 -0
- data/test/unit/blobs/service_test.rb +17 -0
- data/test/unit/blobs/shared_access_signature_test.rb +66 -0
- data/test/unit/blobs_test.rb +156 -0
- data/test/unit/core/service_test.rb +57 -0
- data/test/unit/core/utils/interval_test.rb +70 -0
- data/test/unit/core/utils/queryable_test.rb +69 -0
- data/test/unit/core/utils/storage_service_properties_test.rb +66 -0
- data/test/unit/error_test.rb +39 -0
- data/test/unit/queues/message_test.rb +40 -0
- data/test/unit/queues/queue_test.rb +64 -0
- data/test/unit/queues/service_properties.rb +35 -0
- data/test/unit/request_test.rb +38 -0
- data/test/unit/response_test.rb +43 -0
- data/test/unit/service_bus/auth/authorizer_test.rb +27 -0
- data/test/unit/service_bus/auth/wrap_token_test.rb +28 -0
- data/test/unit/service_bus/queues/queue_test.rb +38 -0
- data/test/unit/service_bus/topics/topic_test.rb +33 -0
- data/test/unit/service_runtime/data/goalstate.xml +9 -0
- data/test/unit/service_runtime/data/roleenvironmentdata.xml +29 -0
- data/test/unit/service_runtime/data/runtime.xml +6 -0
- data/test/unit/service_runtime/role_environment_test.rb +144 -0
- data/test/unit/tables/auth/shared_key_lite_test.rb +39 -0
- data/test/unit/tables/auth/shared_key_test.rb +45 -0
- data/test/unit/tables/entities_collection_test.rb +39 -0
- data/test/unit/tables/entity_test.rb +72 -0
- data/test/unit/tables/table_test.rb +57 -0
- data/test/unit/tables_test.rb +302 -0
- data/test/unit/types_test.rb +67 -0
- metadata +310 -47
- data/LICENSE +0 -0
- data/README +0 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
require "integration/test_helper"
|
2
|
+
|
3
|
+
describe "Manage Blob Leases" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@container = Azure::Blobs.create_container(ContainerNameHelper.name)
|
7
|
+
@blob = Azure::Blobs.create_block_blob(@container, "myBlob", nil)
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
ContainerNameHelper.clean
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should be able to acquire a lease" do
|
15
|
+
Azure::Blobs.lease(@blob, :acquire)
|
16
|
+
@blob.error.must_be_nil
|
17
|
+
@blob.lease_id.wont_be_nil
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should fail trying to acquire a lease in a blob with an active lease" do
|
21
|
+
Azure::Blobs.lease(@blob, :acquire)
|
22
|
+
Azure::Blobs.lease(@blob, :acquire)
|
23
|
+
@blob.error.wont_be_nil
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should be able to renew a lease" do
|
27
|
+
Azure::Blobs.lease(@blob, :acquire)
|
28
|
+
Azure::Blobs.lease(@blob, :renew)
|
29
|
+
@blob.error.must_be_nil
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should be able to release a lease" do
|
33
|
+
Azure::Blobs.lease(@blob, :acquire)
|
34
|
+
Azure::Blobs.lease(@blob, :release)
|
35
|
+
Azure::Blobs.lease(@blob, :acquire)
|
36
|
+
@blob.error.must_be_nil
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should be able to break a lease" do
|
40
|
+
Azure::Blobs.lease(@blob, :acquire)
|
41
|
+
Azure::Blobs.lease(@blob, :break)
|
42
|
+
Azure::Blobs.lease(@blob, :acquire)
|
43
|
+
@blob.error.wont_be_nil
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "integration/test_helper"
|
2
|
+
|
3
|
+
describe "Managing the blob's metadata" do
|
4
|
+
let :container do
|
5
|
+
Azure::Blobs.create_container(ContainerNameHelper.name)
|
6
|
+
end
|
7
|
+
|
8
|
+
after do
|
9
|
+
ContainerNameHelper.clean
|
10
|
+
end
|
11
|
+
|
12
|
+
it "can set the metadata on blob creation (but changes key casing)" do
|
13
|
+
blob = Azure::Blobs.create_block_blob(
|
14
|
+
container,
|
15
|
+
"myblob.jpg",
|
16
|
+
Fixtures["32px-fulls-black.jpg"].to_path,
|
17
|
+
"Key" => "Value"
|
18
|
+
)
|
19
|
+
|
20
|
+
blob.metadata.clear
|
21
|
+
blob.load_metadata!
|
22
|
+
blob.metadata["key"].must_equal "Value"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "gets the metadata when listing blobs" do
|
26
|
+
create_block_blob(:container => container, :metadata => {"Key" => "Value"})
|
27
|
+
|
28
|
+
blob = Azure::Blobs.blobs(container).first
|
29
|
+
blob.metadata["Key"].must_equal "Value"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "force-loads the metadata when calling #load_metadata!" do
|
33
|
+
blob = create_block_blob(:container => container, :metadata => {"name" => "Xara"})
|
34
|
+
blob.metadata["name"] = "NotXara" # change the metadata locally
|
35
|
+
blob.load_metadata! # it gets replaced by the metadata on the server
|
36
|
+
|
37
|
+
blob.metadata["name"].must_equal "Xara"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "can update the metadata on the server after you modify the hash" do
|
41
|
+
blob = create_block_blob(:container => container)
|
42
|
+
blob.metadata.update("name" => "Manu")
|
43
|
+
|
44
|
+
result = blob.save_metadata!
|
45
|
+
result.must_equal true
|
46
|
+
|
47
|
+
blob.metadata["name"] = "NotManu"
|
48
|
+
metadata = blob.load_metadata!
|
49
|
+
blob.metadata["name"].must_equal "Manu"
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "integration/test_helper"
|
2
|
+
|
3
|
+
describe "Managing the blob's properties" do
|
4
|
+
before do
|
5
|
+
@container = Azure::Blobs.create_container(ContainerNameHelper.name)
|
6
|
+
end
|
7
|
+
|
8
|
+
after do
|
9
|
+
ContainerNameHelper.clean
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should set blob properties" do
|
13
|
+
# FIXME: Why do this if we're not checking for any property getting set?
|
14
|
+
blob = create_block_blob(:container => @container)
|
15
|
+
result = blob.save_properties!
|
16
|
+
result.must_equal true
|
17
|
+
end
|
18
|
+
|
19
|
+
it "force-loads the properties" do
|
20
|
+
blob = create_block_blob(:container => @container)
|
21
|
+
blob.properties.clear
|
22
|
+
blob.load_properties!
|
23
|
+
blob.properties["etag"].wont_be_nil
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "integration/test_helper"
|
2
|
+
require "azure/core/utils/storage_service_properties"
|
3
|
+
|
4
|
+
describe "Manage Blob Service Properties" do
|
5
|
+
it "should be able to set blob service properties" do
|
6
|
+
|
7
|
+
properties = {
|
8
|
+
"Logging" => {
|
9
|
+
"Version" => "1.0",
|
10
|
+
"Delete" => "true",
|
11
|
+
"Read" => "true",
|
12
|
+
"Write" => "true",
|
13
|
+
"RetentionPolicy" => {
|
14
|
+
"Enabled" => true,
|
15
|
+
"Days" => 7
|
16
|
+
}
|
17
|
+
},
|
18
|
+
"Metrics"=> {
|
19
|
+
"Version" => "1.0",
|
20
|
+
"Enabled" => "true",
|
21
|
+
"IncludeAPIs" => "false",
|
22
|
+
"RetentionPolicy" => {
|
23
|
+
"Enabled" => true,
|
24
|
+
"Days" => 7
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
Azure::Blobs.set_service_properties(properties).must_equal true
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should be able to get blob service properties" do
|
33
|
+
response = Azure::Blobs.get_service_properties
|
34
|
+
response.must_be :kind_of?, Hash
|
35
|
+
response["Metrics"].must_be :kind_of?, Hash
|
36
|
+
response["Metrics"]["Version"].must_equal "1.0"
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "integration/test_helper"
|
2
|
+
|
3
|
+
describe "Managing the container's metadata" do
|
4
|
+
after do
|
5
|
+
ContainerNameHelper.clean
|
6
|
+
end
|
7
|
+
|
8
|
+
it "sets metadata on container creation (Azure changes the casing of metadata keys)" do
|
9
|
+
Azure::Blobs.create_container(
|
10
|
+
ContainerNameHelper.name,
|
11
|
+
"UppercaseKey" => "U", "downcaseKey" => "D"
|
12
|
+
)
|
13
|
+
|
14
|
+
# FIXME: Change this once we have a way of finding a container by name.
|
15
|
+
container = Azure::Blobs.containers.first
|
16
|
+
|
17
|
+
container.metadata["Uppercasekey"].must_equal "U"
|
18
|
+
container.metadata["Downcasekey"].must_equal "D"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "gets metadata when listing containers" do
|
22
|
+
Azure::Blobs.create_container(ContainerNameHelper.name, "Key" => "Value")
|
23
|
+
|
24
|
+
# FIXME: Change this once we have a way of finding a container by name.
|
25
|
+
container = Azure::Blobs.containers.first
|
26
|
+
container.metadata["Key"].must_equal "Value"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "force-loads the metadata when calling #metadata!" do
|
30
|
+
container = Azure::Blobs.create_container(ContainerNameHelper.name, "Key" => "Value")
|
31
|
+
|
32
|
+
container.metadata.must_be_empty
|
33
|
+
container.load_metadata!.wont_be_empty
|
34
|
+
container.metadata.wont_be_empty
|
35
|
+
end
|
36
|
+
|
37
|
+
it "saves the metadata in the server if you modify the metadata hash" do
|
38
|
+
container = Azure::Blobs.create_container(ContainerNameHelper.name)
|
39
|
+
container.metadata["Key"] = "Value"
|
40
|
+
container.save_metadata!
|
41
|
+
|
42
|
+
# FIXME: Change this once we have a way of finding a container by name.
|
43
|
+
loaded_container = Azure::Blobs.containers.first
|
44
|
+
loaded_container.metadata["Key"].must_equal "Value"
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "integration/test_helper"
|
2
|
+
|
3
|
+
describe "Managing a container's permissions" do
|
4
|
+
after do
|
5
|
+
ContainerNameHelper.clean
|
6
|
+
end
|
7
|
+
|
8
|
+
it "can grant temporary anonymous access to a blob via shared access signstures" do
|
9
|
+
container = Azure::Blobs.create_container(ContainerNameHelper.name)
|
10
|
+
blob = create_block_blob(:container => container)
|
11
|
+
|
12
|
+
url = blob.shared_access_signature("r", 10 * 60) # read permissions, 10 minutes
|
13
|
+
|
14
|
+
response = Net::HTTP.get_response(url)
|
15
|
+
response.code.must_equal "200"
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "integration/test_helper"
|
2
|
+
|
3
|
+
describe "Update Page Range" do
|
4
|
+
before do
|
5
|
+
@container = Azure::Blobs.create_container(ContainerNameHelper.name)
|
6
|
+
@blob = Azure::Blobs.create_page_blob(@container, "myBlob", 2048)
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
ContainerNameHelper.clean
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be able to update a range of bytes" do
|
14
|
+
stream = "Hello World!" + (" " * (1024 - 12))
|
15
|
+
|
16
|
+
stream.bytesize.must_equal 1024
|
17
|
+
|
18
|
+
Azure::Blobs.update_page_range(@blob, 0, 1023, stream).must_equal true
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "integration/test_helper"
|
2
|
+
|
3
|
+
describe "Clear Messages" do
|
4
|
+
after do
|
5
|
+
QueueNameHelper.clean
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
@queue = Azure::Queues.create(QueueNameHelper.name)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be able to delete all messages from the queue" do
|
13
|
+
@queue << "message 1"
|
14
|
+
@queue << "message 2"
|
15
|
+
|
16
|
+
result = @queue.clear
|
17
|
+
result.must_equal true
|
18
|
+
|
19
|
+
messages = @queue.get(5)
|
20
|
+
messages.must_be_empty
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "integration/test_helper"
|
2
|
+
|
3
|
+
describe "Create queues" do
|
4
|
+
after do
|
5
|
+
QueueNameHelper.clean
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should be able to create a new queue" do
|
9
|
+
queue = Azure::Queues.create(QueueNameHelper.name)
|
10
|
+
queue.must_be_kind_of Azure::Queues::Queue
|
11
|
+
assert queue.valid?, "must be valid"
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "integration/test_helper"
|
2
|
+
|
3
|
+
describe "Delete Messages" do
|
4
|
+
after do
|
5
|
+
QueueNameHelper.clean
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
@queue = Azure::Queues.create(QueueNameHelper.name)
|
10
|
+
@queue << "some sample text"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be able to delete a message from the queue" do
|
14
|
+
message = @queue.pop
|
15
|
+
response = message.delete
|
16
|
+
response.must_equal true
|
17
|
+
assert message.frozen?
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "Invalid delete operations" do
|
21
|
+
it "shouldn't be able to delete an expired message" do
|
22
|
+
skip "Docs say so but in fact this test it's not passing as of now"
|
23
|
+
|
24
|
+
Azure::Queues::Message.new("some sample text") do |message|
|
25
|
+
message.ttl = 1
|
26
|
+
end
|
27
|
+
|
28
|
+
message = @queue.pop
|
29
|
+
sleep 1
|
30
|
+
|
31
|
+
response = message.delete
|
32
|
+
response.must_equal false
|
33
|
+
end
|
34
|
+
|
35
|
+
it "shouldn't be able to delete an already deleted message" do
|
36
|
+
message = @queue.pop
|
37
|
+
message.delete
|
38
|
+
|
39
|
+
proc { message.delete }.must_raise RuntimeError
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "integration/test_helper"
|
2
|
+
|
3
|
+
describe "Deleting a queue" do
|
4
|
+
after do
|
5
|
+
QueueNameHelper.clean
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should return false if the queue cannot be deleted" do
|
9
|
+
queue = Azure::Queues::Queue.new(QueueNameHelper.name)
|
10
|
+
response = queue.delete
|
11
|
+
|
12
|
+
response.must_equal false
|
13
|
+
refute queue.valid?
|
14
|
+
refute queue.frozen?
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return true if the queue can be deleted" do
|
18
|
+
queue = Azure::Queues.create(QueueNameHelper.name)
|
19
|
+
response = queue.delete
|
20
|
+
|
21
|
+
response.must_equal true
|
22
|
+
assert queue.frozen?
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "integration/test_helper"
|
2
|
+
|
3
|
+
describe "Get Messages" do
|
4
|
+
after do
|
5
|
+
QueueNameHelper.clean
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
@queue = Azure::Queues.create(QueueNameHelper.name)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "gets the last message when calling #pop" do
|
13
|
+
@queue << "message 1"
|
14
|
+
@queue << "message 2"
|
15
|
+
|
16
|
+
message = @queue.pop
|
17
|
+
message.text.must_equal "message 1"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "can get more than once message at a time" do
|
21
|
+
@queue << "message 1"
|
22
|
+
@queue << "message 2"
|
23
|
+
|
24
|
+
messages = @queue.get(5)
|
25
|
+
messages.must_respond_to :each
|
26
|
+
messages.size.must_equal 2
|
27
|
+
end
|
28
|
+
|
29
|
+
it "can reset the visibilitytimeout option for retrieved messages" do
|
30
|
+
@queue << "message 1"
|
31
|
+
|
32
|
+
message = @queue.pop(visibilitytimeout: 10)
|
33
|
+
|
34
|
+
next_visible_at = message.time_next_visible.to_i
|
35
|
+
inserted_at = message.insertion_time.to_i
|
36
|
+
|
37
|
+
next_visible_at.must_be_close_to(inserted_at + 10, 2.0)
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "integration/test_helper"
|
2
|
+
|
3
|
+
describe "Obtaining a list of queues" do
|
4
|
+
after do
|
5
|
+
QueueNameHelper.clean
|
6
|
+
end
|
7
|
+
|
8
|
+
it "returns a list of queues" do
|
9
|
+
queue = Azure::Queues.create(QueueNameHelper.name)
|
10
|
+
|
11
|
+
all_queues = Azure::Queues.all
|
12
|
+
all_queues.must_include queue
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should be able to use maxresults" do
|
16
|
+
Azure::Queues.create(QueueNameHelper.name)
|
17
|
+
Azure::Queues.create(QueueNameHelper.name)
|
18
|
+
|
19
|
+
all_queues = Azure::Queues.all(:maxresults => 1).size.must_equal 1
|
20
|
+
all_queues = Azure::Queues.all(:maxresults => 2).size.must_equal 2
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should be able to use the prefix option when listing" do
|
24
|
+
Azure::Queues.create(QueueNameHelper.name)
|
25
|
+
Azure::Queues.create(QueueNameHelper.name)
|
26
|
+
q3 = Azure::Queues.create(QueueNameHelper.name)
|
27
|
+
|
28
|
+
prefixed_queues = Azure::Queues.all(:prefix => q3.name)
|
29
|
+
prefixed_queues.size.must_equal 1
|
30
|
+
prefixed_queues.first.must_equal q3
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should be able to use the marker option when listing" do
|
34
|
+
skip
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should be able to use the include metadata option when listing" do
|
38
|
+
Azure::Queues.create(QueueNameHelper.name, "Somekey" => "Somevalue")
|
39
|
+
queue = Azure::Queues.all(:include => 'metadata').first
|
40
|
+
queue.metadata["Somekey"].must_equal "Somevalue"
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "integration/test_helper"
|
2
|
+
|
3
|
+
describe "Managing the queue's metadata" do
|
4
|
+
after do
|
5
|
+
QueueNameHelper.clean
|
6
|
+
end
|
7
|
+
|
8
|
+
it "sets metadata on queue creation (Azure changes the casing of metadata keys)" do
|
9
|
+
Azure::Queues.create(
|
10
|
+
QueueNameHelper.name,
|
11
|
+
"UppercaseKey" => "U", "downcaseKey" => "D"
|
12
|
+
)
|
13
|
+
|
14
|
+
queue = Azure::Queues.all(:include => 'metadata').first
|
15
|
+
|
16
|
+
queue.metadata["Uppercasekey"].must_equal "U"
|
17
|
+
queue.metadata["Downcasekey"].must_equal "D"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "#load_metadata! reloads the queue metadata" do
|
21
|
+
queue = Azure::Queues.create(QueueNameHelper.name, "Key" => "Value")
|
22
|
+
queue.metadata.must_be_empty
|
23
|
+
|
24
|
+
queue.load_metadata!.wont_be_empty
|
25
|
+
queue.metadata.wont_be_empty
|
26
|
+
end
|
27
|
+
|
28
|
+
it "saves the metadata in the server if you modify the metadata hash" do
|
29
|
+
queue = Azure::Queues.create(QueueNameHelper.name)
|
30
|
+
queue.metadata["Key"] = "Value"
|
31
|
+
queue.save_metadata!
|
32
|
+
|
33
|
+
loaded_queue = Azure::Queues.all(:include => 'metadata').first
|
34
|
+
loaded_queue.metadata["Key"].must_equal "Value"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "deletes all metadata when setting queue.metadata to an empty hash" do
|
38
|
+
queue = Azure::Queues.create(QueueNameHelper.name, "Key" => "Value")
|
39
|
+
queue.metadata = {}
|
40
|
+
queue.save_metadata!
|
41
|
+
|
42
|
+
loaded_queue = Azure::Queues.all(:include => 'metadata').first
|
43
|
+
loaded_queue.metadata.must_be_empty
|
44
|
+
end
|
45
|
+
end
|