Update json module to jsonutils
oslo project provide jsonutils, and the others use it in many place, this PS to update the json module to oslo jsonutils for consistency. Change-Id: Ie8bdc41e420fbbbafaca7d7eaeaa702d93c6a18d
This commit is contained in:
parent
d1b2092c8f
commit
378083e91e
@ -12,9 +12,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
|
||||||
from vitrage_tempest_plugin.tests.base import BaseVitrageTempest
|
from vitrage_tempest_plugin.tests.base import BaseVitrageTempest
|
||||||
@ -70,7 +69,7 @@ class BaseRcaTest(BaseVitrageTempest):
|
|||||||
LOG.debug("The rca taken from cli is : %s", cli_rca)
|
LOG.debug("The rca taken from cli is : %s", cli_rca)
|
||||||
LOG.debug("The rca taken by api is : %s", api_rca)
|
LOG.debug("The rca taken by api is : %s", api_rca)
|
||||||
|
|
||||||
parsed_rca = json.loads(cli_rca)
|
parsed_rca = jsonutils.loads(cli_rca)
|
||||||
sorted_cli_graph = self._clean_timestamps(sorted(parsed_rca.items()))
|
sorted_cli_graph = self._clean_timestamps(sorted(parsed_rca.items()))
|
||||||
sorted_api_graph = self._clean_timestamps(sorted(api_rca.items()))
|
sorted_api_graph = self._clean_timestamps(sorted(api_rca.items()))
|
||||||
self.assert_list_equal(sorted_cli_graph, sorted_api_graph)
|
self.assert_list_equal(sorted_cli_graph, sorted_api_graph)
|
||||||
|
@ -12,9 +12,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
|
||||||
from vitrage_tempest_plugin.tests.base import BaseVitrageTempest
|
from vitrage_tempest_plugin.tests.base import BaseVitrageTempest
|
||||||
@ -172,7 +171,7 @@ class TestResource(BaseVitrageTempest):
|
|||||||
'The resources taken from rest api is empty')
|
'The resources taken from rest api is empty')
|
||||||
|
|
||||||
sorted_cli_resources = sorted(
|
sorted_cli_resources = sorted(
|
||||||
json.loads(cli_resources),
|
jsonutils.loads(cli_resources),
|
||||||
key=lambda resource: resource["ID"])
|
key=lambda resource: resource["ID"])
|
||||||
sorted_api_resources = sorted(
|
sorted_api_resources = sorted(
|
||||||
api_resources,
|
api_resources,
|
||||||
|
@ -11,9 +11,12 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import json
|
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from vitrage_tempest_plugin.tests.common.constants import AodhProperties as \
|
from vitrage_tempest_plugin.tests.common.constants import AodhProperties as \
|
||||||
AodhProps
|
AodhProps
|
||||||
from vitrage_tempest_plugin.tests.common.tempest_clients import TempestClients
|
from vitrage_tempest_plugin.tests.common.tempest_clients import TempestClients
|
||||||
@ -125,7 +128,7 @@ def _aodh_request(type, resource_id=None, name=None, rule=None):
|
|||||||
# alarms, update accordingly
|
# alarms, update accordingly
|
||||||
query[0].update(dict(field='resource_id'))
|
query[0].update(dict(field='resource_id'))
|
||||||
rule[AodhProps.RESOURCES_THRESHOLD_RULE].update(dict(
|
rule[AodhProps.RESOURCES_THRESHOLD_RULE].update(dict(
|
||||||
query=json.dumps(query)))
|
query=jsonutils.dump_as_bytes(query)))
|
||||||
|
|
||||||
request.update(rule)
|
request.update(rule)
|
||||||
return request
|
return request
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
from testtools.matchers import HasLength
|
from testtools.matchers import HasLength
|
||||||
|
|
||||||
from vitrage_tempest_plugin.tests.api.event.base import BaseTestEvents
|
from vitrage_tempest_plugin.tests.api.event.base import BaseTestEvents
|
||||||
@ -140,7 +140,7 @@ class TestMistralNotifier(BaseTestEvents):
|
|||||||
# are at the end. Check the last `num_instances` executions.
|
# are at the end. Check the last `num_instances` executions.
|
||||||
execution = \
|
execution = \
|
||||||
self.mistral_client.executions.get(executions[-i].id)
|
self.mistral_client.executions.get(executions[-i].id)
|
||||||
execution_input = json.loads(execution.input)
|
execution_input = jsonutils.loads(execution.input)
|
||||||
executed_on_instances.add(execution_input['farewell'])
|
executed_on_instances.add(execution_input['farewell'])
|
||||||
|
|
||||||
msg = "There are %d instances in the graph but only %d distinct " \
|
msg = "There are %d instances in the graph but only %d distinct " \
|
||||||
@ -160,7 +160,7 @@ class TestMistralNotifier(BaseTestEvents):
|
|||||||
'The last execution had no input')
|
'The last execution had no input')
|
||||||
self.assertIn('farewell', execution_input_str,
|
self.assertIn('farewell', execution_input_str,
|
||||||
'No \'farewell\' key in the last execution input')
|
'No \'farewell\' key in the last execution input')
|
||||||
execution_input = json.loads(execution_input_str)
|
execution_input = jsonutils.loads(execution_input_str)
|
||||||
farewell_value = execution_input['farewell']
|
farewell_value = execution_input['farewell']
|
||||||
self.assertIsNotNone(farewell_value, '\'farewell\' input parameter is '
|
self.assertIsNotNone(farewell_value, '\'farewell\' input parameter is '
|
||||||
'None in last workflow execution')
|
'None in last workflow execution')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user