Exemplo n.º 1
0
 def test_send_symlink(self, dcos_node: Node, tmpdir: local) -> None:
     """
     If sending the path to a symbolic link, the link's target is sent.
     """
     random = str(uuid.uuid4())
     dir_containing_real_file = tmpdir.mkdir(uuid.uuid4().hex)
     dir_containing_symlink = tmpdir.mkdir(uuid.uuid4().hex)
     local_file = dir_containing_real_file.join('example_file.txt')
     local_file.write(random)
     symlink_file = dir_containing_symlink.join('symlink.txt')
     symlink_file_path = Path(str(symlink_file))
     symlink_file_path.symlink_to(target=Path(str(local_file)))
     master_destination_dir = '/etc/{random}'.format(random=random)
     master_destination_path = Path(master_destination_dir) / 'file.txt'
     dcos_node.send_file(
         local_path=symlink_file_path,
         remote_path=master_destination_path,
     )
     args = ['cat', str(master_destination_path)]
     result = dcos_node.run(args=args)
     assert result.stdout.decode() == random
Exemplo n.º 2
0
    def test_send_directory(
        self,
        dcos_node: Node,
        tmpdir: local,
    ) -> None:
        """
        It is possible to send a directory to a cluster node as the default
        user.
        """
        original_content = str(uuid.uuid4())
        dir_name = 'directory'
        file_name = 'example_file.txt'
        dir_path = tmpdir.mkdir(dir_name)
        local_file_path = dir_path.join(file_name)
        local_file_path.write(original_content)

        random = uuid.uuid4().hex
        master_base_dir = '/etc/{random}'.format(random=random)
        master_destination_dir = Path(master_base_dir)

        dcos_node.send_file(
            local_path=Path(str(local_file_path)),
            remote_path=master_destination_dir / dir_name / file_name,
        )

        args = ['cat', str(master_destination_dir / dir_name / file_name)]
        result = dcos_node.run(args=args)
        assert result.stdout.decode() == original_content

        new_content = str(uuid.uuid4())
        local_file_path.write(new_content)

        dcos_node.send_file(
            local_path=Path(str(dir_path)),
            remote_path=master_destination_dir,
        )
        args = ['cat', str(master_destination_dir / dir_name / file_name)]
        result = dcos_node.run(args=args)
        assert result.stdout.decode() == new_content
Exemplo n.º 3
0
def database(tmpdir: local):

    database_dir = "database"
    database_file = "test_database.db"

    return tmpdir.mkdir(database_dir).join(database_file)