fog-google 1.25.0 → 1.26.0
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 +4 -4
- data/.github/workflows/integration-compute-core.yml +2 -2
- data/.github/workflows/integration-compute-instance_groups.yml +2 -2
- data/.github/workflows/integration-compute-loadbalancing.yml +2 -2
- data/.github/workflows/integration-compute-networking.yml +2 -2
- data/.github/workflows/integration-monitoring.yml +2 -2
- data/.github/workflows/integration-pubsub.yml +2 -2
- data/.github/workflows/integration-sql.yml +2 -2
- data/.github/workflows/integration-storage.yml +2 -2
- data/.github/workflows/unit.yml +2 -2
- data/CHANGELOG.md +46 -27
- data/SECURITY.md +3 -14
- data/fog-google.gemspec +2 -3
- data/lib/fog/google/compute/models/server.rb +1 -1
- data/lib/fog/google/storage/storage_json/real.rb +4 -2
- data/lib/fog/google/storage/storage_json/utils.rb +4 -2
- data/lib/fog/google/storage/storage_xml/real.rb +4 -2
- data/lib/fog/google/storage/storage_xml/requests/get_bucket.rb +1 -1
- data/lib/fog/google/storage/storage_xml/utils.rb +4 -2
- data/lib/fog/google/version.rb +1 -1
- metadata +5 -198
- data/.github/workflows/stale.yml +0 -23
- data/test/helpers/client_helper.rb +0 -63
- data/test/helpers/integration_test_helper.rb +0 -108
- data/test/helpers/test_collection.rb +0 -60
- data/test/helpers/test_helper.rb +0 -28
- data/test/integration/compute/core_compute/test_client_options.rb +0 -12
- data/test/integration/compute/core_compute/test_coverage.rb +0 -6
- data/test/integration/compute/core_compute/test_disk_types.rb +0 -43
- data/test/integration/compute/core_compute/test_disks.rb +0 -53
- data/test/integration/compute/core_compute/test_images.rb +0 -32
- data/test/integration/compute/core_compute/test_machine_types.rb +0 -55
- data/test/integration/compute/core_compute/test_operations.rb +0 -45
- data/test/integration/compute/core_compute/test_projects.rb +0 -19
- data/test/integration/compute/core_compute/test_regions.rb +0 -33
- data/test/integration/compute/core_compute/test_servers.rb +0 -235
- data/test/integration/compute/core_compute/test_snapshots.rb +0 -21
- data/test/integration/compute/core_compute/test_zones.rb +0 -35
- data/test/integration/compute/core_networking/test_addresses.rb +0 -107
- data/test/integration/compute/core_networking/test_coverage.rb +0 -6
- data/test/integration/compute/core_networking/test_firewalls.rb +0 -11
- data/test/integration/compute/core_networking/test_networks.rb +0 -30
- data/test/integration/compute/core_networking/test_routes.rb +0 -26
- data/test/integration/compute/core_networking/test_subnetworks.rb +0 -11
- data/test/integration/compute/instance_groups/test_coverage.rb +0 -6
- data/test/integration/compute/instance_groups/test_instance_group_managers.rb +0 -11
- data/test/integration/compute/instance_groups/test_instance_groups.rb +0 -11
- data/test/integration/compute/instance_groups/test_instance_templates.rb +0 -11
- data/test/integration/compute/loadbalancing/test_backend_services.rb +0 -11
- data/test/integration/compute/loadbalancing/test_coverage.rb +0 -6
- data/test/integration/compute/loadbalancing/test_forwarding_rules.rb +0 -11
- data/test/integration/compute/loadbalancing/test_global_addresses.rb +0 -11
- data/test/integration/compute/loadbalancing/test_global_forwarding_rules.rb +0 -11
- data/test/integration/compute/loadbalancing/test_http_health_checks.rb +0 -11
- data/test/integration/compute/loadbalancing/test_ssl_certificates.rb +0 -11
- data/test/integration/compute/loadbalancing/test_target_http_proxies.rb +0 -11
- data/test/integration/compute/loadbalancing/test_target_https_proxies.rb +0 -11
- data/test/integration/compute/loadbalancing/test_target_instances.rb +0 -11
- data/test/integration/compute/loadbalancing/test_target_pools.rb +0 -55
- data/test/integration/compute/loadbalancing/test_url_maps.rb +0 -11
- data/test/integration/factories/addresses_factory.rb +0 -20
- data/test/integration/factories/backend_services_factory.rb +0 -19
- data/test/integration/factories/collection_factory.rb +0 -52
- data/test/integration/factories/disks_factory.rb +0 -22
- data/test/integration/factories/firewalls_factory.rb +0 -13
- data/test/integration/factories/forwarding_rules_factory.rb +0 -25
- data/test/integration/factories/global_addresses_factory.rb +0 -15
- data/test/integration/factories/global_forwarding_rules_factory.rb +0 -20
- data/test/integration/factories/http_health_checks_factory.rb +0 -11
- data/test/integration/factories/images_factory.rb +0 -16
- data/test/integration/factories/instance_group_manager_factory.rb +0 -30
- data/test/integration/factories/instance_groups_factory.rb +0 -20
- data/test/integration/factories/instance_template_factory.rb +0 -24
- data/test/integration/factories/networks_factory.rb +0 -14
- data/test/integration/factories/servers_factory.rb +0 -30
- data/test/integration/factories/sql_certs_factory.rb +0 -20
- data/test/integration/factories/sql_instances_factory.rb +0 -19
- data/test/integration/factories/sql_users_factory.rb +0 -23
- data/test/integration/factories/ssl_certificates_factory.rb +0 -13
- data/test/integration/factories/subnetworks_factory.rb +0 -26
- data/test/integration/factories/target_http_proxies_factory.rb +0 -19
- data/test/integration/factories/target_https_proxies_factory.rb +0 -26
- data/test/integration/factories/target_instances_factory.rb +0 -24
- data/test/integration/factories/target_pools_factory.rb +0 -28
- data/test/integration/factories/url_maps_factory.rb +0 -19
- data/test/integration/monitoring/test_coverage.rb +0 -6
- data/test/integration/monitoring/test_metric_descriptors.rb +0 -131
- data/test/integration/monitoring/test_monitored_resource_descriptors.rb +0 -37
- data/test/integration/monitoring/test_timeseries.rb +0 -253
- data/test/integration/pubsub/pubsub_shared.rb +0 -75
- data/test/integration/pubsub/test_coverage.rb +0 -6
- data/test/integration/pubsub/test_pubsub_models.rb +0 -135
- data/test/integration/pubsub/test_pubsub_requests.rb +0 -105
- data/test/integration/sql/test_certs.rb +0 -50
- data/test/integration/sql/test_common_flags.rb +0 -31
- data/test/integration/sql/test_common_tiers.rb +0 -26
- data/test/integration/sql/test_coverage.rb +0 -6
- data/test/integration/sql/test_instances.rb +0 -101
- data/test/integration/sql/test_users.rb +0 -37
- data/test/integration/storage/storage_shared.rb +0 -101
- data/test/integration/storage/test_buckets.rb +0 -112
- data/test/integration/storage/test_coverage.rb +0 -6
- data/test/integration/storage/test_directories.rb +0 -67
- data/test/integration/storage/test_files.rb +0 -168
- data/test/integration/storage/test_objects.rb +0 -226
- data/test/integration/test_authentication.rb +0 -38
- data/test/unit/compute/test_common_collections.rb +0 -42
- data/test/unit/compute/test_common_models.rb +0 -35
- data/test/unit/compute/test_disk.rb +0 -26
- data/test/unit/compute/test_server.rb +0 -29
- data/test/unit/dns/test_common_collections.rb +0 -43
- data/test/unit/monitoring/test_comon_collections.rb +0 -44
- data/test/unit/pubsub/test_common_collections.rb +0 -35
- data/test/unit/sql/test_common_collections.rb +0 -46
- data/test/unit/storage/test_common_json_collections.rb +0 -38
- data/test/unit/storage/test_common_xml_collections.rb +0 -50
- data/test/unit/storage/test_json_requests.rb +0 -60
- data/test/unit/storage/test_xml_requests.rb +0 -60
@@ -1,135 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "integration/pubsub/pubsub_shared"
|
3
|
-
require "securerandom"
|
4
|
-
require "base64"
|
5
|
-
|
6
|
-
class TestPubsubModels < PubSubShared
|
7
|
-
def test_topics_create
|
8
|
-
name = new_topic_name
|
9
|
-
result = @client.topics.create(:name => name)
|
10
|
-
assert_equal(result.name, name)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_topics_get
|
14
|
-
result = @client.topics.get(some_topic_name)
|
15
|
-
assert_equal(result.name, some_topic_name)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_topics_all
|
19
|
-
# Force a topic to be created just so we have at least 1 to list
|
20
|
-
name = new_topic_name
|
21
|
-
@client.create_topic(name)
|
22
|
-
|
23
|
-
Fog.wait_for(5) do
|
24
|
-
result = @client.topics.all
|
25
|
-
if result.nil?
|
26
|
-
false
|
27
|
-
end
|
28
|
-
|
29
|
-
result.any? { |topic| topic.name == name }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_topic_publish_string
|
34
|
-
@client.topics.get(some_topic_name)
|
35
|
-
message_ids = @client.topics.get(some_topic_name).publish(["apples"])
|
36
|
-
assert_operator(message_ids.length, :>, 0)
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_topic_publish_hash
|
40
|
-
@client.topics.get(some_topic_name)
|
41
|
-
message_ids = @client.topics.get(some_topic_name).publish(["data" => "apples"])
|
42
|
-
assert_operator(message_ids.length, :>, 0)
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_topic_delete
|
46
|
-
topic_to_delete = new_topic_name
|
47
|
-
topic = @client.topics.create(:name => topic_to_delete)
|
48
|
-
|
49
|
-
topic.destroy
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_subscriptions_create
|
53
|
-
push_config = {}
|
54
|
-
ack_deadline_seconds = 18
|
55
|
-
|
56
|
-
subscription_name = new_subscription_name
|
57
|
-
result = @client.subscriptions.create(:name => subscription_name,
|
58
|
-
:topic => some_topic_name,
|
59
|
-
:push_config => push_config,
|
60
|
-
:ack_deadline_seconds => ack_deadline_seconds)
|
61
|
-
assert_equal(result.name, subscription_name)
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_subscriptions_get
|
65
|
-
subscription_name = some_subscription_name
|
66
|
-
result = @client.subscriptions.get(subscription_name)
|
67
|
-
|
68
|
-
assert_equal(result.name, subscription_name)
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_subscriptions_list
|
72
|
-
# Force a subscription to be created just so we have at least 1 to list
|
73
|
-
subscription_name = new_subscription_name
|
74
|
-
@client.subscriptions.create(:name => subscription_name, :topic => some_topic_name)
|
75
|
-
|
76
|
-
Fog.wait_for(5) do
|
77
|
-
result = @client.subscriptions.all
|
78
|
-
if result.nil?
|
79
|
-
false
|
80
|
-
end
|
81
|
-
|
82
|
-
result.any? { |subscription| subscription.name == subscription_name }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_subscription_delete
|
87
|
-
push_config = {}
|
88
|
-
ack_deadline_seconds = 18
|
89
|
-
|
90
|
-
subscription_name = new_subscription_name
|
91
|
-
subscription = @client.subscriptions.create(:name => subscription_name,
|
92
|
-
:topic => some_topic_name,
|
93
|
-
:push_config => push_config,
|
94
|
-
:ack_deadline_seconds => ack_deadline_seconds)
|
95
|
-
subscription.destroy
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_subscription_pull
|
99
|
-
subscription_name = new_subscription_name
|
100
|
-
message_bytes = Base64.strict_encode64("some message")
|
101
|
-
subscription = @client.subscriptions.create(:name => subscription_name,
|
102
|
-
:topic => some_topic_name)
|
103
|
-
@client.topics.get(some_topic_name).publish(["data" => message_bytes])
|
104
|
-
|
105
|
-
result = subscription.pull(:return_immediately => false)
|
106
|
-
assert_operator(result.length, :>, 0)
|
107
|
-
|
108
|
-
contained = result.any? { |received| received.message[:data] == message_bytes }
|
109
|
-
assert_equal(true, contained, "sent messsage not contained within pulled responses")
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_subscription_acknowledge
|
113
|
-
subscription_name = new_subscription_name
|
114
|
-
subscription = @client.subscriptions.create(:name => subscription_name,
|
115
|
-
:topic => some_topic_name)
|
116
|
-
@client.topics.get(some_topic_name).publish(["data" => Base64.strict_encode64("some message")])
|
117
|
-
|
118
|
-
result = subscription.pull(:return_immediately => false)
|
119
|
-
assert_operator(result.length, :>, 0)
|
120
|
-
|
121
|
-
subscription.acknowledge([result[0].ack_id])
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_message_acknowledge
|
125
|
-
subscription_name = new_subscription_name
|
126
|
-
subscription = @client.subscriptions.create(:name => subscription_name,
|
127
|
-
:topic => some_topic_name)
|
128
|
-
@client.topics.get(some_topic_name).publish(["data" => Base64.strict_encode64("some message")])
|
129
|
-
|
130
|
-
result = subscription.pull(:return_immediately => false)
|
131
|
-
assert_operator(result.length, :>, 0)
|
132
|
-
|
133
|
-
result[0].acknowledge
|
134
|
-
end
|
135
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "integration/pubsub/pubsub_shared"
|
3
|
-
require "securerandom"
|
4
|
-
require "base64"
|
5
|
-
|
6
|
-
class TestPubsubRequests < PubSubShared
|
7
|
-
def test_create_topic
|
8
|
-
name = new_topic_name
|
9
|
-
result = @client.create_topic(name)
|
10
|
-
assert_equal(result.name, name)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_get_topic
|
14
|
-
result = @client.get_topic(some_topic_name)
|
15
|
-
assert_equal(result.name, some_topic_name)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_list_topics
|
19
|
-
# Force a topic to be created just so we have at least 1 to list
|
20
|
-
name = new_topic_name
|
21
|
-
@client.create_topic(name)
|
22
|
-
|
23
|
-
Fog.wait_for(5) do
|
24
|
-
result = @client.list_topics
|
25
|
-
if result.topics.nil?
|
26
|
-
false
|
27
|
-
end
|
28
|
-
|
29
|
-
result.topics.any? { |topic| topic.name == name }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_delete_topic
|
34
|
-
topic_to_delete = new_topic_name
|
35
|
-
@client.create_topic(topic_to_delete)
|
36
|
-
|
37
|
-
@client.delete_topic(topic_to_delete)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_publish_topic
|
41
|
-
@client.publish_topic(some_topic_name, [:data => Base64.strict_encode64("some message")])
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_create_subscription
|
45
|
-
push_config = {}
|
46
|
-
ack_deadline_seconds = 18
|
47
|
-
|
48
|
-
subscription_name = new_subscription_name
|
49
|
-
result = @client.create_subscription(subscription_name, some_topic_name,
|
50
|
-
push_config, ack_deadline_seconds)
|
51
|
-
assert_equal(result.name, subscription_name)
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_get_subscription
|
55
|
-
subscription_name = some_subscription_name
|
56
|
-
result = @client.get_subscription(subscription_name)
|
57
|
-
|
58
|
-
assert_equal(result.name, subscription_name)
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_list_subscriptions
|
62
|
-
# Force a subscription to be created just so we have at least 1 to list
|
63
|
-
subscription_name = new_subscription_name
|
64
|
-
@client.create_subscription(subscription_name, some_topic_name)
|
65
|
-
|
66
|
-
Fog.wait_for(5) do
|
67
|
-
result = @client.list_subscriptions
|
68
|
-
if result.subscriptions.nil?
|
69
|
-
false
|
70
|
-
end
|
71
|
-
|
72
|
-
result.subscriptions.any? { |sub| sub.name == subscription_name }
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_delete_subscription
|
77
|
-
subscription_to_delete = new_subscription_name
|
78
|
-
@client.create_subscription(subscription_to_delete, some_topic_name)
|
79
|
-
|
80
|
-
@client.delete_subscription(subscription_to_delete)
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_pull_subscription
|
84
|
-
subscription_name = new_subscription_name
|
85
|
-
message_bytes = Base64.strict_encode64("some message")
|
86
|
-
@client.create_subscription(subscription_name, some_topic_name)
|
87
|
-
@client.publish_topic(some_topic_name, [:data => message_bytes])
|
88
|
-
|
89
|
-
result = @client.pull_subscription(subscription_name, {:return_immediately => false})
|
90
|
-
|
91
|
-
contained = result.received_messages.any? { |received| received.message.data == message_bytes }
|
92
|
-
assert_equal(true, contained, "sent messsage not contained within pulled responses")
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_acknowledge_subscription
|
96
|
-
subscription_name = new_subscription_name
|
97
|
-
@client.create_subscription(subscription_name, some_topic_name)
|
98
|
-
@client.publish_topic(some_topic_name, [:data => Base64.strict_encode64("some message")])
|
99
|
-
pull_result = @client.pull_subscription(subscription_name, {:return_immediately => false})
|
100
|
-
assert_operator(pull_result.received_messages.length, :>, 0)
|
101
|
-
|
102
|
-
@client.acknowledge_subscription(subscription_name,
|
103
|
-
pull_result.received_messages[0].ack_id)
|
104
|
-
end
|
105
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "integration/factories/sql_certs_factory"
|
3
|
-
|
4
|
-
class TestSQLCerts < FogIntegrationTest
|
5
|
-
# This test doesn't include TestCollection as certs are not an independent resource.
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@subject = Fog::Google[:sql].ssl_certs
|
9
|
-
@factory = SqlCertsFactory.new(namespaced_name)
|
10
|
-
@client = Fog::Google::SQL.new
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
@factory.cleanup
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_ssl_certs
|
18
|
-
# Create an instance and an SSL cert
|
19
|
-
ssl_cert = @factory.create
|
20
|
-
instance_name = ssl_cert.instance
|
21
|
-
|
22
|
-
# Create a second cert and attach to the same instance
|
23
|
-
ssl_cert2 = @subject.new(:common_name => "#{ssl_cert.common_name}-2",
|
24
|
-
:instance => instance_name)
|
25
|
-
ssl_cert2.save
|
26
|
-
|
27
|
-
# Verify it can be retrieved
|
28
|
-
@subject.get(instance_name, ssl_cert2.sha1_fingerprint).tap do |result|
|
29
|
-
assert_equal(ssl_cert2.common_name, result.common_name)
|
30
|
-
assert_equal("sql#sslCert", result.kind)
|
31
|
-
end
|
32
|
-
|
33
|
-
# Verify instance returns 2 certs
|
34
|
-
list_result = @subject.all(instance_name)
|
35
|
-
assert_equal(2, list_result.size,
|
36
|
-
"expected 2 SSL certs")
|
37
|
-
|
38
|
-
# Delete one cert
|
39
|
-
ssl_cert2.destroy(:async => false)
|
40
|
-
list_result = @subject.all(instance_name)
|
41
|
-
assert_equal(1, list_result.size,
|
42
|
-
"expected one less SSL cert after deletion")
|
43
|
-
|
44
|
-
# Test if SSL config is reset correctly
|
45
|
-
instance = @client.instances.get(instance_name)
|
46
|
-
instance.reset_ssl_config(:async => false)
|
47
|
-
assert_equal(0, @subject.all(instance_name).size,
|
48
|
-
"expected no SSL certs after reset")
|
49
|
-
end
|
50
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
|
3
|
-
class TestCommonFlags < FogIntegrationTest
|
4
|
-
def setup
|
5
|
-
@client = Fog::Google::SQL.new
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_list
|
9
|
-
resp = @client.list_flags
|
10
|
-
|
11
|
-
assert_operator(resp.items.size, :>, 0,
|
12
|
-
"resource descriptor count should be positive")
|
13
|
-
|
14
|
-
_sanity_check_flag(resp.items.first)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_all
|
18
|
-
resp = @client.flags.all
|
19
|
-
|
20
|
-
assert_operator(resp.size, :>, 0,
|
21
|
-
"resource descriptor count should be positive")
|
22
|
-
|
23
|
-
_sanity_check_flag(resp.first)
|
24
|
-
end
|
25
|
-
|
26
|
-
def _sanity_check_flag(flag)
|
27
|
-
assert_equal(flag.kind, "sql#flag")
|
28
|
-
refute(flag.name.nil?, "flag name should not be empty")
|
29
|
-
refute_empty(flag.applies_to, "flag should apply to some database version")
|
30
|
-
end
|
31
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
|
3
|
-
class TestCommonTiers < FogIntegrationTest
|
4
|
-
def setup
|
5
|
-
@subject = Fog::Google[:sql].tiers
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_all
|
9
|
-
tiers = @subject.all
|
10
|
-
|
11
|
-
assert_operator(tiers.size, :>, 0,
|
12
|
-
"tier count should be positive")
|
13
|
-
_sanity_check_tier(tiers.first)
|
14
|
-
end
|
15
|
-
|
16
|
-
def _sanity_check_tier(tier)
|
17
|
-
assert_equal(tier.kind, "sql#tier")
|
18
|
-
refute(tier.tier.nil?, "tier name should not be empty")
|
19
|
-
assert_operator(tier.disk_quota, :>, 0,
|
20
|
-
"tier disk quota should be positive")
|
21
|
-
assert_operator(tier.ram, :>, 0,
|
22
|
-
"tier ram should be positive")
|
23
|
-
assert_operator(tier.region.size, :>, 0,
|
24
|
-
"tier should have regions")
|
25
|
-
end
|
26
|
-
end
|
@@ -1,6 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
|
3
|
-
# This is a simple coverage helper that helps differentiate
|
4
|
-
# the tests when run in parallel so the final coverage report
|
5
|
-
# can be properly combined together from multiple runners
|
6
|
-
SimpleCov.command_name "test:sql" if ENV["COVERAGE"]
|
@@ -1,101 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "integration/factories/sql_instances_factory"
|
3
|
-
# Client helper is imported for `wait_until_complete`
|
4
|
-
# TODO: Remove when fog-google#339 or fog-google#340 is resolved
|
5
|
-
require "helpers/client_helper"
|
6
|
-
|
7
|
-
class TestSQLV2Instances < FogIntegrationTest
|
8
|
-
include TestCollection
|
9
|
-
# TODO: Remove when fog-google#339 or fog-google#340 is resolved
|
10
|
-
include ClientHelper
|
11
|
-
attr_reader :client
|
12
|
-
|
13
|
-
def setup
|
14
|
-
@subject = Fog::Google[:sql].instances
|
15
|
-
@factory = SqlInstancesFactory.new(namespaced_name)
|
16
|
-
@backup_runs = Fog::Google[:sql].backup_runs
|
17
|
-
# TODO: Remove after BackupRuns get save/reload - fog-google#339
|
18
|
-
# See https://github.com/fog/fog-google/issues/339
|
19
|
-
@client = Fog::Google::SQL.new
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_update
|
23
|
-
instance = @factory.create
|
24
|
-
|
25
|
-
settings_version = instance.settings_version
|
26
|
-
labels = {
|
27
|
-
:foo => "bar"
|
28
|
-
}
|
29
|
-
instance.settings[:user_labels] = labels
|
30
|
-
instance.save
|
31
|
-
|
32
|
-
updated = @subject.get(instance.name)
|
33
|
-
assert_equal(labels, updated.settings[:user_labels])
|
34
|
-
assert_operator(updated.settings_version, :>, settings_version)
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_default_settings
|
38
|
-
instance = @factory.create
|
39
|
-
assert_equal([], instance.ssl_certs, "new instance should have 0 initial ssl certs")
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_restore_backup_run
|
43
|
-
instance = @factory.create
|
44
|
-
|
45
|
-
data = { :description => "test", :instance => instance.name }
|
46
|
-
wait_until_complete { @client.insert_backup_run(instance.name, data) }
|
47
|
-
|
48
|
-
backup_run = @backup_runs.all(instance.name).first
|
49
|
-
|
50
|
-
# Wait for backup operation to be finished
|
51
|
-
# or fail if it never finishes.
|
52
|
-
instance.restore_backup(backup_run.id, :async => false)
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_backup_runs
|
56
|
-
# TODO: This probably can get pulled into the test above as those tests
|
57
|
-
# very expensive time-wize (5 minutes or so each)
|
58
|
-
instance = @factory.create
|
59
|
-
|
60
|
-
description = "test backup run"
|
61
|
-
operation = wait_until_complete do
|
62
|
-
@client.insert_backup_run(
|
63
|
-
instance.name,
|
64
|
-
:description => description
|
65
|
-
)
|
66
|
-
end
|
67
|
-
|
68
|
-
assert_equal(operation.operation_type, "BACKUP_VOLUME")
|
69
|
-
runs = @backup_runs.all(instance.name)
|
70
|
-
assert_operator(runs.size, :>, 0, "expected at least one backup run")
|
71
|
-
assert_equal(description, runs.first.description)
|
72
|
-
|
73
|
-
created_run = @backup_runs.get(instance.name, runs.first.id)
|
74
|
-
assert_equal(created_run, runs.first)
|
75
|
-
|
76
|
-
wait_until_complete do
|
77
|
-
@client.delete_backup_run(instance.name, runs.first.id)
|
78
|
-
end
|
79
|
-
|
80
|
-
deleted_run = @backup_runs.get(instance.name, runs.first.id)
|
81
|
-
assert_equal("DELETED", deleted_run.status)
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_clone
|
85
|
-
instance = @factory.create
|
86
|
-
instance.clone("#{instance.name}-clone", :async => false)
|
87
|
-
cloned = @client.instances.get("#{instance.name}-clone")
|
88
|
-
|
89
|
-
# Sanity check some attributes
|
90
|
-
compare = %i(current_disk_size project region ip_configuration_require_ssl activation_policy)
|
91
|
-
compare.each do |k|
|
92
|
-
v = instance.attributes[k]
|
93
|
-
cloned_v = cloned.attributes[k]
|
94
|
-
if v.nil?
|
95
|
-
assert_nil(cloned_v)
|
96
|
-
else
|
97
|
-
assert_equal(v, cloned_v, "attribute #{k} in original instance is #{v}, cloned = #{cloned_v}")
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "integration/factories/sql_instances_factory"
|
3
|
-
require "integration/factories/sql_users_factory"
|
4
|
-
|
5
|
-
class TestSQLUsers < FogIntegrationTest
|
6
|
-
# This test doesn't include TestCollection as Users is not a
|
7
|
-
# classical Fog model, as it's tied to a particular instance
|
8
|
-
# I.e.:
|
9
|
-
# - Fog::Google::SQL.users.all() requires an instance
|
10
|
-
# - API doesn't provide a GET request for Users model
|
11
|
-
# See: https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/users
|
12
|
-
|
13
|
-
def setup
|
14
|
-
@subject = Fog::Google[:sql].users
|
15
|
-
@factory = SqlUsersFactory.new(namespaced_name)
|
16
|
-
end
|
17
|
-
|
18
|
-
def teardown
|
19
|
-
@factory.cleanup
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_users
|
23
|
-
# Create user
|
24
|
-
user = @factory.create
|
25
|
-
|
26
|
-
# Check user was created
|
27
|
-
users = @subject.all(user.instance).select { |u| u.name == user.name }
|
28
|
-
assert_equal(1, users.size, "expected user to have been created")
|
29
|
-
|
30
|
-
# Delete user
|
31
|
-
users.first.destroy(:async => false)
|
32
|
-
assert_empty(
|
33
|
-
@subject.all(user.instance).select { |u| u.name == user.name },
|
34
|
-
"expected no user #{user.name}"
|
35
|
-
)
|
36
|
-
end
|
37
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "integration/pubsub/pubsub_shared"
|
3
|
-
require "securerandom"
|
4
|
-
require "base64"
|
5
|
-
require "tempfile"
|
6
|
-
|
7
|
-
class StorageShared < FogIntegrationTest
|
8
|
-
def setup
|
9
|
-
@client = Fog::Google::Storage.new
|
10
|
-
# Enable retries during the suite. This prevents us from
|
11
|
-
# having to manually rate limit our requests.
|
12
|
-
::Google::Apis::RequestOptions.default.retries = 5
|
13
|
-
# Ensure any resources we create with test prefixes are removed
|
14
|
-
Minitest.after_run do
|
15
|
-
delete_test_resources
|
16
|
-
::Google::Apis::RequestOptions.default.retries = 0
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def delete_test_resources
|
21
|
-
unless @some_temp_file.nil?
|
22
|
-
@some_temp_file.unlink
|
23
|
-
end
|
24
|
-
|
25
|
-
buckets_result = @client.list_buckets
|
26
|
-
|
27
|
-
unless buckets_result.items.nil?
|
28
|
-
begin
|
29
|
-
buckets_result.items
|
30
|
-
.map(&:name)
|
31
|
-
.select { |t| t.start_with?(bucket_prefix) }
|
32
|
-
.each do |t|
|
33
|
-
object_result = @client.list_objects(t)
|
34
|
-
unless object_result.items.nil?
|
35
|
-
object_result.items.each { |object| @client.delete_object(t, object.name) }
|
36
|
-
end
|
37
|
-
|
38
|
-
begin
|
39
|
-
@client.delete_bucket(t)
|
40
|
-
# Given that bucket operations are specifically rate-limited, we handle that
|
41
|
-
# by waiting a significant amount of time and trying.
|
42
|
-
rescue Google::Apis::RateLimitError
|
43
|
-
Fog::Logger.warning("encountered rate limit, backing off")
|
44
|
-
sleep(10)
|
45
|
-
@client.delete_bucket(t)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
# We ignore errors here as list operations may not represent changes applied recently.
|
49
|
-
rescue Google::Apis::Error
|
50
|
-
Fog::Logger.warning("ignoring Google Api error during delete_test_resources")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def bucket_prefix
|
56
|
-
"fog-integration-test"
|
57
|
-
end
|
58
|
-
|
59
|
-
def object_prefix
|
60
|
-
"fog-integration-test-object"
|
61
|
-
end
|
62
|
-
|
63
|
-
def new_bucket_name
|
64
|
-
"#{bucket_prefix}-#{SecureRandom.uuid}"
|
65
|
-
end
|
66
|
-
|
67
|
-
def new_object_name
|
68
|
-
"#{object_prefix}-#{SecureRandom.uuid}"
|
69
|
-
end
|
70
|
-
|
71
|
-
def some_bucket_name
|
72
|
-
# create lazily to speed tests up
|
73
|
-
@some_bucket ||= new_bucket_name.tap do |t|
|
74
|
-
@client.put_bucket(t)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def some_object_name
|
79
|
-
# create lazily to speed tests up
|
80
|
-
@some_object ||= new_object_name.tap do |t|
|
81
|
-
@client.put_object(some_bucket_name, t, some_temp_file)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def temp_file_content
|
86
|
-
"hello world"
|
87
|
-
end
|
88
|
-
|
89
|
-
def binary_file_content
|
90
|
-
"PK\x03\x04\x14\x00\x00\x00\b\x00\x18\x89\x8AM\xE7!\xB7\x1C\x1C\x15j\x00\xB4\xB9".force_encoding(Encoding::ASCII_8BIT)
|
91
|
-
end
|
92
|
-
|
93
|
-
def some_temp_file(content = temp_file_content)
|
94
|
-
@some_temp_file ||= Tempfile.new("fog-google-storage").tap do |t|
|
95
|
-
t.binmode
|
96
|
-
t.write(content)
|
97
|
-
t.close
|
98
|
-
end
|
99
|
-
File.open(@some_temp_file.path, "r")
|
100
|
-
end
|
101
|
-
end
|