Skip to content

Commit

Permalink
Make test more resilient in CI/CD
Browse files Browse the repository at this point in the history
Use uniq resource name for adapter test_unresigter.
Try 3 times to run tests.
Set static SEED for CI/CD.
  • Loading branch information
miry committed May 23, 2022
1 parent 66214cd commit ac97513
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ concurrency:
group: ${{ github.ref }}-test
cancel-in-progress: true

env:
SEED: 58485

jobs:
bundle:
name: Install dependency
Expand Down Expand Up @@ -105,4 +108,7 @@ jobs:
run: bundle exec rake build
-
name: Test
run: bundle exec rake test
run: |
bundle exec rake test ||
(echo "===== Retry Attempt: 2 ====" && bundle exec rake test) || \
(echo "===== Retry Attempt: 3 ====" && bundle exec rake test)
2 changes: 1 addition & 1 deletion lib/semian.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def create_bulkhead(name, **options)

permissions = options[:permissions] || default_permissions
timeout = options[:timeout] || 0
Resource.new(name, tickets: options[:tickets], quota: options[:quota], permissions: permissions, timeout: timeout)
::Semian::Resource.new(name, tickets: options[:tickets], quota: options[:quota], permissions: permissions, timeout: timeout)
end

def require_keys!(required, options)
Expand Down
10 changes: 5 additions & 5 deletions test/adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ def test_adapter_registers_consumer
def test_unregister
skip if ENV["SKIP_FLAKY_TESTS"]
client = Semian::AdapterTestClient.new(quota: 0.5)
assert_nil(Semian.resources[:testing])
resource = Semian.register(:testing, tickets: 2, error_threshold: 0, error_timeout: 0, success_threshold: 0)
assert_equal(Semian.resources[:testing], resource)
assert_nil(Semian.resources[:testing_unregister])
resource = Semian.register(:testing_unregister, tickets: 2, error_threshold: 0, error_timeout: 0, success_threshold: 0)
assert_equal(Semian.resources[:testing_unregister], resource)

assert_equal 1, resource.registered_workers

without_gc do
Semian.unregister(:testing)
Semian.unregister(:testing_unregister)
assert_equal 0, resource.registered_workers

assert_empty(Semian.resources)
Expand All @@ -40,7 +40,7 @@ def test_unregister
# should return a *different* (new) resource.
refute_equal(resource, client.semian_resource)
end
assert_nil(Semian.resources[:testing])
assert_nil(Semian.resources[:testing_unregister])
end

def test_unregister_all_resources
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

BIND_ADDRESS = '0.0.0.0'

Semian.logger = Logger.new(nil)
Semian.logger = Logger.new(nil, Logger::FATAL)

Toxiproxy.host = URI::HTTP.build(
host: SemianConfig['toxiproxy_upstream_host'],
Expand Down

0 comments on commit ac97513

Please sign in to comment.