aboutsummaryrefslogtreecommitdiffstats
path: root/tests/utilities_tests.py
Commit message (Collapse)AuthorAgeFilesLines
* [tests] Start using avocado for test suiteJake Hunsaker2021-04-151-103/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit represents the start of an overhaul of the test suite used by sos. Note that several more commits to follow will be required in order for the test suite to be considered stable. The new test suite will use the avocado-framework to build out new tests. This first part adopts a new 'stageX' naming scheme for our tests as follows: stage0 -> Unittests stage1 -> Basic function tests, no mocking allowed stage2 -> Mocked tests for specific scenarios/regressions stage3 -> Complex setups for layered products/environments At the moment, these unittests are not updated for avocado, though most should still work with `nosetest` directly. A new set of base classes is defined in tests/sos_tests.py which provide the foundation for actual tests cases. This approach entails new test cases subclassing a base class, such as the new `StageOneReportTest`, and setting the `sos_cmd` class attr to the _options_ for an sos report run. By default `sos report --batch` will be run, and targeted to the test job's directory as a tmpdir. Each sos command will be executed once, and all test_* methods within a test case that subclasses `StageOneReportTest` will be checked against the output of that execution. Note that this diverges from avocado's typical approach where each test_* method is performed against a brand new instance of the class (thus meaning any setup including our sos report run would normally be run fresh). However, after speaking with the avocado devel team, this is still seen as a valid pattern for the framework. The current organizational approach is to separate the tests by component rather than stage. For example. `tests/report_tests/` should hold any report-centric tests, and the `plugin_tests` directory therein should be used for plugin-specific tests. As of this commit, there are basic functionality tests under `tests/report_tests/` and a single plugin test under `tests/report_tests/plugin_tests/` to act as a POC. Further, there is a `tests/vendor_tests/` directory for organizing vendor-specific bug/feature tests that are not covered by the generic project-wide tests. A POC test from RHBZ1928628 is available with this commit. Note that in order for these tests to be run properly _without_ installing the current branch to the local system, you will need to run the following command: `PYTHONPATH=tests/ avocado run -t stageone tests/` Related: #2431 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [travis,style] Upgrade to 20.04 and cover more in testsBryan Quigley2020-08-131-4/+7
| | | | | Signed-off-by: Bryan Quigley <code@bryanquigley.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] Fix unittestsJake Hunsaker2020-04-211-1/+1
| | | | | | | | | | Fixes a unittest failure due to an attempt to pass print() a `file` keyword for Red Hat, which is no longer accepted in python3 Additionally fixes 2 string related errors in the test suite since changing from python2 to python3. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [global] Drop use of python six and other 2.X bitsBryan Quigley2020-04-091-4/+3
| | | | | | Resolves: #2006 Signed-off-by: Bryan Quigley <bryan.quigley@canonical.com>
* [tests] add license header to source filesBryn M. Reeves2020-02-261-0/+7
| | | | | | | Resolves: #1958 Signed-off-by: Bryn M. Reeves <bmr@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] use echo instead of py script in test_{output,shell_out}()Bryn M. Reeves2020-02-261-4/+2
| | | | | | | Related: #1949 Signed-off-by: Bryn M. Reeves <bmr@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] compare correct string types in test_nonexe_file()Bryn M. Reeves2020-02-261-1/+1
| | | | | | | | | Use a byte string instead of a regular string. Related: #1949 Signed-off-by: Bryn M. Reeves <bmr@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [tests] look for 'true' in test_exe_file() instead of py scriptBryn M. Reeves2020-02-261-2/+1
| | | | | | | | | | Use the executable 'true' when testing is_executable() on a non-absolute path. Related: #1949 Signed-off-by: Bryn M. Reeves <bmr@redhat.com> Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
* [policies] move hash determination to policiesBryn M. Reeves2015-12-041-1/+1
| | | | | | | | | | | | | It's crazy having the Policy classes call a function in the utilities module only to have that function then load the Policy module, call policy.get_preferred_hash_algorithm() and then test the result. Get rid of the get_hash_name() function in the utilities module and simplify the calls in the policies module to obtain the preferred hash name. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
* [sosreport] add --chroot optionBryn M. Reeves2015-07-081-1/+3
| | | | | | | | | | | | | | | | Add a --chroot option to sosreport to control command chrooting. The option takes one of three values: * auto - Allow callers of the API to control chroot behaviour * always - Always chroot external commands to --sysroot * never - Never chroot external commands This is a fairly low-level option and may not be exposed to the user in a final release; for now it will allow tests in container environments to control the chrooting behaviour used for a run. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
* [utilities] add chroot support to sos_get_command_output()Bryn M. Reeves2015-07-071-0/+5
| | | | | | | Allow callers of sos_get_command_output() to specify a path to chroot into before executing command. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
* [global] Fix vim tags typo in all python source filesKamalesh Babulal2015-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the syntax of the vim modeline used to enable the required editing mode in all python sources files. The desired options are: et - expand tabs (convert tab chars to spaces) ts=4 - set tabstop to 4 characters sw=4 - set shiftwidth to 4 characters Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> (edits for commit message, modeline compatibility & options) Signed-off-by: Bryn M. Reeves <bmr@redhat.com> --- __run__.py | 2 +- example_plugins/example.py | 2 +- setup.py | 2 +- sos/archive.py | 2 +- sos/plugins/__init__.py | 2 +- sos/plugins/abrt.py | 2 +- sos/plugins/acpid.py | 2 +- sos/plugins/anaconda.py | 2 +- sos/plugins/anacron.py | 2 +- sos/plugins/apache.py | 2 +- sos/plugins/apparmor.py | 2 +- sos/plugins/apport.py | 2 +- sos/plugins/apt.py | 2 +- sos/plugins/ata.py | 2 +- sos/plugins/auditd.py | 2 +- sos/plugins/autofs.py | 2 +- sos/plugins/azure.py | 2 +- sos/plugins/block.py | 2 +- sos/plugins/boot.py | 2 +- sos/plugins/ceph.py | 2 +- sos/plugins/cgroups.py | 2 +- sos/plugins/cluster.py | 2 +- sos/plugins/cobbler.py | 2 +- sos/plugins/corosync.py | 2 +- sos/plugins/cron.py | 2 +- sos/plugins/cs.py | 2 +- sos/plugins/ctdb.py | 2 +- sos/plugins/cups.py | 2 +- sos/plugins/dbus.py | 2 +- sos/plugins/devicemapper.py | 2 +- sos/plugins/dhcp.py | 2 +- sos/plugins/distupgrade.py | 2 +- sos/plugins/dmraid.py | 2 +- sos/plugins/docker.py | 2 +- sos/plugins/dovecot.py | 2 +- sos/plugins/dpkg.py | 2 +- sos/plugins/ds.py | 2 +- sos/plugins/fcoe.py | 2 +- sos/plugins/filesys.py | 2 +- sos/plugins/firewalld.py | 2 +- sos/plugins/foreman.py | 2 +- sos/plugins/gdm.py | 2 +- sos/plugins/general.py | 2 +- sos/plugins/gluster.py | 2 +- sos/plugins/grub.py | 2 +- sos/plugins/grub2.py | 2 +- sos/plugins/haproxy.py | 2 +- sos/plugins/hardware.py | 2 +- sos/plugins/hpasm.py | 2 +- sos/plugins/hts.py | 2 +- sos/plugins/i18n.py | 2 +- sos/plugins/infiniband.py | 2 +- sos/plugins/ipa.py | 2 +- sos/plugins/ipsec.py | 2 +- sos/plugins/ipvs.py | 2 +- sos/plugins/iscsi.py | 2 +- sos/plugins/iscsitarget.py | 2 +- sos/plugins/java.py | 2 +- sos/plugins/juju.py | 2 +- sos/plugins/kdump.py | 2 +- sos/plugins/keepalived.py | 2 +- sos/plugins/kernel.py | 2 +- sos/plugins/kernelrt.py | 2 +- sos/plugins/keyutils.py | 2 +- sos/plugins/kpatch.py | 2 +- sos/plugins/krb5.py | 2 +- sos/plugins/kvm.py | 2 +- sos/plugins/landscape.py | 2 +- sos/plugins/ldap.py | 2 +- sos/plugins/libraries.py | 2 +- sos/plugins/libvirt.py | 2 +- sos/plugins/lightdm.py | 2 +- sos/plugins/lilo.py | 2 +- sos/plugins/logrotate.py | 2 +- sos/plugins/logs.py | 2 +- sos/plugins/lsbrelease.py | 2 +- sos/plugins/lvm2.py | 2 +- sos/plugins/maas.py | 2 +- sos/plugins/manageiq.py | 2 +- sos/plugins/md.py | 2 +- sos/plugins/megacli.py | 2 +- sos/plugins/memory.py | 2 +- sos/plugins/mongodb.py | 2 +- sos/plugins/mpt.py | 2 +- sos/plugins/mrggrid.py | 2 +- sos/plugins/mrgmessg.py | 2 +- sos/plugins/multipath.py | 2 +- sos/plugins/mysql.py | 2 +- sos/plugins/named.py | 2 +- sos/plugins/navicli.py | 2 +- sos/plugins/networking.py | 2 +- sos/plugins/nfs.py | 2 +- sos/plugins/nfsserver.py | 2 +- sos/plugins/nis.py | 2 +- sos/plugins/nscd.py | 2 +- sos/plugins/ntp.py | 2 +- sos/plugins/numa.py | 2 +- sos/plugins/oddjob.py | 2 +- sos/plugins/openhpi.py | 2 +- sos/plugins/openshift.py | 2 +- sos/plugins/openssl.py | 2 +- sos/plugins/openstack_ceilometer.py | 2 +- sos/plugins/openstack_cinder.py | 2 +- sos/plugins/openstack_glance.py | 2 +- sos/plugins/openstack_heat.py | 2 +- sos/plugins/openstack_horizon.py | 2 +- sos/plugins/openstack_keystone.py | 2 +- sos/plugins/openstack_neutron.py | 2 +- sos/plugins/openstack_nova.py | 2 +- sos/plugins/openstack_swift.py | 2 +- sos/plugins/openstack_trove.py | 2 +- sos/plugins/openswan.py | 2 +- sos/plugins/openvswitch.py | 2 +- sos/plugins/pam.py | 2 +- sos/plugins/pci.py | 2 +- sos/plugins/pcp.py | 2 +- sos/plugins/postfix.py | 2 +- sos/plugins/postgresql.py | 2 +- sos/plugins/powerpath.py | 2 +- sos/plugins/powerpc.py | 2 +- sos/plugins/ppp.py | 2 +- sos/plugins/procenv.py | 2 +- sos/plugins/process.py | 2 +- sos/plugins/processor.py | 2 +- sos/plugins/psacct.py | 2 +- sos/plugins/pxe.py | 2 +- sos/plugins/python.py | 2 +- sos/plugins/qpid.py | 2 +- sos/plugins/quagga.py | 2 +- sos/plugins/rabbitmq.py | 2 +- sos/plugins/radius.py | 2 +- sos/plugins/rhui.py | 2 +- sos/plugins/rpm.py | 2 +- sos/plugins/s390.py | 2 +- sos/plugins/samba.py | 2 +- sos/plugins/sanlock.py | 2 +- sos/plugins/sar.py | 2 +- sos/plugins/satellite.py | 2 +- sos/plugins/scsi.py | 2 +- sos/plugins/selinux.py | 2 +- sos/plugins/sendmail.py | 2 +- sos/plugins/smartcard.py | 2 +- sos/plugins/snmp.py | 2 +- sos/plugins/soundcard.py | 2 +- sos/plugins/squid.py | 2 +- sos/plugins/ssh.py | 2 +- sos/plugins/ssmtp.py | 2 +- sos/plugins/sssd.py | 2 +- sos/plugins/startup.py | 2 +- sos/plugins/sunrpc.py | 2 +- sos/plugins/symcli.py | 2 +- sos/plugins/system.py | 2 +- sos/plugins/systemd.py | 2 +- sos/plugins/systemtap.py | 2 +- sos/plugins/sysvipc.py | 2 +- sos/plugins/targetcli.py | 2 +- sos/plugins/teamd.py | 2 +- sos/plugins/tftpserver.py | 2 +- sos/plugins/tomcat.py | 2 +- sos/plugins/tuned.py | 2 +- sos/plugins/udev.py | 2 +- sos/plugins/unity.py | 2 +- sos/plugins/upstart.py | 2 +- sos/plugins/usb.py | 2 +- sos/plugins/veritas.py | 2 +- sos/plugins/vmware.py | 2 +- sos/plugins/vsftpd.py | 2 +- sos/plugins/x11.py | 2 +- sos/plugins/xen.py | 2 +- sos/plugins/xfs.py | 2 +- sos/plugins/xinetd.py | 2 +- sos/plugins/yum.py | 2 +- sos/policies/__init__.py | 2 +- sos/policies/debian.py | 2 +- sos/policies/osx.py | 2 +- sos/policies/redhat.py | 2 +- sos/policies/ubuntu.py | 2 +- sos/reporting.py | 2 +- sos/sosreport.py | 2 +- sos/utilities.py | 2 +- tests/archive_tests.py | 2 +- tests/importer_tests.py | 2 +- tests/option_tests.py | 2 +- tests/plugin_tests.py | 2 +- tests/policy_tests.py | 2 +- tests/report_tests.py | 2 +- tests/sosreport_pexpect.py | 2 +- tests/test_exe.py | 2 +- tests/utilities_tests.py | 2 +- 189 files changed, 189 insertions(+), 189 deletions(-)
* Clean up sos_get_command_output() and friendsBryn M. Reeves2014-04-041-6/+6
| | | | | | | | | | | | | Returning a 3-tuple has always been ugly. It gets worse as the parameter list for this family of functions grows. Worse, the 3rd member of the tuple is unused and is always set to 0. Rip the whole mess out and return a single, simple dictionary object with 'status' and 'output' keys. Update utilities_tests to reflect the new interface. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
* Remove obsolete checksum reference from utilities_tests.pyBryn M. Reeves2014-03-271-1/+1
| | | | Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
* Add vim tags to all python source filesBryn M. Reeves2014-03-261-0/+2
| | | | | | Fixes Issue #243. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
* Dead code removal: utilities.checksum()Bryn M. Reeves2014-03-261-12/+0
| | | | | | Has test case but no callers. Delete it. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
* Dead code removal: DirTreeBryn M. Reeves2014-03-261-10/+1
| | | | | | | The DirTree class has remained unused since it was implemented. Remove the definition and associated test cases. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
* Fix unittests to report on strings and not binaryAdam Stokes2014-01-271-2/+2
| | | | Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
* Python 3 portAdam Stokes2013-10-301-5/+8
| | | | | | | | | | | | This includes a necessary dependency on python-six for its compability layer since we are wanting to continue support for both Python 2.7.x and Python 3.x. In addition, this will allow us to effectively phase out Python 2 support when/if the time arises that all interested distributions have done away with Python 2. This port passes all unittests for both python 2.7.x and python 3.3.x Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
* Fix shell output unittestsAdam Stokes2013-10-181-2/+2
| | | | | | Since fix for 0ed431a went in we revert our unittests to the old (working) behavior. Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
* Update utilities_tests.pyAdam Stokes2013-08-091-2/+2
| | | Update unittests to reflect 4a594b6dce129f8d9837c0d93768576badf2b2b7
* Add support for distutilsAdam Stokes2013-07-261-1/+1
| | | | | | | | | | - We are planning on moving to python distutils for future packaging however, we still want to keep our current build infrastructure around until we are able to test the builds overtime. For now distutils will live alongside the current build process and slowly replace the Makefiles once deemed fit. Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>
* Make more names pep8 compliant across the treeBryn M. Reeves2013-03-281-3/+3
| | | | | | | | | Fix policy and utility function, method and variable names to use lower case underscored style instead of camelCase. Related to Issue #112. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
* Include new-line in shell_outAdam Stokes2013-02-111-2/+2
|
* using /usr/bin/timeout if it's thereJesse Jaggars2012-03-201-1/+8
|
* Squashed commit of the following:Jesse Jaggars2012-03-131-1/+13
| | | | | | | | | | | | | | commit 1c2cf82a424125decda210a557755e8467bf0b2b Author: Jesse Jaggars <jjaggars@redhat.com> Date: Tue Mar 13 15:20:47 2012 -0500 adding regex sub tests and some docstrings commit d72f2f28b364519710f95a53330821138fc40849 Author: Jesse Jaggars <jjaggars@redhat.com> Date: Tue Mar 13 11:13:06 2012 -0500 adding many tests for plugins
* fixing fileGrep to pass multiple search paths better and we handle ↵Jesse Jaggars2012-03-081-0/+4
| | | | non-existant files as well
* Refactoring PackageManagers and ArchivesJesse Jaggars2012-03-051-1/+47
| | | | | | | Pulled up PackageManager implementation to simplify subclass responsibilities Moved compress method to Archive classes Re-organized utilities.py Added tests to exercise more utilities methods
* adding ability to specify multiple files for Plugin.fileGrepJesse Jaggars2012-02-271-0/+37