spec/inputs/jdbc_spec.rb in logstash-input-jdbc-4.3.5 vs spec/inputs/jdbc_spec.rb in logstash-input-jdbc-4.3.6

- old
+ new

@@ -257,10 +257,12 @@ expect(updated_last_run).to be > last_run_time last_run_time = updated_last_run end plugin.stop + runner.join + Timecop.return end end context "when iterating result-set via paging" do @@ -734,9 +736,68 @@ it "should respect last run metadata" do plugin.run(queue) expect(plugin.instance_variable_get("@value_tracker").value).to be > last_run_time + end + end + + context "when previous runs are to be respected upon successful query execution (by time string)" do + + let(:settings) do + { "statement" => "SELECT custom_time FROM test_table WHERE custom_time > :sql_last_value", + "use_column_value" => true, + "tracking_column" => "custom_time", + "tracking_column_type" => "timestamp", + "last_run_metadata_path" => Stud::Temporary.pathname } + end + + let(:last_run_time) { '2010-03-19T14:48:40.483Z' } + + before do + File.write(settings["last_run_metadata_path"], YAML.dump(last_run_time)) + test_table = db[:test_table] + test_table.insert(:num => 0, :custom_time => Time.now.utc) + plugin.register + end + + after do + plugin.stop + end + + it "should respect last run metadata" do + plugin.run(queue) + expect(plugin.instance_variable_get("@value_tracker").value).to be > DateTime.parse(last_run_time).to_time + end + end + + context "when previous runs are to be respected upon successful query execution (by date/time string)" do + + let(:settings) do + { "statement" => "SELECT custom_time FROM test_table WHERE custom_time > :sql_last_value", + "use_column_value" => true, + "tracking_column" => "custom_time", + "tracking_column_type" => "timestamp", + "jdbc_default_timezone" => "UTC", #this triggers the last_run_time to be treated as date/time + "last_run_metadata_path" => Stud::Temporary.pathname } + end + + let(:last_run_time) { '2010-03-19T14:48:40.483Z' } + + before do + File.write(settings["last_run_metadata_path"], YAML.dump(last_run_time)) + test_table = db[:test_table] + test_table.insert(:num => 0, :custom_time => Time.now.utc) + plugin.register + end + + after do + plugin.stop + end + + it "should respect last run metadata" do + plugin.run(queue) + expect(plugin.instance_variable_get("@value_tracker").value).to be > DateTime.parse(last_run_time) end end context "when previous runs are to be respected upon successful query execution (by column)" do