public async Task QueryToPoco() { MockServer.Given(Request.Create().WithPath("/api/v2/query").UsingPost()) .RespondWith(CreateResponse()); var result = await FluxClient.Query <Free>("from(bucket:\"telegraf\")"); Assert.That(result.Count == 4); // 1 Assert.AreEqual("A", result[0].Host); Assert.AreEqual("west", result[0].Region); Assert.AreEqual(10L, result[0].Mem); // 2 Assert.AreEqual("B", result[1].Host); Assert.AreEqual("west", result[1].Region); Assert.AreEqual(20L, result[1].Mem); // 3 Assert.AreEqual("A", result[2].Host); Assert.AreEqual("west", result[2].Region); Assert.AreEqual(11L, result[2].Mem); // 4 Assert.AreEqual("B", result[3].Host); Assert.AreEqual("west", result[3].Region); Assert.AreEqual(22L, result[3].Mem); }
public async Task Query() { MockServer.Given(Request.Create().WithPath("/api/v2/query").UsingPost()) .RespondWith(CreateResponse()); var result = await FluxClient.Query("from(bucket:\"telegraf\")"); AssertSuccessResult(result); }
public async Task QueryCallbackError() { MockServer.Given(Request.Create().WithPath("/api/v2/query").UsingPost()) .RespondWith(CreateErrorResponse("Flux query is not valid")); await FluxClient.Query("from(bucket:\"telegraf\")", (cancellable, result) => Assert.Fail("Unreachable"), error => CountdownEvent.Signal()); WaitToCallback(); }
public async Task ChunkedOneTable() { await PrepareChunkRecords(); var flux = FromFluxDatabase + "\n" + "\t|> filter(fn: (r) => r[\"_measurement\"] == \"chunked\")\n" + "\t|> range(start: 1970-01-01T00:00:00.000000000Z)"; await FluxClient.Query(flux, (cancellable, fluxRecord) => { // +1 record CountdownEvent.Signal(); if (CountdownEvent.CurrentCount % 100_000 == 0) { Trace.WriteLine($"Remaining parsed: {CountdownEvent.CurrentCount} records"); } });
public async Task QueryCallback() { CountdownEvent = new CountdownEvent(4); MockServer.Given(Request.Create().WithPath("/api/v2/query").UsingPost()) .RespondWith(CreateResponse()); var records = new List <FluxRecord>(); await FluxClient.Query("from(bucket:\"telegraf\")", (cancellable, result) => { records.Add(result); CountdownEvent.Signal(); }); WaitToCallback(); AssertRecords(records); }
public async Task QueryErrorSuccessResponseWithoutReference() { var error = "#datatype,string,string\n" + "#group,true,true\n" + "#default,,\n" + ",error,reference\n" + ",failed to create physical plan: invalid time bounds from procedure from: bounds contain zero time,"; MockServer.Given(Request.Create().WithPath("/api/v2/query").UsingPost()) .RespondWith(CreateResponse(error)); try { await FluxClient.Query("from(bucket:\"telegraf\")"); Assert.Fail(); } catch (InfluxException e) { Assert.That(e.Message.Equals("failed to create physical plan: invalid time bounds from procedure from: bounds contain zero time")); } }