Skip to content

Commit

Permalink
Merge pull request #1 from amccool/BufferedWriteStream
Browse files Browse the repository at this point in the history
Buffered write stream
  • Loading branch information
Alex McCool committed Jan 16, 2016
2 parents db75f24 + 3d5f121 commit 8dede33
Show file tree
Hide file tree
Showing 8 changed files with 449 additions and 26 deletions.
2 changes: 1 addition & 1 deletion ElasticSearch.Diagnostics.Tester/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

<sharedListeners>
<add name="ElkNET" type="ElasticSearch.Diagnostics.ElasticSearchTraceListener, ElasticSearch.Diagnostics"
ElasticSearchUri="http://SmellyCat01.sbp-rbdev.net:9200"
ElasticSearchUri="http://192.168.2.50:9200"
ElasticSearchIndex="trace"
ElasticSearchTraceIndex="trace"
traceOutputOptions="LogicalOperationStack,Callstack"
Expand Down
69 changes: 69 additions & 0 deletions ElasticSearch.Diagnostics.Tests/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>


<!--<system.diagnostics>
<trace autoflush="false" indentsize="4">
<listeners>
--><!--<remove name="Default" />--><!--
<add name="ElkNET" />
</listeners>
</trace>
<sources>
<source name="alextrace" switchValue="All">
<listeners>
<add name="ElkNET" />
</listeners>
</source>
<source name="System.Net" switchValue="All">
<listeners>
<add name="ElkNET" />
</listeners>
</source>
<source name="System.ServiceModel" switchValue="All">
<listeners>
<add name="ElkNET" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="ElkNET" type="ElasticSearch.Diagnostics.ElasticSearchTraceListener, ElasticSearch.Diagnostics"
ElasticSearchUri="http://192.168.2.50:9200"
ElasticSearchIndex="trace"
ElasticSearchTraceIndex="trace"
traceOutputOptions="LogicalOperationStack,Callstack"
/>
</sharedListeners>
</system.diagnostics>-->


<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WeatherSoap" />
</basicHttpBinding>
<customBinding>
<binding name="WeatherSoap12">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://wsf.cdyne.com/WeatherWS/Weather.asmx"
binding="basicHttpBinding" bindingConfiguration="WeatherSoap"
contract="weatherService.WeatherSoap" name="WeatherSoap" />
<endpoint address="http://wsf.cdyne.com/WeatherWS/Weather.asmx"
binding="customBinding" bindingConfiguration="WeatherSoap12"
contract="weatherService.WeatherSoap" name="WeatherSoap12" />
</client>
</system.serviceModel>
</configuration>
184 changes: 179 additions & 5 deletions ElasticSearch.Diagnostics.Tests/ESTLUnitTests.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,197 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;

namespace ElasticSearch.Diagnostics.Tests
{
[TestClass]
public class ESTLUnitTests
{
[TestInitialize]
public void TestInit()
public TestContext TestContext { get; set; }



[ClassInitialize()] //Use ClassInitialize to run code before you run the first test in the class.
public static void ci(TestContext tc)
{
TaskScheduler.UnobservedTaskException += (object sender, UnobservedTaskExceptionEventArgs eventArgs) =>
{
eventArgs.SetObserved();
((AggregateException)eventArgs.Exception).Handle(ex =>
{
Debug.WriteLine("Exception type: {0}", ex.GetType());
return true;
});
};
}

[ClassCleanup()]// Use ClassCleanup to run code after all tests in a class have run.
public static void cc()
{ }

[TestInitialize()] //Use TestInitialize to run code before you run each test.
public void ti()
{ }

[TestCleanup()] //Use TestCleanup to run code after each test has run.
public void tc()
{
Thread.Sleep(500);
}

[TestMethod]
public void SimpleWrite()
{
var x = new ElasticSearchTraceListener("tester");
x.ElasticSearchUri = "http://192.168.2.50:9200";
x.ElasticSearchIndex = "trace";
x.ElasticSearchTraceIndex = "trace";

x.Write(4);
}

[TestMethod]
public void WriteObjectTest()
{
var x = new ElasticSearchTraceListener("tester");
x.ElasticSearchUri = "http://192.168.2.50:9200";
x.ElasticSearchIndex = "trace";
x.ElasticSearchTraceIndex = "trace";


x.Write(new
{
thing = "ggg",
morethings = 11111,
anotherthing = "yyyy"
});
}
[ClassInitialize]
public static void ClassInit()

[TestMethod]
public void WriteExceptionest()
{
var x = new ElasticSearchTraceListener("tester");
x.ElasticSearchUri = "http://192.168.2.50:9200";
x.ElasticSearchIndex = "trace";
x.ElasticSearchTraceIndex = "trace";

try
{
var n = 0;
var y = 100000 / n;
}
catch (Exception ex)
{
x.Write(ex);
//throw;
}

}





[TestMethod]
public void TestMethod1()
public void ALOTofExmsgs()
{
var x = new ElasticSearchTraceListener("tester");
x.ElasticSearchUri = "http://192.168.2.50:9200";
x.ElasticSearchIndex = "trace";
x.ElasticSearchTraceIndex = "trace";

for (int i = 0; i < 100; i++)
{
x.Write(new Exception());
}

x.Flush();
}

[TestMethod]
public void WriteManySimpleStringsTest()
{
var x = new ElasticSearchTraceListener("tester");
x.ElasticSearchUri = "http://192.168.2.50:9200";
x.ElasticSearchIndex = "trace";
x.ElasticSearchTraceIndex = "trace";

for (int i = 0; i < 10; i++)
{
x.Write("xxxxx" + i);
}
x.Flush();
}

[TestMethod]
public void TraceSourceManySimpleStringsTest()
{
var x = new ElasticSearchTraceListener("tester");
x.ElasticSearchUri = "http://192.168.2.50:9200";
x.ElasticSearchIndex = "trace";
x.ElasticSearchTraceIndex = "trace";

var ts = new TraceSource("x", SourceLevels.All);
ts.Listeners.Add(x);

for (int i = 0; i < 10; i++)
{
ts.TraceInformation("xxxxx" + i);
}
x.Flush();

}

[TestMethod]
public void TSTestTimeIds()
{
var x = new ElasticSearchTraceListener("tester");
x.ElasticSearchUri = "http://192.168.2.50:9200";
x.ElasticSearchIndex = "trace";
x.ElasticSearchTraceIndex = "trace";

var ts = new TraceSource("x", SourceLevels.All);
ts.Listeners.Add(x);

for (int i = 0; i < 10; i++)
{
ts.TraceEvent(TraceEventType.Error, 1000, DateTime.Now.ToString());
}
x.Flush();

}

[TestMethod]
public void TSManyWriteExceptionsTest()
{
var x = new ElasticSearchTraceListener("tester");
x.ElasticSearchUri = "http://192.168.2.50:9200";
x.ElasticSearchIndex = "trace";
x.ElasticSearchTraceIndex = "trace";

var ts = new TraceSource("exxxxx", SourceLevels.All);
ts.Listeners.Add(x);

try
{
var n = 0;
var y = 100000 / n;
}
catch (Exception ex)
{
for (int i = 0; i < 10000; i++)
{
ts.TraceData(TraceEventType.Error, 99, ex);
}
}



x.Flush();

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@
<Compile Include="ESTLUnitTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ElasticSearch.Diagnostics\ElasticSearch.Diagnostics.csproj">
<Project>{b6efb16c-8fb2-4a19-bf34-312429fff491}</Project>
<Name>ElasticSearch.Diagnostics</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand Down
21 changes: 19 additions & 2 deletions ElasticSearch.Diagnostics/ElasticSearch.Diagnostics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
<HintPath>..\packages\Elasticsearch.Net.1.7.1\lib\net45\Elasticsearch.Net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=96c599bbe3e70f5d, processorArchitecture=MSIL">
<HintPath>..\packages\NEST.1.7.1\lib\net45\Nest.dll</HintPath>
<Reference Include="Elasticsearch.Net.JsonNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=96c599bbe3e70f5d, processorArchitecture=MSIL">
<HintPath>..\packages\Elasticsearch.Net.JsonNET.1.7.1\lib\net45\Elasticsearch.Net.JsonNet.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
Expand All @@ -49,6 +49,22 @@
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Reactive.Core, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Reactive.Interfaces, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Reactive.Linq, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Rx-Linq.2.2.5\lib\net45\System.Reactive.Linq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Reactive.PlatformServices, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Rx-PlatformServices.2.2.5\lib\net45\System.Reactive.PlatformServices.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -64,6 +80,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resource.resx</DependentUpon>
</Compile>
<Compile Include="TraceEntry.cs" />
<Compile Include="TraceListenerBase.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
Loading

0 comments on commit 8dede33

Please sign in to comment.