Пример #1
0
 def test_get_osutil_it_should_return_coreos(self):
     ret = _get_osutil(distro_name="coreos",
                       distro_code_name="",
                       distro_version="",
                       distro_full_name="")
     self.assertTrue(isinstance(ret, CoreOSUtil))
     self.assertEqual(ret.get_service_name(), "waagent")
     ret = _get_osutil(distro_name="flatcar",
                       distro_code_name="",
                       distro_version="",
                       distro_full_name="")
     self.assertTrue(isinstance(ret, CoreOSUtil))
     self.assertEqual(ret.get_service_name(), "waagent")
    def test_get_osutil_it_should_return_debian(self):
        ret = _get_osutil(distro_name="debian",
                          distro_code_name="",
                          distro_full_name="",
                          distro_version="7")
        self.assertTrue(type(ret) == DebianOSBaseUtil)
        self.assertEquals(ret.get_service_name(), "waagent")

        ret = _get_osutil(distro_name="debian",
                          distro_code_name="",
                          distro_full_name="",
                          distro_version="8")
        self.assertTrue(type(ret) == DebianOSModernUtil)
        self.assertEquals(ret.get_service_name(), "walinuxagent")
Пример #3
0
 def test_get_osutil_it_should_return_openwrt(self):
     ret = _get_osutil(distro_name="openwrt",
                       distro_code_name="",
                       distro_version="",
                       distro_full_name="")
     self.assertTrue(type(ret) == OpenWRTOSUtil)  # pylint: disable=unidiomatic-typecheck
     self.assertEqual(ret.get_service_name(), "waagent")
 def test_get_osutil_it_should_return_arch(self):
     ret = _get_osutil(distro_name="arch",
                       distro_code_name="",
                       distro_version="",
                       distro_full_name="")
     self.assertTrue(type(ret) == ArchUtil)
     self.assertEquals(ret.get_service_name(), "waagent")
Пример #5
0
 def test_get_osutil_it_should_return_kali(self):
     ret = _get_osutil(distro_name="kali",
                       distro_code_name="",
                       distro_version="",
                       distro_full_name="")
     self.assertTrue(type(ret) == DebianOSBaseUtil)  # pylint: disable=unidiomatic-typecheck
     self.assertEqual(ret.get_service_name(), "waagent")
 def test_get_osutil_it_should_return_openwrt(self):
     ret = _get_osutil(distro_name="openwrt",
                       distro_code_name="",
                       distro_version="",
                       distro_full_name="")
     self.assertTrue(type(ret) == OpenWRTOSUtil)
     self.assertEquals(ret.get_service_name(), "waagent")
 def test_get_osutil_it_should_return_euleros(self):
     ret = _get_osutil(distro_name="euleros",
                       distro_code_name="",
                       distro_version="",
                       distro_full_name="")
     self.assertTrue(type(ret) == RedhatOSUtil)
     self.assertEquals(ret.get_service_name(), "waagent")
 def test_get_osutil_it_should_return_freebsd(self):
     ret = _get_osutil(distro_name="freebsd",
                       distro_code_name="",
                       distro_version="",
                       distro_full_name="")
     self.assertTrue(type(ret) == FreeBSDOSUtil)
     self.assertEquals(ret.get_service_name(), "waagent")
 def test_get_osutil_it_should_return_clear_linux(self):
     ret = _get_osutil(distro_name="clear linux",
                       distro_code_name="",
                       distro_version="",
                       distro_full_name="Clear Linux")
     self.assertTrue(type(ret) == ClearLinuxUtil)
     self.assertEquals(ret.get_service_name(), "waagent")
 def test_get_osutil_it_should_return_kali(self):
     ret = _get_osutil(distro_name="kali",
                       distro_code_name="",
                       distro_version="",
                       distro_full_name="")
     self.assertTrue(type(ret) == DebianOSBaseUtil)
     self.assertEquals(ret.get_service_name(), "waagent")
Пример #11
0
 def test_get_osutil_it_should_return_iosxe(self):
     ret = _get_osutil(distro_name="iosxe",
                       distro_code_name="",
                       distro_version="",
                       distro_full_name="")
     self.assertTrue(isinstance(ret, IosxeOSUtil))
     self.assertEqual(ret.get_service_name(), "waagent")
Пример #12
0
 def test_get_osutil_it_should_return_openbsd(self):
     ret = _get_osutil(distro_name="openbsd",
                       distro_code_name="",
                       distro_version="",
                       distro_full_name="")
     self.assertTrue(isinstance(ret, OpenBSDOSUtil))
     self.assertEqual(ret.get_service_name(), "waagent")
Пример #13
0
def mock_get_osutil(*args):
    # It's a known issue that calling platform.linux_distribution() in Travis will result in the wrong info.
    # See https://github.com/travis-ci/travis-ci/issues/2755
    # When running in Travis, use manual distro resolution that relies on environment variables.
    if running_under_travis():
        return get_osutil_for_travis()
    else:
        return _get_osutil(*args)
 def test_get_osutil_it_should_return_default(self, patch_logger):
     ret = _get_osutil(distro_name="",
                       distro_code_name="",
                       distro_version="",
                       distro_full_name="")
     self.assertTrue(type(ret) == DefaultOSUtil)
     self.assertEquals(patch_logger.call_count, 1)
     self.assertEquals(ret.get_service_name(), "waagent")
Пример #15
0
    def test_get_osutil_it_should_return_redhat(self):
        ret = _get_osutil(distro_name="redhat",
                          distro_code_name="",
                          distro_full_name="",
                          distro_version="6")
        self.assertTrue(isinstance(ret, Redhat6xOSUtil))
        self.assertEqual(ret.get_service_name(), "waagent")

        ret = _get_osutil(distro_name="rhel",
                          distro_code_name="",
                          distro_full_name="",
                          distro_version="6")
        self.assertTrue(isinstance(ret, Redhat6xOSUtil))
        self.assertEqual(ret.get_service_name(), "waagent")

        ret = _get_osutil(distro_name="centos",
                          distro_code_name="",
                          distro_full_name="",
                          distro_version="6")
        self.assertTrue(isinstance(ret, Redhat6xOSUtil))
        self.assertEqual(ret.get_service_name(), "waagent")

        ret = _get_osutil(distro_name="oracle",
                          distro_code_name="",
                          distro_full_name="",
                          distro_version="6")
        self.assertTrue(isinstance(ret, Redhat6xOSUtil))
        self.assertEqual(ret.get_service_name(), "waagent")

        ret = _get_osutil(distro_name="redhat",
                          distro_code_name="",
                          distro_full_name="",
                          distro_version="7")
        self.assertTrue(isinstance(ret, RedhatOSUtil))
        self.assertEqual(ret.get_service_name(), "waagent")

        ret = _get_osutil(distro_name="rhel",
                          distro_code_name="",
                          distro_full_name="",
                          distro_version="7")
        self.assertTrue(isinstance(ret, RedhatOSUtil))
        self.assertEqual(ret.get_service_name(), "waagent")

        ret = _get_osutil(distro_name="centos",
                          distro_code_name="",
                          distro_full_name="",
                          distro_version="7")
        self.assertTrue(isinstance(ret, RedhatOSUtil))
        self.assertEqual(ret.get_service_name(), "waagent")

        ret = _get_osutil(distro_name="oracle",
                          distro_code_name="",
                          distro_full_name="",
                          distro_version="7")
        self.assertTrue(isinstance(ret, RedhatOSUtil))
        self.assertEqual(ret.get_service_name(), "waagent")
    def test_get_osutil_it_should_return_suse(self):
        ret = _get_osutil(distro_name="suse",
                          distro_code_name="",
                          distro_version="10",
                          distro_full_name="")
        self.assertTrue(type(ret) == SUSEOSUtil)
        self.assertEquals(ret.get_service_name(), "waagent")

        ret = _get_osutil(distro_name="suse",
                          distro_code_name="",
                          distro_full_name="SUSE Linux Enterprise Server",
                          distro_version="11")
        self.assertTrue(type(ret) == SUSE11OSUtil)
        self.assertEquals(ret.get_service_name(), "waagent")

        ret = _get_osutil(distro_name="suse",
                          distro_code_name="",
                          distro_full_name="openSUSE",
                          distro_version="12")
        self.assertTrue(type(ret) == SUSE11OSUtil)
        self.assertEquals(ret.get_service_name(), "waagent")
Пример #17
0
    def test_get_osutil_it_should_return_ubuntu(self):
        ret = _get_osutil(distro_name="ubuntu",
                          distro_code_name="",
                          distro_version="10.04",
                          distro_full_name="")
        self.assertTrue(type(ret) == UbuntuOSUtil)  # pylint: disable=unidiomatic-typecheck
        self.assertEqual(ret.get_service_name(), "walinuxagent")

        ret = _get_osutil(distro_name="ubuntu",
                          distro_code_name="",
                          distro_version="12.04",
                          distro_full_name="")
        self.assertTrue(type(ret) == Ubuntu12OSUtil)  # pylint: disable=unidiomatic-typecheck
        self.assertEqual(ret.get_service_name(), "walinuxagent")

        ret = _get_osutil(distro_name="ubuntu",
                          distro_code_name="trusty",
                          distro_version="14.04",
                          distro_full_name="")
        self.assertTrue(type(ret) == Ubuntu14OSUtil)  # pylint: disable=unidiomatic-typecheck
        self.assertEqual(ret.get_service_name(), "walinuxagent")

        ret = _get_osutil(distro_name="ubuntu",
                          distro_code_name="xenial",
                          distro_version="16.04",
                          distro_full_name="")
        self.assertTrue(type(ret) == Ubuntu16OSUtil)  # pylint: disable=unidiomatic-typecheck
        self.assertEqual(ret.get_service_name(), "walinuxagent")

        ret = _get_osutil(distro_name="ubuntu",
                          distro_code_name="bionic",
                          distro_version="18.04",
                          distro_full_name="")
        self.assertTrue(type(ret) == Ubuntu18OSUtil)  # pylint: disable=unidiomatic-typecheck
        self.assertEqual(ret.get_service_name(), "walinuxagent")

        ret = _get_osutil(distro_name="ubuntu",
                          distro_code_name="focal",
                          distro_version="20.04",
                          distro_full_name="")
        self.assertTrue(type(ret) == Ubuntu18OSUtil)  # pylint: disable=unidiomatic-typecheck
        self.assertEqual(ret.get_service_name(), "walinuxagent")

        ret = _get_osutil(distro_name="ubuntu",
                          distro_code_name="",
                          distro_version="10.04",
                          distro_full_name="Snappy Ubuntu Core")
        self.assertTrue(type(ret) == UbuntuSnappyOSUtil)  # pylint: disable=unidiomatic-typecheck
        self.assertEqual(ret.get_service_name(), "walinuxagent")
Пример #18
0
    def test_get_osutil_it_should_return_ubuntu(self):
        ret = _get_osutil(distro_name="ubuntu",
                          distro_code_name="",
                          distro_version="10.04",
                          distro_full_name="")
        self.assertTrue(isinstance(ret, UbuntuOSUtil))
        self.assertEqual(ret.get_service_name(), "walinuxagent")

        ret = _get_osutil(distro_name="ubuntu",
                          distro_code_name="",
                          distro_version="12.04",
                          distro_full_name="")
        self.assertTrue(isinstance(ret, Ubuntu12OSUtil))
        self.assertEqual(ret.get_service_name(), "walinuxagent")

        ret = _get_osutil(distro_name="ubuntu",
                          distro_code_name="trusty",
                          distro_version="14.04",
                          distro_full_name="")
        self.assertTrue(isinstance(ret, Ubuntu14OSUtil))
        self.assertEqual(ret.get_service_name(), "walinuxagent")

        ret = _get_osutil(distro_name="ubuntu",
                          distro_code_name="xenial",
                          distro_version="16.04",
                          distro_full_name="")
        self.assertTrue(isinstance(ret, Ubuntu16OSUtil))
        self.assertEqual(ret.get_service_name(), "walinuxagent")

        ret = _get_osutil(distro_name="ubuntu",
                          distro_code_name="bionic",
                          distro_version="18.04",
                          distro_full_name="")
        self.assertTrue(isinstance(ret, Ubuntu18OSUtil))
        self.assertEqual(ret.get_service_name(), "walinuxagent")

        ret = _get_osutil(distro_name="ubuntu",
                          distro_code_name="focal",
                          distro_version="20.04",
                          distro_full_name="")
        self.assertTrue(isinstance(ret, Ubuntu18OSUtil))
        self.assertEqual(ret.get_service_name(), "walinuxagent")

        ret = _get_osutil(distro_name="ubuntu",
                          distro_code_name="",
                          distro_version="10.04",
                          distro_full_name="Snappy Ubuntu Core")
        self.assertTrue(isinstance(ret, UbuntuSnappyOSUtil))
        self.assertEqual(ret.get_service_name(), "walinuxagent")
Пример #19
0
    def test_get_osutil_it_should_return_redhat(self):
        ret = _get_osutil(distro_name="redhat",
                          distro_code_name="",
                          distro_full_name="",
                          distro_version="6")
        self.assertTrue(type(ret) == Redhat6xOSUtil)  # pylint: disable=unidiomatic-typecheck
        self.assertEqual(ret.get_service_name(), "waagent")

        ret = _get_osutil(distro_name="centos",
                          distro_code_name="",
                          distro_full_name="",
                          distro_version="6")
        self.assertTrue(type(ret) == Redhat6xOSUtil)  # pylint: disable=unidiomatic-typecheck
        self.assertEqual(ret.get_service_name(), "waagent")

        ret = _get_osutil(distro_name="oracle",
                          distro_code_name="",
                          distro_full_name="",
                          distro_version="6")
        self.assertTrue(type(ret) == Redhat6xOSUtil)  # pylint: disable=unidiomatic-typecheck
        self.assertEqual(ret.get_service_name(), "waagent")

        ret = _get_osutil(distro_name="redhat",
                          distro_code_name="",
                          distro_full_name="",
                          distro_version="7")
        self.assertTrue(type(ret) == RedhatOSUtil)  # pylint: disable=unidiomatic-typecheck
        self.assertEqual(ret.get_service_name(), "waagent")

        ret = _get_osutil(distro_name="centos",
                          distro_code_name="",
                          distro_full_name="",
                          distro_version="7")
        self.assertTrue(type(ret) == RedhatOSUtil)  # pylint: disable=unidiomatic-typecheck
        self.assertEqual(ret.get_service_name(), "waagent")

        ret = _get_osutil(distro_name="oracle",
                          distro_code_name="",
                          distro_full_name="",
                          distro_version="7")
        self.assertTrue(type(ret) == RedhatOSUtil)  # pylint: disable=unidiomatic-typecheck
        self.assertEqual(ret.get_service_name(), "waagent")