def test_makedirs(): ssh_config = get_ssh_test_config(use_password=True, use_rsa_file=False)[0] with ssh_utils.sftp_client(**ssh_config) as client: p1 = common_util.generate_short_id() p2 = common_util.generate_short_id() r_path = (Path("/tmp") / p1 / p2).as_posix() print(f"made {r_path}") assert not ssh_utils.exists(client, r_path) ssh_utils.makedirs(client, r_path) assert ssh_utils.exists(client, r_path)
def test_makedirs(): ssh_config = load_ssh_psw_config() with ssh_utils.sftp_client(**ssh_config) as client: p1 = common_util.generate_short_id() p2 = common_util.generate_short_id() r_path = (Path("/tmp") / p1 / p2).as_posix() print(f"made {r_path}") assert not ssh_utils.exists(client, r_path) ssh_utils.makedirs(client, r_path) assert ssh_utils.exists(client, r_path)
def run_upload_file(self, remote_file): print('remote_file') print(remote_file) with ssh_utils.sftp_client(**self.ssh_config) as client: ssh_utils.upload_file(client, self.file_a, remote_file) # check file in remote assert ssh_utils.exists(client, remote_file)
def test_upload(): ssh_config = load_ssh_psw_config() # generate temp file fd, fp = tempfile.mkstemp() os.close(fd) # upload with ssh_utils.sftp_client(**ssh_config) as client: p1 = common_util.generate_short_id() p2 = common_util.generate_short_id() r_path = (Path("/tmp") / p1 / p2 / Path(fp).name).as_posix() # check file in remote ssh_utils.upload_file(client, fp, r_path) assert ssh_utils.exists(client, r_path)
def test_upload(): ssh_config = get_ssh_test_config(use_password=True, use_rsa_file=False)[0] # generate temp file fd, fp = tempfile.mkstemp() os.close(fd) # upload with ssh_utils.sftp_client(**ssh_config) as client: p1 = common_util.generate_short_id() p2 = common_util.generate_short_id() r_path = (Path("/tmp") / p1 / p2 / Path(fp).name).as_posix() # check file in remote ssh_utils.copy_from_local_to_remote(client, fp, r_path) assert ssh_utils.exists(client, r_path)
def test_upload_dir(self): remote_dir = self.upload_dir() with ssh_utils.sftp_client(**self.ssh_config) as client: remote_dir_path = Path(remote_dir) assert ssh_utils.exists(client, remote_dir) remote_destination_dir_path = remote_dir_path / self.data_dir.name print("remote_destination_dir_path") print(remote_destination_dir_path) assert ssh_utils.exists(client, remote_destination_dir_path.as_posix()) assert ssh_utils.exists(client, (remote_destination_dir_path / "a.txt").as_posix()) assert ssh_utils.exists(client, (remote_destination_dir_path / "empty_dir").as_posix()) assert ssh_utils.exists(client, (remote_destination_dir_path / "sub_dir").as_posix()) assert ssh_utils.exists(client, (remote_destination_dir_path / "sub_dir" / "b.txt").as_posix())
def test_run_batch(self): app = self.app batch = app.batch app.start() job_scheduler = app.job_scheduler assert isinstance(job_scheduler.executor_manager, RemoteSSHExecutorManager) assert len(job_scheduler.executor_manager.machines) == 1 assert_batch_finished(batch, ShellJob.STATUS_SUCCEED) # check assets in remote job1_data_dir_path = Path(batch.jobs[0].data_dir) with ssh_utils.sftp_client(**self.ssh_config) as client: remote_assert_path = job1_data_dir_path / "resources" / self.data_dir.name ssh_utils.exists(client, (remote_assert_path / "empty_dir").as_posix()) ssh_utils.exists(client, (remote_assert_path / "a.txt").as_posix()) ssh_utils.exists(client, (remote_assert_path / "sub_dir" / "b.txt").as_posix())