Commit fd21be7e authored by Thomas Goirand's avatar Thomas Goirand
Browse files

Merge tag '1.3.0' into debian/wallaby

oslo.upgradecheck 1.3.0 release

meta:version: 1.3.0
meta:diff-start: -
meta:series: wallaby
meta:release-type: release
meta:pypi: yes
meta:first: no
meta:release:Author: Ghanshyam Mann <gmann@ghanshyammann.com>
meta:release:Commit: Ghanshyam <gmann@ghanshyammann.com>
meta:release:Change-Id: I29b3d9b76a08b031ce67d486e76cac7cf2e1abc5
meta:release:Code-Review+2: Hervé Beraud <hberaud@redhat.com>
meta:release:Code-Review+2: Thierry Carrez <thierry@openstack.org>
meta:release:Workflow+1: Thierry Carrez <thierry@openstack.org>
parents 876762a4 9f95a6e1
# We from the Oslo project decided to pin repos based on the
# commit hash instead of the version tag to prevend arbitrary
# code from running in developer's machines. To update to a
# newer version, run `pre-commit autoupdate` and then replace
# the newer versions with their commit hash.
default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: ebc15addedad713c86ef18ae9632c88e187dd0af # v3.1.0
hooks:
- id: trailing-whitespace
# Replaces or checks mixed line ending
- id: mixed-line-ending
args: ['--fix', 'lf']
exclude: '.*\.(svg)$'
# Forbid files which have a UTF-8 byte-order marker
- id: check-byte-order-marker
# Checks that non-binary executables have a proper shebang
- id: check-executables-have-shebangs
# Check for files that contain merge conflict strings.
- id: check-merge-conflict
# Check for debugger imports and py37+ breakpoint()
# calls in python source
- id: debug-statements
- id: check-yaml
files: .*\.(yaml|yml)$
- repo: https://gitlab.com/pycqa/flake8
rev: 181bb46098dddf7e2d45319ea654b4b4d58c2840 # 3.8.3
hooks:
- id: flake8
additional_dependencies:
- hacking>=3.0.1,<3.1.0
- project:
templates:
- publish-openstack-docs-pti
- openstack-python3-victoria-jobs
- openstack-python3-wallaby-jobs
- check-requirements
- release-notes-jobs-python3
- periodic-stable-jobs
......
# -*- coding: utf-8 -*-
# Copyright (C) 2020 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Configuration file for the Sphinx documentation builder.
#
......
......@@ -2,5 +2,8 @@ oslo.config==5.2.0
oslo.i18n==3.15.3
enum34==1.0.4
PrettyTable==0.7.1
oslotest==1.5.1
oslotest==3.5.0
stestr==2.0.0
oslo.serialization==2.21.1
oslo.utils==4.5.0
oslo.policy==2.0.0
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_policy import opts as policy_opts
from oslo_utils import fileutils
from oslo_upgradecheck import upgradecheck
"""
Common checks which can be used by multiple services.
"""
def check_policy_json(self, conf):
"Checks to see if policy file is JSON-formatted policy file."
# NOTE(gmann): This method need [oslo_policy].policy_file
# config value so register those options in case they
# are not register by services.
conf.register_opts(policy_opts._options,
group=policy_opts._option_group)
msg = ("Your policy file is JSON-formatted which is "
"deprecated. You need to switch to YAML-formatted file. "
"Use the ``oslopolicy-convert-json-to-yaml`` "
"tool to convert the existing JSON-formatted files to "
"YAML in a backwards-compatible manner: "
"https://docs.openstack.org/oslo.policy/"
"latest/cli/oslopolicy-convert-json-to-yaml.html.")
status = upgradecheck.Result(upgradecheck.Code.SUCCESS)
# Check if policy file exist and is JSON-formatted.
policy_path = conf.find_file(conf.oslo_policy.policy_file)
if policy_path and fileutils.is_json(policy_path):
status = upgradecheck.Result(upgradecheck.Code.FAILURE, msg)
return status
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import fixtures
import os.path
import tempfile
import yaml
from oslo_config import cfg
from oslo_config import fixture as config
from oslo_policy import opts as policy_opts
from oslo_serialization import jsonutils
from oslotest import base
from oslo_upgradecheck import common_checks
from oslo_upgradecheck import upgradecheck
class TestUpgradeCheckPolicyJSON(base.BaseTestCase):
def setUp(self):
super(TestUpgradeCheckPolicyJSON, self).setUp()
conf_fixture = self.useFixture(config.Config())
conf_fixture.load_raw_values()
self.conf = conf_fixture.conf
self.conf.register_opts(policy_opts._options,
group=policy_opts._option_group)
self.cmd = upgradecheck.UpgradeCommands()
self.cmd._upgrade_checks = (('Policy File JSON to YAML Migration',
(common_checks.check_policy_json,
{'conf': self.conf})),)
self.data = {
'rule_admin': 'True',
'rule_admin2': 'is_admin:True'
}
self.temp_dir = self.useFixture(fixtures.TempDir())
fd, self.json_file = tempfile.mkstemp(dir=self.temp_dir.path)
fd, self.yaml_file = tempfile.mkstemp(dir=self.temp_dir.path)
with open(self.json_file, 'w') as fh:
jsonutils.dump(self.data, fh)
with open(self.yaml_file, 'w') as fh:
yaml.dump(self.data, fh)
original_search_dirs = cfg._search_dirs
def fake_search_dirs(dirs, name):
dirs.append(self.temp_dir.path)
return original_search_dirs(dirs, name)
mock_search_dir = self.useFixture(
fixtures.MockPatch('oslo_config.cfg._search_dirs')).mock
mock_search_dir.side_effect = fake_search_dirs
def test_policy_json_file_fail_upgrade(self):
# Test with policy json file full path set in config.
self.conf.set_override('policy_file', self.json_file,
group="oslo_policy")
self.assertEqual(upgradecheck.Code.FAILURE,
self.cmd.check())
def test_policy_yaml_file_pass_upgrade(self):
# Test with full policy yaml file path set in config.
self.conf.set_override('policy_file', self.yaml_file,
group="oslo_policy")
self.assertEqual(upgradecheck.Code.SUCCESS,
self.cmd.check())
def test_no_policy_file_pass_upgrade(self):
# Test with no policy file exist, means use policy from code.
self.conf.set_override('policy_file', 'non_exist_file',
group="oslo_policy")
self.assertEqual(upgradecheck.Code.SUCCESS,
self.cmd.check())
def test_default_policy_yaml_file_pass_upgrade(self):
self.conf.set_override('policy_file', 'policy.yaml',
group="oslo_policy")
tmpfilename = os.path.join(self.temp_dir.path, 'policy.yaml')
with open(tmpfilename, 'w') as fh:
yaml.dump(self.data, fh)
self.assertEqual(upgradecheck.Code.SUCCESS,
self.cmd.check())
def test_old_default_policy_json_file_fail_upgrade(self):
self.conf.set_override('policy_file', 'policy.json',
group="oslo_policy")
tmpfilename = os.path.join(self.temp_dir.path, 'policy.json')
with open(tmpfilename, 'w') as fh:
jsonutils.dump(self.data, fh)
self.assertEqual(upgradecheck.Code.FAILURE,
self.cmd.check())
......@@ -99,7 +99,11 @@ class UpgradeCommands(object):
# This is a list if 2-item tuples for the check name and it's results.
check_results = []
for name, func in self._upgrade_checks:
result = func(self)
if isinstance(func, tuple):
func_name, kwargs = func
result = func_name(self, **kwargs)
else:
result = func(self)
# store the result of the check for the summary table
check_results.append((name, result))
# we want to end up with the highest level code of all checks
......
# -*- coding: utf-8 -*-
# Copyright (C) 2020 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Configuration file for the Sphinx documentation builder.
#
......
......@@ -5,6 +5,7 @@ oslo.upgradecheck Release Notes
:maxdepth: 1
unreleased
victoria
ussuri
train
stein
=============================
Victoria Series Release Notes
=============================
.. release-notes::
:branch: stable/victoria
......@@ -5,3 +5,5 @@
oslo.config>=5.2.0 # Apache-2.0
oslo.i18n>=3.15.3 # Apache-2.0
PrettyTable<0.8,>=0.7.1 # BSD
oslo.utils>=4.5.0 # Apache-2.0
oslo.policy>=2.0.0 # Apache-2.0
......@@ -3,5 +3,7 @@
# process, which may cause wedges in the gate later.
hacking>=3.0,<3.1.0 # Apache-2.0
oslotest>=1.5.1
oslotest>=3.5.0
stestr>=2.0.0
pre-commit>=2.6.0 # MIT
oslo.serialization>=2.21.1 # Apache-2.0
......@@ -19,7 +19,7 @@ deps =
commands = stestr run --slowest {posargs}
[testenv:pep8]
commands = flake8 {posargs}
commands = pre-commit run -a
[testenv:venv]
commands = {posargs}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment