def test_list_setup_task_files_for_cluster_when_cluster_doesnt_support_suffix(self): with self.assertRaisesRegexp(CLIError, 'List files is not supported for this cluster'): cluster = Cluster( node_setup=NodeSetup( setup_task=SetupTask( comman_line='true', std_out_err_path_prefix='$AZ_BATCHAI_MOUNT_ROOT/nfs'))) _list_node_setup_files_for_cluster(TestCli(), cluster, '.', 60)
def test_setup_task_overwrite(self): # Should overwrite setup task but keep other parameters of node setup (here we use mount_volumes to check it) actual = _add_setup_task('echo hi', '/tmp', ClusterCreateParameters( node_setup=NodeSetup( setup_task=SetupTask(command_line='different'), mount_volumes=[] ))) self.assertEqual(actual, ClusterCreateParameters( node_setup=NodeSetup( setup_task=SetupTask( command_line='echo hi', std_out_err_path_prefix='/tmp', run_elevated=False ), mount_volumes=[])))
def test_list_setup_task_files_for_cluster_when_output_not_on_mounts_root(self): with self.assertRaisesRegexp(CLIError, 'List files is supported only for clusters with startup task'): cluster = Cluster( node_setup=NodeSetup( setup_task=SetupTask( comman_line='true', std_out_err_path_prefix='/somewhere'))) _list_node_setup_files_for_cluster(TestCli(), cluster, '.', 60)
def test_list_setup_task_files_for_cluster_when_cluster_has_not_mount_volumes(self): with self.assertRaisesRegexp(CLIError, 'List files is supported only for clusters with startup task'): cluster = Cluster( node_setup=NodeSetup( setup_task=SetupTask( comman_line='true', std_out_err_path_prefix='$AZ_BATCHAI_MOUNT_ROOT/nfs'))) cluster.node_setup.setup_task.std_out_err_path_suffix = 'path/segment' _list_node_setup_files_for_cluster(TestCli(), cluster, '.', 60)
def test_setup_task_added_to_cluster_without_setup_task(self): actual = _add_setup_task('echo hi', '/tmp', ClusterCreateParameters(node_setup=NodeSetup())) self.assertEqual(actual, ClusterCreateParameters( node_setup=NodeSetup( setup_task=SetupTask( command_line='echo hi', std_out_err_path_prefix='/tmp', run_elevated=False ))))
def test_list_setup_task_files_for_cluster_when_output_on_bfs(self, get_files_from_bfs): cluster = Cluster( node_setup=NodeSetup( setup_task=SetupTask( comman_line='true', std_out_err_path_prefix='$AZ_BATCHAI_MOUNT_ROOT/bfs'))) cluster.node_setup.setup_task.std_out_err_path_suffix = 'path/segment' cluster.node_setup.mount_volumes = MountVolumes( azure_blob_file_systems=[ AzureBlobFileSystemReference(relative_mount_path='bfs')]) cli_ctx = TestCli() _list_node_setup_files_for_cluster(cli_ctx, cluster, '.', 60) get_files_from_bfs.assert_called_once_with( cli_ctx, AzureBlobFileSystemReference(relative_mount_path='bfs'), os.path.join('path/segment/', '.'), 60)
def test_list_setup_task_files_for_cluster_when_output_not_on_afs_or_bfs(self): with self.assertRaisesRegexp(CLIError, 'List files is supported only for clusters with startup task'): cluster = Cluster( node_setup=NodeSetup( setup_task=SetupTask( comman_line='true', std_out_err_path_prefix='$AZ_BATCHAI_MOUNT_ROOT/nfs')), mount_volumes=MountVolumes( azure_file_shares=[ AzureFileShareReference( azure_file_url='https://account.file.core.windows.net/share', relative_mount_path='afs' )] )) cluster.node_setup.setup_task.std_out_err_path_suffix = 'path/segment' _list_node_setup_files_for_cluster(TestCli(), cluster, '.', 60)