public FileEntry(TestFsShellPermission _enclosing, string path, bool isDir, string owner, string group, string permission) { this._enclosing = _enclosing; this.path = path; this.isDir = isDir; this.owner = owner; this.group = group; this.permission = permission; }
/// <exception cref="System.Exception"/> public virtual void Execute(Configuration conf, FileSystem fs) { fs.Mkdirs(new Path(TestFsShellPermission.TestRoot)); this._enclosing.CreateFiles(fs, TestFsShellPermission.TestRoot, this.fileEntries); FsShell fsShell = new FsShell(conf); string deletePath = TestFsShellPermission.TestRoot + "/" + this.deleteEntry.GetPath (); string[] tmpCmdOpts = StringUtils.Split(this.cmdAndOptions); AList <string> tmpArray = new AList <string>(Arrays.AsList(tmpCmdOpts)); tmpArray.AddItem(deletePath); string[] cmdOpts = Sharpen.Collections.ToArray(tmpArray, new string[tmpArray.Count ]); this.userUgi.DoAs(new _PrivilegedExceptionAction_153(fsShell, cmdOpts)); bool deleted = !fs.Exists(new Path(deletePath)); NUnit.Framework.Assert.AreEqual(this.expectedToDelete, deleted); TestFsShellPermission.Deldir(fs, TestFsShellPermission.TestRoot); }
public TestDeleteHelper(TestFsShellPermission _enclosing, TestFsShellPermission.FileEntry [] fileEntries, TestFsShellPermission.FileEntry deleteEntry, string cmdAndOptions , string doAsUser, bool expectedToDelete) { this._enclosing = _enclosing; /* * Each instance of TestDeleteHelper captures one testing scenario. * * To create all files listed in fileEntries, and then delete as user * doAsuser the deleteEntry with command+options specified in cmdAndOptions. * * When expectedToDelete is true, the deleteEntry is expected to be deleted; * otherwise, it's not expected to be deleted. At the end of test, * the existence of deleteEntry is checked against expectedToDelete * to ensure the command is finished with expected result */ this.fileEntries = fileEntries; this.deleteEntry = deleteEntry; this.cmdAndOptions = cmdAndOptions; this.expectedToDelete = expectedToDelete; this.doAsGroup = doAsUser.Equals("hdfs") ? "supergroup" : "users"; this.userUgi = TestFsShellPermission.CreateUGI(doAsUser, this.doAsGroup); }
/// <exception cref="System.Exception"/> public string Run() { return(TestFsShellPermission.ExecCmd(fsShell, cmdOpts)); }