def test_download_script__solaris__no_file(self):
        def _assert(download_sh, cmdline):
            with self.assertRaises(ExecutionError) as _context:
                execute_assert_success(cmdline)
            self.assertEquals(_context.exception.result.get_stdout(), '')
            self.assertIn("file not found",
                          _context.exception.result.get_stderr())

        def _patch(download_sh):
            self.inject_patch_to_script(download_sh,
                                        '_system() {\n    echo SunOS\n}')
            self.inject_patch_to_script(download_sh,
                                        '_processor() {\n    echo sparc\n}')
            self.inject_patch_to_script(download_sh,
                                        '_release() {\n    echo 5.11\n}')

        with patch_all(), self.server_context() as config:
            download_sh = self.get_download_script(config)
            self.log_script(download_sh)
            _patch(download_sh)
            _assert(download_sh, ["sh", download_sh, "no-such-package", "1.0"])
            download_sh = self.get_download_script(config,
                                                   package='no-such-package',
                                                   version="1.0")
            _patch(download_sh)
            _assert(download_sh, ["sh", download_sh])
Esempio n. 2
0
 def _setup_context(self):
     with self.temporary_base_directory_context(), patch_all():
         config = Configuration.from_disk(None)
         ensure_incoming_and_rejected_directories_exist_for_all_indexers(config)
         setup_gpg(config)
         try:
             yield config
         finally:
             destroy_all(config)
Esempio n. 3
0
 def test_counters_from_web_and_ftp_servers(self):
     with patch_all(), self.temporary_base_directory_context():
         config = self._get_config_for_test()
         setup_all(config)
         with self.web_server_context(config), self.ftp_server_context(config):
             self._get_from_http(config, "/packages/main-stable/index/packages.json")
             self._get_from_ftp(config, "/packages/main-stable/index/packages.json")
         sleep(1)
         counters = get_counters(config)
         self.assertEqual(counters, {"/packages/main-stable/index/packages.json": 2})
Esempio n. 4
0
 def test_counters_from_web_and_ftp_servers(self):
     with patch_all(), self.temporary_base_directory_context():
         config = self._get_config_for_test()
         setup_all(config)
         with self.web_server_context(config), self.ftp_server_context(config):
             self._get_from_http(config, "/packages/main-stable/index/packages.json")
             self._get_from_ftp(config, "/packages/main-stable/index/packages.json")
         sleep(1)
         counters = get_counters(config)
         self.assertEquals(counters, {"/packages/main-stable/index/packages.json": 2})
Esempio n. 5
0
 def _setup_context(self):
     with self.temporary_base_directory_context(), patch_all():
         config = Configuration.from_disk(None)
         ensure_incoming_and_rejected_directories_exist_for_all_indexers(
             config)
         setup_gpg(config)
         try:
             yield config
         finally:
             destroy_all(config)
Esempio n. 6
0
def patch_all_and_patch_relevant_indexes():
    with patch_all():
        with patch("infi.app_repo.indexers.apt.AptIndexer.rebuild_index") as apt_rebuild_index:
            with patch("infi.app_repo.indexers.wget.PrettyIndexer.rebuild_index") as wget_rebuild_index:
                with patch("infi.app_repo.indexers.yum.YumIndexer.rebuild_index") as yum_rebuild_index:
                    with patch("infi.app_repo.indexers.python.PythonIndexer.rebuild_index") as python_rebuild_index:
                        with patch("infi.app_repo.indexers.vmware_studio_updates.VmwareStudioUpdatesIndexer.rebuild_index") as vmware_rebuild_index:
                            with patch("infi.app_repo.indexers.pypi.PypiIndexer.rebuild_index") as pypi_rebuild_index:
                                patched_methods = {'APT': apt_rebuild_index, 'WGET': wget_rebuild_index, 'YUM': yum_rebuild_index,
                                                   'PYTHON': python_rebuild_index, 'VMWARE': vmware_rebuild_index, 'PYPI': pypi_rebuild_index}
                                yield patched_methods
Esempio n. 7
0
def patch_all_and_patch_relevant_indexes():
    with patch_all():
        with patch("infi.app_repo.indexers.apt.AptIndexer.rebuild_index") as apt_rebuild_index:
            with patch("infi.app_repo.indexers.wget.PrettyIndexer.rebuild_index") as wget_rebuild_index:
                with patch("infi.app_repo.indexers.yum.YumIndexer.rebuild_index") as yum_rebuild_index:
                    with patch("infi.app_repo.indexers.python.PythonIndexer.rebuild_index") as python_rebuild_index:
                        with patch("infi.app_repo.indexers.vmware_studio_updates.VmwareStudioUpdatesIndexer.rebuild_index") as vmware_rebuild_index:
                            with patch("infi.app_repo.indexers.pypi.PypiIndexer.rebuild_index") as pypi_rebuild_index:
                                patched_methods = {'APT': apt_rebuild_index, 'WGET': wget_rebuild_index, 'YUM': yum_rebuild_index,
                                                   'PYTHON': python_rebuild_index, 'VMWARE': vmware_rebuild_index, 'PYPI': pypi_rebuild_index}
                                yield patched_methods
Esempio n. 8
0
 def test_pull(self):
     with patch_all():
         with self.source_context() as source:
             with self.target_context() as target:
                 self.upload_dummy_package(target)
                 sleep(1)
                 source.remote_servers = [RemoteConfiguration(dict(address='127.0.0.1',
                                                                   http_port=target.webserver.port,
                                                                   ftp_port=target.ftpserver.port))]
                 sync.pull_packages(source, 'main-stable', '127.0.0.1', 'main-stable', 'my-app')
                 sleep(1)
                 self.assert_package_exists(source, "my-app")
    def test_download_script__no_such_package(self):
        def _assert(download_sh, cmdline):
            with self.assertRaises(ExecutionError) as _context:
                execute_assert_success(cmdline)
            self.assertEquals(_context.exception.result.get_stdout(), '')
            self.assertIn("package not found", _context.exception.result.get_stderr())

        with patch_all(), self.server_context() as config:
            download_sh = self.get_download_script(config)
            _assert(download_sh, ["sh", download_sh, "no-such-package"])
            download_sh = self.get_download_script(config, package='no-such-package')
            _assert(download_sh, ["sh", download_sh])
    def test_download_script__no_such_package(self):
        def _assert(download_sh, cmdline):
            with self.assertRaises(ExecutionError) as _context:
                execute_assert_success(cmdline)
            self.assertEqual(_context.exception.result.get_stdout(), b'')
            self.assertIn(b"package not found", _context.exception.result.get_stderr())

        with patch_all(), self.server_context() as config:
            download_sh = self.get_download_script(config)
            _assert(download_sh, ["sh", download_sh, "no-such-package"])
            download_sh = self.get_download_script(config, package='no-such-package')
            _assert(download_sh, ["sh", download_sh])
Esempio n. 11
0
 def test_pull(self):
     with patch_all():
         with self.source_context() as source:
             with self.target_context() as target:
                 self.upload_dummy_package(target)
                 sleep(1)
                 source.remote_servers = [
                     RemoteConfiguration(
                         dict(address='127.0.0.1',
                              http_port=target.webserver.port,
                              ftp_port=target.ftpserver.port))
                 ]
                 sync.pull_packages(source, 'main-stable', '127.0.0.1',
                                    'main-stable', 'my-app')
                 sleep(1)
                 self.assert_package_exists(source, "my-app")
    def test_download_script__solaris(self):
        def _assert(download_sh, cmdline):
            pid = execute_assert_success(cmdline)
            self.assertEquals(pid.get_stdout(), "some-package-1.0-solaris-11-sparc.pkg.gz\n")

        def _patch(download_sh):
            self.inject_patch_to_script(download_sh, '_system() {\n    echo SunOS\n}')
            self.inject_patch_to_script(download_sh, '_processor() {\n    echo sparc\n}')
            self.inject_patch_to_script(download_sh, '_release() {\n    echo 5.11\n}')
            self.inject_patch_to_script(download_sh, '_curl() {\n    echo "$1"\n}')
            self.inject_patch_to_script(download_sh, '_gunzip() {\n    echo "gunzip"\n}')

        with patch_all(), self.server_context() as config:
            download_sh = self.get_download_script(config)
            self.log_script(download_sh)
            _patch(download_sh)
            _assert(download_sh, ["sh", download_sh, "some-package", "1.0"])
    def test_download_script__solaris(self):
        def _assert(download_sh, cmdline):
            pid = execute_assert_success(cmdline)
            self.assertEqual(pid.get_stdout(), b"some-package-1.0-solaris-11-sparc.pkg.gz\n")

        def _patch(download_sh):
            self.inject_patch_to_script(download_sh, '_system() {\n    echo SunOS\n}')
            self.inject_patch_to_script(download_sh, '_processor() {\n    echo sparc\n}')
            self.inject_patch_to_script(download_sh, '_release() {\n    echo 5.11\n}')
            self.inject_patch_to_script(download_sh, '_curl() {\n    echo "$1"\n}')
            self.inject_patch_to_script(download_sh, '_gunzip() {\n    echo "gunzip"\n}')

        with patch_all(), self.server_context() as config:
            download_sh = self.get_download_script(config)
            self.log_script(download_sh)
            _patch(download_sh)
            _assert(download_sh, ["sh", download_sh, "some-package", "1.0"])
    def test_install_script__aix(self):
        def _assert(install_sh, cmdline):
            pid = execute_assert_success(cmdline)
            self.assertEquals(pid.get_stdout(), "rpm\n")

        def _patch(install_sh):
            self.inject_patch_to_script(install_sh, '_system() {\n    echo AIX\n}')
            self.inject_patch_to_script(install_sh, '_processor() {\n    echo powerpc\n}')
            self.inject_patch_to_script(install_sh, '_release() {\n    echo 1\n}')
            self.inject_patch_to_script(install_sh, '_osversion() {\n    echo 7\n}')
            self.inject_patch_to_script(install_sh, '_curl() {\n    echo "$1"\n}')
            self.inject_patch_to_script(install_sh, '_rpm() {\n    echo "rpm"\n}')

        with patch_all(), self.server_context() as config:
            install_sh = self.get_install_script(config)
            _patch(install_sh)
            self.log_script(install_sh)
            _assert(install_sh, ["sh", install_sh, "some-package", "1.0"])
    def test_install_script__aix(self):
        def _assert(install_sh, cmdline):
            pid = execute_assert_success(cmdline)
            self.assertEqual(pid.get_stdout(), b"rpm\n")

        def _patch(install_sh):
            self.inject_patch_to_script(install_sh, '_system() {\n    echo AIX\n}')
            self.inject_patch_to_script(install_sh, '_processor() {\n    echo powerpc\n}')
            self.inject_patch_to_script(install_sh, '_release() {\n    echo 1\n}')
            self.inject_patch_to_script(install_sh, '_osversion() {\n    echo 7\n}')
            self.inject_patch_to_script(install_sh, '_curl() {\n    echo "$1"\n}')
            self.inject_patch_to_script(install_sh, '_rpm() {\n    echo "rpm"\n}')

        with patch_all(), self.server_context() as config:
            install_sh = self.get_install_script(config)
            _patch(install_sh)
            self.log_script(install_sh)
            _assert(install_sh, ["sh", install_sh, "some-package", "1.0"])
    def test_pkgadd_fails(self):
        def _assert(install_sh, cmdline):
            with self.assertRaises(ExecutionError):
                pid = execute_assert_success(cmdline)

        def _patch(install_sh):
            self.inject_patch_to_script(install_sh, '_system() {\n    echo SunOS\n}')
            self.inject_patch_to_script(install_sh, '_processor() {\n    echo sparc\n}')
            self.inject_patch_to_script(install_sh, '_release() {\n    echo 5.11\n}')
            self.inject_patch_to_script(install_sh, '_curl() {\n    echo "$1"\n}')
            self.inject_patch_to_script(install_sh, '_gunzip() {\n    echo "gunzip"\n}')
            self.inject_patch_to_script(install_sh, '_pkgadd() {\n    exit 1\n}')

        with patch_all(), self.server_context() as config:
            install_sh = self.get_install_script(config)
            _patch(install_sh)
            self.log_script(install_sh)
            _assert(install_sh, ["sh", install_sh, "some-package", "1.0"])
    def test_install_script__solaris(self):
        def _assert(install_sh, cmdline):
            pid = execute_assert_success(cmdline)
            self.assertEqual(pid.get_stdout(), b"gunzip\npkgadd\n")

        def _patch(install_sh):
            self.inject_patch_to_script(install_sh, '_system() {\n    echo SunOS\n}')
            self.inject_patch_to_script(install_sh, '_processor() {\n    echo sparc\n}')
            self.inject_patch_to_script(install_sh, '_release() {\n    echo 5.11\n}')
            self.inject_patch_to_script(install_sh, '_curl() {\n    echo "$1"\n}')
            self.inject_patch_to_script(install_sh, '_gunzip() {\n    echo "gunzip"\n}')
            self.inject_patch_to_script(install_sh, '_pkgadd() {\n    echo "pkgadd"\n}')

        with patch_all(), self.server_context() as config:
            install_sh = self.get_install_script(config)
            _patch(install_sh)
            self.log_script(install_sh)
            _assert(install_sh, ["sh", install_sh, "some-package", "1.0"])
    def test_pkgadd_fails(self):
        def _assert(install_sh, cmdline):
            with self.assertRaises(ExecutionError):
                pid = execute_assert_success(cmdline)

        def _patch(install_sh):
            self.inject_patch_to_script(install_sh, '_system() {\n    echo SunOS\n}')
            self.inject_patch_to_script(install_sh, '_processor() {\n    echo sparc\n}')
            self.inject_patch_to_script(install_sh, '_release() {\n    echo 5.11\n}')
            self.inject_patch_to_script(install_sh, '_curl() {\n    echo "$1"\n}')
            self.inject_patch_to_script(install_sh, '_gunzip() {\n    echo "gunzip"\n}')
            self.inject_patch_to_script(install_sh, '_pkgadd() {\n    exit 1\n}')

        with patch_all(), self.server_context() as config:
            install_sh = self.get_install_script(config)
            _patch(install_sh)
            self.log_script(install_sh)
            _assert(install_sh, ["sh", install_sh, "some-package", "1.0"])
    def test_download_script__solaris__no_file(self):
        def _assert(download_sh, cmdline):
            with self.assertRaises(ExecutionError) as _context:
                execute_assert_success(cmdline)
            self.assertEquals(_context.exception.result.get_stdout(), '')
            self.assertIn("file not found", _context.exception.result.get_stderr())

        def _patch(download_sh):
            self.inject_patch_to_script(download_sh, '_system() {\n    echo SunOS\n}')
            self.inject_patch_to_script(download_sh, '_processor() {\n    echo sparc\n}')
            self.inject_patch_to_script(download_sh, '_release() {\n    echo 5.11\n}')

        with patch_all(), self.server_context() as config:
            download_sh = self.get_download_script(config)
            self.log_script(download_sh)
            _patch(download_sh)
            _assert(download_sh, ["sh", download_sh, "no-such-package", "1.0"])
            download_sh = self.get_download_script(config, package='no-such-package', version="1.0")
            _patch(download_sh)
            _assert(download_sh, ["sh", download_sh])
 def test_setup_script_is_downloadable(self):
     with patch_all(), self.server_context() as config:
         setup_sh = self.download_setup_script(config)
         with open(setup_sh) as fd:
             assert fd.read() != ''
 def test_setup_script_is_downloadable(self):
     with patch_all(), self.server_context() as config:
         setup_sh = self.download_setup_script(config)
         with open(setup_sh) as fd:
             assert fd.read() != ''