GraphiteTest.cs 912 B

12345678910111213141516171819202122232425
  1. using System;
  2. using System.Net.Http;
  3. using System.Threading;
  4. using Xunit;
  5. namespace OhmGraphite.Test
  6. {
  7. public class GraphiteTest
  8. {
  9. [Fact, Trait("Category", "integration")]
  10. public async void InsertGraphiteTest()
  11. {
  12. var writer = new GraphiteWriter("graphite", 2003, "my-pc", tags: false);
  13. await writer.ReportMetrics(DateTime.Now, TestSensorCreator.Values());
  14. // wait for carbon to sync to disk
  15. Thread.Sleep(TimeSpan.FromSeconds(1));
  16. var client = new HttpClient();
  17. var resp = await client.GetAsync("http://graphite/render?format=csv&target=ohm.my-pc.intelcpu.0.temperature.cpucore.1");
  18. Assert.True(resp.IsSuccessStatusCode);
  19. var content = await resp.Content.ReadAsStringAsync();
  20. Assert.True(content.Contains("ohm.my-pc.intelcpu.0.temperature.cpucore.1"));
  21. }
  22. }
  23. }