test/instrumentation/redis_test.rb in instana-1.7.6 vs test/instrumentation/redis_test.rb in instana-1.7.7
- old
+ new
@@ -15,103 +15,83 @@
def test_normal_call_with_error
clear_all!
redis_client = create_redis_client
- redis_client.client.instance_eval do
- def read
- raise 'Something went wrong'
- end
- end
-
Instana.tracer.start_or_continue_trace(:redis_test) do
begin
- redis_client.set('hello', 'world')
+ redis_client.zadd('hello', 'invalid', 'value')
rescue; end
end
redis_client.disconnect!
- assert_redis_trace('SET', with_error: 'Something went wrong')
+ assert_redis_trace('ZADD', with_error: 'ERR value is not a valid float')
end
def test_pipeline_call
clear_all!
redis_client = create_redis_client
Instana.tracer.start_or_continue_trace(:redis_test) do
redis_client.pipelined do
- exec_sample_pipeline_calls(redis_client)
+ redis_client.set('hello', 'world')
+ redis_client.set('other', 'world')
end
end
assert_redis_trace('PIPELINE')
end
def test_pipeline_call_with_error
clear_all!
redis_client = create_redis_client
- redis_client.client.instance_eval do
- def read
- raise 'Something went wrong'
- end
- end
-
Instana.tracer.start_or_continue_trace(:redis_test) do
begin
redis_client.pipelined do
- exec_sample_pipeline_calls(redis_client)
+ redis_client.set('other', 'world')
+ redis_client.call('invalid')
end
rescue; end
end
- assert_redis_trace('PIPELINE', with_error: 'Something went wrong')
+ assert_redis_trace('PIPELINE', with_error: "ERR unknown command 'invalid'")
end
def test_multi_call
clear_all!
redis_client = create_redis_client
Instana.tracer.start_or_continue_trace(:redis_test) do
redis_client.multi do
- exec_sample_pipeline_calls(redis_client)
+ redis_client.set('hello', 'world')
+ redis_client.set('other', 'world')
end
end
assert_redis_trace('MULTI')
end
def test_multi_call_with_error
clear_all!
redis_client = create_redis_client
- redis_client.client.instance_eval do
- def read
- raise 'Something went wrong'
- end
- end
-
Instana.tracer.start_or_continue_trace(:redis_test) do
begin
redis_client.multi do
- exec_sample_pipeline_calls(redis_client)
+ redis_client.set('other', 'world')
+ redis_client.call('invalid')
end
rescue; end
end
- assert_redis_trace('MULTI', with_error: 'Something went wrong')
+ assert_redis_trace('MULTI', with_error: "ERR unknown command 'invalid'")
end
private
def create_redis_client
Redis.new(url: ENV['I_REDIS_URL'])
- end
-
- def exec_sample_pipeline_calls(redis_client)
- redis_client.set('hello', 'world')
- redis_client.set('other', 'world')
- redis_client.hmset('awesome', 'wonderful', 'world')
end
def assert_redis_trace(command, with_error: nil)
assert_equal 1, ::Instana.processor.queue_count
trace = ::Instana.processor.queued_traces.first