• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python supersearch.SuperSearch类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中socorro.external.elasticsearch.supersearch.SuperSearch的典型用法代码示例。如果您正苦于以下问题:Python SuperSearch类的具体用法?Python SuperSearch怎么用?Python SuperSearch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SuperSearch类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_get

    def test_get(self):
        """Test a search with default values returns the right structure. """
        with _get_config_manager().context() as config:
            api = SuperSearch(config)

        res = api.get()

        self.assertTrue('total' in res)
        self.assertEqual(res['total'], 21)

        self.assertTrue('hits' in res)
        self.assertEqual(len(res['hits']), res['total'])

        self.assertTrue('facets' in res)
        self.assertTrue('signature' in res['facets'])

        expected_signatures = [
            {'term': 'js::break_your_browser', 'count': 20},
            {'term': 'my_bad', 'count': 1},
        ]
        self.assertEqual(res['facets']['signature'], expected_signatures)

        # Test fields are being renamed
        self.assertTrue('date' in res['hits'][0])  # date_processed > date
        self.assertTrue('build_id' in res['hits'][0])  # build > build_id
        self.assertTrue('platform' in res['hits'][0])  # os_name > platform
开发者ID:GabiThume,项目名称:socorro,代码行数:26,代码来源:test_supersearch.py


示例2: test_get_indexes

    def test_get_indexes(self):
        with _get_config_manager(self.config).context() as config:
            api = SuperSearch(config)

        now = datetime.datetime(2000, 2, 1, 0, 0)
        lastweek = now - datetime.timedelta(weeks=1)
        lastmonth = now - datetime.timedelta(weeks=4)

        dates = [search_common.SearchParam("date", now, "<"), search_common.SearchParam("date", lastweek, ">")]

        res = api.get_indexes(dates)
        self.assertEqual(res, "socorro_integration_test")

        with _get_config_manager(self.config, es_index="socorro_%Y%W").context() as config:
            api = SuperSearch(config)

        dates = [search_common.SearchParam("date", now, "<"), search_common.SearchParam("date", lastweek, ">")]

        res = api.get_indexes(dates)
        self.assertEqual(res, "socorro_200004,socorro_200005")

        dates = [search_common.SearchParam("date", now, "<"), search_common.SearchParam("date", lastmonth, ">")]

        res = api.get_indexes(dates)
        self.assertEqual(res, "socorro_200001,socorro_200002,socorro_200003,socorro_200004," "socorro_200005")
开发者ID:vfazio,项目名称:socorro,代码行数:25,代码来源:test_supersearch.py


示例3: test_get_with_pagination

    def test_get_with_pagination(self):
        """Test a search with pagination returns expected results. """
        with _get_config_manager().context() as config:
            api = SuperSearch(config)

        args = {
            '_results_number': '10',
        }
        res = api.get(**args)
        self.assertEqual(res['total'], 21)
        self.assertEqual(len(res['hits']), 10)

        args = {
            '_results_number': '10',
            '_results_offset': '10',
        }
        res = api.get(**args)
        self.assertEqual(res['total'], 21)
        self.assertEqual(len(res['hits']), 10)

        args = {
            '_results_number': '10',
            '_results_offset': '15',
        }
        res = api.get(**args)
        self.assertEqual(res['total'], 21)
        self.assertEqual(len(res['hits']), 6)

        args = {
            '_results_number': '10',
            '_results_offset': '30',
        }
        res = api.get(**args)
        self.assertEqual(res['total'], 21)
        self.assertEqual(len(res['hits']), 0)
开发者ID:GabiThume,项目名称:socorro,代码行数:35,代码来源:test_supersearch.py


示例4: test_get_with_range_operators

    def test_get_with_range_operators(self):
        """Test a search with several filters and operators returns expected
        results. """
        with _get_config_manager(self.config).context() as config:
            api = SuperSearch(config)

        # Test date
        now = datetimeutil.utc_now()
        lastweek = now - datetime.timedelta(days=7)
        lastmonth = lastweek - datetime.timedelta(weeks=4)
        args = {"date": ["<%s" % lastweek, ">=%s" % lastmonth]}
        res = api.get(**args)
        self.assertEqual(res["total"], 1)
        self.assertEqual(res["hits"][0]["signature"], "my_little_signature")

        # Test build id
        args = {"build_id": "<1234567890"}
        res = api.get(**args)
        self.assertEqual(res["total"], 1)
        self.assertEqual(res["hits"][0]["signature"], "js::break_your_browser")
        self.assertTrue(res["hits"][0]["build_id"] < 1234567890)

        args = {"build_id": ">1234567889"}
        res = api.get(**args)
        self.assertEqual(res["total"], 20)
        self.assertTrue(res["hits"])
        for report in res["hits"]:
            self.assertTrue(report["build_id"] > 1234567889)

        args = {"build_id": "<=1234567890"}
        res = api.get(**args)
        self.assertEqual(res["total"], 21)
        self.assertTrue(res["hits"])
        for report in res["hits"]:
            self.assertTrue(report["build_id"] <= 1234567890)
开发者ID:vfazio,项目名称:socorro,代码行数:35,代码来源:test_supersearch.py


示例5: test_get_with_not_operator

    def test_get_with_not_operator(self):
        """Test a search with a few NOT operators. """
        with _get_config_manager(self.config).context() as config:
            api = SuperSearch(config)

        # Test signature
        args = {"signature": ["js", "break_your_browser"]}
        res = api.get(**args)
        self.assertEqual(res["total"], 20)
        self.assertTrue(res["hits"])
        for report in res["hits"]:
            self.assertEqual(report["signature"], "js::break_your_browser")

        # - Test contains mode
        args = {"signature": "!~bad"}
        res = api.get(**args)
        self.assertEqual(res["total"], 20)

        # - Test is_exactly mode
        args = {"signature": "!=js::break_your_browser"}
        res = api.get(**args)
        self.assertEqual(res["total"], 1)
        self.assertEqual(res["hits"][0]["signature"], "my_bad")

        # - Test starts_with mode
        args = {"signature": "!$js"}
        res = api.get(**args)
        self.assertEqual(res["total"], 1)
        self.assertEqual(res["hits"][0]["signature"], "my_bad")

        # - Test ends_with mode
        args = {"signature": "!^browser"}
        res = api.get(**args)
        self.assertEqual(res["total"], 1)
        self.assertEqual(res["hits"][0]["signature"], "my_bad")

        # Test build id
        args = {"build_id": "!<1234567890"}
        res = api.get(**args)
        self.assertEqual(res["total"], 20)
        self.assertTrue(res["hits"])
        for report in res["hits"]:
            self.assertTrue(report["build_id"] > 1234567889)

        args = {"build_id": "!>1234567889"}
        res = api.get(**args)
        self.assertEqual(res["total"], 1)
        self.assertEqual(res["hits"][0]["signature"], "js::break_your_browser")
        self.assertTrue(res["hits"][0]["build_id"] < 1234567890)

        args = {"build_id": "!<=1234567890"}
        res = api.get(**args)
        self.assertEqual(res["total"], 0)
开发者ID:vfazio,项目名称:socorro,代码行数:53,代码来源:test_supersearch.py


示例6: setUp

    def setUp(self):
        super(IntegrationTestSettings, self).setUp()

        config = self.get_config_context()
        self.storage = crashstorage.ElasticSearchCrashStorage(config)

        # clear the indices cache so the index is created on every test
        self.storage.indices_cache = set()

        self.now = utc_now()

        # Create the index that will be used.
        es_index = self.storage.get_index_for_crash(self.now)
        self.storage.create_socorro_index(es_index)

        # Create the supersearch fields.
        self.storage.es.bulk_index(
            index=config.webapi.elasticsearch_default_index,
            doc_type='supersearch_fields',
            docs=SUPERSEARCH_FIELDS.values(),
            id_field='name',
            refresh=True,
        )

        self.api = SuperSearch(config=config)

        # This an ugly hack to give elasticsearch some time to finish creating
        # the new index. It is needed for jenkins only, because we have a
        # special case here where we index only one or two documents before
        # querying. Other tests are not affected.
        # TODO: try to remove it, or at least understand why it is needed.
        time.sleep(1)
开发者ID:Earth4,项目名称:socorro,代码行数:32,代码来源:test_settings.py


示例7: setUp

    def setUp(self):
        super(IntegrationTestSettings, self).setUp()

        config = self.get_config_context()
        self.storage = crashstorage.ElasticSearchCrashStorage(config)

        # clear the indices cache so the index is created on every test
        self.storage.indices_cache = set()

        self.now = utc_now()

        # Create the supersearch fields.
        self.storage.es.bulk_index(
            index=config.webapi.elasticsearch_default_index,
            doc_type='supersearch_fields',
            docs=SUPERSEARCH_FIELDS.values(),
            id_field='name',
            refresh=True,
        )

        # Create the index that will be used.
        es_index = self.storage.get_index_for_crash(self.now)
        self.storage.create_socorro_index(es_index)

        self.api = SuperSearch(config=config)
开发者ID:dehachoudhry,项目名称:socorro,代码行数:25,代码来源:test_settings.py


示例8: test_get_with_range_operators

    def test_get_with_range_operators(self):
        """Test a search with several filters and operators returns expected
        results. """
        with _get_config_manager().context() as config:
            api = SuperSearch(config)

        # Test date
        now = datetimeutil.utc_now()
        lastweek = now - datetime.timedelta(days=7)
        lastmonth = lastweek - datetime.timedelta(weeks=4)
        args = {
            'date': [
                '<%s' % lastweek,
                '>=%s' % lastmonth,
            ]
        }
        res = api.get(**args)
        self.assertEqual(res['total'], 1)
        self.assertEqual(res['hits'][0]['signature'], 'my_little_signature')

        # Test build id
        args = {
            'build_id': '<1234567890',
        }
        res = api.get(**args)
        self.assertEqual(res['total'], 1)
        self.assertEqual(res['hits'][0]['signature'], 'js::break_your_browser')
        self.assertTrue(res['hits'][0]['build'] < 1234567890)

        args = {
            'build_id': '>1234567889',
        }
        res = api.get(**args)
        self.assertEqual(res['total'], 20)
        self.assertTrue(res['hits'])
        for report in res['hits']:
            self.assertTrue(report['build'] > 1234567889)

        args = {
            'build_id': '<=1234567890',
        }
        res = api.get(**args)
        self.assertEqual(res['total'], 21)
        self.assertTrue(res['hits'])
        for report in res['hits']:
            self.assertTrue(report['build'] <= 1234567890)
开发者ID:GabiThume,项目名称:socorro,代码行数:46,代码来源:test_supersearch.py


示例9: test_get_indexes

    def test_get_indexes(self):
        config = self.get_config_context()
        api = SuperSearch(config=config)

        now = datetime.datetime(2000, 2, 1, 0, 0)
        lastweek = now - datetime.timedelta(weeks=1)
        lastmonth = now - datetime.timedelta(weeks=4)

        dates = [
            search_common.SearchParam('date', now, '<'),
            search_common.SearchParam('date', lastweek, '>'),
        ]

        res = api.get_indexes(dates)
        eq_(res, ['socorro_integration_test'])

        config = self.get_config_context(es_index='socorro_%Y%W')
        api = SuperSearch(config=config)

        dates = [
            search_common.SearchParam('date', now, '<'),
            search_common.SearchParam('date', lastweek, '>'),
        ]

        res = api.get_indexes(dates)
        eq_(res, ['socorro_200004', 'socorro_200005'])

        dates = [
            search_common.SearchParam('date', now, '<'),
            search_common.SearchParam('date', lastmonth, '>'),
        ]

        res = api.get_indexes(dates)
        eq_(
            res,
            [
                'socorro_200001', 'socorro_200002', 'socorro_200003',
                'socorro_200004', 'socorro_200005'
            ]
        )
开发者ID:JisJis,项目名称:socorro,代码行数:40,代码来源:test_supersearch.py


示例10: test_get_with_facets

    def test_get_with_facets(self):
        """Test a search with facets returns expected results. """
        with _get_config_manager(self.config).context() as config:
            api = SuperSearch(config)

        # Test several facets
        args = {"_facets": ["signature", "platform"]}
        res = api.get(**args)

        self.assertTrue("facets" in res)
        self.assertTrue("signature" in res["facets"])

        expected_signatures = [{"term": "js::break_your_browser", "count": 20}, {"term": "my_bad", "count": 1}]
        self.assertEqual(res["facets"]["signature"], expected_signatures)

        self.assertTrue("platform" in res["facets"])
        expected_platforms = [{"term": "Linux", "count": 20}, {"term": "Windows NT", "count": 1}]
        self.assertEqual(res["facets"]["platform"], expected_platforms)

        # Test one facet with filters
        args = {"_facets": ["release_channel"], "release_channel": "aurora"}
        res = api.get(**args)

        self.assertTrue("release_channel" in res["facets"])

        expected_signatures = [{"term": "aurora", "count": 1}]
        self.assertEqual(res["facets"]["release_channel"], expected_signatures)

        # Test one facet with a different filter
        args = {"_facets": ["release_channel"], "platform": "linux"}
        res = api.get(**args)

        self.assertTrue("release_channel" in res["facets"])

        expected_signatures = [{"term": "release", "count": 19}, {"term": "aurora", "count": 1}]
        self.assertEqual(res["facets"]["release_channel"], expected_signatures)

        # Test errors
        self.assertRaises(BadArgumentError, api.get, _facets=["unkownfield"])
开发者ID:vfazio,项目名称:socorro,代码行数:39,代码来源:test_supersearch.py


示例11: test_get_indexes

    def test_get_indexes(self):
        with _get_config_manager(self.config).context() as config:
            api = SuperSearch(config)

        now = datetime.datetime(2000, 2, 1, 0, 0)
        lastweek = now - datetime.timedelta(weeks=1)
        lastmonth = now - datetime.timedelta(weeks=4)

        dates = [
            search_common.SearchParam('date', now, '<'),
            search_common.SearchParam('date', lastweek, '>'),
        ]

        res = api.get_indexes(dates)
        self.assertEqual(res, 'socorro_integration_test')

        with _get_config_manager(self.config, es_index='socorro_%Y%W') \
            .context() as config:
            api = SuperSearch(config)

        dates = [
            search_common.SearchParam('date', now, '<'),
            search_common.SearchParam('date', lastweek, '>'),
        ]

        res = api.get_indexes(dates)
        self.assertEqual(res, 'socorro_200004,socorro_200005')

        dates = [
            search_common.SearchParam('date', now, '<'),
            search_common.SearchParam('date', lastmonth, '>'),
        ]

        res = api.get_indexes(dates)
        self.assertEqual(
            res,
            'socorro_200001,socorro_200002,socorro_200003,socorro_200004,'
            'socorro_200005'
        )
开发者ID:kidundead,项目名称:socorro,代码行数:39,代码来源:test_supersearch.py


示例12: test_get

    def test_get(self):
        """Test a search with default values returns the right structure. """
        with _get_config_manager(self.config).context() as config:
            api = SuperSearch(config)

        res = api.get()

        self.assertTrue("total" in res)
        self.assertEqual(res["total"], 21)

        self.assertTrue("hits" in res)
        self.assertEqual(len(res["hits"]), res["total"])

        self.assertTrue("facets" in res)
        self.assertTrue("signature" in res["facets"])

        expected_signatures = [{"term": "js::break_your_browser", "count": 20}, {"term": "my_bad", "count": 1}]
        self.assertEqual(res["facets"]["signature"], expected_signatures)

        # Test fields are being renamed
        self.assertTrue("date" in res["hits"][0])  # date_processed > date
        self.assertTrue("build_id" in res["hits"][0])  # build > build_id
        self.assertTrue("platform" in res["hits"][0])  # os_name > platform
开发者ID:vfazio,项目名称:socorro,代码行数:23,代码来源:test_supersearch.py


示例13: test_get_with_pagination

    def test_get_with_pagination(self):
        """Test a search with pagination returns expected results. """
        with _get_config_manager(self.config).context() as config:
            api = SuperSearch(config)

        args = {"_results_number": "10"}
        res = api.get(**args)
        self.assertEqual(res["total"], 21)
        self.assertEqual(len(res["hits"]), 10)

        args = {"_results_number": "10", "_results_offset": "10"}
        res = api.get(**args)
        self.assertEqual(res["total"], 21)
        self.assertEqual(len(res["hits"]), 10)

        args = {"_results_number": "10", "_results_offset": "15"}
        res = api.get(**args)
        self.assertEqual(res["total"], 21)
        self.assertEqual(len(res["hits"]), 6)

        args = {"_results_number": "10", "_results_offset": "30"}
        res = api.get(**args)
        self.assertEqual(res["total"], 21)
        self.assertEqual(len(res["hits"]), 0)
开发者ID:vfazio,项目名称:socorro,代码行数:24,代码来源:test_supersearch.py


示例14: setUp

    def setUp(self):
        super(IntegrationTestSettings, self).setUp()

        config = self.get_config_context()
        self.storage = crashstorage.ElasticSearchCrashStorage(config)
        self.api = SuperSearch(config)

        # clear the indices cache so the index is created on every test
        self.storage.indices_cache = set()

        self.now = utc_now()

        # Create the index that will be used.
        es_index = self.storage.get_index_for_crash(self.now)
        self.storage.create_socorro_index(es_index)

        # This an ugly hack to give elasticsearch some time to finish creating
        # the new index. It is needed for jenkins only, because we have a
        # special case here where we index only one or two documents before
        # querying. Other tests are not affected.
        # TODO: try to remove it, or at least understand why it is needed.
        time.sleep(1)
开发者ID:FishingCactus,项目名称:socorro,代码行数:22,代码来源:test_settings.py


示例15: IntegrationTestSettings

class IntegrationTestSettings(ElasticSearchTestCase):
    """Test the settings and mappings used in elasticsearch, through
    the supersearch service. """

    def setUp(self):
        super(IntegrationTestSettings, self).setUp()

        config = self.get_config_context()
        self.storage = crashstorage.ElasticSearchCrashStorage(config)
        self.api = SuperSearch(config=config)

        # clear the indices cache so the index is created on every test
        self.storage.indices_cache = set()

        self.now = utc_now()

        # Create the index that will be used.
        es_index = self.storage.get_index_for_crash(self.now)
        self.storage.create_socorro_index(es_index)

        # This an ugly hack to give elasticsearch some time to finish creating
        # the new index. It is needed for jenkins only, because we have a
        # special case here where we index only one or two documents before
        # querying. Other tests are not affected.
        # TODO: try to remove it, or at least understand why it is needed.
        time.sleep(1)

    def tearDown(self):
        # clear the test index
        config = self.get_config_context()
        self.storage.es.delete_index(config.webapi.elasticsearch_index)

        super(IntegrationTestSettings, self).tearDown()

    def test_dump_field(self):
        """Verify that the 'dump' field can be queried as expected. """
        # Index some data.
        processed_crash = {
            'uuid': '06a0c9b5-0381-42ce-855a-ccaaa2120100',
            'date_processed': self.now,
            'dump': EXAMPLE_DUMP,
        }
        self.storage.save_processed(processed_crash)
        self.storage.es.refresh()

        # Simple test with one word, no upper case.
        res = self.api.get(dump='~family')
        self.assertEqual(res['total'], 1)

        # Several words, with upper case.
        res = self.api.get(dump='~Windows NT')
        self.assertEqual(res['total'], 1)

    def test_cpu_info_field(self):
        """Verify that the 'cpu_info' field can be queried as expected. """
        processed_crash = {
            'uuid': '06a0c9b5-0381-42ce-855a-ccaaa2120101',
            'date_processed': self.now,
            'cpu_info': 'GenuineIntel family 6 model 15 stepping 13',
        }
        self.storage.save_processed(processed_crash)
        self.storage.es.refresh()

        # Simple test with one word, no upper case.
        res = self.api.get(cpu_info='~model')
        self.assertEqual(res['total'], 1)
        self.assertTrue('model' in res['hits'][0]['cpu_info'])

        # Several words, with upper case, 'starts with' mode.
        res = self.api.get(cpu_info='$GenuineIntel family')
        self.assertEqual(res['total'], 1)
        self.assertTrue('GenuineIntel family' in res['hits'][0]['cpu_info'])

    def test_dom_ipc_enabled_field(self):
        """Verify that the 'dom_ipc_enabled' field can be queried as
        expected. """
        processed_crash = {
            'uuid': '06a0c9b5-0381-42ce-855a-ccaaa2120101',
            'date_processed': self.now,
        }
        raw_crash = {
            'DOMIPCEnabled': True,
        }
        self.storage.save_raw_and_processed(
            raw_crash, None, processed_crash, processed_crash['uuid']
        )
        processed_crash = {
            'uuid': '06a0c9b5-0381-42ce-855a-ccaaa2120102',
            'date_processed': self.now,
        }
        raw_crash = {
            'DOMIPCEnabled': False,
        }
        self.storage.save_raw_and_processed(
            raw_crash, None, processed_crash, processed_crash['uuid']
        )
        processed_crash = {
            'uuid': '06a0c9b5-0381-42ce-855a-ccaaa2120103',
            'date_processed': self.now,
        }
#.........这里部分代码省略.........
开发者ID:pkucoin,项目名称:socorro,代码行数:101,代码来源:test_settings.py


示例16: IntegrationTestSettings

class IntegrationTestSettings(ElasticSearchTestCase):
    """Test the settings and mappings used in elasticsearch, through
    the supersearch service. """

    def setUp(self):
        super(IntegrationTestSettings, self).setUp()

        config = self.get_config_context()
        self.storage = crashstorage.ElasticSearchCrashStorage(config)

        # clear the indices cache so the index is created on every test
        self.storage.indices_cache = set()

        self.now = utc_now()

        # Create the supersearch fields.
        self.storage.es.bulk_index(
            index=config.webapi.elasticsearch_default_index,
            doc_type='supersearch_fields',
            docs=SUPERSEARCH_FIELDS.values(),
            id_field='name',
            refresh=True,
        )

        # Create the index that will be used.
        es_index = self.storage.get_index_for_crash(self.now)
        self.storage.create_socorro_index(es_index)

        self.api = SuperSearch(config=config)

    def tearDown(self):
        # clear the test index
        config = self.get_config_context()
        self.storage.es.delete_index(config.webapi.elasticsearch_index)
        self.storage.es.delete_index(config.webapi.elasticsearch_default_index)

        super(IntegrationTestSettings, self).tearDown()

    def test_dump_field(self):
        """Verify that the 'dump' field can be queried as expected. """
        # Index some data.
        processed_crash = {
            'uuid': '06a0c9b5-0381-42ce-855a-ccaaa2120100',
            'date_processed': self.now,
            'dump': EXAMPLE_DUMP,
        }
        self.storage.save_processed(processed_crash)
        self.storage.es.refresh()

        # Simple test with one word, no upper case.
        res = self.api.get(dump='~family')
        eq_(res['total'], 1)

        # Several words, with upper case.
        res = self.api.get(dump='~Windows NT')
        eq_(res['total'], 1)

    @maximum_es_version('0.90')
    def test_cpu_info_field(self):
        """Verify that the 'cpu_info' field can be queried as expected. """
        processed_crash = {
            'uuid': '06a0c9b5-0381-42ce-855a-ccaaa2120101',
            'date_processed': self.now,
            'cpu_info': 'GenuineIntel family 6 model 15 stepping 13',
        }
        self.storage.save_processed(processed_crash)
        self.storage.es.refresh()

        # Simple test with one word, no upper case.
        res = self.api.get(cpu_info='~model')
        eq_(res['total'], 1)
        ok_('model' in res['hits'][0]['cpu_info'])

        # Several words, with upper case, 'starts with' mode.
        res = self.api.get(cpu_info='$GenuineIntel family')
        eq_(res['total'], 1)
        ok_('GenuineIntel family' in res['hits'][0]['cpu_info'])

    def test_dom_ipc_enabled_field(self):
        """Verify that the 'dom_ipc_enabled' field can be queried as
        expected. """
        processed_crash = {
            'uuid': '06a0c9b5-0381-42ce-855a-ccaaa2120101',
            'date_processed': self.now,
        }
        raw_crash = {
            'DOMIPCEnabled': True,
        }
        self.storage.save_raw_and_processed(
            raw_crash, None, processed_crash, processed_crash['uuid']
        )
        processed_crash = {
            'uuid': '06a0c9b5-0381-42ce-855a-ccaaa2120102',
            'date_processed': self.now,
        }
        raw_crash = {
            'DOMIPCEnabled': False,
        }
        self.storage.save_raw_and_processed(
            raw_crash, None, processed_crash, processed_crash['uuid']
#.........这里部分代码省略.........
开发者ID:dehachoudhry,项目名称:socorro,代码行数:101,代码来源:test_settings.py


示例17: setUp

    def setUp(self):
        super(IntegrationTestSuperSearch, self).setUp()

        config = self.get_config_context()
        self.api = SuperSearch(config=config)
        self.storage = crashstorage.ElasticSearchCrashStorage(config)

        # clear the indices cache so the index is created on every test
        self.storage.indices_cache = set()

        now = datetimeutil.utc_now()

        yesterday = now - datetime.timedelta(days=1)
        yesterday = datetimeutil.date_to_string(yesterday)

        last_month = now - datetime.timedelta(weeks=4)
        last_month = datetimeutil.date_to_string(last_month)

        # insert data into elasticsearch
        default_crash_report = {
            'uuid': 100,
            'address': '0x0',
            'signature': 'js::break_your_browser',
            'date_processed': yesterday,
            'product': 'WaterWolf',
            'version': '1.0',
            'release_channel': 'release',
            'os_name': 'Linux',
            'build': 1234567890,
            'reason': 'MOZALLOC_WENT_WRONG',
            'hangid': None,
            'process_type': None,
            'email': '[email protected]',
            'url': 'https://mozilla.org',
            'user_comments': '',
            'install_age': 0,
        }
        default_raw_crash_report = {
            'Accessibility': True,
            'AvailableVirtualMemory': 10211743,
            'B2G_OS_Version': '1.1.203448',
            'BIOS_Manufacturer': 'SUSA',
            'IsGarbageCollecting': False,
            'Vendor': 'mozilla',
            'useragent_locale': 'en-US',
        }

        self.storage.save_raw_and_processed(
            default_raw_crash_report,
            None,
            default_crash_report,
            default_crash_report['uuid']
        )

        self.storage.save_raw_and_processed(
            dict(default_raw_crash_report, Accessibility=False),
            None,
            dict(default_crash_report, uuid=1, product='EarthRaccoon'),
            1
        )

        self.storage.save_raw_and_processed(
            dict(default_raw_crash_report, AvailableVirtualMemory=0),
            None,
            dict(default_crash_report, uuid=2, version='2.0'),
            2
        )

        self.storage.save_raw_and_processed(
            dict(default_raw_crash_report, B2G_OS_Version='1.3'),
            None,
            dict(default_crash_report, uuid=3, release_channel='aurora'),
            3
        )

        self.storage.save_raw_and_processed(
            dict(default_raw_crash_report, BIOS_Manufacturer='aidivn'),
            None,
            dict(default_crash_report, uuid=4, os_name='Windows NT'),
            4
        )

        self.storage.save_raw_and_processed(
            dict(default_raw_crash_report, IsGarbageCollecting=True),
            None,
            dict(default_crash_report, uuid=5, build=987654321),
            5
        )

        self.storage.save_raw_and_processed(
            dict(default_raw_crash_report, Vendor='gnusmas'),
            None,
            dict(default_crash_report, uuid=6, reason='VERY_BAD_EXCEPTION'),
            6
        )

        self.storage.save_raw_and_processed(
            dict(default_raw_crash_report, useragent_locale='fr'),
            None,
            dict(default_crash_report, uuid=7, hangid=12),
#.........这里部分代码省略.........
开发者ID:JisJis,项目名称:socorro,代码行数:101,代码来源:test_supersearch.py


示例18: IntegrationTestSuperSearch

class IntegrationTestSuperSearch(ElasticSearchTestCase):
    """Test SuperSearch with an elasticsearch database containing fake data.
    """

    def setUp(self):
        super(IntegrationTestSuperSearch, self).setUp()

        config = self.get_config_context()
        self.api = SuperSearch(config=config)
        self.storage = crashstorage.ElasticSearchCrashStorage(config)

        # clear the indices cache so the index is created on every test
        self.storage.indices_cache = set()

        now = datetimeutil.utc_now()

        yesterday = now - datetime.timedelta(days=1)
        yesterday = datetimeutil.date_to_string(yesterday)

        last_month = now - datetime.timedelta(weeks=4)
        last_month = datetimeutil.date_to_string(last_month)

        # insert data into elasticsearch
        default_crash_report = {
            'uuid': 100,
            'address': '0x0',
            'signature': 'js::break_your_browser',
            'date_processed': yesterday,
            'product': 'WaterWolf',
            'version': '1.0',
            'release_channel': 'release',
            'os_name': 'Linux',
            'build': 1234567890,
            'reason': 'MOZALLOC_WENT_WRONG',
            'hangid': None,
            'process_type': None,
            'email': '[email protected]',
            'url': 'https://mozilla.org',
            'user_comments': '',
            'install_age': 0,
        }
        default_raw_crash_report = {
            'Accessibility': True,
            'AvailableVirtualMemory': 10211743,
            'B2G_OS_Version': '1.1.203448',
            'BIOS_Manufacturer': 'SUSA',
            'IsGarbageCollecting': False,
            'Vendor': 'mozilla',
            'useragent_locale': 'en-US',
        }

        self.storage.save_raw_and_processed(
            default_raw_crash_report,
            None,
            default_crash_report,
            default_crash_report['uuid']
        )

        self.storage.save_raw_and_processed(
            dict(default_raw_crash_report, Accessibility=False),
            None,
            dict(default_crash_report, uuid=1, product='EarthRaccoon'),
            1
        )

        self.storage.save_raw_and_processed(
            dict(default_raw_crash_report, AvailableVirtualMemory=0),
            None,
            dict(default_crash_report, uuid=2, version='2.0'),
            2
        )

        self.storage.save_raw_and_processed(
            dict(default_raw_crash_report, B2G_OS_Version='1.3'),
            None,
            dict(default_crash_report, uuid=3, release_channel='aurora'),
            3
        )

        self.storage.save_raw_and_processed(
            dict(default_raw_crash_report, BIOS_Manufacturer='aidivn'),
            None,
            dict(default_crash_report, uuid=4, os_name='Windows NT'),
            4
        )

        self.storage.save_raw_and_processed(
            dict(default_raw_crash_report, IsGarbageCollecting=True),
            None,
            dict(default_crash_report, uuid=5, build=987654321),
            5
        )

        self.storage.save_raw_and_processed(
            dict(default_raw_crash_report, Vendor='gnusmas'),
            None,
            dict(default_crash_report, uuid=6, reason='VERY_BAD_EXCEPTION'),
            6
        )

#.........这里部分代码省略.........
开发者ID:JisJis,项目名称:socorro,代码行数:101,代码来源:test_supersearch.py


示例19: test_get_with_string_operators

    def test_get_with_string_operators(self):
        """Test a search with several filters and operators returns expected
        results. """
        with _get_config_manager(self.config).context() as config:
            api = SuperSearch(config)

        # Test signature
        args = {"signature": ["js", "break_your_browser"]}
        res = api.get(**args)
        self.assertEqual(res["total"], 20)
        self.assertTrue(res["hits"])
        for report in res["hits"]:
            self.assertEqual(report["signature"], "js::break_your_browser")

        # - Test contains mode
        args = {"signature": "~bad"}
        res = api.get(**args)
        self.assertEqual(res["total"], 1)
        self.assertEqual(res["hits"][0]["signature"], "my_bad")

        args = {"signature": "~js::break"}
        res = api.get(**args)
        self.assertEqual(res["total"], 20)
        self.assertTrue(res["hits"])
        for report in res["hits"]:
            self.assertEqual(report["signature"], "js::break_your_browser")

        # - Test is_exactly mode
        args = {"signature": "=js::break_your_browser"}
        res = api.get(**args)
        self.assertEqual(res["total"], 20)
        self.assertTrue(res["hits"])
        for report in res["hits"]:
            self.assertEqual(report["signature"], "js::break_your_browser")

        args = {"signature": "=my_bad"}
        res = api.get(**args)
        self.assertEqual(res["total"], 1)
        self.assertEqual(res["hits"][0]["signature"], "my_bad")

        # - Test starts_with mode
        args = {"signature": "$js"}
        res = api.get(**args)
        self.assertEqual(res["total"], 20)
        self.assertTrue(res["hits"])
        for report in res["hits"]:
            self.assertEqual(report["signature"], "js::break_your_browser")

        # - Test ends_with mode
        args = {"signature": "^browser"}
        res = api.get(**args)
        self.assertEqual(res["total"], 20)
        self.assertTrue(res["hits"])
        for report in res["hits"]:
            self.assertEqual(report["signature"], "js::break_your_browser")

        # Test email
        args = {"email": "[email protected]"}
        res = api.get(**args)
        self.assertEqual(res["total"], 1)
        self.assertTrue(res["hits"])
        self.assertEqual(res["hits"][0]["email"], "[email protected]")

        args = {"email": "~mail.com"}
        res = api.get(**args)
        self.assertEqual(res["total"], 19)
        self.assertTrue(res["hits"])
        for report in res["hits"]:
            self.assertTrue("@" in report["email"])
            self.assertTrue("mail.com" in report["email"])

        args = {"email": "[email protected]"}
        res = api.get(**args)
        self.assertEqual(res["total"], 2)
        self.assertTrue(res["hits"])
        for report in res["hits"]:
            self.assertTrue("[email protected]" in report["email"])

        # Test url
        args = {"url": "https://mozilla.org"}
        res = api.get(**args)
        self.assertEqual(res["total"], 19)

        args = {"url": "~mozilla.org"}
        res = api.get(**args)
        self.assertEqual(res["total"], 20)
        self.assertTrue(res["hits"])
        for report in res["hits"]:
            self.assertTrue("mozilla.org" in report["url"])

        args = {"url": "^.com"}
        res = api.get(**args)
        self.assertEqual(res["total"], 1)
        self. 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python crashstorage.ESCrashStorage类代码示例发布时间:2022-05-27
下一篇:
Python search.Search类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap