fog-google 1.5.0 → 1.6.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/.rubocop.yml +4 -0
- data/CHANGELOG.md +53 -0
- data/CONTRIBUTING.md +9 -1
- data/MIGRATING.md +11 -0
- data/README.md +16 -2
- data/ci/pipeline.yml +31 -1
- data/examples/bootstrap.rb +18 -9
- data/lib/fog/compute/google/models/server.rb +9 -0
- data/lib/fog/compute/google/models/servers.rb +21 -12
- data/lib/fog/compute/google/models/ssl_certificate.rb +1 -1
- data/lib/fog/google/models/sql/instance.rb +19 -4
- data/lib/fog/google/models/sql/user.rb +9 -3
- data/lib/fog/google/requests/sql/insert_instance.rb +2 -2
- data/lib/fog/google/version.rb +1 -1
- data/lib/fog/storage/google_xml/utils.rb +1 -1
- data/tasks/lint.rake +6 -0
- data/tasks/test.rake +21 -8
- data/test/helpers/integration_test_helper.rb +1 -1
- data/test/integration/compute/test_disk_types.rb +6 -11
- data/test/integration/compute/test_servers.rb +35 -1
- data/test/integration/factories/sql_v1_certs_factory.rb +20 -0
- data/test/integration/factories/sql_v1_instances_factory.rb +19 -0
- data/test/integration/factories/sql_v1_users_factory.rb +20 -0
- data/test/integration/factories/sql_v2_instances_factory.rb +19 -0
- data/test/integration/monitoring/test_timeseries.rb +6 -8
- data/test/integration/sql/{test_flags.rb → test_common_flags.rb} +1 -1
- data/test/integration/sql/{test_tiers.rb → test_common_tiers.rb} +5 -13
- data/test/integration/sql/test_v1_certs.rb +50 -0
- data/test/integration/sql/test_v1_instances.rb +31 -0
- data/test/integration/sql/test_v1_users.rb +37 -0
- data/test/integration/sql/test_v2_instances.rb +81 -0
- data/test/unit/compute/test_server.rb +28 -0
- data/test/unit/storage/test_xml_requests.rb +24 -0
- metadata +27 -12
- data/test/integration/sql/sql_instances_shared.rb +0 -57
- data/test/integration/sql/test_instances.rb +0 -97
- data/test/integration/sql/test_instances_second_gen.rb +0 -88
@@ -0,0 +1,37 @@
|
|
1
|
+
require "helpers/integration_test_helper"
|
2
|
+
require "integration/factories/sql_v1_instances_factory"
|
3
|
+
require "integration/factories/sql_v1_users_factory"
|
4
|
+
|
5
|
+
class TestSQLV1Users < 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 = SqlV1UsersFactory.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
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require "helpers/integration_test_helper"
|
2
|
+
require "integration/factories/sql_v2_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 = SqlV2InstancesFactory.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_restore_backup_run
|
23
|
+
instance = @factory.create
|
24
|
+
|
25
|
+
data = { :description => "test", :instance => instance.name }
|
26
|
+
wait_until_complete { @client.insert_backup_run(instance.name, data) }
|
27
|
+
|
28
|
+
backup_run = @backup_runs.all(instance.name).first
|
29
|
+
|
30
|
+
# Wait for backup operation to be finished
|
31
|
+
# or fail if it never finishes.
|
32
|
+
instance.restore_backup(backup_run.id, :async => false)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_backup_runs
|
36
|
+
# TODO: This probably can get pulled into the test above as those tests
|
37
|
+
# very expensive time-wize (5 minutes or so each)
|
38
|
+
instance = @factory.create
|
39
|
+
|
40
|
+
description = "test backup run"
|
41
|
+
operation = wait_until_complete do
|
42
|
+
@client.insert_backup_run(
|
43
|
+
instance.name,
|
44
|
+
:description => description
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
assert_equal(operation.operation_type, "BACKUP_VOLUME")
|
49
|
+
runs = @backup_runs.all(instance.name)
|
50
|
+
assert_operator(runs.size, :>, 0, "expected at least one backup run")
|
51
|
+
assert_equal(description, runs.first.description)
|
52
|
+
|
53
|
+
created_run = @backup_runs.get(instance.name, runs.first.id)
|
54
|
+
assert_equal(created_run, runs.first)
|
55
|
+
|
56
|
+
wait_until_complete do
|
57
|
+
@client.delete_backup_run(instance.name, runs.first.id)
|
58
|
+
end
|
59
|
+
|
60
|
+
deleted_run = @backup_runs.get(instance.name, runs.first.id)
|
61
|
+
assert_equal("DELETED", deleted_run.status)
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_clone
|
65
|
+
instance = @factory.create
|
66
|
+
instance.clone("#{instance.name}-clone", :async => false)
|
67
|
+
cloned = @client.instances.get("#{instance.name}-clone")
|
68
|
+
|
69
|
+
# Sanity check some attributes
|
70
|
+
compare = %i(current_disk_size project region ip_configuration_require_ssl activation_policy)
|
71
|
+
compare.each do |k|
|
72
|
+
v = instance.attributes[k]
|
73
|
+
cloned_v = cloned.attributes[k]
|
74
|
+
if v.nil?
|
75
|
+
assert_nil(cloned_v)
|
76
|
+
else
|
77
|
+
assert_equal(v, cloned_v, "attribute #{k} in original instance is #{v}, cloned = #{cloned_v}")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "helpers/test_helper"
|
2
|
+
|
3
|
+
class UnitTestServer < MiniTest::Test
|
4
|
+
def setup
|
5
|
+
Fog.mock!
|
6
|
+
@client = Fog::Compute.new(:provider => "Google", :google_project => "foo")
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
Fog.unmock!
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_if_server_accepts_ssh_keys
|
14
|
+
key = "ssh-rsa IAMNOTAREALSSHKEYAMA== user@host.subdomain.example.com"
|
15
|
+
|
16
|
+
File.stub :read, key do
|
17
|
+
server = Fog::Compute::Google::Server.new(
|
18
|
+
:name => "foo",
|
19
|
+
:machine_type => "bar",
|
20
|
+
:disks => ["baz"],
|
21
|
+
:zone => "foo",
|
22
|
+
:public_key_path => key
|
23
|
+
)
|
24
|
+
assert_equal(server.public_key, key,
|
25
|
+
"Fog::Compute::Google::Server loads public_key properly")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "helpers/test_helper"
|
2
|
+
|
3
|
+
class UnitTestXMLRequests < MiniTest::Test
|
4
|
+
def setup
|
5
|
+
Fog.mock!
|
6
|
+
@client = Fog::Storage.new(provider: "google",
|
7
|
+
google_storage_access_key_id: "",
|
8
|
+
google_storage_secret_access_key: "")
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
Fog.unmock!
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_put_url_path_is_properly_escaped
|
16
|
+
url = @client.put_object_url("bucket",
|
17
|
+
"just some file.json",
|
18
|
+
Time.now + 2 * 60,
|
19
|
+
"Content-Type" => "application/json")
|
20
|
+
|
21
|
+
assert_match(/just%20some%20file\.json/, url,
|
22
|
+
"space should be escaped with '%20'")
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-google
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nat Welch
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-06-
|
12
|
+
date: 2018-06-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog-core
|
@@ -256,6 +256,7 @@ files:
|
|
256
256
|
- CONTRIBUTORS.md
|
257
257
|
- Gemfile
|
258
258
|
- LICENSE.md
|
259
|
+
- MIGRATING.md
|
259
260
|
- README.md
|
260
261
|
- Rakefile
|
261
262
|
- ci/.gitignore
|
@@ -729,6 +730,10 @@ files:
|
|
729
730
|
- test/integration/factories/instance_group_manager_factory.rb
|
730
731
|
- test/integration/factories/instance_template_factory.rb
|
731
732
|
- test/integration/factories/servers_factory.rb
|
733
|
+
- test/integration/factories/sql_v1_certs_factory.rb
|
734
|
+
- test/integration/factories/sql_v1_instances_factory.rb
|
735
|
+
- test/integration/factories/sql_v1_users_factory.rb
|
736
|
+
- test/integration/factories/sql_v2_instances_factory.rb
|
732
737
|
- test/integration/factories/target_http_proxies_factory.rb
|
733
738
|
- test/integration/factories/target_instances_factory.rb
|
734
739
|
- test/integration/factories/target_pools_factory.rb
|
@@ -739,11 +744,12 @@ files:
|
|
739
744
|
- test/integration/pubsub/pubsub_shared.rb
|
740
745
|
- test/integration/pubsub/test_pubsub_models.rb
|
741
746
|
- test/integration/pubsub/test_pubsub_requests.rb
|
742
|
-
- test/integration/sql/
|
743
|
-
- test/integration/sql/
|
744
|
-
- test/integration/sql/
|
745
|
-
- test/integration/sql/
|
746
|
-
- test/integration/sql/
|
747
|
+
- test/integration/sql/test_common_flags.rb
|
748
|
+
- test/integration/sql/test_common_tiers.rb
|
749
|
+
- test/integration/sql/test_v1_certs.rb
|
750
|
+
- test/integration/sql/test_v1_instances.rb
|
751
|
+
- test/integration/sql/test_v1_users.rb
|
752
|
+
- test/integration/sql/test_v2_instances.rb
|
747
753
|
- test/integration/storage/storage_shared.rb
|
748
754
|
- test/integration/storage/test_buckets.rb
|
749
755
|
- test/integration/storage/test_directories.rb
|
@@ -752,6 +758,8 @@ files:
|
|
752
758
|
- test/integration/test_authentication.rb
|
753
759
|
- test/unit/compute/test_common_collections.rb
|
754
760
|
- test/unit/compute/test_common_models.rb
|
761
|
+
- test/unit/compute/test_server.rb
|
762
|
+
- test/unit/storage/test_xml_requests.rb
|
755
763
|
homepage: https://github.com/fog/fog-google
|
756
764
|
licenses:
|
757
765
|
- MIT
|
@@ -813,6 +821,10 @@ test_files:
|
|
813
821
|
- test/integration/factories/instance_group_manager_factory.rb
|
814
822
|
- test/integration/factories/instance_template_factory.rb
|
815
823
|
- test/integration/factories/servers_factory.rb
|
824
|
+
- test/integration/factories/sql_v1_certs_factory.rb
|
825
|
+
- test/integration/factories/sql_v1_instances_factory.rb
|
826
|
+
- test/integration/factories/sql_v1_users_factory.rb
|
827
|
+
- test/integration/factories/sql_v2_instances_factory.rb
|
816
828
|
- test/integration/factories/target_http_proxies_factory.rb
|
817
829
|
- test/integration/factories/target_instances_factory.rb
|
818
830
|
- test/integration/factories/target_pools_factory.rb
|
@@ -823,11 +835,12 @@ test_files:
|
|
823
835
|
- test/integration/pubsub/pubsub_shared.rb
|
824
836
|
- test/integration/pubsub/test_pubsub_models.rb
|
825
837
|
- test/integration/pubsub/test_pubsub_requests.rb
|
826
|
-
- test/integration/sql/
|
827
|
-
- test/integration/sql/
|
828
|
-
- test/integration/sql/
|
829
|
-
- test/integration/sql/
|
830
|
-
- test/integration/sql/
|
838
|
+
- test/integration/sql/test_common_flags.rb
|
839
|
+
- test/integration/sql/test_common_tiers.rb
|
840
|
+
- test/integration/sql/test_v1_certs.rb
|
841
|
+
- test/integration/sql/test_v1_instances.rb
|
842
|
+
- test/integration/sql/test_v1_users.rb
|
843
|
+
- test/integration/sql/test_v2_instances.rb
|
831
844
|
- test/integration/storage/storage_shared.rb
|
832
845
|
- test/integration/storage/test_buckets.rb
|
833
846
|
- test/integration/storage/test_directories.rb
|
@@ -836,3 +849,5 @@ test_files:
|
|
836
849
|
- test/integration/test_authentication.rb
|
837
850
|
- test/unit/compute/test_common_collections.rb
|
838
851
|
- test/unit/compute/test_common_models.rb
|
852
|
+
- test/unit/compute/test_server.rb
|
853
|
+
- test/unit/storage/test_xml_requests.rb
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "helpers/client_helper"
|
3
|
-
|
4
|
-
class TestSqlInstancesShared < FogIntegrationTest
|
5
|
-
include ClientHelper
|
6
|
-
attr_reader :client
|
7
|
-
|
8
|
-
INSTANCE_NAME = "fogtest-#{Fog::Mock.random_letters(8)}".freeze
|
9
|
-
|
10
|
-
def setup
|
11
|
-
@client = Fog::Google::SQL.new
|
12
|
-
Minitest.after_run do
|
13
|
-
delete_test_resources
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def delete_test_resources
|
18
|
-
try_delete_instance(INSTANCE_NAME)
|
19
|
-
end
|
20
|
-
|
21
|
-
def some_instance_name
|
22
|
-
# Create one test instance per generation per test suite.
|
23
|
-
INSTANCE_NAME.tap do |name|
|
24
|
-
begin
|
25
|
-
@client.get_instance(name)
|
26
|
-
rescue ::Google::Apis::ClientError
|
27
|
-
create_test_instance(INSTANCE_NAME,
|
28
|
-
TEST_SQL_TIER_FIRST,
|
29
|
-
TEST_SQL_REGION_FIRST)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def some_clone_name
|
35
|
-
"#{INSTANCE_NAME}-clone"
|
36
|
-
end
|
37
|
-
|
38
|
-
def create_test_instance(instance_name, tier, region)
|
39
|
-
# Create one test instance per generation per test suite.
|
40
|
-
Fog::Logger.debug("creating test SQL instance...")
|
41
|
-
# Create test instance if it hasn't been created yet
|
42
|
-
@client = Fog::Google::SQL.new
|
43
|
-
wait_until_complete do
|
44
|
-
@client.insert_instance(instance_name, tier, :region => region)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def try_delete_instance(instance)
|
49
|
-
@client = Fog::Google::SQL.new
|
50
|
-
wait_until_complete { @client.delete_instance(instance) }
|
51
|
-
rescue ::Google::Apis::ClientError => e
|
52
|
-
# 409: Invalid state
|
53
|
-
# 404: Not found
|
54
|
-
raise e unless e.status_code == 404 || e.status_code == 409
|
55
|
-
Fog::Logger.warning("ignoring error in try_delete_instance")
|
56
|
-
end
|
57
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "helpers/client_helper"
|
3
|
-
require "integration/sql/sql_instances_shared"
|
4
|
-
|
5
|
-
class TestFirstGenInstances < TestSqlInstancesShared
|
6
|
-
def test_all
|
7
|
-
test_name = some_instance_name
|
8
|
-
instances = @client.instances.all
|
9
|
-
assert_operator(instances.size, :>=, 1,
|
10
|
-
"expected at least one instance")
|
11
|
-
|
12
|
-
filtered = instances.select { |i| i.name == test_name }
|
13
|
-
assert_equal(1, filtered.size, "expected instance with name #{test_name}")
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_update
|
17
|
-
instance = @client.instances.get(some_instance_name)
|
18
|
-
settings_version = instance.settings_version
|
19
|
-
labels = {
|
20
|
-
:foo => "bar"
|
21
|
-
}
|
22
|
-
instance.settings[:user_labels] = labels
|
23
|
-
instance.save
|
24
|
-
|
25
|
-
updated = @client.instances.get(some_instance_name)
|
26
|
-
assert_equal(labels, updated.settings[:user_labels])
|
27
|
-
assert_operator(updated.settings_version, :>, settings_version)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_users
|
31
|
-
# Create user
|
32
|
-
username = "test_user"
|
33
|
-
|
34
|
-
wait_until_complete do
|
35
|
-
@client.insert_user(some_instance_name, :name => username)
|
36
|
-
end
|
37
|
-
|
38
|
-
# Check user was created
|
39
|
-
users = @client.users.all(some_instance_name)
|
40
|
-
.select { |u| u.name == username }
|
41
|
-
assert_equal(1, users.size, "expected user to have been created")
|
42
|
-
|
43
|
-
# Delete user
|
44
|
-
users.first.destroy(:async => false)
|
45
|
-
assert_empty(
|
46
|
-
@client.users.all(some_instance_name).select { |u| u.name == username },
|
47
|
-
"expected no user #{username}"
|
48
|
-
)
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_operations
|
52
|
-
operations = @client.operations.all(some_instance_name)
|
53
|
-
operations.select do |op|
|
54
|
-
op.operation_type == "CREATE"
|
55
|
-
end
|
56
|
-
|
57
|
-
create_op = @client.operations.get(operations.first.name)
|
58
|
-
assert(create_op.ready?)
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_ssl_certs
|
62
|
-
list_result = @client.ssl_certs.all(some_instance_name)
|
63
|
-
# initial Count
|
64
|
-
cert_cnt = list_result.size
|
65
|
-
assert_equal(0, cert_cnt, "new instance should have 0 initial ssl certs")
|
66
|
-
|
67
|
-
# create new certs
|
68
|
-
ssl_certs = (0..1).map do
|
69
|
-
name = Fog::Mock.random_letters(16)
|
70
|
-
create_resp = @client.insert_ssl_cert(some_instance_name, name)
|
71
|
-
wait_until_complete { create_resp.operation }
|
72
|
-
fingerprint = create_resp.client_cert.cert_info.sha1_fingerprint
|
73
|
-
# verify it was created
|
74
|
-
@client.ssl_certs.get(some_instance_name, fingerprint).tap do |result|
|
75
|
-
assert_equal(name, result.common_name)
|
76
|
-
assert_equal("sql#sslCert", result.kind)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# check i1 was created
|
81
|
-
list_result = @client.ssl_certs.all(some_instance_name)
|
82
|
-
assert_equal(ssl_certs.size, list_result.size,
|
83
|
-
"expected #{ssl_certs.size} SSL certs")
|
84
|
-
|
85
|
-
# delete one cert
|
86
|
-
ssl_certs.first.destroy(:async => false)
|
87
|
-
list_result = @client.ssl_certs.all(some_instance_name)
|
88
|
-
assert_equal(ssl_certs.size - 1, list_result.size,
|
89
|
-
"expected one less SSL cert after deletion")
|
90
|
-
|
91
|
-
# Reset SSL config
|
92
|
-
instance = @client.instances.get(some_instance_name)
|
93
|
-
instance.reset_ssl_config(:async => false)
|
94
|
-
assert_equal(0, @client.ssl_certs.all(some_instance_name).size,
|
95
|
-
"expected no SSL certs after reset")
|
96
|
-
end
|
97
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
require "helpers/integration_test_helper"
|
2
|
-
require "helpers/client_helper"
|
3
|
-
require "integration/sql/sql_instances_shared"
|
4
|
-
|
5
|
-
##
|
6
|
-
# Tests requests and resources specific to 2nd generation instances.
|
7
|
-
|
8
|
-
class TestSecondGenInstances < TestSqlInstancesShared
|
9
|
-
# Test
|
10
|
-
INSTANCE_NAME = "fogtest2ndgen-#{Fog::Mock.random_letters(8)}".freeze
|
11
|
-
|
12
|
-
def some_clone_name
|
13
|
-
"#{INSTANCE_NAME}-clone"
|
14
|
-
end
|
15
|
-
|
16
|
-
def some_instance_name
|
17
|
-
# Create one test instance per generation per test suite.
|
18
|
-
INSTANCE_NAME.tap do |name|
|
19
|
-
begin
|
20
|
-
@client.get_instance(name)
|
21
|
-
rescue ::Google::Apis::ClientError
|
22
|
-
create_test_instance(INSTANCE_NAME,
|
23
|
-
TEST_SQL_TIER_SECOND,
|
24
|
-
TEST_SQL_REGION_SECOND)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def delete_test_resources
|
30
|
-
super
|
31
|
-
try_delete_instance(some_clone_name)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_restore_backup_run
|
35
|
-
data = { :description => "test", :instance => some_instance_name }
|
36
|
-
wait_until_complete { @client.insert_backup_run(some_instance_name, data) }
|
37
|
-
|
38
|
-
backup_run = @client.backup_runs.all(some_instance_name).first
|
39
|
-
instance = @client.instances.get(some_instance_name)
|
40
|
-
|
41
|
-
# Wait for backup operation to be finished
|
42
|
-
# or fail if it never finishes.
|
43
|
-
instance.restore_backup(backup_run.id, :async => false)
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_backup_runs
|
47
|
-
description = "test backup run"
|
48
|
-
op = wait_until_complete do
|
49
|
-
@client.insert_backup_run(
|
50
|
-
some_instance_name,
|
51
|
-
:description => description
|
52
|
-
)
|
53
|
-
end
|
54
|
-
|
55
|
-
assert_equal(op.operation_type, "BACKUP_VOLUME")
|
56
|
-
runs = @client.backup_runs.all(some_instance_name)
|
57
|
-
assert_operator(runs.size, :>, 0, "expected at least one backup run")
|
58
|
-
assert_equal(description, runs.first.description)
|
59
|
-
|
60
|
-
created_run = @client.backup_runs.get(some_instance_name, runs.first.id)
|
61
|
-
assert_equal(created_run, runs.first)
|
62
|
-
|
63
|
-
wait_until_complete do
|
64
|
-
@client.delete_backup_run(some_instance_name, runs.first.id)
|
65
|
-
end
|
66
|
-
|
67
|
-
deleted_run = @client.backup_runs.get(some_instance_name, runs.first.id)
|
68
|
-
assert_equal("DELETED", deleted_run.status)
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_clone
|
72
|
-
instance = @client.instances.get(some_instance_name)
|
73
|
-
instance.clone(some_clone_name, :async => false)
|
74
|
-
cloned = @client.instances.get(some_clone_name)
|
75
|
-
|
76
|
-
# Sanity check some attributes
|
77
|
-
compare = %i(current_disk_size tier project region ip_configuration_require_ssl activation_policy)
|
78
|
-
compare.each do |k|
|
79
|
-
v = instance.attributes[k]
|
80
|
-
cloned_v = cloned.attributes[k]
|
81
|
-
if v.nil?
|
82
|
-
assert_nil(cloned_v)
|
83
|
-
else
|
84
|
-
assert_equal(v, cloned_v, "attribute #{k} in original instance is #{v}, cloned = #{cloned_v}")
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|