diff --git a/.gitignore b/.gitignore index b62bb99..3041f8d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,58 @@ -*\.egg-info -*\.py[co] -\.eggs +*.py[cod] + +# C extensions +*.so + +# Packages +*.egg +*.egg-info dist +build +.eggs +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg +lib +lib64 + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox +nosetests.xml +.stestr/ +.venv + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Complexity +output/*.html +output/*/index.html + +# Sphinx +doc/build +releasenotes/build + +# pbr generates these +AUTHORS +ChangeLog + +# Editors +*~ +.*.swp +.*sw? + +# generated docs +doc/source/ref/ diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..45314a6 --- /dev/null +++ b/.gitreview @@ -0,0 +1,5 @@ +[gerrit] +host=review.opendev.org +port=29418 +project=openstack/python-observabilityclient.git +defaultbranch=master diff --git a/.zuul.yaml b/.zuul.yaml new file mode 100644 index 0000000..9da640a --- /dev/null +++ b/.zuul.yaml @@ -0,0 +1,41 @@ +- project: + queue: telemetry + templates: + - openstack-python3-jobs + - check-requirements + #- release-notes-jobs-python3 + check: + jobs: + - telemetry-dsvm-integration: + irrelevant-files: &pobsc-irrelevant-files + - ^(test-|)requirements.txt$ + - ^setup.cfg$ + - ^.*\.rst$ + - ^releasenotes/.*$ + - ^observabilityclient/tests/.*$ + - ^tools/.*$ + - ^tox.ini$ + voting: false + - telemetry-dsvm-integration-ipv6-only: + irrelevant-files: *pobsc-irrelevant-files + voting: false + - telemetry-dsvm-integration-centos-9s: + irrelevant-files: *pobsc-irrelevant-files + voting: false + - telemetry-dsvm-integration-centos-9s-fips: + irrelevant-files: *pobsc-irrelevant-files + voting: false + gate: + jobs: + - telemetry-dsvm-integration: + irrelevant-files: *pobsc-irrelevant-files + voting: false + - telemetry-dsvm-integration-ipv6-only: + irrelevant-files: *pobsc-irrelevant-files + voting: false + - telemetry-dsvm-integration-centos-9s: + irrelevant-files: *pobsc-irrelevant-files + voting: false + - telemetry-dsvm-integration-centos-9s-fips: + irrelevant-files: *pobsc-irrelevant-files + voting: false diff --git a/observabilityclient/tests/unit/test_cli.py b/observabilityclient/tests/unit/test_cli.py index ee698a1..0d56fd8 100644 --- a/observabilityclient/tests/unit/test_cli.py +++ b/observabilityclient/tests/unit/test_cli.py @@ -35,10 +35,10 @@ class CliTest(testtools.TestCase): expected = (['metric_name'], [['name1'], ['name2'], ['name3']]) cli_list = cli.List(mock.Mock(), mock.Mock()) - with (mock.patch.object(metric_utils, 'get_client', - return_value=self.client), - mock.patch.object(self.client.query, 'list', - return_value=metric_names) as m): + with mock.patch.object(metric_utils, 'get_client', + return_value=self.client), \ + mock.patch.object(self.client.query, 'list', + return_value=metric_names) as m: ret1 = cli_list.take_action(args_enabled) m.assert_called_with(disable_rbac=False) @@ -61,10 +61,10 @@ class CliTest(testtools.TestCase): cli_show = cli.Show(mock.Mock(), mock.Mock()) - with (mock.patch.object(metric_utils, 'get_client', - return_value=self.client), - mock.patch.object(self.client.query, 'show', - return_value=prom_metric) as m): + with mock.patch.object(metric_utils, 'get_client', + return_value=self.client), \ + mock.patch.object(self.client.query, 'show', + return_value=prom_metric) as m: ret1 = cli_show.take_action(args_enabled) m.assert_called_with('metric_name', disable_rbac=False) @@ -91,10 +91,10 @@ class CliTest(testtools.TestCase): cli_query = cli.Query(mock.Mock(), mock.Mock()) - with (mock.patch.object(metric_utils, 'get_client', - return_value=self.client), - mock.patch.object(self.client.query, 'query', - return_value=prom_metric) as m): + with mock.patch.object(metric_utils, 'get_client', + return_value=self.client), \ + mock.patch.object(self.client.query, 'query', + return_value=prom_metric) as m: ret1 = cli_query.take_action(args_enabled) m.assert_called_with(query, disable_rbac=False) @@ -111,9 +111,9 @@ class CliTest(testtools.TestCase): cli_delete = cli.Delete(mock.Mock(), mock.Mock()) - with (mock.patch.object(metric_utils, 'get_client', - return_value=self.client), - mock.patch.object(self.client.query, 'delete') as m): + with mock.patch.object(metric_utils, 'get_client', + return_value=self.client), \ + mock.patch.object(self.client.query, 'delete') as m: cli_delete.take_action(args) m.assert_called_with(matches, 0, 10) @@ -121,9 +121,9 @@ class CliTest(testtools.TestCase): def test_clean_combstones(self): cli_clean_tombstones = cli.CleanTombstones(mock.Mock(), mock.Mock()) - with (mock.patch.object(metric_utils, 'get_client', - return_value=self.client), - mock.patch.object(self.client.query, 'clean_tombstones') as m): + with mock.patch.object(metric_utils, 'get_client', + return_value=self.client), \ + mock.patch.object(self.client.query, 'clean_tombstones') as m: cli_clean_tombstones.take_action({}) m.assert_called_once() @@ -132,10 +132,10 @@ class CliTest(testtools.TestCase): cli_snapshot = cli.Snapshot(mock.Mock(), mock.Mock()) file_name = 'some_file_name' - with (mock.patch.object(metric_utils, 'get_client', - return_value=self.client), - mock.patch.object(self.client.query, 'snapshot', - return_value=file_name) as m): + with mock.patch.object(metric_utils, 'get_client', + return_value=self.client), \ + mock.patch.object(self.client.query, 'snapshot', + return_value=file_name) as m: ret = cli_snapshot.take_action({}) m.assert_called_once() diff --git a/observabilityclient/tests/unit/test_utils.py b/observabilityclient/tests/unit/test_utils.py index be65b11..3386033 100644 --- a/observabilityclient/tests/unit/test_utils.py +++ b/observabilityclient/tests/unit/test_utils.py @@ -26,8 +26,8 @@ class GetConfigFileTest(testtools.TestCase): super(GetConfigFileTest, self).setUp() def test_current_dir(self): - with (mock.patch.object(os.path, 'exists', return_value=True), - mock.patch.object(metric_utils, 'open') as m): + with mock.patch.object(os.path, 'exists', return_value=True), \ + mock.patch.object(metric_utils, 'open') as m: metric_utils.get_config_file() m.assert_called_with(metric_utils.CONFIG_FILE_NAME, 'r') @@ -50,35 +50,35 @@ class GetPrometheusClientTest(testtools.TestCase): self.config_file = mock.mock_open(read_data=config_data)("name", 'r') def test_get_prometheus_client_from_file(self): - with (mock.patch.object(metric_utils, 'get_config_file', - return_value=self.config_file), - mock.patch.object(prometheus_client.PrometheusAPIClient, - "__init__", return_value=None) as m): + with mock.patch.object(metric_utils, 'get_config_file', + return_value=self.config_file), \ + mock.patch.object(prometheus_client.PrometheusAPIClient, + "__init__", return_value=None) as m: metric_utils.get_prometheus_client() m.assert_called_with("somehost:1234") def test_get_prometheus_client_env_overide(self): - with (mock.patch.dict(os.environ, {'PROMETHEUS_HOST': 'env_overide'}), - mock.patch.object(metric_utils, 'get_config_file', - return_value=self.config_file), - mock.patch.object(prometheus_client.PrometheusAPIClient, - "__init__", return_value=None) as m): + with mock.patch.dict(os.environ, {'PROMETHEUS_HOST': 'env_overide'}), \ + mock.patch.object(metric_utils, 'get_config_file', + return_value=self.config_file), \ + mock.patch.object(prometheus_client.PrometheusAPIClient, + "__init__", return_value=None) as m: metric_utils.get_prometheus_client() m.assert_called_with("env_overide:1234") def test_get_prometheus_client_no_config_file(self): patched_env = {'PROMETHEUS_HOST': 'env_overide', 'PROMETHEUS_PORT': 'env_port'} - with (mock.patch.dict(os.environ, patched_env), - mock.patch.object(prometheus_client.PrometheusAPIClient, - "__init__", return_value=None) as m): + with mock.patch.dict(os.environ, patched_env), \ + mock.patch.object(prometheus_client.PrometheusAPIClient, + "__init__", return_value=None) as m: metric_utils.get_prometheus_client() m.assert_called_with("env_overide:env_port") def test_get_prometheus_client_missing_configuration(self): - with (mock.patch.dict(os.environ, {}), - mock.patch.object(prometheus_client.PrometheusAPIClient, - "__init__", return_value=None)): + with mock.patch.dict(os.environ, {}), \ + mock.patch.object(prometheus_client.PrometheusAPIClient, + "__init__", return_value=None): self.assertRaises(metric_utils.ConfigurationError, metric_utils.get_prometheus_client) diff --git a/requirements.txt b/requirements.txt index ac645ff..3f333b7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ osc-lib>=1.0.1 # Apache-2.0 keystoneauth1>=1.0.0 -cliff!=1.16.0,>=1.14.0 # Apache-2.0 +cliff>=1.14.0 # Apache-2.0