Skip to content

Commit

Permalink
Merge pull request #493 from Temikus/bye_sqlv1
Browse files Browse the repository at this point in the history
Removing SQLv1 API support + small SQL model fixes
  • Loading branch information
Temikus authored Mar 27, 2020
2 parents 220eef2 + d689d77 commit e2ca89b
Show file tree
Hide file tree
Showing 21 changed files with 165 additions and 197 deletions.
24 changes: 0 additions & 24 deletions ci/integration-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,29 +137,6 @@ jobs:
path: fog-google-src
status: failure

- name: integration-sqlv1
serial: true
plan:
- get: fog-google-src
resource: pull-request
version: every
trigger: true
- put: pull-request
params: {path: fog-google-src, status: pending}

- task: run-integration-tests
file: fog-google-src/ci/tasks/run-int.yml
params:
rake_task: test:sql-sqlv1
codecov_token: {{codecov_token}}
google_project: {{google_project}}
google_json_key_data: {{google_json_key_data}}
on_failure:
put: pull-request
params:
path: fog-google-src
status: failure

- name: integration-sqlv2
serial: true
plan:
Expand Down Expand Up @@ -213,7 +190,6 @@ jobs:
passed: [integration-tests-storage,
integration-tests-pubsub,
integration-tests-monitoring,
integration-sqlv1,
integration-sqlv2,
integration-compute-core_compute,
integration-compute-core_networking,
Expand Down
16 changes: 10 additions & 6 deletions examples/sql/flags.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
def test
connection = Fog::Google::SQL.new
# All examples presume that you have a ~/.fog credentials file set up.
# More info on it can be found here: http://fog.io/about/getting_started.html

puts "Listing all Flags..."
puts "--------------------"
connection.flags
end
require "bundler"
Bundler.require(:default, :development)

connection = Fog::Google::SQL.new

puts "Listing all Flags..."
puts "--------------------"
connection.flags
72 changes: 38 additions & 34 deletions examples/sql/instances.rb
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
def test
connection = Fog::Google::SQL.new

puts "Create a Instance..."
puts "--------------------"
instance = connection.instances.create(:name => Fog::Mock.random_letters(16), :tier => "D1")
instance.wait_for { ready? }

puts "Get the Instance..."
puts "----------------------"
connection.instances.get(instance.name)

puts "List all Instances..."
puts "---------------------"
connection.instances.all

puts "Update the Instance..."
puts "----------------------"
instance.settings[:activation_policy] = "ALWAYS"
instance.update
instance.wait_for { ready? }

puts "Reset the Instance SSL configuration..."
puts "---------------------------------------"
instance.reset_ssl_config

puts "Restart the Instance..."
puts "-----------------------"
instance.restart

puts "Delete the Instance..."
puts "----------------------"
instance.destroy
end
# All examples presume that you have a ~/.fog credentials file set up.
# More info on it can be found here: http://fog.io/about/getting_started.html

require "bundler"
Bundler.require(:default, :development)

connection = Fog::Google::SQL.new

puts "Create a Instance..."
puts "--------------------"
instance = connection.instances.create(:name => Fog::Mock.random_letters(16), :tier => "db-n1-standard-1")
instance.wait_for { ready? }

puts "Get the Instance..."
puts "----------------------"
connection.instances.get(instance.name)

puts "List all Instances..."
puts "---------------------"
connection.instances.all

puts "Update the Instance..."
puts "----------------------"
instance.settings[:activation_policy] = "ALWAYS"
instance.update
instance.wait_for { ready? }

puts "Reset the Instance SSL configuration..."
puts "---------------------------------------"
instance.reset_ssl_config

puts "Restart the Instance..."
puts "-----------------------"
instance.restart

puts "Delete the Instance..."
puts "----------------------"
instance.destroy
36 changes: 20 additions & 16 deletions examples/sql/operations.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
def test
connection = Fog::Google::SQL.new
# All examples presume that you have a ~/.fog credentials file set up.
# More info on it can be found here: http://fog.io/about/getting_started.html

puts "Create a Instance..."
puts "--------------------"
instance = connection.instances.create(:name => Fog::Mock.random_letters(16), :tier => "D1")
instance.wait_for { ready? }
require "bundler"
Bundler.require(:default, :development)

puts "Delete the Instance..."
puts "----------------------"
operation = instance.destroy
connection = Fog::Google::SQL.new

puts "Get the Operation..."
puts "--------------------"
connection.operations.get(operation.identity)
puts "Create a Instance..."
puts "--------------------"
instance = connection.instances.create(:name => Fog::Mock.random_letters(16), :tier => "D1")
instance.wait_for { ready? }

puts "Listing all Operations..."
puts "-------------------------"
connection.operations.all(instance.identity)
end
puts "Delete the Instance..."
puts "----------------------"
operation = instance.destroy

puts "Get the Operation..."
puts "--------------------"
connection.operations.get(operation.identity)

puts "Listing all Operations..."
puts "-------------------------"
connection.operations.all(instance.identity)
60 changes: 32 additions & 28 deletions examples/sql/ssl_certs.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
def test
connection = Fog::Google::SQL.new

puts "Create a Instance..."
puts "--------------------"
instance = connection.instances.create(:name => Fog::Mock.random_letters(16), :tier => "D1")
instance.wait_for { ready? }

puts "Create a SSL certificate..."
puts "---------------------------"
ssl_cert = connection.ssl_certs.create(:instance => instance.name, :common_name => Fog::Mock.random_letters(16))

puts "Get the SSL certificate..."
puts "--------------------------"
connection.ssl_certs.get(instance.name, ssl_cert.sha1_fingerprint)

puts "List all SSL certificate..."
puts "---------------------------"
connection.ssl_certs.all(instance.name)

puts "Delete the SSL certificate..."
puts "-----------------------------"
ssl_cert.destroy

puts "Delete the Instance..."
puts "----------------------"
instance.destroy
end
# All examples presume that you have a ~/.fog credentials file set up.
# More info on it can be found here: http://fog.io/about/getting_started.html

require "bundler"
Bundler.require(:default, :development)

connection = Fog::Google::SQL.new

puts "Create a Instance..."
puts "--------------------"
instance = connection.instances.create(:name => Fog::Mock.random_letters(16), :tier => "db-n1-standard-1")
instance.wait_for { ready? }

puts "Create a SSL certificate..."
puts "---------------------------"
ssl_cert = connection.ssl_certs.create(:instance => instance.name, :common_name => Fog::Mock.random_letters(16))

puts "Get the SSL certificate..."
puts "--------------------------"
connection.ssl_certs.get(instance.name, ssl_cert.sha1_fingerprint)

puts "List all SSL certificate..."
puts "---------------------------"
connection.ssl_certs.all(instance.name)

puts "Delete the SSL certificate..."
puts "-----------------------------"
ssl_cert.destroy

puts "Delete the Instance..."
puts "----------------------"
instance.destroy
16 changes: 10 additions & 6 deletions examples/sql/tiers.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
def test
connection = Fog::Google::SQL.new
# All examples presume that you have a ~/.fog credentials file set up.
# More info on it can be found here: http://fog.io/about/getting_started.html

puts "Listing all Tiers..."
puts "--------------------"
connection.tiers
end
require "bundler"
Bundler.require(:default, :development)

connection = Fog::Google::SQL.new

puts "Listing all Tiers..."
puts "--------------------"
connection.tiers
8 changes: 7 additions & 1 deletion lib/fog/google/models/sql/ssl_cert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,18 @@ def reload
# Creates a SSL certificate. The new certificate will not be usable until the instance is restarted.
#
# @raise [Fog::Errors::Error] If SSL certificate already exists
def save
def save(async: false)
requires :instance, :common_name

raise Fog::Errors::Error.new("Resaving an existing object may create a duplicate") if persisted?

data = service.insert_ssl_cert(instance, common_name)
# data.operation.name is used here since InsertSslCert returns a
# special object, not an operation, as usual. See documentation:
# https://cloud.google.com/sql/docs/mysql/admin-api/rest/v1beta4/sslCerts/insert#response-body
operation = Fog::Google::SQL::Operations.new(:service => service).get(data.operation.name)
operation.wait_for { ready? } unless async

merge_attributes(data.client_cert.cert_info.to_h)
self.server_ca_cert = Fog::Google::SQL::SslCert.new(data.server_ca_cert.to_h)
self.cert_private_key = data.client_cert.cert_private_key
Expand Down
8 changes: 6 additions & 2 deletions tasks/test.rake
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,14 @@ namespace :test do
end

desc "Run SQL API tests"
task :compute => SQL_TEST_TASKS
task :sql => SQL_TEST_TASKS

desc "Run SQL API tests in parallel"
multitask :compute_parallel => SQL_TEST_TASKS
multitask :sql_parallel => SQL_TEST_TASKS

# TODO(temikus): Remove after v1 is renamed in pipeline
desc "Run SQL API tests - v1 compat alias"
task :"sql-sqlv2" => :sql

Rake::TestTask.new do |t|
t.name = "sql"
Expand Down
7 changes: 2 additions & 5 deletions test/helpers/integration_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@
# The image was created like so: https://cloud.google.com/compute/docs/images#export_an_image_to_google_cloud_storage
TEST_RAW_DISK_SOURCE = "http://storage.googleapis.com/fog-test-bucket/fog-test-raw-disk-source.image.tar.gz".freeze

TEST_SQL_TIER_FIRST = "D1".freeze
TEST_SQL_REGION_FIRST = "us-central".freeze

TEST_SQL_TIER_SECOND = "db-n1-standard-1".freeze
TEST_SQL_REGION_SECOND = TEST_REGION
TEST_SQL_TIER = "db-n1-standard-1".freeze
TEST_SQL_REGION = TEST_REGION

# Test certificate/key for SSL Proxy tests, generated via:
# $ openssl genrsa -out example.key 2048
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require "integration/factories/collection_factory"
require "integration/factories/sql_v1_instances_factory"
require "integration/factories/sql_instances_factory"

class SqlV1CertsFactory < CollectionFactory
class SqlCertsFactory < CollectionFactory
def initialize(example)
@instances = SqlV1InstancesFactory.new(example)
@instances = SqlInstancesFactory.new(example)
super(Fog::Google[:sql].ssl_certs, example)
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "integration/factories/collection_factory"

class SqlV1InstancesFactory < CollectionFactory
class SqlInstancesFactory < CollectionFactory
def initialize(example)
super(Fog::Google[:sql].instances, example)
end
Expand All @@ -13,7 +13,7 @@ def params
# Name has a time suffix due to SQL resources API objects having
# a _very_ long life on the backend (n(days)) after deletion.
{ :name => "#{resource_name}-#{Time.now.to_i}",
:region => TEST_SQL_REGION_FIRST,
:tier => TEST_SQL_TIER_FIRST }
:region => TEST_SQL_REGION,
:tier => TEST_SQL_TIER }
end
end
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require "integration/factories/collection_factory"
require "integration/factories/sql_v1_instances_factory"
require "integration/factories/sql_instances_factory"

class SqlV1UsersFactory < CollectionFactory
class SqlUsersFactory < CollectionFactory
def initialize(example)
@instances = SqlV1InstancesFactory.new(example)
@instances = SqlInstancesFactory.new(example)
super(Fog::Google[:sql].users, example)
end

Expand Down
19 changes: 0 additions & 19 deletions test/integration/factories/sql_v2_instances_factory.rb

This file was deleted.

6 changes: 0 additions & 6 deletions test/integration/sql/sqlv1/test_coverage.rb

This file was deleted.

Loading

0 comments on commit e2ca89b

Please sign in to comment.