def submitOoidToElasticSearch(self, ooid, urllib2=urllib2): try: if self.config.elasticSearchOoidSubmissionUrl: # import poster import socorro.storage.hbaseClient as hbc dummy_form_data = {} row_id = hbc.ooid_to_row_id(ooid) url = self.config.elasticSearchOoidSubmissionUrl % row_id request = urllib2.Request(url, dummy_form_data) try: urllib2.urlopen(request, timeout=2).read() except urllib2.socket.timeout: logger.critical("%s may not have been submitted to Elastic Search", ooid) sutil.reportExceptionAndContinue(logger, logging.CRITICAL, showTraceback=False) except Exception: logger.critical("Submition to Elastic Search failed for %s", ooid) sutil.reportExceptionAndContinue(logger, logging.CRITICAL, showTraceback=False) except KeyError: self.config.logger.info("no Elastic Search URL has been configured")
def test_ooid_to_row_id(): ooid = 'abcdefghijklmnopqrstuvwxy20100102' expectedOoid = 'a100102abcdefghijklmnopqrstuvwxy20100102' result = hbc.ooid_to_row_id(ooid) assert result == expectedOoid, 'expected %s, but got %s' % (expectedOoid, result)