/// <summary>Test the AuditLog format for successful events.</summary> private void TestSuccessLogFormatHelper(bool checkIP, ApplicationId appId, ApplicationAttemptId attemptId, ContainerId containerId) { string sLog = RMAuditLogger.CreateSuccessLog(User, Operation, Target, appId, attemptId , containerId); StringBuilder expLog = new StringBuilder(); expLog.Append("USER=test\t"); if (checkIP) { IPAddress ip = Org.Apache.Hadoop.Ipc.Server.GetRemoteIp(); expLog.Append(RMAuditLogger.Keys.Ip.ToString() + "=" + ip.GetHostAddress() + "\t" ); } expLog.Append("OPERATION=oper\tTARGET=tgt\tRESULT=SUCCESS"); if (appId != null) { expLog.Append("\tAPPID=app_1"); } if (attemptId != null) { expLog.Append("\tAPPATTEMPTID=app_attempt_1"); } if (containerId != null) { expLog.Append("\tCONTAINERID=container_1"); } NUnit.Framework.Assert.AreEqual(expLog.ToString(), sLog); }
/// <summary>Test the AuditLog format for successful events passing nulls.</summary> private void TestSuccessLogNulls(bool checkIP) { string sLog = RMAuditLogger.CreateSuccessLog(null, null, null, null, null, null); StringBuilder expLog = new StringBuilder(); expLog.Append("USER=null\t"); if (checkIP) { IPAddress ip = Org.Apache.Hadoop.Ipc.Server.GetRemoteIp(); expLog.Append(RMAuditLogger.Keys.Ip.ToString() + "=" + ip.GetHostAddress() + "\t" ); } expLog.Append("OPERATION=null\tTARGET=null\tRESULT=SUCCESS"); NUnit.Framework.Assert.AreEqual(expLog.ToString(), sLog); }