From 89f8987c8aa21223e7f93f174f889ce4a679d9b6 Mon Sep 17 00:00:00 2001 From: Jay Mundrawala Date: Mon, 1 Feb 2016 21:24:44 -0800 Subject: Make windows event log tests faster Using SecureRandom is slow if it is not initialized. Random is good enough for this test. --- spec/functional/event_loggers/windows_eventlog_spec.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'spec') diff --git a/spec/functional/event_loggers/windows_eventlog_spec.rb b/spec/functional/event_loggers/windows_eventlog_spec.rb index cfab3763e1..eab58adede 100644 --- a/spec/functional/event_loggers/windows_eventlog_spec.rb +++ b/spec/functional/event_loggers/windows_eventlog_spec.rb @@ -25,16 +25,21 @@ if Chef::Platform.windows? and not Chef::Platform::windows_server_2003? end describe Chef::EventLoggers::WindowsEventLogger, :windows_only, :not_supported_on_win2k3 do - let(:run_id) { SecureRandom.uuid } - let(:version) { SecureRandom.uuid } - let(:elapsed_time) { SecureRandom.random_number(100) } + def rand + random.rand(1<<32).to_s + end + + let(:random) { Random.new } + let(:run_id) { rand } + let(:version) { rand } + let(:elapsed_time) { rand } let(:logger) { Chef::EventLoggers::WindowsEventLogger.new } let(:flags) { nil } let(:node) { nil } let(:run_status) { double("Run Status", {run_id: run_id, elapsed_time: elapsed_time }) } let(:event_log) { EventLog.new("Application") } let!(:offset) { event_log.read_last_event.record_number } - let(:mock_exception) { double("Exception", {message: SecureRandom.uuid, backtrace:[SecureRandom.uuid, SecureRandom.uuid]})} + let(:mock_exception) { double("Exception", {message: rand, backtrace:[rand, rand]})} it "is available" do expect(Chef::EventLoggers::WindowsEventLogger.available?).to be_truthy -- cgit v1.2.1