Skip to content

Commit

Permalink
Remove climate_control in favor of ice_age
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Jan 15, 2024
1 parent 2c9386d commit 8b08fe8
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 107 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ gem 'stackprof'
gem 'benchmark-ips'
gem 'stackprof-webnav'
gem 'flamegraph'
gem 'climate_control'
gem 'mysql2'
gem 'pg'
gem 'cuprite'
Expand Down
5 changes: 2 additions & 3 deletions spec/flipper/adapters/mongo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@

load 'flipper/adapters/mongo.rb'

with_env "MONGO_URL" => ENV.fetch("MONGO_URL", "mongodb://127.0.0.1:27017/testing") do
expect(Flipper.adapter.adapter).to be_a(Flipper::Adapters::Mongo)
end
ENV["MONGO_URL"] = ENV.fetch("MONGO_URL", "mongodb://127.0.0.1:27017/testing")
expect(Flipper.adapter.adapter).to be_a(Flipper::Adapters::Mongo)
end
end
63 changes: 27 additions & 36 deletions spec/flipper/cloud/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
end

it "can set token from ENV var" do
with_env "FLIPPER_CLOUD_TOKEN" => "from_env" do
instance = described_class.new(required_options.reject { |k, v| k == :token })
expect(instance.token).to eq("from_env")
end
ENV["FLIPPER_CLOUD_TOKEN"] = "from_env"
instance = described_class.new(required_options.reject { |k, v| k == :token })
expect(instance.token).to eq("from_env")
end

it "can set instrumenter" do
Expand All @@ -30,10 +29,9 @@
end

it "can set read_timeout from ENV var" do
with_env "FLIPPER_CLOUD_READ_TIMEOUT" => "9" do
instance = described_class.new(required_options.reject { |k, v| k == :read_timeout })
expect(instance.read_timeout).to eq(9)
end
ENV["FLIPPER_CLOUD_READ_TIMEOUT"] = "9"
instance = described_class.new(required_options.reject { |k, v| k == :read_timeout })
expect(instance.read_timeout).to eq(9)
end

it "can set open_timeout" do
Expand All @@ -42,10 +40,9 @@
end

it "can set open_timeout from ENV var" do
with_env "FLIPPER_CLOUD_OPEN_TIMEOUT" => "9" do
instance = described_class.new(required_options.reject { |k, v| k == :open_timeout })
expect(instance.open_timeout).to eq(9)
end
ENV["FLIPPER_CLOUD_OPEN_TIMEOUT"] = "9"
instance = described_class.new(required_options.reject { |k, v| k == :open_timeout })
expect(instance.open_timeout).to eq(9)
end

it "can set write_timeout" do
Expand All @@ -54,10 +51,9 @@
end

it "can set write_timeout from ENV var" do
with_env "FLIPPER_CLOUD_WRITE_TIMEOUT" => "9" do
instance = described_class.new(required_options.reject { |k, v| k == :write_timeout })
expect(instance.write_timeout).to eq(9)
end
ENV["FLIPPER_CLOUD_WRITE_TIMEOUT"] = "9"
instance = described_class.new(required_options.reject { |k, v| k == :write_timeout })
expect(instance.write_timeout).to eq(9)
end

it "can set sync_interval" do
Expand All @@ -66,10 +62,9 @@
end

it "can set sync_interval from ENV var" do
with_env "FLIPPER_CLOUD_SYNC_INTERVAL" => "15" do
instance = described_class.new(required_options.reject { |k, v| k == :sync_interval })
expect(instance.sync_interval).to eq(15)
end
ENV["FLIPPER_CLOUD_SYNC_INTERVAL"] = "15"
instance = described_class.new(required_options.reject { |k, v| k == :sync_interval })
expect(instance.sync_interval).to eq(15)
end

it "passes sync_interval into sync adapter" do
Expand All @@ -87,10 +82,9 @@
end

it "defaults debug_output to STDOUT if FLIPPER_CLOUD_DEBUG_OUTPUT_STDOUT set to true" do
with_env "FLIPPER_CLOUD_DEBUG_OUTPUT_STDOUT" => "true" do
instance = described_class.new(required_options)
ENV["FLIPPER_CLOUD_DEBUG_OUTPUT_STDOUT"] = "true"
instance = described_class.new(required_options)
expect(instance.debug_output).to eq(STDOUT)
end
end

it "defaults adapter block" do
Expand Down Expand Up @@ -128,10 +122,9 @@
end

it "can override URL using ENV var" do
with_env "FLIPPER_CLOUD_URL" => "https://example.com" do
instance = described_class.new(required_options.reject { |k, v| k == :url })
expect(instance.url).to eq("https://example.com")
end
ENV["FLIPPER_CLOUD_URL"] = "https://example.com"
instance = described_class.new(required_options.reject { |k, v| k == :url })
expect(instance.url).to eq("https://example.com")
end

it "defaults sync_method to :poll" do
Expand All @@ -150,12 +143,11 @@
end

it "sets sync_method to :webhook if FLIPPER_CLOUD_SYNC_SECRET set" do
with_env "FLIPPER_CLOUD_SYNC_SECRET" => "abc" do
instance = described_class.new(required_options)
ENV["FLIPPER_CLOUD_SYNC_SECRET"] = "abc"
instance = described_class.new(required_options)

expect(instance.sync_method).to eq(:webhook)
expect(instance.adapter).to be_instance_of(Flipper::Adapters::DualWrite)
end
expect(instance.sync_method).to eq(:webhook)
expect(instance.adapter).to be_instance_of(Flipper::Adapters::DualWrite)
end

it "can set sync_secret" do
Expand All @@ -164,10 +156,9 @@
end

it "can override sync_secret using ENV var" do
with_env "FLIPPER_CLOUD_SYNC_SECRET" => "from_env" do
instance = described_class.new(required_options.reject { |k, v| k == :sync_secret })
expect(instance.sync_secret).to eq("from_env")
end
ENV["FLIPPER_CLOUD_SYNC_SECRET"] = "from_env"
instance = described_class.new(required_options.reject { |k, v| k == :sync_secret })
expect(instance.sync_secret).to eq("from_env")
end

it "can sync with cloud" do
Expand Down
17 changes: 8 additions & 9 deletions spec/flipper/cloud/telemetry/backoff_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,18 @@
end

it "from env" do
env = {
ENV.update(
"FLIPPER_BACKOFF_MIN_TIMEOUT_MS" => "1000",
"FLIPPER_BACKOFF_MAX_TIMEOUT_MS" => "2000",
"FLIPPER_BACKOFF_MULTIPLIER" => "1.9",
"FLIPPER_BACKOFF_RANDOMIZATION_FACTOR" => "0.1",
}
with_env env do
policy = described_class.new
expect(policy.min_timeout_ms).to eq(1000)
expect(policy.max_timeout_ms).to eq(2000)
expect(policy.multiplier).to eq(1.9)
expect(policy.randomization_factor).to eq(0.1)
end
)

policy = described_class.new
expect(policy.min_timeout_ms).to eq(1000)
expect(policy.max_timeout_ms).to eq(2000)
expect(policy.multiplier).to eq(1.9)
expect(policy.randomization_factor).to eq(0.1)
end
end

Expand Down
5 changes: 2 additions & 3 deletions spec/flipper/cloud_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@
end

it 'can initialize with no token explicitly provided' do
with_env 'FLIPPER_CLOUD_TOKEN' => 'asdf' do
expect(described_class.new).to be_instance_of(Flipper::Cloud::DSL)
end
ENV['FLIPPER_CLOUD_TOKEN'] = 'asdf'
expect(described_class.new).to be_instance_of(Flipper::Cloud::DSL)
end

it 'can set instrumenter' do
Expand Down
83 changes: 35 additions & 48 deletions spec/flipper/engine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,25 @@
let(:adapter) { Flipper.adapter.adapter }

it 'can set strict=true from ENV' do
with_env 'FLIPPER_STRICT' => 'true' do
subject
expect(config.strict).to eq(:raise)
expect(adapter).to be_instance_of(Flipper::Adapters::Strict)
end
ENV['FLIPPER_STRICT'] = 'true'
subject
expect(config.strict).to eq(:raise)
expect(adapter).to be_instance_of(Flipper::Adapters::Strict)
end

it 'can set strict=warn from ENV' do
with_env 'FLIPPER_STRICT' => 'warn' do
subject
expect(config.strict).to eq(:warn)
expect(adapter).to be_instance_of(Flipper::Adapters::Strict)
expect(adapter.handler).to be(:warn)
end
ENV['FLIPPER_STRICT'] = 'warn'
subject
expect(config.strict).to eq(:warn)
expect(adapter).to be_instance_of(Flipper::Adapters::Strict)
expect(adapter.handler).to be(:warn)
end

it 'can set strict=false from ENV' do
with_env 'FLIPPER_STRICT' => 'false' do
subject
expect(config.strict).to eq(false)
expect(adapter).to be_instance_of(Flipper::Adapters::Memory)
end
ENV['FLIPPER_STRICT'] = 'false'
subject
expect(config.strict).to eq(false)
expect(adapter).to be_instance_of(Flipper::Adapters::Memory)
end

[true, :raise, :warn].each do |value|
Expand Down Expand Up @@ -104,39 +101,34 @@
it_behaves_like 'config.strict'

it 'can set env_key from ENV' do
with_env 'FLIPPER_ENV_KEY' => 'flopper' do
subject
expect(config.env_key).to eq('flopper')
end
ENV['FLIPPER_ENV_KEY'] = 'flopper'
subject
expect(config.env_key).to eq('flopper')
end

it 'can set memoize from ENV' do
with_env 'FLIPPER_MEMOIZE' => 'false' do
subject
expect(config.memoize).to eq(false)
end
ENV['FLIPPER_MEMOIZE'] = 'false'
subject
expect(config.memoize).to eq(false)
end

it 'can set preload from ENV' do
with_env 'FLIPPER_PRELOAD' => 'false' do
subject
expect(config.preload).to eq(false)
end
ENV['FLIPPER_PRELOAD'] = 'false'
subject
expect(config.preload).to eq(false)
end

it 'can set instrumenter from ENV' do
stub_const('My::Cool::Instrumenter', Class.new)
with_env 'FLIPPER_INSTRUMENTER' => 'My::Cool::Instrumenter' do
subject
expect(config.instrumenter).to eq(My::Cool::Instrumenter)
end
ENV['FLIPPER_INSTRUMENTER'] = 'My::Cool::Instrumenter'
subject
expect(config.instrumenter).to eq(My::Cool::Instrumenter)
end

it 'can set log from ENV' do
with_env 'FLIPPER_LOG' => 'false' do
subject
expect(config.log).to eq(false)
end
ENV['FLIPPER_LOG'] = 'false'
subject
expect(config.log).to eq(false)
end

it 'sets defaults' do
Expand Down Expand Up @@ -220,10 +212,8 @@
end

context 'with cloud' do
around do |example|
with_env "FLIPPER_CLOUD_TOKEN" => "test-token" do
example.run
end
before do
ENV["FLIPPER_CLOUD_TOKEN"] = "test-token"
end

# App for Rack::Test
Expand All @@ -248,10 +238,8 @@
end

context "with CLOUD_SYNC_SECRET" do
around do |example|
with_env "FLIPPER_CLOUD_SYNC_SECRET" => "test-secret" do
example.run
end
before do
ENV["FLIPPER_CLOUD_SYNC_SECRET"] = "test-secret"
end

let(:request_body) do
Expand Down Expand Up @@ -296,10 +284,9 @@

context "without FLIPPER_CLOUD_TOKEN" do
it "gracefully skips configuring webhook app" do
with_env "FLIPPER_CLOUD_TOKEN" => nil do
application.initialize!
expect(Flipper.instance).to be_a(Flipper::DSL)
end
ENV["FLIPPER_CLOUD_TOKEN"] = nil
application.initialize!
expect(Flipper.instance).to be_a(Flipper::DSL)

post "/_flipper"
expect(last_response.status).to eq(404)
Expand Down
7 changes: 0 additions & 7 deletions spec/support/climate_control.rb

This file was deleted.

0 comments on commit 8b08fe8

Please sign in to comment.