Skip to content

Commit

Permalink
Support non text time stamps like epoch and binary (#30)
Browse files Browse the repository at this point in the history
Support non text time stamps like epoch and binary (#30), Fix #24, #29
  • Loading branch information
mvadu authored Nov 11, 2017
1 parent 8e0e8ea commit af7cd16
Show file tree
Hide file tree
Showing 27 changed files with 6,465 additions and 6,283 deletions.
12 changes: 12 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## v0.9.0.0 [11/11/2017]

### Release Notes
Added the functionality to parse files with binary or epoch time stamps. `-typetype` parameter can be used to select between text, binary or epoch formats.

### Features

- [#30](https://github.com/AdysTech/Influxer/pull/30): Support non text time stamps like epoch and binary

### Bugfixes

- [#29](https://github.com/AdysTech/Influxer/issues/29): Fix Issues with arguments, Thanks to @R-Sommer
15 changes: 8 additions & 7 deletions Influxer.Test/Influxer.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="AdysTech.InfluxDB.Client.Net, Version=0.6.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\AdysTech.InfluxDB.Client.Net.0.6.5\lib\net451\AdysTech.InfluxDB.Client.Net.dll</HintPath>
<Reference Include="AdysTech.InfluxDB.Client.Net, Version=0.6.7.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\AdysTech.InfluxDB.Client.Net.0.6.7\lib\net451\AdysTech.InfluxDB.Client.Net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
Expand Down Expand Up @@ -67,18 +67,19 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="TestFiles\MicroSecSemicolonSeperated.txt" />
<None Include="app.config" />
<None Include="TestSetup.ps1" />
<Content Include="TestFiles\binary.csv" />
<Content Include="TestFiles\epoch_s.csv" />
<Content Include="TestFiles\epoch_u.csv" />
<None Include="packages.config" />
<None Include="TestSetup.ps1" />
<None Include="TestFiles\HeaderlessText.txt" />
<None Include="TestFiles\HeaderlessText.conf" />
<None Include="TestFiles\Perfmon.csv" />
<None Include="TestFiles\Simple-2.csv" />
<None Include="TestFiles\Simple.csv" />
</ItemGroup>
<ItemGroup>
<Content Include="TestFiles\MicroSecSemicolonSeperated.txt" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand Down
70 changes: 67 additions & 3 deletions Influxer.Test/InfluxerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ public void TestAutoLayoutCommand()
Assert.IsFalse(CommandLineProcessor.ProcessArguments(args), "Processing AutoLayout Command failed");
}

[TestMethod]
public void TestExportCommand()
{
var args = new string[] {
"/export"
};
Assert.IsFalse(CommandLineProcessor.ProcessArguments(args), "Processing Export Command failed");
}

[TestMethod]
public async Task TestGenericHeaderless()
{
Expand All @@ -83,7 +92,8 @@ public async Task TestGenericMicroSecPrecision()
"-format", "Generic",
"-TimeFormat", "yyyy-MM-dd-hh.mm.ss.ffffff",
"-Precision", "Microseconds",
"-splitter", ";" };
"-splitter", ";",
"-table" ,"MicroSecPrecision"};
InfluxerConfigSection settings;
CommandLineProcessor.ProcessArguments(args);
settings = CommandLineProcessor.Settings;
Expand All @@ -101,6 +111,7 @@ public async Task TestGenericSimple()
settings.InputFileName = Path.Combine(TestFilesPath, "Simple.csv");
settings.InfluxDB.RetentionPolicy = "autogen";
settings.GenericFile.TimeFormat = "yyyy-MM-dd m:ss";
settings.InfluxDB.Measurement = "simple";
var client = await GetClientAsync(settings);
var file = new GenericFile();
var result = await file.ProcessGenericFile(settings.InputFileName, client);
Expand All @@ -125,7 +136,7 @@ public async Task TestGenericSimple2()
[TestMethod]
public void TestHelpCommand()
{
var args = new string[] { "--help" };
var args = new string[] { "/?" };
Assert.IsFalse(CommandLineProcessor.ProcessArguments(args), "Processing help command failed");
}

Expand All @@ -135,6 +146,7 @@ public async Task TestPerfmonFile()
var settings = InfluxerConfigSection.LoadDefault();
settings.FileFormat = FileFormats.Perfmon;
settings.InputFileName = Path.Combine(TestFilesPath, "Perfmon.csv");
settings.InfluxDB.PointsInSingleBatch = 2000;
var client = await GetClientAsync(settings);
var result = await new PerfmonFile().ProcessPerfMonLog(settings.InputFileName, client);
//Debug.WriteLine (result.ToString ());
Expand All @@ -146,14 +158,66 @@ public async Task TestPerfmonFileMultiMeasurement()
{
var settings = InfluxerConfigSection.LoadDefault();
settings.FileFormat = FileFormats.Perfmon;
settings.InfluxDB.RetentionDuration = (int)TimeSpan.FromDays(365).TotalMinutes;
settings.InfluxDB.RetentionDuration = (int)TimeSpan.FromDays(365*2).TotalMinutes;
settings.InfluxDB.RetentionPolicy = "autogen1";
settings.PerfmonFile.MultiMeasurements = true;

settings.InputFileName = Path.Combine(TestFilesPath, "Perfmon.csv");
var client = await GetClientAsync(settings);
var result = await new PerfmonFile().ProcessPerfMonLog(settings.InputFileName, client);
//Debug.WriteLine (result.ToString ());
Assert.IsTrue(result.ExitCode == ExitCode.ProcessedWithErrors && result.PointsFound == 5347 && result.PointsFailed == 0, "Processing Perfmon file failed");
}

[TestMethod]
public async Task TestBinary()
{
var args = new string[] { "-input", Path.Combine (TestFilesPath, "binary.csv"),
"-format", "Generic",
"-timetype", "binary",
"-Precision", "Microseconds",
"-table" ,"binary"};
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 binary file failed");
}

[TestMethod]
public async Task TestEpoch()
{
var args = new string[] { "-input", Path.Combine (TestFilesPath, "epoch_u.csv"),
"-format", "Generic",
"-timetype", "epoch",
"-Precision", "Microseconds",
"-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");
}

[TestMethod]
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");
}
}
}
2 changes: 1 addition & 1 deletion Influxer.Test/TestFiles/HeaderlessText.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"RetentionDuration": 0,
"RetentionPolicy": null,
"Measurement": "InfluxerData"
"Measurement": "Headerless"
},
"PerfmonFile": {
"ColumnSplitter": ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)",
Expand Down
Loading

0 comments on commit af7cd16

Please sign in to comment.