示例#1
0
文件: hunt_test.py 项目: cdstelly/grr
    def testFailingOutputPluginDoesNotAffectOtherOutputPlugins(self):
        failing_plugin_descriptor = rdf_output_plugin.OutputPluginDescriptor(
            plugin_name="FailingDummyHuntOutputPlugin")
        plugin_descriptor = rdf_output_plugin.OutputPluginDescriptor(
            plugin_name="DummyHuntOutputPlugin")

        hunt_id, _ = self._CreateAndRunHunt(
            num_clients=5,
            client_mock=hunt_test_lib.SampleHuntMock(failrate=-1),
            client_rule_set=foreman_rules.ForemanClientRuleSet(),
            client_rate=0,
            args=self.GetFileHuntArgs(),
            output_plugins=[failing_plugin_descriptor, plugin_descriptor])

        errors = hunt.GetHuntOutputPluginErrors(hunt_id, 0, sys.maxsize)
        self.assertLen(errors, 5)

        # Check that non-failing output plugin is still correctly processed.
        logs = hunt.GetHuntOutputPluginLogs(hunt_id, 0, sys.maxsize)
        self.assertLen(logs, 5)
示例#2
0
文件: hunt_test.py 项目: cdstelly/grr
    def testOutputPluginsErrorsAreCorrectlyWrittenAndCanBeRead(self):
        failing_plugin_descriptor = rdf_output_plugin.OutputPluginDescriptor(
            plugin_name="FailingDummyHuntOutputPlugin")

        hunt_id, _ = self._CreateAndRunHunt(
            num_clients=5,
            client_mock=hunt_test_lib.SampleHuntMock(failrate=-1),
            client_rule_set=foreman_rules.ForemanClientRuleSet(),
            client_rate=0,
            args=self.GetFileHuntArgs(),
            output_plugins=[failing_plugin_descriptor])

        errors = hunt.GetHuntOutputPluginErrors(hunt_id, 0, sys.maxsize)
        self.assertLen(errors, 5)
        for e in errors:
            self.assertEqual(e.batch_size, 1)
            self.assertEqual(
                e.status,
                output_plugin.OutputPluginBatchProcessingStatus.Status.ERROR)
            self.assertEqual(e.plugin_descriptor, failing_plugin_descriptor)
            self.assertEqual(e.summary, "Oh no!")
示例#3
0
文件: hunt_test.py 项目: cdstelly/grr
    def testOutputPluginFlushErrorIsLoggedProperly(self):
        plugin_descriptor = rdf_output_plugin.OutputPluginDescriptor(
            plugin_name="FailingInFlushDummyHuntOutputPlugin")

        hunt_id, _ = self._CreateAndRunHunt(
            num_clients=5,
            client_mock=hunt_test_lib.SampleHuntMock(failrate=-1),
            client_rule_set=foreman_rules.ForemanClientRuleSet(),
            client_rate=0,
            args=self.GetFileHuntArgs(),
            output_plugins=[plugin_descriptor])

        logs = hunt.GetHuntOutputPluginLogs(hunt_id, 0, sys.maxsize)
        self.assertEmpty(logs)

        errors = hunt.GetHuntOutputPluginErrors(hunt_id, 0, sys.maxsize)
        self.assertLen(errors, 5)
        for e in errors:
            self.assertEqual(e.batch_size, 1)
            self.assertEqual(
                e.status,
                output_plugin.OutputPluginBatchProcessingStatus.Status.ERROR)
            self.assertEqual(e.plugin_descriptor, plugin_descriptor)
            self.assertEqual(e.summary, "Flush, oh no!")