-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from amccool/BufferedWriteStream
Buffered write stream
- Loading branch information
Showing
8 changed files
with
449 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.