Пример #1
0
    def test_plugin_info_repr(self):
        panoptes_plugin_info = PanoptesPluginInfo("plugin_name",
                                                  "path/to/plugin")
        panoptes_plugin_info.panoptes_context = self._panoptes_context
        panoptes_plugin_info.data = self._panoptes_resource
        panoptes_plugin_info.kv_store_class = PanoptesTestKeyValueStore
        panoptes_plugin_info.last_executed = _LAST_EXECUTED_TEST_VALUE
        panoptes_plugin_info.last_results = _LAST_RESULTS_TEST_VALUE

        repr_string = "PanoptesPluginInfo: Normalized name: plugin__name, Config file: None, " \
                      "Panoptes context: [PanoptesContext: KV Stores: [PanoptesTestKeyValueStore], " \
                      "Config: ConfigObj({'main': {'sites': ['local'], " \
                      "'plugins_extension': 'panoptes-plugin', 'plugins_skew': 1}, " \
                      "'log': {'config_file': 'tests/config_files/test_panoptes_logging.ini', 'rate': 1000, " \
                      "'per': 1, 'burst': 10000, " \
                      "'formatters': {'keys': ['root_log_format', 'log_file_format', 'discovery_plugins_format']}}, " \
                      "'redis': {'default': {'namespace': 'panoptes', 'shards': {'shard1': " \
                      "{'host': 'localhost', 'port': 6379, 'db': 0, 'password': '******'}}}}, " \
                      "'kafka': {'topic_key_delimiter': ':', 'topic_name_delimiter': '-', " \
                      "'brokers': {'broker1': {'host': 'localhost', 'port': 9092}}, " \
                      "'topics': {'metrics': {'raw_topic_name_suffix': 'metrics', " \
                      "'transformed_topic_name_suffix': 'processed'}}}, " \
                      "'zookeeper': {'connection_timeout': 30, 'servers': {'server1': " \
                      "{'host': 'localhost', 'port': 2181}}}, 'discovery': {" \
                      "'plugins_paths': ['tests/plugins/discovery'], 'plugin_scan_interval': 60, " \
                      "'celerybeat_max_loop_interval': 5}, " \
                      "'polling': {'plugins_paths': ['tests/plugins/polling'], 'plugin_scan_interval': 60, " \
                      "'celerybeat_max_loop_interval': 5}, " \
                      "'enrichment': {'plugins_paths': ['tests/plugins/enrichment'], " \
                      "'plugin_scan_interval': 60, 'celerybeat_max_loop_interval': 5}, " \
                      "'snmp': {'port': 10161, 'connection_factory_module': " \
                      "'yahoo_panoptes.framework.utilities.snmp.connection', 'connection_factory_class': " \
                      "'PanoptesSNMPConnectionFactory', 'community': '**', 'timeout': 5, 'retries': 1, " \
                      "'non_repeaters': 0, 'max_repetitions': 25, 'proxy_port': 10161, " \
                      "'community_string_key': 'snmp_community_string'}}), Redis pool set: False, " \
                      "Message producer set: False, Kafka client set: False, Zookeeper client set: False], " \
                      "KV store class: PanoptesTestKeyValueStore, Last executed timestamp: 1458947997, " \
                      "Last executed key: plugin_metadata:plugin__name:" \
                      "61547fbb304169f2a076016678bc9cca:last_executed, " \
                      "Last results timestamp: 1458948005, " \
                      "Last results key: plugin_metadata:plugin__name:" \
                      "61547fbb304169f2a076016678bc9cca:last_results, " \
                      "Data: Data object passed, " \
                      "Lock: Lock is set"
        self.assertEqual(repr(panoptes_plugin_info), repr_string)
Пример #2
0
    def test_plugininfo_repr(self):
        panoptes_context = PanoptesContext(self.panoptes_test_conf_file,
                                           key_value_store_class_list=[PanoptesTestKeyValueStore],
                                           create_message_producer=False, async_message_producer=False,
                                           create_zookeeper_client=True)

        panoptes_resource = PanoptesResource(resource_site='test', resource_class='test',
                                             resource_subclass='test',
                                             resource_type='test', resource_id='test', resource_endpoint='test',
                                             resource_plugin='test')

        panoptes_plugininfo = PanoptesPluginInfo("plugin_name", "plugin_path")
        panoptes_plugininfo.panoptes_context = panoptes_context
        panoptes_plugininfo.data = panoptes_resource
        panoptes_plugininfo.kv_store_class = PanoptesTestKeyValueStore
        panoptes_plugininfo.last_executed = "1458947997"
        panoptes_plugininfo.last_results = "1458948005"

        repr_string = "PanoptesPluginInfo: Normalized name: plugin__name, Config file: None, "\
                      "Panoptes context: " \
                      "[PanoptesContext: KV Stores: [PanoptesTestKeyValueStore], "\
                      "Config: ConfigObj({'main': {'sites': " \
                      "['local'], 'plugins_extension': 'panoptes-plugin', 'plugins_skew': 1}, " \
                      "'log': " \
                      "{'config_file': 'tests/config_files/test_panoptes_logging.ini', " \
                      "'rate': 1000, " \
                      "'per': 1, " \
                      "'burst': 10000, " \
                      "'formatters': {'keys': ['root_log_format', 'log_file_format', 'discovery_plugins_format']}}, " \
                      "'redis': {'default': {'namespace': 'panoptes', "\
                      "'shards': {'shard1': {'host': 'localhost', 'port': 6379, 'db': 0, 'password': '******'}}}}, "\
                      "'kafka': {'topic_key_delimiter': ':', 'topic_name_delimiter': '-', " \
                      "'brokers': {'broker1': {'host': 'localhost', 'port': 9092}}, " \
                      "'topics': " \
                      "{'metrics': {'raw_topic_name_suffix': 'metrics', " \
                      "'transformed_topic_name_suffix': 'processed'}}}, " \
                      "'zookeeper': {'connection_timeout': 30, 'servers': {'server1': {'host': " \
                      "'localhost', 'port': 2181}}}, " \
                      "'discovery': " \
                      "{'plugins_path': 'tests/plugins/discovery', " \
                      "'plugin_scan_interval': 60, " \
                      "'celerybeat_max_loop_interval': 5}, " \
                      "'polling': " \
                      "{'plugins_path': 'tests/plugins/polling', " \
                      "'plugin_scan_interval': 60, " \
                      "'celerybeat_max_loop_interval': 5}, " \
                      "'enrichment': " \
                      "{'plugins_path': 'tests/plugins/enrichment', " \
                      "'plugin_scan_interval': 60, " \
                      "'celerybeat_max_loop_interval': 5}, " \
                      "'snmp': " \
                      "{'port': 10161, " \
                      "'connection_factory_module': 'yahoo_panoptes.framework.utilities.snmp.connection', " \
                      "'connection_factory_class': 'PanoptesSNMPConnectionFactory', " \
                      "'community': '**', 'timeout': 5, 'retries': 1, 'non_repeaters': 0, 'max_repetitions': 25, " \
                      "'proxy_port': 10161, 'community_string_key': 'snmp_community_string'}}), "\
                      "Redis pool set: False, " \
                      "Message producer set: False, " \
                      "Kafka client set: False, " \
                      "Zookeeper client set: False], " \
                      "KV store class: PanoptesTestKeyValueStore, " \
                      "Last executed timestamp: 1458947997, " \
                      "Last executed key: " \
                      "plugin_metadata:plugin__name:be7eabbca3b05b9aaa8c81201aa0ca3e:last_executed, " \
                      "Last results timestamp: 1458948005, " \
                      "Last results key: plugin_metadata:plugin__name:be7eabbca3b05b9aaa8c81201aa0ca3e:last_results, " \
                      "Data: Data object passed, " \
                      "Lock: Lock is set"
        self.assertEqual(repr(panoptes_plugininfo), repr_string)