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

Improve Compute coverage #394

Merged
merged 14 commits into from
Jul 15, 2018
Merged

Conversation

Temikus
Copy link
Member

@Temikus Temikus commented Jul 14, 2018

Server is our most complicated model but it has the worst test coverage.
This is trying to improve it and fix the docs while I'm at it.

Due to the need to instantiate a bunch of servers during the test this slows them down quite a bit...
Looking at ballpark figures - 73 minutes :|

I'll start thinking about speeding things up. I think we can parallelise things more, but that requires careful planning of cleanup (since different API's can trump eachother).

@Temikus Temikus changed the title Compute improv coverage Improve Compute coverage Jul 14, 2018
@Temikus
Copy link
Member Author

Temikus commented Jul 14, 2018

Something's up with GitHub - PR's no longer update :|

Wrote to support - I'll revisit this tomorrow.

@codecov
Copy link

codecov bot commented Jul 15, 2018

Codecov Report

Merging #394 into master will increase coverage by 2.05%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #394      +/-   ##
==========================================
+ Coverage   83.44%   85.49%   +2.05%     
==========================================
  Files         339      114     -225     
  Lines        5762     2117    -3645     
==========================================
- Hits         4808     1810    -2998     
+ Misses        954      307     -647
Impacted Files Coverage Δ
lib/fog/google/models/sql/instance.rb 65.57% <0%> (-13.94%) ⬇️
lib/fog/google/models/sql/user.rb 46.42% <0%> (-50%) ⬇️
lib/fog/google/models/sql/ssl_certs.rb 45% <0%> (-35%) ⬇️
lib/fog/google/models/sql/ssl_cert.rb 54.28% <0%> (-34.29%) ⬇️
lib/fog/google/requests/sql/update_instance.rb 58.33% <0%> (-33.34%) ⬇️
lib/fog/google/models/sql/tiers.rb 80% <0%> (-20%) ⬇️
lib/fog/google/models/sql/users.rb 80% <0%> (-20%) ⬇️
...fog/google/requests/sql/restore_instance_backup.rb 70% <0%> (-20%) ⬇️
lib/fog/google/requests/sql/delete_ssl_cert.rb 77.77% <0%> (-11.12%) ⬇️
... and 218 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 72ae50e...ecfdfd2. Read the comment docs.

# Grab the test suit name from the example
suit_name = [@example].join("_").gsub(/\W/, "").tr("_", "-").downcase.split('-')[0]
# Select all resources matching the test suite
resources = @subject.all.select { |resource| resource.name.match? /#{PREFIX}-[0-9]*-#{suit_name}/ }

Choose a reason for hiding this comment

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

Lint/AmbiguousRegexpLiteral: Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.

@@ -8,7 +8,10 @@ def initialize(subject, example)
end

def cleanup(async = false)
resources = @subject.all.select { |resource| resource.name.start_with? PREFIX }
# Grab the test suit name from the example
suit_name = [@example].join("_").gsub(/\W/, "").tr("_", "-").downcase.split('-')[0]

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 Temikus force-pushed the compute_improv_coverage branch from 4f0be9f to d1c537f Compare July 15, 2018 01:57
@Temikus Temikus force-pushed the compute_improv_coverage branch from d1c537f to 8ca0339 Compare July 15, 2018 02:03
Temikus added 5 commits July 15, 2018 13:29
This should be mostly a no-op, just a logical improvement.

Waiting for !PENDING may cause some issues when operation is in a transitional state or they add another status to an operation on the backend.
This will make it easier to spot long-running tests and get results from CI quicker.
In theory this isn’t even needed as the bottom routine actually waits for resources to disappear from the listing:
```
resources.each { |r| Fog.wait_for { !@subject.all.map(&:identity).include? r.identity } }
```
We’ll need to parallelise CI more so trying to split test cleanup once more
if DEBUG
p "Cleanup invoked in #{self} for example: #{@example}"
p "Resources to be deleted: #{resources.map { |r| r.name }}"
p "All subject resources: #{@subject.all.map { |s| s.name }}"

Choose a reason for hiding this comment

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

Style/SymbolProc: Pass &:name as an argument to map instead of a block.

resources = @subject.all.select { |resource| resource.name.match? /#{PREFIX}-[0-9]*-#{suit_name}/ }
if DEBUG
p "Cleanup invoked in #{self} for example: #{@example}"
p "Resources to be deleted: #{resources.map { |r| r.name }}"

Choose a reason for hiding this comment

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

Style/SymbolProc: Pass &:name as an argument to map instead of a block.

def cleanup(async = false)
resources = @subject.all.select { |resource| resource.name.start_with? PREFIX }
suit_name = @example.gsub(/\W/, "").tr("_", "-").downcase.split('-')[0]
resources = @subject.all.select { |resource| resource.name.match? /#{PREFIX}-[0-9]*-#{suit_name}/ }

Choose a reason for hiding this comment

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

Lint/AmbiguousRegexpLiteral: Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.

def cleanup(async = false)
resources = @subject.all.select { |resource| resource.name.start_with? PREFIX }
suit_name = @example.gsub(/\W/, "").tr("_", "-").downcase.split('-')[0]

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.

@@ -5,6 +5,9 @@
# XXX not sure if this will work on Travis CI or not
Fog.credential = :test

# Enable test debugging, providing additional information in some methods
DEBUG = ENV['DEBUG'] || false

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.

if DEBUG
p "Cleanup invoked in #{self} for example: #{@example}"
p "Resources to be deleted: #{resources.map { |r| r.name }}"
p "All subject resources: #{@subject.all.map { |s| s.name }}"

Choose a reason for hiding this comment

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

Style/SymbolProc: Pass &:name as an argument to map instead of a block.

resources = @subject.all.select { |resource| resource.name.match? /#{PREFIX}-[0-9]*-#{suit_name}/ }
if DEBUG
p "Cleanup invoked in #{self} for example: #{@example}"
p "Resources to be deleted: #{resources.map { |r| r.name }}"

Choose a reason for hiding this comment

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

Style/SymbolProc: Pass &:name as an argument to map instead of a block.

def cleanup(async = false)
resources = @subject.all.select { |resource| resource.name.start_with? PREFIX }
suit_name = @example.gsub(/\W/, "").tr("_", "-").downcase.split('-')[0]
resources = @subject.all.select { |resource| resource.name.match? /#{PREFIX}-[0-9]*-#{suit_name}/ }

Choose a reason for hiding this comment

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

Lint/AmbiguousRegexpLiteral: Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.

def cleanup(async = false)
resources = @subject.all.select { |resource| resource.name.start_with? PREFIX }
suit_name = @example.gsub(/\W/, "").tr("_", "-").downcase.split('-')[0]

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.

@@ -5,6 +5,9 @@
# XXX not sure if this will work on Travis CI or not
Fog.credential = :test

# Enable test debugging, providing additional information in some methods
DEBUG = ENV['DEBUG'] || false

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 Temikus force-pushed the compute_improv_coverage branch from cbff6d2 to eb3e6e6 Compare July 15, 2018 06:38
@Temikus
Copy link
Member Author

Temikus commented Jul 15, 2018

Alright, merging this. I'll need to parallelise things though. It now takes literally 2 hours.

@Temikus Temikus merged commit d1d8058 into fog:master Jul 15, 2018
@Temikus Temikus deleted the compute_improv_coverage branch March 20, 2019 02:00
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.

2 participants