<commit_before>module Ragios
  module Plugin
    class PassingPlugin 
      attr_accessor :test_result
      def init(options)
      end
      def test_command
        @test_result = {result:'PASSED'}
        return true
      end
    end
  end
end

module Ragios
  module Plugin
    class FailingPlugin 
      attr_accessor :test_result
      def init(options)
      end
      def test_command
        @test_result = {result:'FAILED'}
        return false
      end
    end
  end
end

module Ragios
  module NotifierTest
    def self.failed_resolved(monitor, notifier)
      controller = Ragios::Controller
      controller.scheduler(Ragios::Scheduler.new(Ragios::Controller))
      controller.model(Ragios::Model::CouchdbMonitorModel)
      controller.logger(Ragios::CouchdbLogger.new)
      failing_monitor = {monitor: monitor,
        every: "5m",
        via: notifier,
        contact: ENV['RAGIOS_CONTACT'],
        plugin: "failing_plugin" }     
    
      #test should fail and send a FAILED notification message
      monitor_id = controller.add([failing_monitor]).first.id
    
      #controller.update automatically restarts and tests monitor
      #test should pass this time and send a PASSED notification message
      controller.update(monitor_id, plugin: "passing_plugin")
      controller.delete(monitor_id)   
    end
  end
end<commit_msg>add delay for background processing<commit_after>module Ragios
  module Plugin
    class PassingPlugin 
      attr_accessor :test_result
      def init(options)
      end
      def test_command
        @test_result = {result:'PASSED'}
        return true
      end
    end
  end
end

module Ragios
  module Plugin
    class FailingPlugin 
      attr_accessor :test_result
      def init(options)
      end
      def test_command
        @test_result = {result:'FAILED'}
        return false
      end
    end
  end
end

module Ragios
  module NotifierTest
    def self.failed_resolved(monitor, notifier)
      controller = Ragios::Controller
      controller.scheduler(Ragios::Scheduler.new(Ragios::Controller))
      controller.model(Ragios::Model::CouchdbMonitorModel)
      controller.logger(Ragios::CouchdbLogger.new)
      failing_monitor = {monitor: monitor,
        every: "5m",
        via: notifier,
        contact: ENV['RAGIOS_CONTACT'],
        plugin: "failing_plugin" }     
    
      #test should fail and send a FAILED notification message
      monitor_id = controller.add([failing_monitor]).first.id
    
      #controller.update automatically restarts and tests monitor
      #test should pass this time and send a PASSED notification message
      controller.update(monitor_id, plugin: "passing_plugin")
      controller.delete(monitor_id)   
      sleep 1 #delay for background processing to complete
    end
  end
end
{'fraction_non_alphanumeric': 0.06823865666309396, 'fraction_numerical': 0.0010718113612004287, 'mean_word_length': 2.7383177570093458, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3715630', 'n_tokens_mistral': 809, 'n_tokens_neox': 793, 'n_words': 211}