From c0e42f00af9ed8d8b3e81de2e67a6e5e7bbcecdf Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 22 Dec 2016 13:06:48 +0100 Subject: [PATCH] Fix the gate failure because of several issues 1. Fix expecting content-type headers in gabbit tests, the headers don't contain the charset anymore, just remove it. 2. Use 'endpoint_type' instead of 'interface' while init novaclient, because novaclient has deprecated the name 'interface', see[1]. 3. Don't use novaclient.HTTPClient, since the 'HTTPCLient' has been deprecated in novaclient, see[2]. [1] https://review.openstack.org/#/c/406299/ [2] https://review.openstack.org/#/c/408728/ Closes-Bug: #1652414 Change-Id: I33f2dd9303b93391ff40d77cf93e6e285c983287 Co-Authored-By: Hanxi Liu Co-Authored-By: liusheng --- ceilometer/nova_client.py | 2 +- .../gabbi/gabbits/api-events-no-data.yaml | 22 +++++++------- .../gabbi/gabbits/api-events-with-data.yaml | 30 +++++++++---------- .../tests/functional/gabbi/gabbits/basic.yaml | 2 +- .../gabbi/gabbits/clean-samples.yaml | 2 +- .../gabbi/gabbits_prefix/basic.yaml | 2 +- .../gabbi/gabbits_prefix/clean-samples.yaml | 2 +- ceilometer/tests/unit/agent/test_manager.py | 7 ----- 8 files changed, 31 insertions(+), 38 deletions(-) diff --git a/ceilometer/nova_client.py b/ceilometer/nova_client.py index 3a74052922..4b258c0a99 100644 --- a/ceilometer/nova_client.py +++ b/ceilometer/nova_client.py @@ -72,7 +72,7 @@ class Client(object): # nova adapter options region_name=creds.region_name, - interface=creds.interface, + endpoint_type=creds.interface, service_type=conf.service_types.nova, logger=logger) diff --git a/ceilometer/tests/functional/gabbi/gabbits/api-events-no-data.yaml b/ceilometer/tests/functional/gabbi/gabbits/api-events-no-data.yaml index d18aad6017..742a38f05a 100644 --- a/ceilometer/tests/functional/gabbi/gabbits/api-events-no-data.yaml +++ b/ceilometer/tests/functional/gabbi/gabbits/api-events-no-data.yaml @@ -14,7 +14,7 @@ tests: X-User-Id: user1 X-Project-Id: project1 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_strings: - "[]" @@ -68,7 +68,7 @@ tests: X-User-Id: user1 X-Project-Id: project1 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_strings: - "[]" @@ -77,7 +77,7 @@ tests: - name: get events that match query via request data url: /v2/events request_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json X-Roles: admin X-User-Id: user1 X-Project-Id: project1 @@ -88,7 +88,7 @@ tests: type: string value: cookies_chocolate.chip response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_strings: - "[]" @@ -101,7 +101,7 @@ tests: X-User-Id: user1 X-Project-Id: project1 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_strings: - "[]" @@ -110,7 +110,7 @@ tests: - name: get events that match bad query via request data url: /v2/events request_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json X-Roles: admin X-User-Id: user1 X-Project-Id: project1 @@ -121,7 +121,7 @@ tests: type: string value: cookies_chocolate.chip response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_strings: - "[]" @@ -130,7 +130,7 @@ tests: - name: get events that match bad query via request data malformed list url: /v2/events request_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json X-Roles: admin X-User-Id: user1 X-Project-Id: project1 @@ -172,7 +172,7 @@ tests: X-User-Id: user1 X-Project-Id: project1 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_strings: - "[]" @@ -193,7 +193,7 @@ tests: X-User-Id: user1 X-Project-Id: project1 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_strings: - "[]" @@ -205,6 +205,6 @@ tests: X-User-Id: user1 X-Project-Id: project1 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_strings: - "[]" diff --git a/ceilometer/tests/functional/gabbi/gabbits/api-events-with-data.yaml b/ceilometer/tests/functional/gabbi/gabbits/api-events-with-data.yaml index 0209db467a..8ae32a0622 100644 --- a/ceilometer/tests/functional/gabbi/gabbits/api-events-with-data.yaml +++ b/ceilometer/tests/functional/gabbi/gabbits/api-events-with-data.yaml @@ -13,7 +13,7 @@ tests: X-User-Id: user1 X-Project-Id: project1 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_json_paths: $.[0].event_type: cookies_chocolate.chip $.[0].traits.[0].value: chocolate.chip @@ -46,7 +46,7 @@ tests: X-User-Id: user1 X-Project-Id: project1 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_json_paths: $.[0].event_type: cookies_chocolate.chip $.[0].traits.[0].value: chocolate.chip @@ -56,7 +56,7 @@ tests: - name: get events that match query via data url: /v2/events request_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json X-Roles: admin X-User-Id: user1 X-Project-Id: project1 @@ -67,7 +67,7 @@ tests: type: string value: cookies_chocolate.chip response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_json_paths: $.[0].event_type: cookies_chocolate.chip $.[0].traits.[0].value: chocolate.chip @@ -81,7 +81,7 @@ tests: X-User-Id: user1 X-Project-Id: project1 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_strings: - "[]" @@ -90,7 +90,7 @@ tests: - name: get events that match bad query via data url: /v2/events request_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json X-Roles: admin X-User-Id: user1 X-Project-Id: project1 @@ -101,7 +101,7 @@ tests: type: string value: cookies_chocolate.chip response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_strings: - "[]" @@ -110,7 +110,7 @@ tests: - name: get events that match bad query via data list url: /v2/events request_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json X-Roles: admin X-User-Id: user1 X-Project-Id: project1 @@ -129,7 +129,7 @@ tests: X-User-Id: user1 X-Project-Id: project1 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_json_paths: $.event_type: cookies_chocolate.chip $.traits.[0].value: chocolate.chip @@ -152,7 +152,7 @@ tests: X-User-Id: user1 X-Project-Id: project1 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_strings: - cookies_chocolate.chip - cookies_peanut.butter @@ -184,7 +184,7 @@ tests: X-User-Id: user1 X-Project-Id: project1 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_json_paths: $.[0].type: string $.[1].name: ate @@ -197,7 +197,7 @@ tests: X-User-Id: user1 X-Project-Id: project1 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_strings: - "[]" @@ -210,7 +210,7 @@ tests: X-User-Id: user1 X-Project-Id: project1 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_json_paths: $.[0].name: ate $.[0].value: '0' @@ -224,7 +224,7 @@ tests: X-User-Id: user1 X-Project-Id: project1 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_strings: - "[]" @@ -237,6 +237,6 @@ tests: X-User-Id: user1 X-Project-Id: project1 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_strings: - "[]" diff --git a/ceilometer/tests/functional/gabbi/gabbits/basic.yaml b/ceilometer/tests/functional/gabbi/gabbits/basic.yaml index 2a67e51014..c2ad2c9970 100644 --- a/ceilometer/tests/functional/gabbi/gabbits/basic.yaml +++ b/ceilometer/tests/functional/gabbi/gabbits/basic.yaml @@ -10,7 +10,7 @@ tests: - name: quick root check url: / response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_strings: - '"base": "application/json"' response_json_paths: diff --git a/ceilometer/tests/functional/gabbi/gabbits/clean-samples.yaml b/ceilometer/tests/functional/gabbi/gabbits/clean-samples.yaml index 0d5927a894..a7cb23268f 100644 --- a/ceilometer/tests/functional/gabbi/gabbits/clean-samples.yaml +++ b/ceilometer/tests/functional/gabbi/gabbits/clean-samples.yaml @@ -33,7 +33,7 @@ tests: $.[0].counter_name: apples status: 201 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json # When POSTing a sample perhaps we should get back a location header # with the URI of the posted sample diff --git a/ceilometer/tests/functional/gabbi/gabbits_prefix/basic.yaml b/ceilometer/tests/functional/gabbi/gabbits_prefix/basic.yaml index d9d2815ba7..26c7b860e6 100644 --- a/ceilometer/tests/functional/gabbi/gabbits_prefix/basic.yaml +++ b/ceilometer/tests/functional/gabbi/gabbits_prefix/basic.yaml @@ -10,7 +10,7 @@ tests: - name: quick root check url: / response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json response_strings: - '"base": "application/json"' response_json_paths: diff --git a/ceilometer/tests/functional/gabbi/gabbits_prefix/clean-samples.yaml b/ceilometer/tests/functional/gabbi/gabbits_prefix/clean-samples.yaml index 61f7c816ae..83835670cc 100644 --- a/ceilometer/tests/functional/gabbi/gabbits_prefix/clean-samples.yaml +++ b/ceilometer/tests/functional/gabbi/gabbits_prefix/clean-samples.yaml @@ -34,7 +34,7 @@ tests: $.[0].counter_name: apples status: 201 response_headers: - content-type: application/json; charset=UTF-8 + content-type: application/json - name: get resources desc: get the resources that exist because of the sample diff --git a/ceilometer/tests/unit/agent/test_manager.py b/ceilometer/tests/unit/agent/test_manager.py index 06a98839c1..8066654bc4 100644 --- a/ceilometer/tests/unit/agent/test_manager.py +++ b/ceilometer/tests/unit/agent/test_manager.py @@ -18,12 +18,10 @@ import shutil from keystoneauth1 import exceptions as ka_exceptions import mock -from novaclient import client as novaclient from oslo_config import fixture as fixture_config from oslo_utils import fileutils from oslotest import base from oslotest import mockpatch -import requests import six from stevedore import extension import yaml @@ -325,11 +323,6 @@ class TestRunTasks(agentbase.BaseAgentManagerTestCase): @mock.patch('ceilometer.agent.manager.LOG') @mock.patch('ceilometer.nova_client.LOG') def test_hardware_discover_fail_minimize_logs(self, novalog, baselog): - self.useFixture(mockpatch.PatchObject( - novaclient.HTTPClient, - 'authenticate', - side_effect=requests.ConnectionError)) - class PollsterHardware(agentbase.TestPollster): discovery = 'tripleo_overcloud_nodes'