public void TestExportCommand() { var args = new string[] { "/export" }; Assert.IsFalse(CommandLineProcessor.ProcessArguments(args), "Processing Export Command failed"); }
public void TestAutoLayoutCommand() { var args = new string[] { "-input", Path.Combine(TestFilesPath, "MicroSecSemicolonSeperated.txt"), "-format", "Generic", "-TimeFormat", "yyyy-MM-dd-hh.mm.ss.ffffff", "-Precision", "Microseconds", "-splitter", ";", "-tags", "Server=abcd", "-ignoreerrors", "/export", "/autolayout" }; Assert.IsFalse(CommandLineProcessor.ProcessArguments(args), "Processing AutoLayout Command failed"); }
public async Task TestEpoch1() { var args = new string[] { "-input", Path.Combine(TestFilesPath, "epoch_s.csv"), "-format", "Generic", "-timetype", "epoch", "-Precision", "Seconds", "-table", "epoch" }; InfluxerConfigSection settings; CommandLineProcessor.ProcessArguments(args); settings = CommandLineProcessor.Settings; var client = await GetClientAsync(settings); var result = await new GenericFile().ProcessGenericFile(settings.InputFileName, client); //Debug.WriteLine (result.ToString ()); Assert.IsTrue(result.ExitCode == ExitCode.Success && result.PointsFound == 4 && result.PointsFailed == 0, "Processing a generic epoch file failed"); }
public async Task TestGenericMicroSecPrecision() { var args = new string[] { "-input", Path.Combine(TestFilesPath, "MicroSecSemicolonSeperated.txt"), "-format", "Generic", "-TimeFormat", "yyyy-MM-dd-hh.mm.ss.ffffff", "-Precision", "Microseconds", "-splitter", ";", "-table", "MicroSecPrecision" }; InfluxerConfigSection settings; CommandLineProcessor.ProcessArguments(args); settings = CommandLineProcessor.Settings; var client = await GetClientAsync(settings); var result = await new GenericFile().ProcessGenericFile(settings.InputFileName, client); //Debug.WriteLine (result.ToString ()); Assert.IsTrue(result.ExitCode == ExitCode.Success && result.PointsFound == 4 && result.PointsFailed == 0, "Processing a generic MicroSecSemicolonSeperated file failed"); }
public void TestHelpCommand() { var args = new string[] { "/?" }; Assert.IsFalse(CommandLineProcessor.ProcessArguments(args), "Processing help command failed"); }
private static int Main(string[] args) { try { if (!CommandLineProcessor.ProcessArguments(args)) { return((int)ExitCode.Success); } settings = CommandLineProcessor.Settings; } catch (ArgumentException e) { Logger.LogLine(LogLevel.Error, e.Message); return((int)ExitCode.InvalidArgument); } catch (FileLoadException e) { Logger.LogLine(LogLevel.Error, e.Message); Logger.LogLine(LogLevel.Info, "Problem loading config file, regenerate it with /config option"); return((int)ExitCode.InvalidFilename); } catch (Exception e) { Logger.LogLine(LogLevel.Error, "Error processing arguments {0}: {1}", e.GetType().Name, e.Message); return((int)ExitCode.InvalidArgument); } #region Validate inputs if (String.IsNullOrWhiteSpace(settings.InputFileName)) { Logger.LogLine(LogLevel.Error, "Input File Name is not specified!! Can't continue"); return((int)ExitCode.InvalidArgument); } try { settings.InputFileName = Path.GetFullPath(settings.InputFileName); } catch (Exception e) { Logger.LogLine(LogLevel.Error, "Error with input file:{0},{1}", e.GetType().Name, e.Message); Logger.LogLine(LogLevel.Info, "Problem with inputfile name, check path"); return((int)ExitCode.InvalidFilename); } if (String.IsNullOrWhiteSpace(settings.InfluxDB.InfluxUri)) { Logger.LogLine(LogLevel.Error, "Influx DB Uri is not configured!!"); return((int)ExitCode.InvalidArgument); } if (String.IsNullOrWhiteSpace(settings.InfluxDB.DatabaseName)) { Logger.LogLine(LogLevel.Error, "Influx DB name is not configured!!"); return((int)ExitCode.InvalidArgument); } #endregion Validate inputs ProcessStatus result = new ProcessStatus() { ExitCode = ExitCode.UnknownError }; try { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); var client = new InfluxDBClient(settings.InfluxDB.InfluxUri, settings.InfluxDB.UserName, settings.InfluxDB.Password); if (!VerifyDatabaseAsync(client, settings.InfluxDB.DatabaseName).Result) { Logger.LogLine(LogLevel.Info, "Unable to create DB {0}", settings.InfluxDB.DatabaseName); return((int)ExitCode.UnableToProcess); } switch (settings.FileFormat) { case FileFormats.Perfmon: result = new PerfmonFile().ProcessPerfMonLog(settings.InputFileName, client).Result; break; case FileFormats.Generic: if (String.IsNullOrWhiteSpace(settings.InfluxDB.Measurement)) { throw new ArgumentException("Generic format needs TableName input"); } result = new GenericFile().ProcessGenericFile(settings.InputFileName, client).Result; break; } stopwatch.Stop(); Logger.LogLine(LogLevel.Info, "\n Finished!! Processed {0} points (Success: {1}, Failed:{2}) in {3}", result.PointsFound, result.PointsProcessed, result.PointsFailed, stopwatch.Elapsed.ToString()); } catch (AggregateException e) { Logger.LogLine(LogLevel.Error, "Error!! {0}:{1} - {2}", e.InnerException.GetType().Name, e.InnerException.Message, e.InnerException.StackTrace); } catch (Exception e) { Logger.LogLine(LogLevel.Error, "Error!! {0}:{1} - {2}", e.GetType().Name, e.Message, e.StackTrace); } return((int)result.ExitCode); }