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,32 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "integration/factories/images_factory"
|
3
|
-
|
4
|
-
class TestImages < FogIntegrationTest
|
5
|
-
include TestCollection
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@subject = Fog::Compute[:google].images
|
9
|
-
@factory = ImagesFactory.new(namespaced_name)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_get_specific_image
|
13
|
-
image = @subject.get(TEST_IMAGE)
|
14
|
-
refute_nil(image, "Images.get(#{TEST_IMAGE}) should not return nil")
|
15
|
-
assert_equal(image.family, TEST_IMAGE_FAMILY)
|
16
|
-
assert_equal(image.project, TEST_IMAGE_PROJECT)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_get_specific_image_from_project
|
20
|
-
image = @subject.get(TEST_IMAGE,TEST_IMAGE_PROJECT)
|
21
|
-
refute_nil(image, "Images.get(#{TEST_IMAGE}) should not return nil")
|
22
|
-
assert_equal(image.family, TEST_IMAGE_FAMILY)
|
23
|
-
assert_equal(image.project, TEST_IMAGE_PROJECT)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_get_from_family
|
27
|
-
image = @subject.get_from_family(TEST_IMAGE_FAMILY)
|
28
|
-
refute_nil(image,"Images.get_from_family(#{TEST_IMAGE_FAMILY}) should not return nil")
|
29
|
-
assert_equal(image.family, TEST_IMAGE_FAMILY)
|
30
|
-
assert_equal(image.project, TEST_IMAGE_PROJECT)
|
31
|
-
end
|
32
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
|
3
|
-
class TestMachineTypes < FogIntegrationTest
|
4
|
-
# List of machine types - not a complete sampling since beefier ones do not
|
5
|
-
# exist in all zones (list last updated June 2018)
|
6
|
-
NAMES = %w(f1-micro g1-small n1-highcpu-16 n1-highcpu-2 n1-highcpu-4
|
7
|
-
n1-highcpu-8 n1-highmem-16 n1-highmem-2 n1-highmem-32 n1-highmem-4
|
8
|
-
n1-highmem-8 n1-standard-1 n1-standard-16 n1-standard-2
|
9
|
-
n1-standard-32 n1-standard-4 n1-standard-8 ).freeze
|
10
|
-
|
11
|
-
# Testing in one random zone per region (list last updated May 2018)
|
12
|
-
ZONES = %w(asia-east1-a asia-northeast1-b asia-south1-c asia-southeast1-a
|
13
|
-
australia-southeast1-b europe-west1-c europe-west2-a europe-west3-b
|
14
|
-
europe-west4-c northamerica-northeast1-a southamerica-east1-b
|
15
|
-
us-central1-c us-east1-b us-east4-a us-west1-c).freeze
|
16
|
-
|
17
|
-
def setup
|
18
|
-
@subject = Fog::Compute[:google].machine_types
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_all
|
22
|
-
assert_operator(@subject.all.size, :>=, NAMES.size * ZONES.size,
|
23
|
-
"Number of all machine types should be greater or equal to test zones * machine_types")
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_scoped_all
|
27
|
-
subject_list = @subject.all
|
28
|
-
scoped_subject_list = @subject.all(zone: TEST_ZONE)
|
29
|
-
|
30
|
-
# Assert that whatever .all(scope) returns is a subset of .all
|
31
|
-
assert(scoped_subject_list.all? { |x| subject_list.include? x },
|
32
|
-
"Output of @subject.all(zone:#{TEST_ZONE}) must be a subset of @subject.all")
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_get
|
36
|
-
# This tests only in last zone since not all zones contain all machine types
|
37
|
-
NAMES.each do |name|
|
38
|
-
ZONES.each do |zone|
|
39
|
-
refute_nil @subject.get(name, zone)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_bad_get
|
45
|
-
assert_nil @subject.get("bad-name", ZONES.first)
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_enumerable
|
49
|
-
assert_respond_to @subject, :each
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_nil_get
|
53
|
-
assert_nil @subject.get(nil)
|
54
|
-
end
|
55
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
|
3
|
-
class TestOperations < FogIntegrationTest
|
4
|
-
def setup
|
5
|
-
@subject = Fog::Compute[:google].operations
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_all
|
9
|
-
# TODO: what if this test runs first on a brand new project?
|
10
|
-
assert_operator(@subject.all.size, :>=, 2,
|
11
|
-
"There should be at least 2 operations in the project")
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_get
|
15
|
-
@subject.all do |operation|
|
16
|
-
refute_nil @subject.get(operation.name)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_zone_scoped_all
|
21
|
-
subject_list = @subject.all
|
22
|
-
scoped_subject_list = @subject.all(zone: TEST_ZONE)
|
23
|
-
|
24
|
-
# Assert that whatever .all(scope) returns is a subset of .all
|
25
|
-
assert(scoped_subject_list.all? { |x| subject_list.include? x },
|
26
|
-
"Output of @subject.all(zone:#{TEST_ZONE}) must be a subset of @subject.all")
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_region_scoped_all
|
30
|
-
subject_list = @subject.all
|
31
|
-
scoped_subject_list = @subject.all(region: TEST_REGION)
|
32
|
-
|
33
|
-
# Assert that whatever .all(scope) returns is a subset of .all
|
34
|
-
assert(scoped_subject_list.all? { |x| subject_list.include? x },
|
35
|
-
"Output of @subject.all(region:#{TEST_REGION}) must be a subset of @subject.all")
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_bad_get
|
39
|
-
assert_nil @subject.get("bad-name")
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_enumerable
|
43
|
-
assert_respond_to @subject, :each
|
44
|
-
end
|
45
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
|
3
|
-
class TestProjects < FogIntegrationTest
|
4
|
-
def setup
|
5
|
-
@subject = Fog::Compute[:google].projects
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_get
|
9
|
-
assert @subject.get(TEST_PROJECT)
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_bad_get
|
13
|
-
assert_nil @subject.get("bad-name")
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_enumerable
|
17
|
-
assert_respond_to @subject, :each
|
18
|
-
end
|
19
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
|
3
|
-
class TestRegions < FogIntegrationTest
|
4
|
-
EXAMPLE_NAMES = %w(asia-east1 asia-northeast1 europe-west1 us-central1 us-east1 us-west1).freeze
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@subject = Fog::Compute[:google].regions
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_all
|
11
|
-
assert_operator(@subject.all.size, :>=, EXAMPLE_NAMES.size)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_get
|
15
|
-
EXAMPLE_NAMES.each do |region|
|
16
|
-
refute_nil @subject.get(region)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_up
|
21
|
-
EXAMPLE_NAMES.each do |region|
|
22
|
-
assert @subject.get(region).up?
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_bad_get
|
27
|
-
assert_nil @subject.get("bad-name")
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_enumerable
|
31
|
-
assert_respond_to @subject, :each
|
32
|
-
end
|
33
|
-
end
|
@@ -1,235 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "integration/factories/servers_factory"
|
3
|
-
require "integration/factories/disks_factory"
|
4
|
-
require "resolv"
|
5
|
-
|
6
|
-
class TestServers < FogIntegrationTest
|
7
|
-
include TestCollection
|
8
|
-
|
9
|
-
# Cleanup is handled by TestCollection
|
10
|
-
def setup
|
11
|
-
@subject = Fog::Compute[:google].servers
|
12
|
-
@factory = ServersFactory.new(namespaced_name)
|
13
|
-
@servers = ServersFactory.new(namespaced_name)
|
14
|
-
@disks = DisksFactory.new(namespaced_name)
|
15
|
-
end
|
16
|
-
|
17
|
-
def teardown
|
18
|
-
# Clean up the server resources used in testing
|
19
|
-
@servers.cleanup
|
20
|
-
super
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_set_machine_type
|
24
|
-
server = @factory.create
|
25
|
-
server.stop
|
26
|
-
server.wait_for { stopped? }
|
27
|
-
server.set_machine_type("n1-standard-2", false)
|
28
|
-
assert_equal "n1-standard-2", server.machine_type.split("/")[-1]
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_set_machine_type_fail
|
32
|
-
server = @factory.create
|
33
|
-
server.wait_for { ready? }
|
34
|
-
assert_raises Fog::Errors::Error do
|
35
|
-
server.set_machine_type("n1-standard-2", false)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_set_metadata
|
40
|
-
server = @factory.create
|
41
|
-
server.wait_for { ready? }
|
42
|
-
server.set_metadata({ "foo" => "bar", "baz" => "foo" }, false)
|
43
|
-
assert_equal [{ :key => "foo", :value => "bar" },
|
44
|
-
{ :key => "baz", :value => "foo" }], server.metadata[:items]
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_add_ssh_key
|
48
|
-
key = "ssh-rsa IAMNOTAREALSSHKEYAMA=="
|
49
|
-
username = "test_user"
|
50
|
-
server = @factory.create
|
51
|
-
server.add_ssh_key(username, key, false)
|
52
|
-
assert_equal [{ :key => "ssh-keys",
|
53
|
-
:value => "test_user:ssh-rsa IAMNOTAREALSSHKEYAMA== test_user" }], server.metadata[:items]
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_bootstrap
|
57
|
-
key = "ssh-rsa IAMNOTAREALSSHKEYAMA== user@host.subdomain.example.com"
|
58
|
-
user = "username"
|
59
|
-
|
60
|
-
File.stub :read, key do
|
61
|
-
# XXX Small hack - name is set this way so it will be cleaned up by CollectionFactory
|
62
|
-
# Bootstrap is special so this is something that needs to be done only for this method
|
63
|
-
# Public_key_path is set to avoid stubbing out File.exist?
|
64
|
-
server = @subject.bootstrap(:name => "#{CollectionFactory.new(nil,namespaced_name).resource_name}",
|
65
|
-
:username => user,
|
66
|
-
:public_key_path => "foo")
|
67
|
-
boot_disk = server.disks.detect { |disk| disk[:boot] }
|
68
|
-
|
69
|
-
assert_equal("RUNNING", server.status, "Bootstrapped server should be running")
|
70
|
-
assert_equal(key, server.public_key, "Bootstrapped server should have a public key set")
|
71
|
-
assert_equal(user, server.username, "Bootstrapped server should have user set to #{user}")
|
72
|
-
assert(boot_disk[:auto_delete], "Bootstrapped server should have disk set to autodelete")
|
73
|
-
|
74
|
-
network_adapter = server.network_interfaces.detect { |x| x.has_key?(:access_configs) }
|
75
|
-
|
76
|
-
refute_nil(network_adapter[:access_configs].detect { |x| x[:nat_ip] },
|
77
|
-
"Bootstrapped server should have an external ip by default")
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_bootstrap_fail
|
82
|
-
# Pretend the ssh key does not exist
|
83
|
-
File.stub :exist?, nil do
|
84
|
-
assert_raises(Fog::Errors::Error) {
|
85
|
-
# XXX Small hack - name is set this way so it will be cleaned up by CollectionFactory
|
86
|
-
# Bootstrap is special so this is something that needs to be done only for this method
|
87
|
-
@subject.bootstrap(:name => "#{CollectionFactory.new(nil,namespaced_name).resource_name}",
|
88
|
-
:public_key_path => nil)
|
89
|
-
}
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_image_name
|
94
|
-
server = @factory.create
|
95
|
-
assert_equal(TEST_IMAGE, server.image_name.split("/")[-1])
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_ip_address_methods
|
99
|
-
# Create a server with ephemeral external IP address
|
100
|
-
server = @factory.create(:network_interfaces => [{ :network => "global/networks/default",
|
101
|
-
:access_configs => [{
|
102
|
-
:name => "External NAT",
|
103
|
-
:type => "ONE_TO_ONE_NAT"
|
104
|
-
}] }])
|
105
|
-
assert_match(Resolv::IPv4::Regex, server.public_ip_address,
|
106
|
-
"Server.public_ip_address should return a valid IP address")
|
107
|
-
refute_empty(server.public_ip_addresses)
|
108
|
-
assert_match(Resolv::IPv4::Regex, server.public_ip_addresses.pop)
|
109
|
-
|
110
|
-
assert_match(Resolv::IPv4::Regex, server.private_ip_address,
|
111
|
-
"Server.public_ip_address should return a valid IP address")
|
112
|
-
refute_empty(server.private_ip_addresses)
|
113
|
-
assert_match(Resolv::IPv4::Regex, server.private_ip_addresses.pop)
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_start_stop_reboot
|
117
|
-
server = @factory.create
|
118
|
-
|
119
|
-
server.stop
|
120
|
-
server.wait_for { stopped? }
|
121
|
-
|
122
|
-
assert server.stopped?
|
123
|
-
|
124
|
-
server.start
|
125
|
-
server.wait_for { ready? }
|
126
|
-
|
127
|
-
assert server.ready?
|
128
|
-
|
129
|
-
server.reboot
|
130
|
-
server.wait_for { ready? }
|
131
|
-
|
132
|
-
assert server.ready?
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_start_stop_discard_local_ssd
|
136
|
-
server = @factory.create
|
137
|
-
|
138
|
-
async = true
|
139
|
-
discard_local_ssd = true
|
140
|
-
|
141
|
-
server.stop(async, discard_local_ssd)
|
142
|
-
server.wait_for { stopped? }
|
143
|
-
|
144
|
-
assert server.stopped?
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_attach_disk
|
148
|
-
# Creating server
|
149
|
-
server = @factory.create
|
150
|
-
server.wait_for { ready? }
|
151
|
-
|
152
|
-
disk_name = "fog-test-1-testservers-test-attach-disk-attachable" # suffix forces disk name to differ from the existing disk
|
153
|
-
# Creating disk #{disk_name}
|
154
|
-
disk = @disks.create(
|
155
|
-
:name => disk_name,
|
156
|
-
:source_image => TEST_IMAGE,
|
157
|
-
:size_gb => 64
|
158
|
-
)
|
159
|
-
device_name = "#{disk.name}-device"
|
160
|
-
|
161
|
-
# Attaching disk #{disk.name} as device #{device_name}
|
162
|
-
self_link = "https://www.googleapis.com/compute/v1/projects/#{TEST_PROJECT}/zones/#{TEST_ZONE}/disks/#{disk.name}"
|
163
|
-
server.attach_disk(self_link, true, device_name: device_name)
|
164
|
-
|
165
|
-
# Waiting for attachment
|
166
|
-
disk.wait_for { ! users.nil? && users != []}
|
167
|
-
|
168
|
-
assert_equal "https://www.googleapis.com/compute/v1/projects/#{TEST_PROJECT}/zones/#{TEST_ZONE}/instances/#{server.name}", disk.users[0]
|
169
|
-
|
170
|
-
server.reload
|
171
|
-
server_attached_disk = server.disks.select{|d| d[:boot] == false}[0]
|
172
|
-
assert_equal device_name, server_attached_disk[:device_name]
|
173
|
-
end
|
174
|
-
|
175
|
-
def test_detach_disk
|
176
|
-
# Creating server
|
177
|
-
server = @factory.create
|
178
|
-
server.wait_for { ready? }
|
179
|
-
|
180
|
-
disk_name = "fog-test-1-testservers-test-detach-attachable" # suffix forces disk name to differ from the existing disk
|
181
|
-
# Creating disk #{disk_name}
|
182
|
-
disk = @disks.create(
|
183
|
-
:name => disk_name,
|
184
|
-
:source_image => TEST_IMAGE,
|
185
|
-
:size_gb => 64
|
186
|
-
)
|
187
|
-
device_name = "#{disk.name}-device"
|
188
|
-
|
189
|
-
# Attaching disk #{disk.name} as device #{device_name}
|
190
|
-
self_link = "https://www.googleapis.com/compute/v1/projects/#{TEST_PROJECT}/zones/#{TEST_ZONE}/disks/#{disk.name}"
|
191
|
-
server.attach_disk(self_link, true, device_name: device_name)
|
192
|
-
disk.wait_for { ! users.nil? && users != []}
|
193
|
-
|
194
|
-
server.reload
|
195
|
-
server_attached_disk = server.disks.select{|d| d[:boot] == false}[0]
|
196
|
-
assert_equal device_name, server_attached_disk[:device_name]
|
197
|
-
|
198
|
-
# Detaching (synchronous) disk #{disk.name}
|
199
|
-
server.detach_disk(device_name, false)
|
200
|
-
|
201
|
-
disk.reload
|
202
|
-
assert disk.users.nil? || disk.users == []
|
203
|
-
|
204
|
-
# Re-attaching disk #{disk.name} as device #{device_name}
|
205
|
-
server.attach_disk(self_link, true, device_name: device_name)
|
206
|
-
disk.wait_for { ! users.nil? && users != []}
|
207
|
-
|
208
|
-
server.reload
|
209
|
-
server_attached_disk = server.disks.select{|d| d[:boot] == false}[0]
|
210
|
-
assert_equal device_name, server_attached_disk[:device_name]
|
211
|
-
|
212
|
-
# Detaching (async) disk #{disk.name}
|
213
|
-
server.detach_disk(device_name, true)
|
214
|
-
|
215
|
-
# Waiting for detachment
|
216
|
-
disk.wait_for { users.nil? || users == []}
|
217
|
-
|
218
|
-
assert disk.users.nil? || disk.users == []
|
219
|
-
end
|
220
|
-
|
221
|
-
def test_reset_windows_password
|
222
|
-
win_disk = @disks.create(
|
223
|
-
:name => "fog-test-1-testservers-test-reset-windows-password-2",
|
224
|
-
:source_image => "windows-server-2019-dc-v20210713",
|
225
|
-
:size_gb => 64
|
226
|
-
)
|
227
|
-
server = @factory.create(:disks => [win_disk])
|
228
|
-
server.wait_for { ready? }
|
229
|
-
server.reset_windows_password("test_user")
|
230
|
-
serial_output = server.serial_port_output(:port => 4)
|
231
|
-
|
232
|
-
assert_includes(serial_output, "encryptedPassword")
|
233
|
-
assert_includes(serial_output, "\"userName\":\"test_user\"")
|
234
|
-
end
|
235
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "securerandom"
|
3
|
-
require "base64"
|
4
|
-
|
5
|
-
class TestComputeSnapshots < FogIntegrationTest
|
6
|
-
def setup
|
7
|
-
@client = Fog::Google::Compute.new
|
8
|
-
# Ensure any resources we create with test prefixes are removed
|
9
|
-
Minitest.after_run do
|
10
|
-
delete_test_resources
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_list_empty_snapshots
|
15
|
-
assert_empty @client.snapshots.all
|
16
|
-
end
|
17
|
-
|
18
|
-
def delete_test_resources
|
19
|
-
# nothing to do
|
20
|
-
end
|
21
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
|
3
|
-
class TestZones < FogIntegrationTest
|
4
|
-
# Testing one random zone per region (list last updated May 2018)
|
5
|
-
ZONES = %w(asia-east1-a asia-northeast1-b asia-south1-c asia-southeast1-a
|
6
|
-
australia-southeast1-b europe-west1-c europe-west2-a europe-west3-b
|
7
|
-
europe-west4-c northamerica-northeast1-a southamerica-east1-b
|
8
|
-
us-central1-c us-east1-b us-east4-a us-west1-c).freeze
|
9
|
-
|
10
|
-
def setup
|
11
|
-
@subject = Fog::Compute[:google].zones
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_all
|
15
|
-
assert_operator(@subject.all.size, :>=, ZONES.size,
|
16
|
-
"Number of all zones should be greater than test zones")
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_get
|
20
|
-
# This tests only in last zone since not all zones contain all machine types
|
21
|
-
ZONES.each do |name|
|
22
|
-
zone = @subject.get(name)
|
23
|
-
refute_nil(zone, "zones.get(#{name}) should not return nil")
|
24
|
-
assert(zone.up?, "zones.up? should return up, unless there's an outage")
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_bad_get
|
29
|
-
assert_nil @subject.get("bad-name")
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_enumerable
|
33
|
-
assert_respond_to @subject, :each
|
34
|
-
end
|
35
|
-
end
|
@@ -1,107 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "integration/factories/addresses_factory"
|
3
|
-
require "integration/factories/servers_factory"
|
4
|
-
|
5
|
-
class TestAddresses < FogIntegrationTest
|
6
|
-
include TestCollection
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@subject = Fog::Compute[:google].addresses
|
10
|
-
@servers = ServersFactory.new(namespaced_name)
|
11
|
-
@factory = AddressesFactory.new(namespaced_name)
|
12
|
-
end
|
13
|
-
|
14
|
-
def teardown
|
15
|
-
# Clean up the server resources used in testing
|
16
|
-
@servers.cleanup
|
17
|
-
super
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_run_instance
|
21
|
-
address = @factory.create
|
22
|
-
server = @servers.create(:external_ip => address.address)
|
23
|
-
|
24
|
-
assert_equal(
|
25
|
-
address.address,
|
26
|
-
server.network_interfaces[0][:access_configs][0][:nat_ip],
|
27
|
-
"Created server should have the correct address after initialization"
|
28
|
-
)
|
29
|
-
|
30
|
-
assert_equal(
|
31
|
-
"IN_USE",
|
32
|
-
@subject.get(address.name, TEST_REGION).status,
|
33
|
-
"Address should now be in use"
|
34
|
-
)
|
35
|
-
|
36
|
-
address.reload
|
37
|
-
|
38
|
-
assert_equal(
|
39
|
-
server,
|
40
|
-
address.server,
|
41
|
-
"Address.server should return an associated server object"
|
42
|
-
)
|
43
|
-
|
44
|
-
address.server = nil
|
45
|
-
address.reload
|
46
|
-
assert_nil(
|
47
|
-
address.server,
|
48
|
-
"Address should not be associated with a server after disassociation"
|
49
|
-
)
|
50
|
-
|
51
|
-
address.server = server
|
52
|
-
address.reload
|
53
|
-
assert_equal(
|
54
|
-
server,
|
55
|
-
address.server,
|
56
|
-
"Address should be associated with a server after association"
|
57
|
-
)
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_bad_get
|
61
|
-
assert_nil @subject.get("bad-name", TEST_REGION)
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_valid_range
|
65
|
-
address = @factory.create
|
66
|
-
|
67
|
-
octet = /\d{,2}|1\d{2}|2[0-4]\d|25[0-5]/
|
68
|
-
re = /\A#{octet}\.#{octet}\.#{octet}\.#{octet}\z/
|
69
|
-
|
70
|
-
assert_match(re, address.address,
|
71
|
-
"Adress should be a valid ipv4 address")
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_addresses_get_address_by_ip
|
75
|
-
address = @factory.create
|
76
|
-
found = @subject.get_by_ip_address(address.address)
|
77
|
-
|
78
|
-
assert_equal(address.name, found.name, "address should have same name")
|
79
|
-
assert_equal(address.address, found.address, "addresses should match")
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_addresses_get_address_by_name
|
83
|
-
address = @factory.create
|
84
|
-
found = @subject.get_by_name(address.name)
|
85
|
-
|
86
|
-
assert_equal(address.name, found.name, "address should have same name")
|
87
|
-
assert_equal(address.address, found.address, "addresses should match")
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_addresses_get_by_ip_address_or_name
|
91
|
-
# Ensure we find the same addresses through both codepaths
|
92
|
-
address = @factory.create
|
93
|
-
with_name = @subject.get_by_ip_address_or_name(address.name)
|
94
|
-
with_ip = @subject.get_by_ip_address_or_name(address.address)
|
95
|
-
|
96
|
-
assert_equal(address.name, with_name.name, "address should have same name")
|
97
|
-
assert_equal(address.address, with_name.address, "addresses should match")
|
98
|
-
|
99
|
-
assert_equal(address.name, with_ip.name, "address should have same name")
|
100
|
-
assert_equal(address.address, with_ip.address, "addresses should match")
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_addresses_in_use
|
104
|
-
address = @factory.create
|
105
|
-
assert_equal(false, address.in_use?, "example address should not be in use")
|
106
|
-
end
|
107
|
-
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:compute-core_networking" if ENV["COVERAGE"]
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "integration/factories/firewalls_factory"
|
3
|
-
|
4
|
-
class TestFirewalls < FogIntegrationTest
|
5
|
-
include TestCollection
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@subject = Fog::Compute[:google].firewalls
|
9
|
-
@factory = FirewallsFactory.new(namespaced_name)
|
10
|
-
end
|
11
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "integration/factories/networks_factory"
|
3
|
-
require "integration/factories/servers_factory"
|
4
|
-
|
5
|
-
class TestNetworks < FogIntegrationTest
|
6
|
-
include TestCollection
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@subject = Fog::Compute[:google].networks
|
10
|
-
@servers = ServersFactory.new(namespaced_name)
|
11
|
-
@factory = NetworksFactory.new(namespaced_name)
|
12
|
-
end
|
13
|
-
|
14
|
-
def teardown
|
15
|
-
# Clean up the server resources used in testing
|
16
|
-
@servers.cleanup
|
17
|
-
super
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_run_instance
|
21
|
-
network = @factory.create
|
22
|
-
server = @servers.create(:network_interfaces => [network.get_as_interface_config])
|
23
|
-
|
24
|
-
assert_equal(
|
25
|
-
network.self_link,
|
26
|
-
server.network_interfaces[0][:network],
|
27
|
-
"Created server should have the network specified on boot"
|
28
|
-
)
|
29
|
-
end
|
30
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
|
3
|
-
class TestRoutes < FogIntegrationTest
|
4
|
-
def setup
|
5
|
-
@subject = Fog::Compute[:google].routes
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_all
|
9
|
-
assert_operator(@subject.all.size, :>=, 2,
|
10
|
-
"Number of all routes should be greater or equal than 2 - default GW and default routes")
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_get
|
14
|
-
@subject.all do |route|
|
15
|
-
refute_nil @subject.get(route.name)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_bad_get
|
20
|
-
assert_nil @subject.get("bad-name")
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_enumerable
|
24
|
-
assert_respond_to @subject, :each
|
25
|
-
end
|
26
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "integration/factories/subnetworks_factory"
|
3
|
-
|
4
|
-
class TestSubnetworks < FogIntegrationTest
|
5
|
-
include TestCollection
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@subject = Fog::Compute[:google].subnetworks
|
9
|
-
@factory = SubnetworksFactory.new(namespaced_name)
|
10
|
-
end
|
11
|
-
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:compute-instance_groups" if ENV["COVERAGE"]
|