From 34b0aff8606a40f557df92c567278c517b0b1245 Mon Sep 17 00:00:00 2001 From: Ken'ichi Ohmichi Date: Fri, 21 Oct 2016 14:14:25 -0700 Subject: [PATCH] Fix gate problem related to _error_checker() and oslo.log change Since I84e3be748af10b158037866e1ee4c1375b2c3541, the internal method _error_checker() is changed and the ceilometer gate is broken. This patch fixes it. (cherry picked from commit e6ff08801ca34536680b43ca896f0dfdf66c761f) something changed and expected logs are in stdout rather than stderr even though it does makes sense as stdout. i have no idea why it was writing to stderr earlier when it shouldn't have. Related-Bug: #1635042 (cherry picked from commit 1695b4774e69e032151a47e0435b7af72826e5b6) Change-Id: I81fe2e60a6fb65e95f477a68267979b8542fa6dc --- ceilometer/tests/functional/test_bin.py | 28 ++++++++++++------- .../service/images/v1/images_client.py | 6 ++-- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/ceilometer/tests/functional/test_bin.py b/ceilometer/tests/functional/test_bin.py index ef46a18e96..aae2c3c183 100644 --- a/ceilometer/tests/functional/test_bin.py +++ b/ceilometer/tests/functional/test_bin.py @@ -14,6 +14,7 @@ import os import subprocess +import time from oslo_utils import fileutils import six @@ -45,13 +46,13 @@ class BinTestCase(base.BaseTestCase): subp = subprocess.Popen(['ceilometer-expirer', '-d', "--config-file=%s" % self.tempfile], - stderr=subprocess.PIPE) - __, err = subp.communicate() + stdout=subprocess.PIPE) + stdout, __ = subp.communicate() self.assertEqual(0, subp.poll()) self.assertIn(b"Nothing to clean, database metering " - b"time to live is disabled", err) + b"time to live is disabled", stdout) self.assertIn(b"Nothing to clean, database event " - b"time to live is disabled", err) + b"time to live is disabled", stdout) def _test_run_expirer_ttl_enabled(self, ttl_name, data_name): content = ("[database]\n" @@ -65,13 +66,13 @@ class BinTestCase(base.BaseTestCase): subp = subprocess.Popen(['ceilometer-expirer', '-d', "--config-file=%s" % self.tempfile], - stderr=subprocess.PIPE) - __, err = subp.communicate() + stdout=subprocess.PIPE) + stdout, __ = subp.communicate() self.assertEqual(0, subp.poll()) msg = "Dropping %s data with TTL 1" % data_name if six.PY3: msg = msg.encode('utf-8') - self.assertIn(msg, err) + self.assertIn(msg, stdout) def test_run_expirer_ttl_enabled(self): self._test_run_expirer_ttl_enabled('metering_time_to_live', @@ -134,9 +135,16 @@ class BinCeilometerPollingServiceTestCase(base.BaseTestCase): "compute", "compute"], stderr=subprocess.PIPE) - out = self.subp.stderr.read(1024) - self.assertIn(b'Duplicated values: [\'compute\', \'compute\'] ' - b'found in CLI options, auto de-duplicated', out) + expected = (b'Duplicated values: [\'compute\', \'compute\'] ' + b'found in CLI options, auto de-duplicated') + # NOTE(gordc): polling process won't quit so wait for a bit and check + start = time.time() + while time.time() - start < 5: + output = self.subp.stderr.readline() + if expected in output: + break + else: + self.fail('Did not detect expected warning: %s' % expected) def test_polling_namespaces_invalid_value_in_config(self): content = ("[DEFAULT]\n" diff --git a/ceilometer/tests/tempest/service/images/v1/images_client.py b/ceilometer/tests/tempest/service/images/v1/images_client.py index dc0732556e..01cd1a7009 100644 --- a/ceilometer/tests/tempest/service/images/v1/images_client.py +++ b/ceilometer/tests/tempest/service/images/v1/images_client.py @@ -109,8 +109,7 @@ class ImagesClient(rest_client.RestClient): def _create_with_data(self, headers, data): resp, body_iter = self.http.raw_request('POST', '/v1/images', headers=headers, body=data) - self._error_checker('POST', '/v1/images', headers, data, resp, - body_iter) + self._error_checker(resp, body_iter) body = json.loads(''.join([c for c in body_iter])) return rest_client.ResponseBody(resp, body) @@ -118,8 +117,7 @@ class ImagesClient(rest_client.RestClient): url = '/v1/images/%s' % image_id resp, body_iter = self.http.raw_request('PUT', url, headers=headers, body=data) - self._error_checker('PUT', url, headers, data, - resp, body_iter) + self._error_checker(resp, body_iter) body = json.loads(''.join([c for c in body_iter])) return rest_client.ResponseBody(resp, body)