Exemplo n.º 1
0
    def runTest(self):
        logging.debug('Posting to endpoint: {0}'.format(self._url))

        payloads = test_util.generate_logging_payloads()
        for payload in payloads:
            _, response_code = test_util.post(self._url, payload)
            if response_code != 0:
                self.fail('Error encountered inside '
                          'sample application!')

            client = google.cloud.logging.Client()
            log_name = payload.get('log_name')
            token = payload.get('token')
            level = payload.get('level')

            logging.info('log name is {0}, '
                         'token is {1}, '
                         'level is {2}'.format(log_name, token, level))

            project_id = test_util.project_id()

            FILTER = 'logName = ' \
                     '"projects/{0}/logs/{1}" ' \
                     'AND (textPayload:{2} OR jsonPayload.message:*) ' \
                     'AND severity = "{3}"'.format(project_id,
                                                   log_name,
                                                   test_util.LOGGING_PREFIX,
                                                   level)

            logging.info('logging filter: {0}'.format(FILTER))

            self.assertTrue(
                self._read_log(client, token, FILTER),
                'Log entry not found for posted token!')
Exemplo n.º 2
0
    def runTest(self):
        logging.debug('Posting to endpoint: {0}'.format(self._url))

        payloads = test_util.generate_logging_payloads()
        for payload in payloads:
            log_name, response_code = test_util.post(self._url, payload)
            if response_code != 0:
                self.fail('Error encountered inside ' 'sample application!')

            logging.info('response from sample app: {0}'.format(log_name))

            client = google.cloud.logging.Client()
            token = payload.get('token')
            level = payload.get('level')

            logging.info('log name is {0}, '
                         'token is {1}, '
                         'level is {2}'.format(log_name, token, level))

            environment = test_util.get_environment(self._base_url)
            if environment == constants.GAE:
                project_id = test_util.project_id()
                FILTER = 'logName = projects/{0}/logs/{1} ' \
                         'AND textPayload:"{2}"'.format(project_id,
                                                        log_name,
                                                        token)
            else:
                FILTER = 'resource.type="container" ' \
                         'AND resource.labels.cluster_name="{0}" ' \
                         'AND textPayload:"{1}"'.format(constants.CLUSTER_NAME,
                                                        token)
            logging.info('logging filter: {0}'.format(FILTER))
            self.assertTrue(self._read_log(client, token, FILTER),
                            'Log entry not found for posted token!')
Exemplo n.º 3
0
    def runTest(self):
        logging.debug('Posting to endpoint: {0}'.format(self._url))

        payloads = test_util.generate_logging_payloads()
        for payload in payloads:
            _, response_code = test_util.post(self._url, payload)
            if response_code != 0:
                self.fail('Error encountered inside ' 'sample application!')

            client = google.cloud.logging.Client()
            log_name = payload.get('log_name')
            token = payload.get('token')
            level = payload.get('level')

            logging.info('log name is {0}, '
                         'token is {1}, '
                         'level is {2}'.format(log_name, token, level))

            self.assertTrue(self._read_log(client, log_name, token, level),
                            'Log entry not found for posted token!')