GithubHelp home page GithubHelp logo

Comments (10)

beccasaurus avatar beccasaurus commented on July 24, 2024

Additional failing build. Spec needs fix.

https://travis-ci.org/GoogleCloudPlatform/ruby-docs-samples/jobs/163856203

from ruby-docs-samples.

beccasaurus avatar beccasaurus commented on July 24, 2024

Thought: each test suite can use bucket [Project ID]-[Name of test suite]-[timestamp], eg. "TestProject-BigQuery-20160115123059.0462"

With our current Travis configuration...

  • Multiple runs of all test suites may happen at the same time (multiple builds of ruby-docs-samples in parallel, eg. multiple pull requests)
  • Multiple runs of test suites may happen at the same time within one overall build (as part of our current Travis matrix setup)

Vote: delete buckets after :all to not leave any buckets behind after each test suite run. Find or create in before each example block.

from ruby-docs-samples.

frankyn avatar frankyn commented on July 24, 2024

Does this mean we will have overhead of creating a bucket for each test? It shouldn't be too bad.

from ruby-docs-samples.

beccasaurus avatar beccasaurus commented on July 24, 2024

There are some specs that create a clean bucket context before each spec, eg. buckets_spec.rb

I think I'd like to update the specs to look like...

before do
  @test_bucket = create_test_bucket "BigQuery"
end

it "test that needs a second bucket" do
  @second_bucket = create_test_bucket "BigQuery second bucket"
end

Where #create_test_bucket is a required helper and the helper registers an after hook:

# */spec_helpers/storage_helper.rb
require "spec_helpers/project_helper.rb"

def test_bucket_names
  @test_bucket_names ||= []
end

def create_test_bucket bucket_suffix
  bucket_suffix = bucket_suffix.downcase.gsub /[^\w+]/, "_"
  bucket_name = "#{default_project_id}-#{bucket_suffic}-#{Time.now.to_f}"
  test_bucket_names << bucket_name
  Google::Cloud.new.storage.create_bucket bucket_name
end

def delete_test_buckets!
  test_bucket_names.each do |bucket_name|
    bucket = Google::Cloud.new.storage.bucket bucket_name
    bucket.delete if bucket
  end
end

RSpec.configure do |config|
  config.after do
    delete_test_buckets!
  end
end

Or something.

Some of the other docs samples repos generate buckets for their test runs using a timestamp which is good for isolation. Pretty simple.

from ruby-docs-samples.

frankyn avatar frankyn commented on July 24, 2024

Gotcha, I like your idea for using RSpec after hooks 👍
Is it possible for concurrent tests to create the same bucket name? Time.now only goes up to seconds.

from ruby-docs-samples.

beccasaurus avatar beccasaurus commented on July 24, 2024

Time in Ruby includes nanoseconds (since Epoch)

from ruby-docs-samples.

frankyn avatar frankyn commented on July 24, 2024

Got it, I should have double checked that.

Thanks!

from ruby-docs-samples.

beccasaurus avatar beccasaurus commented on July 24, 2024

I have not proven that this is the reason for Storage samples, so I am renaming to focus on fixing all flakiness in Storage sample tests.

from ruby-docs-samples.

beccasaurus avatar beccasaurus commented on July 24, 2024

Upgrading all flaky test failures to p0

Example of Storage failures:

from ruby-docs-samples.

frankyn avatar frankyn commented on July 24, 2024

Fixed in #211

from ruby-docs-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.