diff --git a/teuthology/orchestra/cluster.py b/teuthology/orchestra/cluster.py index 654ef0c3d..5e4bba45c 100644 --- a/teuthology/orchestra/cluster.py +++ b/teuthology/orchestra/cluster.py @@ -102,7 +102,8 @@ def sh(self, script, **kwargs): remotes = sorted(self.remotes.keys(), key=lambda rem: rem.name) return [remote.sh(script, **kwargs) for remote in remotes] - def write_file(self, file_name, content, sudo=False, perms=None, owner=None): + def write_file(self, file_name, content, sudo=False, perms=None, owner=None, + **kwargs): """ Write text to a file on each node. @@ -110,16 +111,19 @@ def write_file(self, file_name, content, sudo=False, perms=None, owner=None): :param content: file content :param sudo: use sudo :param perms: file permissions (passed to chmod) ONLY if sudo is True + :param owner: file owner (passed to chmod) ONLY if sudo is True """ remotes = sorted(self.remotes.keys(), key=lambda rem: rem.name) for remote in remotes: if sudo: - remote.write_file(file_name, content, - sudo=True, mode=perms, owner=owner) + kwargs['sudo'] = True + kwargs['mode'] = perms + kwargs['owner'] = owner else: if perms is not None or owner is not None: raise ValueError("To specify perms or owner, sudo must be True") - remote.write_file(file_name, content) + + remote.write_file(file_name, content, **kwargs) def only(self, *roles): """ diff --git a/teuthology/orchestra/test/test_cluster.py b/teuthology/orchestra/test/test_cluster.py index 27bef8b83..147b654b3 100644 --- a/teuthology/orchestra/test/test_cluster.py +++ b/teuthology/orchestra/test/test_cluster.py @@ -230,3 +230,13 @@ def test_fails_with_invalid_owner(self, m_write_file): def test_with_sudo(self, m_write_file): self.c.write_file("filename", "content", sudo=True) m_write_file.assert_called_with("filename", "content", sudo=True, owner=None, mode=None) + + @patch("teuthology.orchestra.remote.RemoteShell.write_file") + def test_write_file_offset(self, m_write_file): + self.c.write_file("filename", "content", bs=1, offset=1024) + m_write_file.assert_called_with("filename", "content", bs=1, offset=1024) + + @patch("teuthology.orchestra.remote.RemoteShell.write_file") + def test_write_file_sync(self, m_write_file): + self.c.write_file("filename", "content", sync=True) + m_write_file.assert_called_with("filename", "content", sync=True)