예제 #1
0
    def test_yum_install(self):
        install_list = []
        for pack in ('httpd', 'wordpress', 'mysql-server'):
            self.mock_unorder_cmd_run(
                ['su', 'root', '-c', 'rpm -q %s' % pack]) \
                .AndReturn(FakePOpen(returncode=1))
            self.mock_unorder_cmd_run(
                ['su', 'root', '-c',
                 'yum -y --showduplicates list available %s' % pack]) \
                .AndReturn(FakePOpen(returncode=0))
            install_list.append(pack)

        # This mock call corresponding to 'su root -c yum -y install .*'
        # But there is no way to ignore the order of the parameters, so only
        # check the return value.
        self.mock_cmd_run(mox.IgnoreArg()).AndReturn(FakePOpen(
            returncode=0))

        self.m.ReplayAll()
        packages = {
            "yum": {
                "mysql-server": [],
                "httpd": [],
                "wordpress": []
            }
        }

        cfn_helper.PackagesHandler(packages).apply_packages()
        self.m.VerifyAll()
예제 #2
0
    def test_zypper_install(self):
        install_list = []
        for pack in ('httpd', 'wordpress', 'mysql-server'):
            self.mock_cmd_run(['su', 'root', '-c',
                               'rpm -q %s' % pack
                               ]).AndReturn(FakePOpen(returncode=1))
            self.mock_cmd_run(
                ['su', 'root', '-c',
                 'zypper -n --no-refresh search %s' % pack]) \
                .AndReturn(FakePOpen(returncode=0))
            install_list.append(pack)

        self.mock_cmd_run(
            ['su', 'root', '-c',
             'zypper -n install %s' % ' '.join(install_list)]) \
            .AndReturn(FakePOpen(returncode=0))

        self.m.ReplayAll()
        packages = {
            "zypper": {
                "mysql-server": [],
                "httpd": [],
                "wordpress": []
            }
        }

        cfn_helper.PackagesHandler(packages).apply_packages()
        self.m.VerifyAll()
예제 #3
0
    def test_apt_install(self):
        install_list = 'httpd wordpress mysql-server'
        cmd = 'DEBIAN_FRONTEND=noninteractive apt-get -y install'

        self.mock_cmd_run(['su', 'root', '-c',
                           '%s %s' % (cmd, install_list)
                           ]).AndReturn(FakePOpen(returncode=0))
        self.m.ReplayAll()

        packages = {"apt": {"mysql-server": [], "httpd": [], "wordpress": []}}

        cfn_helper.PackagesHandler(packages).apply_packages()
        self.m.VerifyAll()
예제 #4
0
    def test_apt_install(self):
        # This mock call corresponding to
        # 'DEBIAN_FRONTEND=noninteractive su root -c apt-get -y install .*'
        # But there is no way to ignore the order of the parameters, so only
        # check the return value.
        self.mock_cmd_run(mox.IgnoreArg()).AndReturn(FakePOpen(
            returncode=0))
        self.m.ReplayAll()

        packages = {
            "apt": {
                "mysql-server": [],
                "httpd": [],
                "wordpress": []
            }
        }

        cfn_helper.PackagesHandler(packages).apply_packages()
        self.m.VerifyAll()
예제 #5
0
    def test_yum_install(self):
        install_list = []
        for pack in ('httpd', 'wordpress', 'mysql-server'):
            self.mock_cmd_run(['su', 'root', '-c',
                               'rpm -q %s' % pack
                               ]).AndReturn(FakePOpen(returncode=1))
            self.mock_cmd_run(
                ['su', 'root', '-c',
                 'yum -y --showduplicates list available %s' % pack]) \
                .AndReturn(FakePOpen(returncode=0))
            install_list.append(pack)

        self.mock_cmd_run(
            ['su', 'root', '-c',
             'yum -y install %s' % ' '.join(install_list)]) \
            .AndReturn(FakePOpen(returncode=0))

        self.m.ReplayAll()
        packages = {"yum": {"mysql-server": [], "httpd": [], "wordpress": []}}

        cfn_helper.PackagesHandler(packages).apply_packages()
        self.m.VerifyAll()