示例#1
0
    def test_script_file_deployment_with_arguments(self):
        file_path = os.path.abspath(__file__)
        client = Mock()
        client.put.return_value = "/home/ubuntu/relative.sh"
        client.run.return_value = ("", "", 0)

        args = ["arg1", "arg2", "--option1=test", "option2"]
        sfd = ScriptFileDeployment(script_file=file_path, args=args, name="/root/relative.sh")

        sfd.run(self.node, client)

        expected = "/root/relative.sh arg1 arg2 --option1=test option2"
        client.run.assert_called_once_with(expected)
示例#2
0
    def test_script_file_deployment_with_arguments(self):
        file_path = os.path.abspath(__file__)
        client = Mock()
        client.put.return_value = '/home/ubuntu/relative.sh'
        client.run.return_value = ('', '', 0)

        args = ['arg1', 'arg2', '--option1=test', 'option2']
        sfd = ScriptFileDeployment(script_file=file_path, args=args,
                                   name='/root/relative.sh')

        sfd.run(self.node, client)

        expected = '/root/relative.sh arg1 arg2 --option1=test option2'
        client.run.assert_called_once_with(expected)
示例#3
0
    def test_script_file_deployment(self):
        file_path = os.path.abspath(__file__)
        with open(file_path, 'rb') as fp:
            content = fp.read()

        if PY3:
            content = content.decode('utf-8')

        sfd1 = ScriptFileDeployment(script_file=file_path)
        self.assertEqual(sfd1.script, content)
        self.assertEqual(sfd1.timeout, None)

        sfd2 = ScriptFileDeployment(script_file=file_path, timeout=20)
        self.assertEqual(sfd2.timeout, 20)
示例#4
0
    def test_script_file_deployment_with_arguments(self):
        file_path = os.path.abspath(__file__)
        client = Mock()
        client.put.return_value = '/home/ubuntu/relative.sh'
        client.run.return_value = ('', '', 0)

        args = ['arg1', 'arg2', '--option1=test', 'option2']
        sfd = ScriptFileDeployment(script_file=file_path, args=args,
                                   name='/root/relative.sh')

        sfd.run(self.node, client)

        expected = '/root/relative.sh arg1 arg2 --option1=test option2'
        client.run.assert_called_once_with(expected)
示例#5
0
    def test_script_file_deployment_with_arguments(self):
        file_path = os.path.abspath(__file__)
        client = Mock()
        client.put.return_value = FILE_PATH
        client.run.return_value = ('', '', 0)

        args = ['arg1', 'arg2', '--option1=test', 'option2']
        sfd = ScriptFileDeployment(script_file=file_path,
                                   args=args,
                                   name=file_path)

        sfd.run(self.node, client)

        expected = '%s arg1 arg2 --option1=test option2' % (file_path)
        client.run.assert_called_once_with(expected)
示例#6
0
    def test_script_file_deployment_with_arguments(self):
        file_path = os.path.abspath(__file__)
        client = Mock()
        client.put.return_value = FILE_PATH
        client.run.return_value = ("", "", 0)

        args = ["arg1", "arg2", "--option1=test", "option2"]
        sfd = ScriptFileDeployment(script_file=file_path,
                                   args=args,
                                   name=file_path)

        sfd.run(self.node, client)

        expected = "%s arg1 arg2 --option1=test option2" % (file_path)
        client.run.assert_called_once_with(expected, timeout=None)
    def deployment_script(self):
        # Once the node is built, it'll be a bare image. Run the configured
        # bootstrap script using libcloud's ScriptDeployment to run the system
        # updates and install Flask.
        if self.deploy_name:
            deployment = ScriptFileDeployment(self.config[self.deploy_name])
            log.info("Created ScriptFileDeployment with %s file.",
                     self.deploy_name)

        return deployment