From e74d7752f1761c3a8d3c19877de4707d00c49d08 Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Mon, 21 Aug 2017 13:46:23 -0600 Subject: tools: Add tooling for basic cloud-init performance analysis. This branch adds cloudinit-analyze into cloud-init proper. It adds an "analyze" subcommand to the cloud-init command line utility for quick performance assessment of cloud-init stages and events. On a cloud-init configured instance, running "cloud-init analyze blame" will now report which cloud-init events cost the most wall time. This allows for quick assessment of the most costly stages of cloud-init. This functionality is pulled from Ryan Harper's analyze work. The cloudinit-analyze main script itself has been refactored a bit for inclusion as a subcommand of cloud-init CLI. There will be a followup branch at some point which will optionally instrument detailed strace profiling, but that approach needs a bit more discussion first. This branch also adds: * additional debugging topic to the sphinx-generated docs describing cloud-init analyze, dump and show as well as cloud-init single usage. * Updates the Makefile unittests target to include cloudinit directory because we now have unittests within that package. LP: #1709761 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index f280911f..9e7f4ee7 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ pyflakes3: @$(CWD)/tools/run-pyflakes3 unittest: clean_pyc - nosetests $(noseopts) tests/unittests + nosetests $(noseopts) tests/unittests cloudinit unittest3: clean_pyc nosetests3 $(noseopts) tests/unittests -- cgit v1.2.3 From 82b2da3a56680b43df00ed31837b8650b5971656 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 20 Sep 2017 15:47:04 -0600 Subject: Makefile: No longer look for yaml files in obsolete ./bin/. The bin/ dir was deleted some time ago, but the Makefile was still searching for files down it. This didn't cause any problems other Than a wierd looking error message in a build log. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 9e7f4ee7..7feea400 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ PYVER ?= $(shell for p in python3 python2; do \ noseopts ?= -v -YAML_FILES=$(shell find cloudinit bin tests tools -name "*.yaml" -type f ) +YAML_FILES=$(shell find cloudinit tests tools -name "*.yaml" -type f ) YAML_FILES+=$(shell find doc/examples -name "cloud-config*.txt" -type f ) PIP_INSTALL := pip install -- cgit v1.2.3 From d3a8777244ebc107e1124c4fab441b5e0eb75f44 Mon Sep 17 00:00:00 2001 From: Chad Smith Date: Wed, 20 Sep 2017 16:41:31 -0600 Subject: tests: Add cloudinit package to all test targets The package cloudinit was sparsely added to only the makefile's unittest target and tox's py3 target. This branch adds cloudinit package to 'make unittest3' and all tox environments. It tweaks one cloudinit unit test to use mocked_object.call_count instead of mocked_object.assert_called_once which is not defined in some python unittest versions. --- Makefile | 2 +- cloudinit/net/tests/test_dhcp.py | 3 ++- tox.ini | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 7feea400..4ace2270 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,7 @@ unittest: clean_pyc nosetests $(noseopts) tests/unittests cloudinit unittest3: clean_pyc - nosetests3 $(noseopts) tests/unittests + nosetests3 $(noseopts) tests/unittests cloudinit ci-deps-ubuntu: @$(PYVER) $(CWD)/tools/read-dependencies --distro ubuntu --test-distro diff --git a/cloudinit/net/tests/test_dhcp.py b/cloudinit/net/tests/test_dhcp.py index 1324c3d0..a38edaec 100644 --- a/cloudinit/net/tests/test_dhcp.py +++ b/cloudinit/net/tests/test_dhcp.py @@ -107,7 +107,8 @@ class TestDHCPDiscoveryClean(CiTestCase): 'os.getuid': 0}, maybe_perform_dhcp_discovery) self.assertEqual({'address': '192.168.2.2'}, retval) - m_dhcp.assert_called_once() + self.assertEqual( + 1, m_dhcp.call_count, 'dhcp_discovery not called once') call = m_dhcp.call_args_list[0] self.assertEqual('/sbin/dhclient', call[0][0]) self.assertEqual('eth9', call[0][1]) diff --git a/tox.ini b/tox.ini index 72de9830..776f4253 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,7 @@ envlist = py27, py3, flake8, xenial, pylint recreate = True [testenv] -commands = python -m nose {posargs:tests/unittests} +commands = python -m nose {posargs:tests/unittests cloudinit} setenv = LC_ALL = en_US.utf-8 -- cgit v1.2.3