Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing SQL #338

Merged
merged 10 commits into from
Jun 23, 2018
Merged

Fixing SQL #338

merged 10 commits into from
Jun 23, 2018

Conversation

Temikus
Copy link
Member

@Temikus Temikus commented May 22, 2018

A lot of SQL refactoring, mostly tests. This will slow tests down a bit but will fix 99% of the flakiness, and add proper lifecycle tests.

SQL Tests

  • Add new test factories for SQLv1/v2 and SQL Users/SslCerts and instantiated basic collection tests
  • Major refactor of SQLv1 and SQLv2 tests, getting rid of old shared helpers and tests that were leaving cruft in test projects and were very flaky, incl.:
    • Adding SQL users factory and migrate user tests to it
    • Adding SslCert factory
    • Breaking out tests by subject collection

Minor CI/Test improvements

  • Make monitoring cleanup less chatty
  • Bump GoogleSQL instance tier to one with SLA and MakeSQL tests serial
  • Set github status if any CI task failed
  • Tweak rubocop rules
  • Add task to lint changed files

Drive-by improvements:

  • Set SQL delete/create operations to synchronous

  • Fixes for SQL Users model workflow

    • If Etag is nil then User doesn't exist, so should be inserted,
      not the other way around.
    • Changed async to positional parameter to match other models.
  • Minor refactor of tier tests

    • Remove list test as .all depends on list
    • Scope down the test to not instantiate a full client
  • Improve disk type test to include more regions

Fixes #337

@factory = SqlV1Factory.new(namespaced_name)
end

end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.

@subject = Fog::Google[:sql].instances
@factory = SqlV1Factory.new(namespaced_name)
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/EmptyLinesAroundClassBody: Extra empty line detected at class body end.

@subject = Fog::Google[:sql].instances
@factory = SqlV1InstancesFactory.new(namespaced_name)
end
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.

assert_equal(labels, updated.settings[:user_labels])
assert_operator(updated.settings_version, :>, settings_version)
end
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.


settings_version = instance.settings_version
labels = {
:foo => "bar"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentHash: Use 2 spaces for indentation in a hash, relative to the start of the line where the left curly brace is.

@Temikus Temikus force-pushed the fix_sql branch 2 times, most recently from 0b53fdf to 4e1a115 Compare May 22, 2018 02:26
"expected no user #{user.name}"
)
end
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.

# Delete user
users.first.destroy(:async => false)
assert_empty(
@subject.all(user.instance).select { |u| u.name == user.name },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/FirstParameterIndentation: Indent the first parameter one step more than the start of the previous line.


def cleanup
# Users will be cleaned up with the test instance.
@instances.cleanup

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationWidth: Use 2 (not 3) spaces for indentation.

@subject.get(instance_name, ssl_cert2.sha1_fingerprint).tap do |result|
assert_equal(ssl_cert2.common_name, result.common_name)
assert_equal("sql#sslCert", result.kind)
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/BlockAlignment: end at 33, 6 is not aligned with @subject.get(instance_name, ssl_cert2.sha1_fingerprint).tap do |result| at 30, 4.

ssl_cert2 = @subject.new(
:common_name => "#{ssl_cert.common_name}-2" ,
:instance => instance_name
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/ClosingParenthesisIndentation: Indent ) the same as the start of the line where ( is.


# Create a second cert and attach to the same instance
ssl_cert2 = @subject.new(
:common_name => "#{ssl_cert.common_name}-2" ,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/FirstParameterIndentation: Indent the first parameter one step more than the start of the previous line.
Layout/SpaceBeforeComma: Space found before comma.


def cleanup
# Certs will be cleaned up with the test instance.
@instances.cleanup

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationWidth: Use 2 (not 3) spaces for indentation.


# Create a second cert and attach to the same instance
ssl_cert2 = @subject.new( :common_name => "#{ssl_cert.common_name}-2",
:instance => instance_name )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceInsideParens: Space inside parentheses detected.

instance_name = ssl_cert.instance

# Create a second cert and attach to the same instance
ssl_cert2 = @subject.new( :common_name => "#{ssl_cert.common_name}-2",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceInsideParens: Space inside parentheses detected.

description = "test backup run"
operation = wait_until_complete do
@client.insert_backup_run(
instance.name,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/FirstParameterIndentation: Indent the first parameter one step more than the start of the previous line.

@Temikus Temikus force-pushed the fix_sql branch 2 times, most recently from 5c0a1ef to 826d293 Compare May 24, 2018 04:05
tasks/test.rake Outdated
t.libs << "test"
t.pattern = FileList['test/integration/sql/test_*.rb']
t.pattern = FileList['test/integration/sql/test_v2*.rb']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

tasks/test.rake Outdated
t.name = "sqlv1"
t.description = "Run SQLv1 API tests"
t.libs << "test"
t.pattern = FileList['test/integration/sql/test_common*.rb','test/integration/sql/test_v1*.rb']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Layout/SpaceAfterComma: Space missing after comma.

tasks/test.rake Outdated
multitask :sql_parallel => [:sqlv1, :sqlv2]

desc 'Run all SQL API tests'
task :sql => [:sqlv1, :sqlv2]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/SymbolArray: Use %i or %I for an array of symbols.

tasks/test.rake Outdated
desc 'Run all SQL API tests in parallel'
multitask :sql_parallel => [:sqlv1, :sqlv2]

desc 'Run all SQL API tests'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

tasks/test.rake Outdated
@@ -46,11 +47,26 @@ namespace :test do
t.verbose = true
end

desc 'Run all SQL API tests in parallel'
multitask :sql_parallel => [:sqlv1, :sqlv2]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/SymbolArray: Use %i or %I for an array of symbols.

tasks/test.rake Outdated
@@ -46,11 +47,26 @@ namespace :test do
t.verbose = true
end

desc 'Run all SQL API tests in parallel'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

tasks/test.rake Outdated
t.libs << "test"
t.pattern = FileList['test/integration/sql/test_*.rb']
t.pattern = FileList['test/integration/sql/test_v2*.rb']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

tasks/test.rake Outdated
t.name = "sqlv1"
t.description = "Run SQLv1 API tests"
t.libs << "test"
t.pattern = FileList['test/integration/sql/test_common*.rb','test/integration/sql/test_v1*.rb']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Layout/SpaceAfterComma: Space missing after comma.

tasks/test.rake Outdated
multitask :sql_parallel => [:sqlv1, :sqlv2]

desc 'Run all SQL API tests'
task :sql => [:sqlv1, :sqlv2]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/SymbolArray: Use %i or %I for an array of symbols.

tasks/test.rake Outdated
desc 'Run all SQL API tests in parallel'
multitask :sql_parallel => [:sqlv1, :sqlv2]

desc 'Run all SQL API tests'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

tasks/test.rake Outdated
@@ -46,11 +47,26 @@ namespace :test do
t.verbose = true
end

desc 'Run all SQL API tests in parallel'
multitask :sql_parallel => [:sqlv1, :sqlv2]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/SymbolArray: Use %i or %I for an array of symbols.

tasks/test.rake Outdated
@@ -46,11 +47,26 @@ namespace :test do
t.verbose = true
end

desc 'Run all SQL API tests in parallel'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@Temikus
Copy link
Member Author

Temikus commented May 24, 2018

SQL Api is being flaky again, it seems -_-

I'll try to figure this out, probably will need to wrap with Retriable like with Stackdriver...

tasks/test.rake Outdated
t.name = "sqlv1"
t.description = "Run SQLv1 API tests"
t.libs << "test"
t.pattern = FileList["test/integration/sql/test_common*.rb","test/integration/sql/test_v1*.rb"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceAfterComma: Space missing after comma.

tasks/test.rake Outdated
multitask :sql_parallel => [:sqlv1, :sqlv2]

desc "Run all SQL API tests"
task :sql => [:sqlv1, :sqlv2]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/SymbolArray: Use %i or %I for an array of symbols.

tasks/test.rake Outdated
end

desc "Run all SQL API tests in parallel"
multitask :sql_parallel => [:sqlv1, :sqlv2]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/SymbolArray: Use %i or %I for an array of symbols.

@Temikus
Copy link
Member Author

Temikus commented May 24, 2018

Ok, it seems only us-central1 is misbehaving. Australia is fine. I'll try to choose another US region first but if this is persistent I'll need to investigate the backend.

@Temikus
Copy link
Member Author

Temikus commented May 24, 2018

So I get tons of Google::Apis::ClientError: invalidState: The instance or operation is not in an appropriate state to handle the request. even though the operations reported as ready. I've synchronised almost everything. All of those errors are in cleanup BUT it still cleans those up properly 0_o. Probably those resources were not designed to be created/destroyed in 10 minutes.

I'll need to sleep on this... Maybe add a simple wait to teardown or something.

@Temikus Temikus force-pushed the fix_sql branch 2 times, most recently from 00ee296 to 22381bb Compare June 5, 2018 21:43
@Temikus Temikus force-pushed the fix_sql branch 2 times, most recently from 6040ca3 to c2a2f9e Compare June 23, 2018 01:44
tasks/test.rake Outdated
t.warning = false
t.verbose = true
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingWhitespace: Trailing whitespace detected.

Temikus added 5 commits June 23, 2018 11:46
- Changes to instantiate proper collection tests:
-- Add sql users factory and migrate user tests to it
-- Adding SslCert factory
-- Breaking out tests by subject collection

- Removing old v1 Tests

- Drive-by fix for SQL Users model workflow
 -- If Etag is nil then User doesn't exist, so should be inserted,
    not the other way around.
 -- Changed async to positional parameter to match other models.
- Remove list test as .all depends on list
- Scope down the test to not instantiate a full client
Refactored old SQLv2 tests, deleting old shared
Temikus and others added 5 commits June 23, 2018 11:46
To locally preempt HoundCI where needed
- Make monitoring cleanup less chatty
- Bump GoogleSQL instance tier
  - Since Shared CPU machine types (db-f1-micro and db-g1-small) are not covered by the Cloud SQL SLA. See: https://cloud.google.com/sql/pricing
- Set github status if any CI task failed
- Make SQL tests serial
- Tweak rubocop rules
@Temikus Temikus changed the title WIP - Fixing SQL Fixing SQL Jun 23, 2018
@Temikus
Copy link
Member Author

Temikus commented Jun 23, 2018

This is now finalised, waiting for integration tests and we should be good to go.

@Temikus Temikus merged commit 1185ec1 into fog:master Jun 23, 2018
@Temikus Temikus deleted the fix_sql branch September 28, 2019 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQL is broken
2 participants