diff options
author | Adam Stokes <adam.stokes@ubuntu.com> | 2013-04-04 20:50:59 -0400 |
---|---|---|
committer | Adam Stokes <adam.stokes@ubuntu.com> | 2013-04-04 20:50:59 -0400 |
commit | 0c48b167ea53362b67c46a10c17ee7bc9ea9887a (patch) | |
tree | 0c4871eb82bc7611cdc29e6711861f26b506422e | |
parent | 76156e8b7a8b7a31e30038819d0aa0d7ca5de197 (diff) | |
download | sos-0c48b167ea53362b67c46a10c17ee7bc9ea9887a.tar.gz |
Fix unittests and more pep8 conforming
- In our unittest we defined 'is_installed' to be a bool when in fact we wanted
to verify if a package is installed via the _method_ is is_installed. Since
overriding that method with our variable definition we basically removed
any functionality of 'is_installed' method in Plugin class.
- Initializing a fake plugin to test was failing due to our global
logger not being initialized. Put a simple check in the library to
make sure the logger is defined no matter what the calling state does.
- Make import selinux conditional
- Add travis-ci support
- Rename README to utilize travis-ci build status and other markdown supported
features
Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
-rw-r--r-- | .travis.yml | 15 | ||||
-rw-r--r-- | AUTHORS | 4 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | README.md (renamed from README) | 20 | ||||
-rw-r--r-- | sos.spec | 2 | ||||
-rw-r--r-- | sos/plugins/__init__.py | 4 | ||||
-rw-r--r-- | sos/utilities.py | 5 | ||||
-rw-r--r-- | tests/plugin_tests.py | 26 |
8 files changed, 58 insertions, 22 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..9b2061b1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +language: python +python: + - 2.6 + - 2.7 + - 3.2 + - 3.3 + - "pypy" +env: + - DEPS=false + - DEPS=true +install: + - "make gpgkey" + - "DESTDIR=. make install" +script: + - "make test" @@ -1,5 +1,6 @@ -Adam Stokes <astokes@redhat.com> +Adam Stokes <adam.stokes@ubuntu.com> Ben Turner <bturner@redhat.com> +Eric Williams <eric.williams@canonical.com> Eugene Teo <eteo@redhat.com> Gary Kotton <gkotton@redhat.com> Jesse Jaggars <jjaggars@redhat.com> @@ -8,6 +9,7 @@ John Berninger <jwb@redhat.com> Justin Payne <jpayne@redhat.com> Keith Kearnan <kearnan_keith@emc.com> Kent Lamb <klamb@redhat.com> +Louis Bouchard <louis.bouchard@canonical.com> Marc Sauton <msauton@redhat.com> Navid Sheikhol-Eslami <navid@redhat.com> Pierre Amadio <pamadio@redhat.com> @@ -48,7 +48,7 @@ install: updateversion install -m755 sosreport $(DESTDIR)/usr/sbin/sosreport install -m644 sosreport.1.gz $(DESTDIR)/usr/share/man/man1/. install -m644 sos.conf.5.gz $(DESTDIR)/usr/share/man/man5/. - install -m644 LICENSE README $(DESTDIR)/usr/share/$(NAME)/. + install -m644 LICENSE README.md $(DESTDIR)/usr/share/$(NAME)/. install -m644 $(NAME).conf $(DESTDIR)/etc/$(NAME).conf install -m644 gpgkeys/$(GPG_TPL)support.pub $(DESTDIR)/usr/share/$(NAME)/. for d in $(SUBDIRS); do make DESTDIR=`cd $(DESTDIR); pwd` -C $$d install; [ $$? = 0 ] || exit 1; done @@ -58,7 +58,7 @@ updateversion: $(NAME)-$(VERSION).tar.gz: clean gpgkey @mkdir -p $(ARCHIVE_DIR) - @tar -cv sosreport sos doc man po sos.conf LICENSE README sos.spec Makefile | tar -x -C $(ARCHIVE_DIR) + @tar -cv sosreport sos doc man po sos.conf LICENSE README.md sos.spec Makefile | tar -x -C $(ARCHIVE_DIR) @mkdir -p $(ARCHIVE_DIR)/gpgkeys @cp gpgkeys/$(GPG_TPL)support.pub $(ARCHIVE_DIR)/gpgkeys/. @tar Ccvzf $(DIST_BUILD_DIR) $(DIST_BUILD_DIR)/$(NAME)-$(VERSION).tar.gz $(NAME)-$(VERSION) @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/battlemidget/sosreport.png?branch=develop)](https://travis-ci.org/battlemidget/sosreport) + This set of tools is designed to provide information to support organizations in an extensible manner, allowing third parties, package maintainers, and anyone else to provide plugins that will collect and report information that @@ -8,15 +10,31 @@ version, to contribute, and for more information, please visit there. To access to the public source code repository for this project run: - git clone git://github.com/sosreport/sosreport.git +``` +git clone git://github.com/sosreport/sosreport.git +``` + +### Manual Installation ### +``` to install locally (as root) ==> make install to build an rpm ==> make rpm to build a deb ==> make deb-unsign to build a zipfile for use with jython ==> make zip +``` + +### Pre-built Packaging ### + +Fedora/RHEL users install via yum: + +``` +yum install sos +``` Debian/Ubuntu users can install via PPA: +``` sudo add-apt-repository ppa:debugmonkeys/sosreport sudo apt-get update sudo apt-get install sos +``` @@ -44,7 +44,7 @@ rm -rf ${RPM_BUILD_ROOT} %{python_sitelib}/* %{_mandir}/man1/* %{_mandir}/man5/* -%doc README LICENSE +%doc README.md LICENSE %config(noreplace) %{_sysconfdir}/sos.conf %changelog diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py index 6df08fc9..b0e3ab3f 100644 --- a/sos/plugins/__init__.py +++ b/sos/plugins/__init__.py @@ -140,8 +140,8 @@ class Plugin(object): self.must_exit = False - self.soslog = self.commons['soslog'] - self.proflog = self.commons['proflog'] + self.soslog = self.commons['soslog'] if self.commons.has_key('soslog') else logging.getLogger('sos') + self.proflog = self.commons['proflog'] if self.commons.has_key('proflog') else logging.getLogger('sosprofile') # get the option list into a dictionary for opt in self.option_list: diff --git a/sos/utilities.py b/sos/utilities.py index ae4763df..64d0ce62 100644 --- a/sos/utilities.py +++ b/sos/utilities.py @@ -35,7 +35,10 @@ import tarfile import hashlib import logging import fnmatch -import selinux +try: + import selinux +except ImportError: + pass from contextlib import closing try: diff --git a/tests/plugin_tests.py b/tests/plugin_tests.py index 09d4c2ac..9f8817d2 100644 --- a/tests/plugin_tests.py +++ b/tests/plugin_tests.py @@ -4,7 +4,8 @@ import tempfile from StringIO import StringIO from sos.plugins import Plugin, regex_findall, sos_relative_path, mangle_command -from sos.utilities import Archive +from sos.archive import TarFileArchive, ZipFileArchive +import sos.policies PATH = os.path.dirname(__file__) @@ -18,7 +19,7 @@ def create_file(size): f.close() return f.name -class MockArchive(Archive): +class MockArchive(TarFileArchive): def __init__(self): self.m = {} @@ -77,9 +78,7 @@ class ForbiddenMockPlugin(Plugin): class EnablerPlugin(Plugin): - is_installed = False - - def isInstalled(self, pkg): + def is_installed(self, pkg): return self.is_installed @@ -206,15 +205,15 @@ class PluginTests(unittest.TestCase): self.assertEquals(p.get_option_as_list("opt"), ['testing']) def test_copy_dir(self): - self.mp.doCopyFileOrDir("tests") + self.mp.do_copy_file_or_dir("tests") self.assertEquals(self.mp.archive.m["tests/plugin_tests.py"], 'tests/plugin_tests.py') def test_copy_dir_sub(self): - self.mp.doCopyFileOrDir("tests", sub=("tests/", "foobar/")) + self.mp.do_copy_file_or_dir("tests", sub=("tests/", "foobar/")) self.assertEquals(self.mp.archive.m["tests/plugin_tests.py"], 'foobar/plugin_tests.py') def test_copy_dir_bad_path(self): - self.mp.doCopyFileOrDir("not_here_tests") + self.mp.do_copy_file_or_dir("not_here_tests") self.assertEquals(self.mp.archive.m, {}) def test_copy_dir_forbidden_path(self): @@ -223,7 +222,7 @@ class PluginTests(unittest.TestCase): }) p.archive = MockArchive() p.setup() - p.doCopyFileOrDir("tests") + p.do_copy_file_or_dir("tests") self.assertEquals(p.archive.m, {}) @@ -269,7 +268,7 @@ class AddCopySpecLimitTests(unittest.TestCase): class CheckEnabledTests(unittest.TestCase): def setUp(self): - self.mp = EnablerPlugin({}) + self.mp = EnablerPlugin({'policy': sos.policies.load()}) def test_checks_for_file(self): f = j("tail_test.txt") @@ -278,7 +277,6 @@ class CheckEnabledTests(unittest.TestCase): def test_checks_for_package(self): self.mp.packages = ('foo',) - self.mp.is_installed = True self.assertTrue(self.mp.check_enabled()) def test_allows_bad_tuple(self): @@ -300,18 +298,18 @@ class RegexSubTests(unittest.TestCase): self.mp.archive = MockArchive() def test_file_never_copied(self): - self.assertEquals(0, self.mp.doFileSub("never_copied", r"^(.*)$", "foobar")) + self.assertEquals(0, self.mp.do_file_sub("never_copied", r"^(.*)$", "foobar")) def test_no_replacements(self): self.mp.add_copy_spec(j("tail_test.txt")) self.mp.collect() - replacements = self.mp.doFileSub(j("tail_test.txt"), r"wont_match", "foobar") + replacements = self.mp.do_file_sub(j("tail_test.txt"), r"wont_match", "foobar") self.assertEquals(0, replacements) def test_replacements(self): self.mp.add_copy_spec(j("tail_test.txt")) self.mp.collect() - replacements = self.mp.doFileSub(j("tail_test.txt"), r"(tail)", "foobar") + replacements = self.mp.do_file_sub(j("tail_test.txt"), r"(tail)", "foobar") self.assertEquals(1, replacements) self.assertTrue("foobar" in self.mp.archive.m.get(j('tail_test.txt'))) |